KsepDbCacheReadDevice

INT64 __fastcall KsepDbCacheReadDevice(WCHAR *a1, CHAR **a2){
  INT64 v4; 
  INT64 v5; 
  _QWORD *v6; 
  int DeviceInternal; 
  NTSTATUS v8; 
  _QWORD *v9; 
  INT64 v10; 
  int v12; 
  PVOID DbHandleOut; 
  DbHandleOut = 0i64;
  *a2 = 0i64;
  KsepPoolAllocatePaged(0x48ui64);
  v5 = v4;
  if( v4 )
  {
    v6 = (_QWORD *)(v4 + 56);
    v6[1] = v6;
    *v6 = v6;
    DeviceInternal = KsepStringDuplicate((UNICODE_STRING *)(v5 + 40), a1);
    if( DeviceInternal >= 0 )
    {
      v8 = KseShimDatabaseOpen(&DbHandleOut);
      v9 = DbHandleOut;
      DeviceInternal = v8;
      if( v8 >= 0 )
      {
        DeviceInternal = KsepDbCacheReadDeviceInternal(*(_QWORD *)DbHandleOut, &KsepMatchMachineInfo, a1, v5);
        if( (int)(DeviceInternal + 0x80000000) < 0 || DeviceInternal == -1073741275 )
        {
          v10 = v9[7];
          if( !v10
            || (v12 = KsepDbCacheReadDeviceInternal(v10, &KsepMatchMachineInfo, a1, v5),
                ((v12 + 0x80000000) & 0x80000000) != 0)
            || v12 == -1073741275 )
          {
            *a2 = (CHAR *)v5;
            v5 = 0i64;
          }
        }
      }
      if( v9 )
        KseShimDatabaseClose(v9);
    }
    if( v5 )
      KsepCacheDeviceFree((PVOID)v5);
  }
  else
  {
    return(unsigned int)-1073741801;
  }
  return(unsigned int)DeviceInternal;
}

Referenced by:

KseQueryDeviceData
KseQueryDeviceDataList