PiDevCfgEnumDeviceKeys
__int64 __fastcall PiDevCfgEnumDeviceKeys(__int64 a1, __int64 a2, __int64 a3, int a4, UINT8 a5, __int64 a6, __int64 a7){
int *v7;
void *v8;
unsigned int v11;
unsigned int v12;
INT64 v13;
NTSTATUS v14;
_CM_KEY_TYPE v16;
NTSTATUS DeviceRegProp;
INT64 v18;
INT64 v19;
INT64 v20;
NTSTATUS v21;
UINT8 *v22;
const WCHAR *v23;
INT64 v24;
NTSTATUS v25;
VOID *DesiredAccess;
INT64 Create;
VOID **DeviceKey;
UINT64 *Disposition;
VOID *Handle;
VOID *KeyHandle;
UINT64 PropertySize;
VOID *v33;
_UNICODE_STRING DestinationString;
__int64 v35;
__int64 v36;
__int64(__fastcall *v37)(__int64, __int64, int *, VOID *);
void *v38;
_OBJECT_ATTRIBUTES ObjectAttributes;
_OBJECT_ATTRIBUTES v40;
UINT8 PropertyBuffer[76];
__int16 v42;
v7 = &dword_140985B9C;
v37 = (__int64(__fastcall *)(__int64, __int64, int *, VOID *))a6;
v8 = (void *)a3;
v35 = a7;
v38 = (void *)a3;
v36 = a1;
v11 = 0;
KeyHandle = 0i64;
DestinationString = 0i64;
Handle = 0i64;
v12 = 0;
v33 = 0i64;
PropertySize = 0i64;
while( 1 )
{
if( (a4 & *(v7 - 1)) == 0 )
goto LABEL_4;
RtlInitUnicodeString(&DestinationString, *(PCWSTR *)(v7 - 3));
*(_QWORD *)&ObjectAttributes.Length = 48i64;
KeyHandle = 0i64;
*(_QWORD *)&ObjectAttributes.Attributes = 576i64;
ObjectAttributes.ObjectName = &DestinationString;
ObjectAttributes.RootDirectory = v8;
*(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
v14 = ZwOpenKey(
&KeyHandle,
0x20019ui64,
&ObjectAttributes,
v13,
(INT64)DesiredAccess,
Create,
(INT64)DeviceKey,
(INT64)Disposition);
if( v14 == -1073741772 )
goto LABEL_4;
if( v14 < 0 )
goto LABEL_26;
v16 = v7[1];
if( v16 )
{
LODWORD(DesiredAccess) = 983103;
DeviceRegProp = CmOpenDeviceRegKey(
*(&stru_140CF2E80 + 607),
*(WCHAR **)(a2 + 8),
v16,
0i64,
(UINT64)DesiredAccess,
a5,
&Handle,
0i64);
goto LABEL_14;
}
if( !CmIsStateSeparationEnabled() )
goto LABEL_20;
if( (_DWORD)v18 == 4 )
{
v18 = 4i64;
LABEL_20:
v21 = PnpCtxOpenContextBaseKey(v19, v18, v20, 0xF003Fui64, (_HANDLE *)&Handle);
goto LABEL_21;
}
if( (_DWORD)v18 == 6 )
goto LABEL_36;
v21 = PnpCtxOpenContextNodeBaseKey(v19, v18, v20, (unsigned int)v18, (INT64)DesiredAccess, Create, &Handle);
LABEL_21:
DeviceRegProp = v21;
if( v21 < 0 )
goto LABEL_14;
if( *v7 == 7 )
{
v23 = *(const WCHAR **)(a2 + 8);
LODWORD(Disposition) = 0;
LODWORD(PropertySize) = 78;
DeviceRegProp = CmGetDeviceRegProp(
*(&stru_140CF2E80 + 607),
v23,
0i64,
9i64,
(UINT64 *)((char *)&PropertySize + 4),
PropertyBuffer,
&PropertySize,
(UINT64)Disposition);
if( DeviceRegProp < 0 )
goto LABEL_14;
if( HIDWORD(PropertySize) != 1 )
{
LABEL_36:
ZwClose((_HANDLE)KeyHandle);
KeyHandle = 0i64;
goto LABEL_4;
}
v42 = 0;
v22 = PropertyBuffer;
}
else
{
v22 = *(UINT8 **)(v7 + 3);
}
if( v22 )
{
RtlInitUnicodeString(&DestinationString, (PCWSTR)v22);
*(_QWORD *)&v40.Length = 48i64;
v33 = 0i64;
v40.RootDirectory = Handle;
*(_QWORD *)&v40.Attributes = 576i64;
v40.ObjectName = &DestinationString;
*(_OWORD *)&v40.SecurityDescriptor = 0i64;
v25 = ZwOpenKey(&v33, 0xF003Fui64, &v40, v24, (INT64)DesiredAccess, Create, (INT64)DeviceKey, (INT64)Disposition);
DeviceRegProp = v25;
if( v25 >= 0 )
{
ZwClose((_HANDLE)Handle);
Handle = v33;
}
}
LABEL_14:
if( DeviceRegProp == -1073741772 )
goto LABEL_36;
if( DeviceRegProp < 0 )
break;
Create = v35;
DesiredAccess = Handle;
v14 = v37(v36, a2, v7 - 3, KeyHandle);
if( v14 == -1073741248 )
goto LABEL_6;
if( v14 < 0 )
{
LABEL_26:
v11 = v14;
goto LABEL_6;
}
ZwClose((_HANDLE)KeyHandle);
KeyHandle = 0i64;
ZwClose((_HANDLE)Handle);
Handle = 0i64;
LABEL_4:
++v12;
v7 += 8;
if( v12 >= 7 )
goto LABEL_6;
v8 = v38;
}
v11 = DeviceRegProp;
LABEL_6:
if( KeyHandle )
ZwClose((_HANDLE)KeyHandle);
if( Handle )
ZwClose((_HANDLE)Handle);
return v11;
}Referenced by:
PiDevCfgConfigureDeviceKeys
PiDevCfgResetDeviceKeys