KsepDbQueryRegistryDeviceDataList

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

Referenced by:

KseQueryDeviceDataList