PiDevCfgQueryIncludedDriverNode
NTSTATUS __stdcall PiDevCfgQueryIncludedDriverNode(
PI_DEVCFG_DRIVER_NODE *DriverNodeParent,
WCHAR *DriverInfName,
WCHAR *ConfigurationId,
UINT64 ConfigurationScope,
PI_DEVCFG_DRIVER_NODE **DriverNodeResult){
int v5;
WCHAR *v7;
_KEY_VALUE_FULL_INFORMATION *v9;
INT64 v10;
INT64 v11;
NTSTATUS v12;
NTSTATUS v13;
NTSTATUS v14;
int v15;
INT64 v16;
NTSTATUS v17;
NTSTATUS v18;
INT64 v19;
INT64 v20;
char v21;
__int64 v22;
NTSTATUS v23;
int v24;
INT64 v25;
NTSTATUS v26;
__int64 v27;
VOID **PoolWithTag;
VOID **v29;
NTSTATUS RegistryValue;
WCHAR *i;
int v32;
char v33;
int DriverConfigurationKeyScope;
int v35;
int v36;
__int64 v37;
WCHAR v38;
INT64 v40;
INT64 v41;
INT64 v42;
INT64 v43;
INT64 v44;
INT64 v45;
INT64 v46;
INT64 v47;
UINT64 *v48;
INT64 v49;
UINT64 *v50;
INT64 v51;
INT64 v52;
INT64 v53;
INT64 v54;
INT64 v55;
VOID *ConfigurationKeyHandle;
_KEY_VALUE_FULL_INFORMATION *Information;
_UNICODE_STRING DriverPackageId;
VOID *DriverPackageKeyHandle;
v5 = ConfigurationScope;
*(_QWORD *)&DriverPackageId.Length = 0i64;
DriverPackageId.Buffer = 0i64;
v7 = DriverInfName;
DriverPackageKeyHandle = 0i64;
ConfigurationKeyHandle = 0i64;
v9 = 0i64;
Information = 0i64;
if( !DriverInfName )
{
v18 = PiDevCfgOpenDriverConfiguration(
*((VOID **)DriverNodeParent + 2),
ConfigurationId,
&ConfigurationKeyHandle,
ConfigurationScope,
v40,
v44,
(INT64)v48,
v52);
v13 = v18;
if( v18 == -1073741772 )
{
v13 = 0;
}
else if( v18 < 0 )
{
goto LABEL_73;
}
if( !ConfigurationKeyHandle )
{
v7 = (WCHAR *)*((_QWORD *)DriverNodeParent + 43);
if( !v7 )
goto LABEL_24;
if( *v7 )
{
while( 1 )
{
v23 = PiDevCfgGetDriverPackageId(v7, &DriverPackageId, v19, v20, v42, v46, v50, v54);
v13 = v23;
if( v23 == -1073741772 )
goto LABEL_41;
if( v23 < 0 )
goto LABEL_73;
v24 = PnpOpenObjectRegKey(
*(&stru_140CF2E80 + 607),
(__int64)DriverPackageId.Buffer,
8u,
131097,
0,
(__int64)&DriverPackageKeyHandle);
v13 = v24;
if( v24 == -1073741772 )
break;
if( v24 < 0 )
goto LABEL_73;
v26 = PiDevCfgOpenDriverConfiguration(
DriverPackageKeyHandle,
ConfigurationId,
&ConfigurationKeyHandle,
v25,
v43,
v47,
v51,
v55);
v13 = v26;
if( v26 < 0 )
{
if( v26 != -1073741772 )
goto LABEL_37;
ZwClose((_HANDLE)DriverPackageKeyHandle);
DriverPackageKeyHandle = 0i64;
RtlFreeAnsiString(&DriverPackageId);
v27 = -1i64;
do
++v27;
while( v7[v27] );
v7 += v27 + 1;
if( *v7 )
continue;
}
goto LABEL_38;
}
v13 = -1073740655;
}
LABEL_37:
if( v13 < 0 )
goto LABEL_73;
LABEL_38:
if( !ConfigurationKeyHandle )
{
LABEL_24:
v13 = -1073740654;
goto LABEL_75;
}
goto LABEL_39;
}
v7 = (WCHAR *)*((_QWORD *)DriverNodeParent + 6);
goto LABEL_17;
}
if( !wcsicmp(DriverInfName, *((const wchar_t **)DriverNodeParent + 6)) )
{
v12 = PiDevCfgOpenDriverConfiguration(
*((VOID **)DriverNodeParent + 2),
ConfigurationId,
&ConfigurationKeyHandle,
v11,
v40,
v44,
(INT64)v48,
v52);
v13 = v12;
if( v12 != -1073741772 )
{
if( v12 < 0 )
goto LABEL_73;
LABEL_17:
v21 = PnpDuplicateUnicodeString((__int64)&DriverPackageId, (__int64)(DriverNodeParent + 14));
v22 = 0i64;
if( !v21 )
{
LABEL_40:
v13 = -1073741670;
goto LABEL_73;
}
if( *(&stru_140CF2E80 + 607) )
v22 = *(_QWORD *)(*(&stru_140CF2E80 + 607) + 224i64);
v17 = SysCtxRegOpenKey(v22, *((VOID **)DriverNodeParent + 2), 0i64, 0, 0x20019u, &DriverPackageKeyHandle);
v13 = v17;
goto LABEL_21;
}
LABEL_11:
v13 = -1073740654;
goto LABEL_73;
}
v14 = PiDevCfgGetDriverPackageId(v7, &DriverPackageId, v10, v11, v40, v44, v48, v52);
v13 = v14;
if( v14 != -1073741772 )
{
if( v14 < 0 )
goto LABEL_73;
v15 = PnpOpenObjectRegKey(
*(&stru_140CF2E80 + 607),
(__int64)DriverPackageId.Buffer,
8u,
131097,
0,
(__int64)&DriverPackageKeyHandle);
v13 = v15;
if( v15 != -1073741772 )
{
if( v15 < 0 )
goto LABEL_73;
v17 = PiDevCfgOpenDriverConfiguration(
DriverPackageKeyHandle,
ConfigurationId,
&ConfigurationKeyHandle,
v16,
v41,
v45,
v49,
v53);
v13 = v17;
if( v17 != -1073741772 )
{
LABEL_21:
if( v17 < 0 )
goto LABEL_73;
LABEL_39:
PoolWithTag = ExAllocatePoolWithTag(1ui64, 0x1A0ui64, 1667526736i64);
v29 = PoolWithTag;
if( !PoolWithTag )
goto LABEL_40;
memset(PoolWithTag, 0i64, 0x1A0u);
*((_DWORD *)v29 + 46) = 32;
v29[29] = v29 + 28;
v29[28] = v29 + 28;
v29[27] = v29 + 26;
v29[26] = v29 + 26;
v29[47] = v29 + 46;
v29[46] = v29 + 46;
if( RtlCreateUnicodeString((INT64)(v29 + 5), (INT8 *)v7)
&& PnpDuplicateUnicodeString((__int64)(v29 + 7), (__int64)&DriverPackageId)
&& RtlCreateUnicodeString((INT64)(v29 + 11), (INT8 *)ConfigurationId) )
{
*((_DWORD *)v29 + 26) = v5;
RegistryValue = IopGetRegistryValue(ConfigurationKeyHandle, (PWCHAR)L"IncludeScope", 0i64, &Information);
v9 = Information;
v13 = RegistryValue;
if( RegistryValue == -1073741772 )
{
v13 = 0;
LABEL_68:
v29[2] = DriverPackageKeyHandle;
v29[4] = ConfigurationKeyHandle;
DriverPackageKeyHandle = 0i64;
ConfigurationKeyHandle = 0i64;
*DriverNodeResult = (PI_DEVCFG_DRIVER_NODE *)v29;
v29 = 0i64;
goto LABEL_69;
}
if( RegistryValue >= 0 )
{
if( !PnpValidateRegistryMultiSz(Information) )
{
v13 = -1073741823;
goto LABEL_69;
}
for( i = (WCHAR *)((char *)v9 + v9->DataOffset); ; i += v37 + 1 )
{
v38 = *i;
if( !*i )
goto LABEL_68;
v32 = *i - 42;
if( *i == 42 )
v32 = i[1];
if( !v32 )
{
*((_DWORD *)v29 + 26) = -1;
goto LABEL_68;
}
v33 = 1;
if( v38 != 43 )
{
if( v38 != 45 )
goto LABEL_59;
v33 = 0;
}
++i;
LABEL_59:
DriverConfigurationKeyScope = PiDevCfgGetDriverConfigurationKeyScope(i);
v35 = *((_DWORD *)v29 + 26);
if( v33 )
v36 = DriverConfigurationKeyScope | v35;
else
v36 = ~DriverConfigurationKeyScope & v35;
v37 = -1i64;
*((_DWORD *)v29 + 26) = v36;
do
++v37;
while( i[v37] );
}
}
}
else
{
v13 = -1073741670;
}
LABEL_69:
if( v29 )
PiDevCfgFreeDriverNode((_PI_DEVCFG_DRIVER_NODE *)v29);
if( v9 )
ExFreePoolWithTag(v9, 0);
goto LABEL_73;
}
goto LABEL_11;
}
}
LABEL_41:
v13 = -1073740655;
LABEL_73:
if( ConfigurationKeyHandle )
ZwClose((_HANDLE)ConfigurationKeyHandle);
LABEL_75:
if( DriverPackageKeyHandle )
ZwClose((_HANDLE)DriverPackageKeyHandle);
RtlFreeAnsiString(&DriverPackageId);
return v13;
}Referenced by:
PiDevCfgQueryIncludedDriverConfigurations