PiDevCfgQueryDriverConfiguration

INT64 __fastcall PiDevCfgQueryDriverConfiguration(INT64 a1){
  int v1; 
  int ObjectProperties; 
  _KEXCEPTION_FRAME *v4; 
  int v5; 
  WCHAR *v6; 
  WCHAR *v7; 
  WCHAR *v8; 
  INT64 v9; 
  INT64 v10; 
  WCHAR v11; 
  UINT8 v12; 
  int v14; 
  __int64 v15; 
  __int64 v16; 
  UINT64 v17; 
  UINT8 BootStart[8]; 
  struct _UNICODE_STRING DestinationString; 
  INT64 result; 
  __int64 v21; 
  const wchar_t *v22; 
  INT64 v23; 
  __int64 v24; 
  const int *v25; 
  int v26; 
  INT64 v27; 
  int v28; 
  int v29; 
  const wchar_t *v30; 
  __int64 *v31; 
  int v32; 
  UINT8 *v33; 
  int v34; 
  int v35; 
  __int64 *v36; 
  const wchar_t *v37; 
  struct _UNICODE_STRING *p_DestinationString; 
  int v39; 
  int v40; 
  int v41; 
  int v42; 
  const WCHAR *v43; 
  INT64 v44; 
  int v45; 
  int v46; 
  const wchar_t *v47; 
  INT64 v48; 
  int v49; 
  int v50; 
  const wchar_t *v51; 
  INT64 v52; 
  int v53; 
  int v54; 
  const wchar_t *v55; 
  INT64 v56; 
  int v57; 
  v1 = *(_DWORD *)(a1 + 184);
  BootStart[1] = 0;
  BootStart[0] = 0;
  *(_QWORD *)&DestinationString.Length = 0i64;
  DestinationString.Buffer = 0i64;
  if( (v1 & 0x20) != 0 )
  {
    v4 = *(_KEXCEPTION_FRAME **)(a1 + 32);
  }
  else
  {
    ObjectProperties = PiDevCfgBuildDriverConfigurationId(a1, (struct _UNICODE_STRING *)(a1 + 392));
    if( ObjectProperties < 0 )
      goto LABEL_43;
    if( !*(_QWORD *)(a1 + 24) )
      goto LABEL_44;
    v4 = *(_KEXCEPTION_FRAME **)(a1 + 32);
  }
  if( !v4 )
    goto LABEL_44;
  memset((INT64)&result, 0i64);
  LODWORD(v24) = 0x1000000;
  v32 = 117440512;
  LODWORD(v21) = 288;
  v39 = 117440512;
  v22 = L"Service";
  v45 = 0x4000000;
  v28 = 304;
  v30 = L"LowerFilters";
  LODWORD(v36) = 304;
  v37 = L"UpperFilters";
  v49 = 117440512;
  v43 = L"ConfigFlags";
  v46 = 304;
  v44 = a1 + 384;
  v53 = 117440512;
  v47 = L"IncludedInfs";
  v50 = 304;
  v51 = L"IncludedConfigs";
  v57 = 0x4000000;
  v55 = L"Reboot";
  v54 = 288;
  v56 = a1 + 388;
  v23 = a1 + 288;
  v31 = (__int64 *)(a1 + 304);
  p_DestinationString = (struct _UNICODE_STRING *)(a1 + 320);
  v42 = 292;
  v48 = a1 + 336;
  v52 = a1 + 352;
  LOBYTE(v5) = RtlpQueryRegistryValues((_KTRAP_FRAME *)0xC0000000i64, v4);
  ObjectProperties = v5;
  if( v5 == -1073741772 )
    goto LABEL_44;
  if( v5 < 0 )
    goto LABEL_43;
  if( *(_WORD *)(a1 + 304) <= 2u && *(_QWORD *)(a1 + 312) )
    RtlFreeAnsiString((_UNICODE_STRING *)(a1 + 304));
  if( *(_WORD *)(a1 + 320) <= 2u && *(_QWORD *)(a1 + 328) )
    RtlFreeAnsiString((_UNICODE_STRING *)(a1 + 320));
  if( *(_WORD *)(a1 + 336) <= 2u && *(_QWORD *)(a1 + 344) )
    RtlFreeAnsiString((_UNICODE_STRING *)(a1 + 336));
  if( *(_WORD *)(a1 + 352) <= 2u && *(_QWORD *)(a1 + 360) )
    RtlFreeAnsiString((_UNICODE_STRING *)(a1 + 352));
  if( (*(_DWORD *)(a1 + 184) & 0x20) != 0 )
  {
    v14 = *(_DWORD *)(a1 + 104);
    if( (v14 & 4) == 0 && *(_QWORD *)(a1 + 296) )
    {
      RtlFreeAnsiString((_UNICODE_STRING *)(a1 + 288));
      v14 = *(_DWORD *)(a1 + 104);
    }
    if( (v14 & 2) == 0 )
    {
      if( *(_QWORD *)(a1 + 312) )
        RtlFreeAnsiString((_UNICODE_STRING *)(a1 + 304));
      if( *(_QWORD *)(a1 + 328) )
        RtlFreeAnsiString((_UNICODE_STRING *)(a1 + 320));
    }
  }
  v6 = *(WCHAR **)(a1 + 296);
  if( !v6 || !*(_WORD *)(a1 + 288) )
    goto LABEL_26;
  ObjectProperties = PiDevCfgVerifyService(v6, &BootStart[1], (UINT64 *)(a1 + 408));
  if( ObjectProperties < 0 )
  {
LABEL_44:
    ObjectProperties = -1073740653;
    goto LABEL_43;
  }
  if( BootStart[1] )
    *(_DWORD *)(a1 + 184) |= 0x10u;
LABEL_26:
  v7 = *(WCHAR **)(a1 + 312);
  if( !v7 )
    goto LABEL_77;
  while( *v7 )
  {
    ObjectProperties = PiDevCfgVerifyService(v7, 0i64, 0i64);
    if( ObjectProperties < 0 )
    {
      ObjectProperties = -1073740653;
      break;
    }
    v15 = -1i64;
    do
      ++v15;
    while( v7[v15] );
    v7 += v15 + 1;
  }
  if( ObjectProperties >= 0 )
  {
LABEL_77:
    v8 = *(WCHAR **)(a1 + 328);
    if( !v8 )
      goto LABEL_28;
    while( *v8 )
    {
      ObjectProperties = PiDevCfgVerifyService(v8, 0i64, 0i64);
      if( ObjectProperties < 0 )
      {
        ObjectProperties = -1073740653;
        break;
      }
      v16 = -1i64;
      do
        ++v16;
      while( v8[v16] );
      v8 += v16 + 1;
    }
    if( ObjectProperties >= 0 )
    {
LABEL_28:
      if( (*(_DWORD *)(a1 + 184) & 0x20) != 0 )
      {
LABEL_42:
        *(_DWORD *)(a1 + 184) |= 1u;
        goto LABEL_43;
      }
      memset((INT64)&result, 0i64);
      v9 = *(_QWORD *)(a1 + 16);
      v10 = *(_QWORD *)(a1 + 64);
      result = (INT64)DEVPKEY_DriverPackage_ClassGuid;
      LODWORD(v17) = 4;
      LODWORD(v21) = 13;
      v25 = &DEVPKEY_DriverPackage_ProviderName;
      v31 = DEVPKEY_DriverPackage_NeedsReconfig;
      v33 = BootStart;
      v22 = (const wchar_t *)(a1 + 240);
      v36 = DEVPKEY_DriverPackage_GroupIds;
      p_DestinationString = &DestinationString;
      LODWORD(v23) = 16;
      v26 = 18;
      v27 = a1 + 272;
      v29 = 6;
      v32 = 17;
      v34 = 1;
      LODWORD(v37) = 8210;
      v40 = 6;
      ObjectProperties = PiDevCfgQueryObjectProperties(6i64, v10, 8ui64, v9, (INT64)&result, v17);
      if( ObjectProperties >= 0 )
      {
        if( (int)v24 < 0 )
        {
          *(_OWORD *)(a1 + 240) = 0i64;
        }
        else
        {
          ObjectProperties = RtlStringFromGUIDEx((const _GUID *const)(a1 + 240), (_UNICODE_STRING *)(a1 + 256), 1u);
          if( ObjectProperties < 0 )
            goto LABEL_43;
        }
        if( (int)v30 < 0 )
          RtlInitUnicodeString((PUNICODE_STRING)(a1 + 272), 0i64, v11);
        v12 = BootStart[0];
        if( v35 < 0 )
          v12 = 0;
        BootStart[0] = v12;
        if( v12 == 0xFF )
          *(_DWORD *)(a1 + 184) |= 0x40u;
        if( v41 < 0 )
          RtlInitUnicodeString(&DestinationString, 0i64, v11);
        if( DestinationString.Buffer && DestinationString.Length > 2u )
          *(_DWORD *)(a1 + 184) |= 0x80u;
        ObjectProperties = PiDevCfgQueryIncludedDriverConfigurations(a1);
        if( ObjectProperties >= 0 )
          goto LABEL_42;
      }
    }
  }
LABEL_43:
  RtlFreeAnsiString(&DestinationString);
  return(unsigned int)ObjectProperties;
}

Referenced by:

PiDevCfgCheckDeviceNeedsUpdate
PiDevCfgConfigureDevice
PiDevCfgQueryIncludedDriverConfigurations
PiDevCfgRequestDriverConfigurations
PpDevCfgProcessDeviceExtensions