PiDevCfgConfigureDeviceInterfaces
NTSTATUS __stdcall PiDevCfgConfigureDeviceInterfaces(
WCHAR *DeviceInstanceId,
VOID *ConfigurationKeyHandle,
PI_DEVCFG_RESOLVE_CONTEXT *ResolveContext){
INT64 v3;
const wchar_t *v4;
NTSTATUS v7;
INT64 v8;
int MatchingFilteredDeviceInterfaceList;
NTSTATUS v11;
VOID **PoolWithTag;
unsigned int v13;
NTSTATUS i;
INT64 v15;
char v16;
NTSTATUS v17;
int v18;
unsigned __int16 v19;
__int64 v20;
UINT8 *MatchCallbackRoutine;
UINT8 *MatchCallbackRoutinea;
UINT8 *MatchCallbackRoutineb;
UINT8 *MatchCallbackRoutinec;
INT64 v25;
INT64 v26;
INT64 v27;
WCHAR *v28;
WCHAR *v29;
WCHAR *v30;
INT64 v31;
INT64 v32;
INT64 v33;
VOID *MatchCallbackContext;
VOID *Handle;
UINT64 BufferLength;
UINT64 *RequiredLength;
VOID *KeyHandle;
_UNICODE_STRING InterfaceKeyName;
UINT64 VariableModifiers;
WCHAR *ReferenceString;
_OBJECT_ATTRIBUTES ObjectAttributes;
_UNICODE_STRING v43;
_UNICODE_STRING DestinationString;
HPNPCTX v45[4];
__int64 v46;
_UNICODE_STRING VariableName;
_GUID InterfaceClassGuid;
v4 = 0i64;
ObjectAttributes.RootDirectory = ConfigurationKeyHandle;
Handle = 0i64;
*(_QWORD *)&InterfaceKeyName.Length = 1441812i64;
v46 = 0i64;
ReferenceString = 0i64;
InterfaceKeyName.Buffer = L"Interfaces";
RequiredLength = 0i64;
ObjectAttributes.ObjectName = &InterfaceKeyName;
LODWORD(BufferLength) = 0;
*(_QWORD *)&ObjectAttributes.Length = 48i64;
*(_QWORD *)&ObjectAttributes.Attributes = 576i64;
*(_OWORD *)v45 = 0i64;
KeyHandle = 0i64;
DestinationString = 0i64;
VariableName = 0i64;
InterfaceClassGuid = 0i64;
*(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
v7 = ZwOpenKey(&KeyHandle, 0x20019ui64, &ObjectAttributes, v3, (INT64)MatchCallbackRoutine, v25, (INT64)v28, v31);
MatchingFilteredDeviceInterfaceList = v7;
if( v7 == -1073741772 )
{
MatchingFilteredDeviceInterfaceList = 0;
goto LABEL_3;
}
if( v7 < 0 )
goto LABEL_3;
*(_DWORD *)&InterfaceKeyName.Length = 262146;
InterfaceKeyName.Buffer = (wchar_t *)L"*";
ObjectAttributes.RootDirectory = KeyHandle;
*(_QWORD *)&ObjectAttributes.Length = 48i64;
ObjectAttributes.ObjectName = &InterfaceKeyName;
*(_QWORD *)&ObjectAttributes.Attributes = 576i64;
*(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
v11 = ZwOpenKey(&Handle, 0x20019ui64, &ObjectAttributes, v8, (INT64)MatchCallbackRoutinea, v26, (INT64)v29, v32);
MatchingFilteredDeviceInterfaceList = v11;
if( v11 == -1073741772 )
goto LABEL_13;
if( v11 < 0 )
goto LABEL_3;
LODWORD(MatchCallbackContext) = 0;
*(_QWORD *)v45 = Handle;
*(_QWORD *)&v45[2] = ResolveContext;
LODWORD(v46) = 0;
MatchingFilteredDeviceInterfaceList = CmGetMatchingFilteredDeviceInterfaceList(
*(&stru_140CF2E80 + 607),
0i64,
DeviceInstanceId,
0i64,
(UINT8 *)PiDevCfgConfigureDeviceInterfaceCallback,
v45,
0i64,
CM_OBJECT_TYPE_NONE,
&BufferLength,
MatchCallbackContext,
(WCHAR *)Handle,
BufferLength,
RequiredLength,
(UINT64)KeyHandle);
ZwClose((_HANDLE)Handle);
Handle = 0i64;
if( MatchingFilteredDeviceInterfaceList >= 0 )
{
MatchingFilteredDeviceInterfaceList = v46;
if( (int)v46 >= 0 )
{
LABEL_13:
PoolWithTag = ExAllocatePoolWithTag(1ui64, 0x26Eui64, 1667526736i64);
if( !PoolWithTag )
{
MatchingFilteredDeviceInterfaceList = -1073741670;
goto LABEL_3;
}
v13 = 0;
LODWORD(MatchCallbackRoutineb) = 622;
for( i = ZwEnumerateKey(
KeyHandle,
0i64,
KeyBasicInformation,
PoolWithTag,
(UINT64)MatchCallbackRoutineb,
&BufferLength);
;
i = ZwEnumerateKey(
KeyHandle,
v13,
KeyBasicInformation,
PoolWithTag,
(UINT64)MatchCallbackRoutinec,
&BufferLength) )
{
MatchingFilteredDeviceInterfaceList = i;
if( i < 0 )
{
if( i == -2147483622 )
{
MatchingFilteredDeviceInterfaceList = 0;
}
else if( i == -2147483643 )
{
MatchingFilteredDeviceInterfaceList = -1073741773;
}
goto LABEL_51;
}
*((_WORD *)PoolWithTag + ((unsigned __int64)*((unsigned int *)PoolWithTag + 3) >> 1) + 8) = 0;
if( wcsicmp((const wchar_t *)PoolWithTag + 8, L"*") )
break;
LABEL_45:
++v13;
LODWORD(MatchCallbackRoutinec) = 622;
}
MatchingFilteredDeviceInterfaceList = RtlInitUnicodeStringEx(&DestinationString, (WCHAR *)PoolWithTag + 8);
if( MatchingFilteredDeviceInterfaceList < 0 )
goto LABEL_51;
v43 = DestinationString;
ObjectAttributes.RootDirectory = KeyHandle;
*(_QWORD *)&ObjectAttributes.Length = 48i64;
ObjectAttributes.ObjectName = &DestinationString;
*(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
*(_QWORD *)&ObjectAttributes.Attributes = 576i64;
Handle = 0i64;
MatchingFilteredDeviceInterfaceList = ZwOpenKey(
&Handle,
0x20019ui64,
&ObjectAttributes,
v15,
(INT64)MatchCallbackRoutinec,
v27,
(INT64)v30,
v33);
if( MatchingFilteredDeviceInterfaceList < 0 )
goto LABEL_51;
LODWORD(VariableModifiers) = 0;
if( !ResolveContext )
goto LABEL_39;
if( !*((_QWORD *)ResolveContext + 2) )
goto LABEL_39;
PiDevCfgParseVariableName(DestinationString.Buffer, &VariableName, &VariableModifiers);
if( !v16 )
goto LABEL_39;
VariableModifiers = 0i64;
v17 = PiDevCfgResolveVariable(
ResolveContext,
VariableName.Buffer,
(_PI_DEVCFG_VARIABLE_ENTRY **)&VariableModifiers);
MatchingFilteredDeviceInterfaceList = v17;
if( v17 < 0 )
{
if( v17 == -1073741772 )
{
v43 = VariableName;
goto LABEL_39;
}
}
else
{
v18 = *(_DWORD *)(VariableModifiers + 32);
if( (unsigned int)(v18 - 1) <= 1 )
{
v19 = *(_WORD *)(VariableModifiers + 36);
v43.Buffer = *(wchar_t **)(VariableModifiers + 40);
v43.MaximumLength = v19;
v43.Length = v19 - 2;
LABEL_28:
if( v4 )
{
if( *v4 )
{
while( 1 )
{
RtlInitUnicodeString(&InterfaceKeyName, v4);
if( PiDevCfgParseInterfaceKeyName(&InterfaceKeyName, &InterfaceClassGuid, &ReferenceString) )
{
MatchingFilteredDeviceInterfaceList = IopRegisterDeviceInterface(
DeviceInstanceId,
&InterfaceClassGuid,
ReferenceString,
1u,
(WCHAR **)&RequiredLength,
0i64);
if( MatchingFilteredDeviceInterfaceList < 0 )
break;
MatchingFilteredDeviceInterfaceList = PiDevCfgConfigureDeviceInterface(
(WCHAR *)RequiredLength,
Handle,
ResolveContext);
ExFreePoolWithTag(RequiredLength, 0);
if( MatchingFilteredDeviceInterfaceList < 0 )
break;
}
v20 = -1i64;
do
++v20;
while( v4[v20] );
v4 += v20 + 1;
if( !*v4 )
goto LABEL_36;
}
LABEL_51:
ExFreePoolWithTag(PoolWithTag, 0);
LABEL_3:
if( Handle )
ZwClose((_HANDLE)Handle);
goto LABEL_5;
}
LABEL_36:
v4 = 0i64;
goto LABEL_42;
}
LABEL_39:
v4 = 0i64;
if( !PiDevCfgParseInterfaceKeyName(&v43, &InterfaceClassGuid, &ReferenceString) )
{
LABEL_43:
ZwClose((_HANDLE)Handle);
goto LABEL_44;
}
MatchingFilteredDeviceInterfaceList = IopRegisterDeviceInterface(
DeviceInstanceId,
&InterfaceClassGuid,
ReferenceString,
1u,
(WCHAR **)&RequiredLength,
0i64);
if( MatchingFilteredDeviceInterfaceList < 0 )
goto LABEL_51;
MatchingFilteredDeviceInterfaceList = PiDevCfgConfigureDeviceInterface(
(WCHAR *)RequiredLength,
Handle,
ResolveContext);
ExFreePoolWithTag(RequiredLength, 0);
LABEL_42:
if( MatchingFilteredDeviceInterfaceList < 0 )
goto LABEL_51;
goto LABEL_43;
}
if( v18 == 7 )
{
v4 = *(const wchar_t **)(VariableModifiers + 40);
goto LABEL_28;
}
}
ZwClose((_HANDLE)Handle);
v4 = 0i64;
LABEL_44:
Handle = 0i64;
goto LABEL_45;
}
}
LABEL_5:
if( KeyHandle )
ZwClose((_HANDLE)KeyHandle);
return MatchingFilteredDeviceInterfaceList;
}Referenced by:
PiDevCfgConfigureDeviceKeys