KsepDbQueryRegistryDeviceDataList

NTSTATUS __stdcall KsepDbQueryRegistryDeviceDataList(
        WCHAR *DeviceId,
        WCHAR *DataList,
        UINT64 DataListLength,
        UINT64 *ActualLength){
  ULONG v4; 
  int v6; 
  int v7; 
  VOID *Paged; 
  unsigned int v9; 
  WCHAR *v10; 
  NTSTATUS v11; 
  __int64 v12; 
  PVOID Handle; 
  UINT64 MaxValueNameLength; 
  UINT64 MaxValueDataLength; 
  size_t Size[2]; 
  _UNICODE_STRING TargetString; 
  unsigned int v19; 

  v19 = DataListLength;
  v4 = 0;
  *(_QWORD *)&TargetString.Length = 0i64;
  TargetString.Buffer = 0i64;
  Handle = 0i64;
  MaxValueNameLength = 0i64;
  MaxValueDataLength = 0i64;
  *(_QWORD *)Size = 0i64;
  v6 = KsepStringTransform(&TargetString, DeviceId);
  if( v6 >= 0 )
  {
    if( KsepRegistryOpenKey(
           (PWCHAR)L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Compatibility\\Device",
           TargetString.Buffer,
           &Handle) >= 0 )
    {
      KsepRegistryQueryKeyInformation(Handle, &MaxValueNameLength, &MaxValueDataLength);
      v6 = v7;
      if( v7 >= 0 )
      {
        Paged = KsepPoolAllocatePaged(MaxValueNameLength);
        if( Paged )
        {
          if( KsepPoolAllocatePaged(MaxValueDataLength) )
          {
            v9 = 0;
            v10 = DataList;
            while( 1 )
            {
              v11 = KsepRegistryEnumValue((_HANDLE)Handle, v4, MaxValueNameLength);
              v6 = v11;
              if( v11 == -2147483622 )
                break;
              if( v11 < 0 )
                goto LABEL_17;
              v12 = *(_QWORD *)Size;
              v9 += Size[0];
              if( v9 <= v19 )
              {
                memmove(v10, Paged, Size[0]);
                v10 = (WCHAR *)((char *)v10 + v12);
              }
              ++v4;
            }
            *(_DWORD *)ActualLength = v9 + 2;
            if( (unsigned __int64)v9 + 2 <= v19 )
            {
              v6 = 0;
              DataList[(unsigned __int64)v9 >> 1] = 0;
            }
            else
            {
              v6 = -1073741789;
            }
          }
          else
          {
            v6 = -1073741801;
          }
LABEL_17:
          KsepPoolFreePaged(Paged);
        }
        else
        {
          v6 = -1073741801;
        }
      }
    }
    else
    {
      v6 = -1073741275;
    }
    if( Handle )
    {
      ZwClose((_HANDLE)Handle);
      _InterlockedIncrement(dword_140C2A7FC);
    }
  }
  KsepStringFree(&TargetString);
  return v6;
}

Referenced by:

KseQueryDeviceDataList