PiDevCfgResolveVariable
NTSTATUS __stdcall PiDevCfgResolveVariable(
_PI_DEVCFG_RESOLVE_CONTEXT *ResolveContext,
WCHAR *VariableName,
_PI_DEVCFG_VARIABLE_ENTRY **VariableEntryResult){
_PI_DEVCFG_RESOLVE_CONTEXT *v3;
NTSTATUS v4;
_KEY_VALUE_FULL_INFORMATION *v5;
__int64(__fastcall *v6)(_PI_DEVCFG_RESOLVE_CONTEXT *, VOID *, VOID **);
int v7;
NTSTATUS v8;
INT64 v9;
unsigned int v10;
_UNICODE_STRING **v11;
_UNICODE_STRING *v12;
void *v13;
NTSTATUS v14;
NTSTATUS RegistryValue;
const wchar_t **v16;
const wchar_t *v17;
unsigned int v18;
const wchar_t **v19;
__int64 v20;
VOID **PoolWithTag;
VOID **v23;
VOID ***v24;
int v25;
wchar_t **v26;
_WORD *v27;
__int64 v28;
unsigned int v29;
VOID **v30;
VOID **v31;
VOID **v32;
VOID ***v33;
INT64 v34;
VOID *KeyHandle;
_KEY_VALUE_FULL_INFORMATION *Information;
VOID *Src;
_UNICODE_STRING DestinationString;
_OBJECT_ATTRIBUTES ObjectAttributes;
UINT64 HashValue;
v3 = ResolveContext;
v4 = 0;
v5 = 0i64;
LODWORD(HashValue) = 0;
v6 = 0i64;
KeyHandle = 0i64;
v7 = 0;
Information = 0i64;
DestinationString = 0i64;
Src = 0i64;
LODWORD(v34) = 0;
if( !*VariableName )
return -1073741772;
*VariableEntryResult = 0i64;
RtlInitUnicodeString(&DestinationString, VariableName);
v8 = RtlHashUnicodeString(&DestinationString, 1u, 0i64, &HashValue);
v10 = HashValue;
if( v8 < 0 )
v10 = 0;
v11 = (_UNICODE_STRING **)(*((_QWORD *)v3 + 3) + 16i64 * (v10 % 0x7F));
v12 = *v11;
if( *v11 != (_UNICODE_STRING *)v11 )
{
do
{
v23 = (VOID **)v12;
if( (unsigned __int8)RtlEqualUnicodeString(&DestinationString, v12 + 1, 1u) )
break;
v12 = *(_UNICODE_STRING **)&v12->Length;
v23 = 0i64;
}
while( v12 != (_UNICODE_STRING *)v11 );
if( v23 )
{
if( *((_DWORD *)v23 + 8) == -1 )
return -1073741823;
goto LABEL_27;
}
v3 = ResolveContext;
}
v13 = (void *)*((_QWORD *)v3 + 2);
*(&ObjectAttributes.Length + 1) = 0;
memset(&ObjectAttributes.Attributes + 1, 0, 20);
ObjectAttributes.RootDirectory = v13;
ObjectAttributes.Length = 48;
ObjectAttributes.ObjectName = &DestinationString;
ObjectAttributes.Attributes = 576;
v14 = ZwOpenKey(&KeyHandle, 0x20019ui64, &ObjectAttributes, v9, v34, (INT64)KeyHandle, (INT64)Information, (INT64)Src);
v4 = v14;
if( v14 >= 0 )
{
RegistryValue = IopGetRegistryValue(KeyHandle, (PWCHAR)&word_14098BF74, 0i64, &Information);
v5 = Information;
v4 = RegistryValue;
if( RegistryValue < 0 )
goto LABEL_29;
if( !PnpValidateRegistryString(Information) )
{
v4 = -1073741823;
goto LABEL_29;
}
v16 = (const wchar_t **)&off_140985A70;
v17 = (const wchar_t *)((char *)v5 + v5->DataOffset);
HashValue = (UINT64)v17;
v18 = 0;
while( wcsicmp(*v16, v17) )
{
v17 = (const wchar_t *)HashValue;
++v18;
v16 += 2;
if( v18 >= 8 )
goto LABEL_11;
}
v6 = (__int64(__fastcall *)(_PI_DEVCFG_RESOLVE_CONTEXT *, VOID *, VOID **))*(&funcs_140773296 + 2 * v18);
if( !v6 )
{
LABEL_11:
v4 = -1073741772;
goto LABEL_29;
}
LABEL_22:
PoolWithTag = ExAllocatePoolWithTag(1ui64, 0x30ui64, 1667526736i64);
v23 = PoolWithTag;
if( !PoolWithTag )
{
v4 = -1073741670;
goto LABEL_29;
}
*(_OWORD *)PoolWithTag = 0i64;
*((_OWORD *)PoolWithTag + 1) = 0i64;
*((_OWORD *)PoolWithTag + 2) = 0i64;
v24 = (VOID ***)v11[1];
if( *v24 != (VOID **)v11 )
LABEL_57:
__fastfail(3u);
*v23 = v11;
v23[1] = v24;
*v24 = v23;
v11[1] = (_UNICODE_STRING *)v23;
if( RtlCreateUnicodeString((INT64)(v23 + 2), (INT8 *)VariableName) )
{
if( v6 )
{
*((_DWORD *)v23 + 8) = -1;
v25 = v6(ResolveContext, KeyHandle, v23);
v4 = v25;
if( v25 >= 0 )
{
LABEL_27:
*VariableEntryResult = (_PI_DEVCFG_VARIABLE_ENTRY *)v23;
v23 = 0i64;
goto LABEL_28;
}
if( v25 == -1073741772 )
v4 = -1073741823;
LABEL_28:
if( !v23 )
goto LABEL_29;
v32 = (VOID **)*v23;
if( *((VOID ***)*v23 + 1) == v23 )
{
v33 = (VOID ***)v23[1];
if( *v33 == v23 )
{
*v33 = v32;
v32[1] = v33;
ExFreePoolWithTag(v23, 0);
LABEL_29:
if( v5 )
ExFreePoolWithTag(v5, 0);
goto LABEL_18;
}
}
goto LABEL_57;
}
v27 = Src;
if( Src )
{
*((_DWORD *)v23 + 8) = 1;
v28 = -1i64;
do
++v28;
while( v27[v28] );
v29 = 2 * v28 + 2;
*((_DWORD *)v23 + 9) = v29;
v30 = ExAllocatePoolWithTag(1ui64, v29, 1667526736i64);
v23[5] = v30;
if( v30 )
{
memmove(v30, v27, *((_DWORD *)v23 + 9));
goto LABEL_27;
}
}
else
{
*((_DWORD *)v23 + 8) = 4;
*((_DWORD *)v23 + 9) = 4;
v31 = ExAllocatePoolWithTag(1ui64, 4ui64, 1667526736i64);
v23[5] = v31;
if( v31 )
{
*(_DWORD *)v31 = v7;
goto LABEL_27;
}
}
}
v4 = -1073741670;
goto LABEL_28;
}
if( v14 == -1073741772 )
{
v4 = 0;
v19 = (const wchar_t **)&off_1409854C0;
v20 = 0i64;
while( wcsicmp(*v19, VariableName) )
{
v20 = (unsigned int)(v20 + 1);
v19 += 3;
if( (unsigned int)v20 >= 4 )
goto LABEL_16;
}
v26 = &(&off_1409854C0)[3 * v20];
if( v26 )
{
v7 = *((_DWORD *)v26 + 4);
Src = v26[1];
goto LABEL_22;
}
LABEL_16:
if( PnpStringToDwordValue((__int64)VariableName, &v34) )
{
v7 = v34;
goto LABEL_22;
}
v4 = -1073741772;
}
LABEL_18:
if( KeyHandle )
ZwClose((_HANDLE)KeyHandle);
return v4;
}Referenced by:
PiDevCfgConfigureDeviceInterfaces
PiDevCfgCopyDeviceKey
PiDevCfgQueryResolveValue
PiDevCfgResolveVariableExpression
PiDevCfgResolveVariableFormatString
PiDevCfgResolveVariableKeyHandle
PiDevCfgResolveVariableKeyValue
PiDevCfgResolveVariableSwitchCase