PiQueryAndAllocateBootResources
NTSTATUS __stdcall PiQueryAndAllocateBootResources(_DEVICE_NODE *DeviceNode){
void *v1;
NTSTATUS v3;
int v4;
NTSTATUS v5;
VOID *v6;
_ETHREAD *CurrentThread;
_OBJECT_TYPE *v9;
UINT64 DesiredAccess;
UINT64 Create;
_UNICODE_STRING ValueName;
UINT64 Length;
VOID *KeyHandle;
VOID *Resource;
v1 = 0i64;
v3 = 0;
Resource = 0i64;
ValueName = 0i64;
LODWORD(Length) = 0;
KeyHandle = 0i64;
if( !DeviceNode->BootResources )
{
IopQueryDeviceResources(DeviceNode->PhysicalDeviceObject, 0i64, &Resource, &Length);
v3 = v4;
if( v4 < 0 )
{
Resource = 0i64;
LODWORD(Length) = 0;
}
else
{
v1 = Resource;
}
}
if( ((DeviceNode->Flags & 0x2000) == 0 || DeviceNode->Problem != 9)
&& ((DeviceNode->Flags & 0x2000) == 0 || DeviceNode->Problem != 3 && DeviceNode->Problem != 19) )
{
LODWORD(DesiredAccess) = 983103;
v5 = CmOpenDeviceRegKey(
*(&stru_140CF2E80 + 607),
DeviceNode->InstancePath.Buffer,
CM_KEY_TYPE_DEVICE_LOGCONF,
0i64,
DesiredAccess,
v1 != 0i64,
&KeyHandle,
0i64);
v6 = KeyHandle;
if( v5 < 0 )
v6 = 0i64;
KeyHandle = v6;
if( v6 )
{
if( !DeviceNode->BootResources )
{
*(_DWORD *)&ValueName.Length = 1441812;
ValueName.Buffer = (wchar_t *)L"BootConfig";
CurrentThread = (_ETHREAD *)KeGetCurrentThread();
--CurrentThread->Tcb.KernelApcDisable;
ExAcquireResourceSharedLite((UINT64)&PnpReplaceEvent + 6688, 1);
if( Resource )
{
LODWORD(Create) = Length;
ZwSetValueKey(KeyHandle, &ValueName, 0i64, 8ui64, Resource, Create);
}
else
{
ZwDeleteValueKey(KeyHandle, &ValueName, v9);
}
ExReleaseResourceLite((PERESOURCE)((char *)&PnpReplaceEvent + 6688));
KeLeaveCriticalRegionThread(KeGetCurrentThread());
v1 = Resource;
if( !Resource )
goto LABEL_11;
v3 = (*(&PnpReplaceEvent + 683))(4i64, DeviceNode->PhysicalDeviceObject, Resource);
if( v3 >= 0 )
PipSetDevNodeFlags(DeviceNode, 0x40ui64);
}
}
}
if( v1 )
ExFreePoolWithTag(v1, 0);
LABEL_11:
if( KeyHandle )
ZwClose((_HANDLE)KeyHandle);
return v3;
}Referenced by:
PiProcessNewDeviceNode