PnpGetDeviceResourcesFromRegistry
__int64 __fastcall PnpGetDeviceResourcesFromRegistry(
_DEVICE_OBJECT *DeviceObject,
unsigned int ResourceType,
unsigned int Preference,
void **Resource,
unsigned int *Length){
UINT64 *v5;
char v6;
int RegistryValue;
HANDLE v10;
__int64 v11;
__int64 result;
NTSTATUS v13;
__int64 v14;
__int64 v15;
NTSTATUS DeviceConfiguration;
WCHAR *v17;
__int64 v18;
unsigned int *v19;
unsigned int v20;
void *PoolWithTag;
_DWORD *v22;
void *P[2];
HANDLE Handle;
v5 = (UINT64 *)Length;
v6 = Preference;
*Resource = 0i64;
Handle = 0i64;
RegistryValue = 0;
*(_DWORD *)v5 = 0;
P[0] = 0i64;
if( ResourceType )
{
if( DeviceObject )
v14 = *(_QWORD *)(*((_QWORD *)DeviceObject + 39) + 40i64);
else
v14 = 0i64;
RegistryValue = CmOpenDeviceRegKey(
PiPnpRtlCtx,
*(const wchar_t **)(v14 + 48),
20,
0,
131097,
0,
(__int64)&Handle,
0i64);
if( RegistryValue < 0 )
return(unsigned int)RegistryValue;
if( (v6 & 1) != 0 )
{
v17 = (WCHAR *)L"OverrideConfigVector";
}
else
{
if( (v6 & 2) == 0 )
{
LABEL_26:
v10 = Handle;
goto LABEL_12;
}
v17 = (WCHAR *)L"BasicConfigVector";
}
RegistryValue = IopGetRegistryValue(Handle, v17, 0i64, (KEY_VALUE_FULL_INFORMATION **)P);
if( RegistryValue >= 0 )
{
v19 = (unsigned int *)P[0];
if( *((_DWORD *)P[0] + 1) == 10 )
{
v20 = *((_DWORD *)P[0] + 3);
if( v20 )
{
PoolWithTag = ExAllocatePoolWithTag(PagedPool, v20, 0x75737050ui64);
*Resource = PoolWithTag;
if( PoolWithTag )
{
*(_DWORD *)v5 = v19[3];
memmove((UINT8 *)*Resource, (UINT8 *)v19 + v19[2], v19[3]);
v22 = *Resource;
if( *((_DWORD *)*Resource + 1) == -1 )
{
v22[2] = 0;
v22[1] = 1;
}
}
else
{
RegistryValue = -1073741584;
}
}
}
ExFreePoolWithTag(v19, 0);
}
goto LABEL_26;
}
if( (Preference & 1) != 0 )
{
v18 = DeviceObject ? *(_QWORD *)(*((_QWORD *)DeviceObject + 39) + 40i64) : 0i64;
RegistryValue = CmOpenDeviceRegKey(
PiPnpRtlCtx,
*(const wchar_t **)(v18 + 48),
19,
0,
131097,
0,
(__int64)&Handle,
0i64);
if( RegistryValue >= 0 )
{
RegistryValue = PnpReadDeviceConfiguration(Handle, 1ui64, (CM_RESOURCE_LIST **)Resource, v5);
ZwClose(Handle);
if( RegistryValue >= 0 )
return(unsigned int)RegistryValue;
}
}
v10 = 0i64;
Handle = 0i64;
if( (v6 & 2) != 0 )
{
if( DeviceObject )
v15 = *(_QWORD *)(*((_QWORD *)DeviceObject + 39) + 40i64);
else
v15 = 0i64;
result = CmOpenDeviceRegKey(PiPnpRtlCtx, *(const wchar_t **)(v15 + 48), 20, 0, 131097, 0, (__int64)&Handle, 0i64);
if( (int)result < 0 )
return result;
DeviceConfiguration = PnpReadDeviceConfiguration(Handle, 2ui64, (CM_RESOURCE_LIST **)Resource, v5);
v10 = Handle;
RegistryValue = DeviceConfiguration;
if( DeviceConfiguration >= 0 )
goto LABEL_12;
}
if( (v6 & 4) == 0 )
goto LABEL_11;
if( v10 )
{
LABEL_10:
v13 = PnpReadDeviceConfiguration(v10, 4ui64, (CM_RESOURCE_LIST **)Resource, v5);
v10 = Handle;
RegistryValue = v13;
LABEL_11:
if( !v10 )
return(unsigned int)RegistryValue;
LABEL_12:
ZwClose(v10);
return(unsigned int)RegistryValue;
}
if( DeviceObject )
v11 = *(_QWORD *)(*((_QWORD *)DeviceObject + 39) + 40i64);
else
v11 = 0i64;
result = CmOpenDeviceRegKey(PiPnpRtlCtx, *(const wchar_t **)(v11 + 48), 20, 0, 131097, 0, (__int64)&Handle, 0i64);
if( (int)result >= 0 )
{
v10 = Handle;
goto LABEL_10;
}
return result;
}Referenced by:
IopInitializeDeviceInstanceKey
IopPnPDispatch
IopQueryDeviceResources