PiDevCfgQueryObjectProperties

INT64 __fastcall PiDevCfgQueryObjectProperties(INT64 a1, INT64 a2, UINT64 a3, INT64 a4, INT64 a5, UINT64 a6){
  const wchar_t *v6; 
  int ObjectProperty; 
  void *v8; 
  ULONG v9; 
  INT64 v10; 
  int v11; 
  unsigned __int64 v12; 
  struct _UNICODE_STRING *v13; 
  unsigned int MaximumLength; 
  __int64 v15; 
  WCHAR v16; 
  UINT64 v18; 
  VOID *PoolWithTag; 
  UINT8 *StringRoutine; 
  wchar_t *Buffer; 
  int v22; 
  VOID *v23; 
  int v24; 
  int v25; 
  HANDLE Handle; 
  __int64 v27; 
  ULONG Size; 
  int Size_4; 
  __int64 v30; 
  unsigned int v31; 
  INT64 v32; 
  v32 = a4;
  v31 = a3;
  v30 = a2;
  Size_4 = HIDWORD(a1);
  v6 = 0i64;
  v27 = PiPnpRtlCtx;
  ObjectProperty = 0;
  Handle = 0i64;
  v8 = 0i64;
  v24 = 1;
  v9 = 0;
  Size = 0;
  if( !a4 )
  {
    v22 = PnpOpenObjectRegKey(PiPnpRtlCtx, a2, a3, 33554433, 0, (__int64)&Handle);
    v6 = 0i64;
    ObjectProperty = v22;
    if( v22 < 0 )
      goto LABEL_23;
  }
  v25 = 0;
  if( !(_DWORD)a6 )
    goto LABEL_23;
  v10 = a5 + 8;
  while( 2 )
  {
    v11 = *(_DWORD *)(v10 + 20);
    v12 = *(_QWORD *)(v10 + 8);
    if( (v11 & 4) != 0 )
    {
      v13 = *(struct _UNICODE_STRING **)(v10 + 8);
      v12 = *(_QWORD *)(v12 + 8);
      MaximumLength = v13->MaximumLength;
    }
    else
    {
      MaximumLength = *(_DWORD *)(v10 + 16);
      v13 = (struct _UNICODE_STRING *)v6;
    }
    if( (v11 & 2) != 0 )
    {
      if( v8
        || (v9 = 260,
            PoolWithTag = ExAllocatePoolWithTag(PagedPool, 0x104ui64, 0x63647050ui64),
            v6 = 0i64,
            (v8 = PoolWithTag) != 0i64) )
      {
        v12 = (unsigned __int64)v8;
        goto LABEL_9;
      }
      ObjectProperty = -1073741670;
      goto LABEL_23;
    }
    while( 1 )
    {
      v15 = (__int64)Handle;
      if( v32 )
        v15 = v32;
      ObjectProperty = PnpGetObjectProperty(
                         v27,
                         v30,
                         v31,
                         v15,
                         v6,
                         *(_QWORD *)(v10 - 8),
                         &v24,
                         v12,
                         MaximumLength,
                         &Size,
                         (int)v6);
      if( ObjectProperty != -1073741789 )
      {
        v6 = 0i64;
        goto LABEL_14;
      }
      if( (*(_DWORD *)(v10 + 20) & 2) == 0 )
        goto LABEL_66;
      if( Size <= MaximumLength )
      {
        ObjectProperty = -1073741595;
LABEL_66:
        v6 = 0i64;
        goto LABEL_16;
      }
      ExFreePoolWithTag(v8, 0);
      v9 = Size;
      v23 = ExAllocatePoolWithTag(PagedPool, Size, 0x63647050ui64);
      v6 = 0i64;
      v8 = v23;
      if( !v23 )
        break;
      v12 = (unsigned __int64)v23;
LABEL_9:
      MaximumLength = v9;
    }
    ObjectProperty = -1073741670;
LABEL_14:
    if( ObjectProperty == -1073741670 )
      break;
    if( ObjectProperty >= 0 )
    {
      v18 = Size;
      if( v24 )
      {
        if( v24 != *(_DWORD *)v10 )
        {
          ObjectProperty = -1073741823;
          goto LABEL_16;
        }
        if( v24 == 18 || v24 == 20 || v24 == 25 )
        {
          if( !PnpValidateStringData((PWCHAR)v12, Size) )
            ObjectProperty = -1073741823;
        }
        else if( v24 == 8210 && !PnpValidateMultiSzData((PWCHAR)v12, Size) )
        {
          ObjectProperty = -1073741823;
        }
      }
      else
      {
        *(_DWORD *)v10 = 0;
      }
      if( ObjectProperty >= 0 )
      {
        if( v13 && (unsigned int)v18 > 0xFFFE )
          ObjectProperty = -2147483643;
        if( ObjectProperty >= 0 )
        {
          if( (*(_DWORD *)(v10 + 20) & 2) == 0 )
            goto LABEL_37;
          if( v13 )
          {
            StringRoutine = (UINT8 *)ExpAllocateStringRoutine(v18);
            v13->Buffer = (wchar_t *)StringRoutine;
            if( StringRoutine )
            {
              v13->MaximumLength = Size;
LABEL_49:
              memmove(StringRoutine, (UINT8 *)v8, Size);
              LODWORD(v18) = Size;
              v6 = 0i64;
LABEL_37:
              if( v13 )
              {
                v13->Length = v18;
                if( v24 != 8210 )
                {
                  Buffer = v13->Buffer;
                  if( Buffer )
                  {
                    if( (unsigned __int16)Size >= 2u
                      && Buffer[((unsigned __int64)(unsigned __int16)Size >> 1) - 1] == (_WORD)v6 )
                    {
                      v13->Length = Size - 2;
                    }
                  }
                }
              }
              else
              {
                if( (*(_DWORD *)(v10 + 20) & 2) != 0 )
                {
                  **(_QWORD **)(v10 + 8) = v12;
                  LODWORD(v18) = Size;
                }
                *(_DWORD *)(v10 + 16) = v18;
              }
              goto LABEL_16;
            }
          }
          else
          {
            StringRoutine = (UINT8 *)ExAllocatePoolWithTag(PagedPool, v18, 0x63647050ui64);
            v12 = (unsigned __int64)StringRoutine;
            if( StringRoutine )
              goto LABEL_49;
          }
          ObjectProperty = -1073741670;
          break;
        }
      }
    }
LABEL_16:
    *(_DWORD *)(v10 + 24) = ObjectProperty;
    if( ObjectProperty < 0 )
    {
      if( (*(_DWORD *)(v10 + 20) & 8) == 0 )
      {
LABEL_18:
        if( (*(_DWORD *)(v10 + 20) & 1) != 0 )
          break;
        ObjectProperty = (int)v6;
        goto LABEL_20;
      }
      if( v13 )
      {
        RtlInitUnicodeString(v13, 0i64, v16);
      }
      else
      {
        if( !v12 )
          goto LABEL_18;
        memset(v12, 0i64);
      }
      v6 = 0i64;
      goto LABEL_18;
    }
LABEL_20:
    v10 += 40i64;
    if( ++v25 < (unsigned int)a6 )
      continue;
    break;
  }
  if( v8 )
    ExFreePoolWithTag(v8, 0);
LABEL_23:
  if( Handle )
    ZwClose(Handle);
  return(unsigned int)ObjectProperty;
}

Referenced by:

PiDevCfgCheckDeviceNeedsUpdate
PiDevCfgConfigureDevice
PiDevCfgFindDeviceMigrationNode
PiDevCfgGetDriverPackageId
PiDevCfgInitDeviceContext
PiDevCfgLogDeviceConfigured
PiDevCfgLogDeviceStarted
PiDevCfgProcessDevice
PiDevCfgQueryDriverConfiguration
PiDevCfgQueryDriverNode
PpDevCfgInit
PpDevCfgProcessDeviceExtensions
PpDevCfgProcessDeviceReset