PnpReleaseResourcesInternal
NTSTATUS __fastcall PnpReleaseResourcesInternal(_DEVICE_NODE *DeviceNode){
_CM_RESOURCE_LIST *ResourceList;
_ARBITER_INTERFACE *v3;
unsigned int Count;
_CM_FULL_RESOURCE_DESCRIPTOR *List;
unsigned int v6;
_INTERFACE_TYPE InterfaceType;
unsigned int BusNumber;
_DEVICE_NODE *Parent;
int v10;
_PI_RESOURCE_ARBITER_ENTRY *p_DeviceArbiterList;
_PI_RESOURCE_ARBITER_ENTRY *i;
__int64 v13;
__int64 v14;
_DEVICE_NODE *LegacyBusDeviceNode;
_DEVICE_NODE *v17;
unsigned int v18;
_CM_PARTIAL_RESOURCE_DESCRIPTOR *PartialDescriptors;
__int64 v20;
__int64 LowPart;
__int64 v22[18];
int v23;
unsigned int v24;
unsigned int v25;
memset(v22, 0i64, 0x60u);
ResourceList = DeviceNode->ResourceList;
v3 = 0i64;
v22[1] = (__int64)v22;
LODWORD(v22[2]) = 0;
v22[0] = (__int64)v22;
v22[4] = (__int64)DeviceNode->PhysicalDeviceObject;
v22[3] = 0i64;
v22[5] = 4i64;
v22[6] = 0i64;
v22[9] = 0i64;
if( (ResourceList || (ResourceList = DeviceNode->BootResources) != 0i64) && (Count = ResourceList->Count) != 0 )
{
List = ResourceList->List;
}
else
{
Count = 1;
ResourceList = 0i64;
List = 0i64;
}
v25 = 0;
v6 = 0;
if( Count )
{
while( ResourceList )
{
InterfaceType = List->InterfaceType;
BusNumber = List->BusNumber;
v24 = BusNumber;
if( List->InterfaceType == InterfaceTypeUndefined )
goto LABEL_28;
LABEL_7:
if( DeviceNode == (_DEVICE_NODE *)*(&PnpReplaceEvent + 831) )
Parent = DeviceNode;
else
Parent = DeviceNode->Parent;
v10 = 1;
v23 = 1;
if( Parent )
{
do
{
if( Parent == (_DEVICE_NODE *)*(&PnpReplaceEvent + 831) && v10 )
{
LegacyBusDeviceNode = IopFindLegacyBusDeviceNode(InterfaceType, BusNumber);
Parent = LegacyBusDeviceNode;
if( LegacyBusDeviceNode == v17 && InterfaceType == Internal )
Parent = IopFindLegacyBusDeviceNode(Isa, 0i64);
v23 = (int)v3;
}
p_DeviceArbiterList = (_PI_RESOURCE_ARBITER_ENTRY *)&Parent->DeviceArbiterList;
for( i = (_PI_RESOURCE_ARBITER_ENTRY *)Parent->DeviceArbiterList.Flink;
i != p_DeviceArbiterList;
i = (_PI_RESOURCE_ARBITER_ENTRY *)i->DeviceArbiterList.Flink )
{
if( i->ArbiterInterface != v3 )
{
v23 = (int)v3;
v22[0] = (__int64)&i->ResourceList;
v22[1] = (__int64)&i->ResourceList;
i->ResourceList.Flink = (_LIST_ENTRY *)v22;
i->ResourceList.Blink = (_LIST_ENTRY *)v22;
IopCallArbiter(i, ArbiterActionTestAllocation, &i->ResourceList);
IopCallArbiter(i, ArbiterActionCommitAllocation, 0i64);
v13 = v22[0];
v14 = v22[1];
if( *(__int64 **)(v22[0] + 8) != v22 || *(__int64 **)v22[1] != v22 )
__fastfail(3u);
*(_QWORD *)v22[1] = v22[0];
v3 = 0i64;
*(_QWORD *)(v13 + 8) = v14;
v22[1] = (__int64)v22;
v22[0] = (__int64)v22;
p_DeviceArbiterList = (_PI_RESOURCE_ARBITER_ENTRY *)&Parent->DeviceArbiterList;
}
}
Parent = Parent->Parent;
v10 = v23;
BusNumber = v24;
}
while( Parent );
v6 = v25;
}
if( Count > 1 )
{
v18 = List->PartialResourceList.Count;
PartialDescriptors = List->PartialResourceList.PartialDescriptors;
if( v18 )
{
v20 = v18;
do
{
LowPart = (unsigned int)v3;
if( PartialDescriptors->Type == 5 )
LowPart = PartialDescriptors->u.Start.anonymous_0.LowPart;
PartialDescriptors = (_CM_PARTIAL_RESOURCE_DESCRIPTOR *)((char *)PartialDescriptors + LowPart + 20);
--v20;
}
while( v20 );
}
List = (_CM_FULL_RESOURCE_DESCRIPTOR *)PartialDescriptors;
}
v25 = ++v6;
if( v6 >= Count )
return IopWriteAllocatedResourcesToRegistry(DeviceNode, 0i64, 0i64);
}
BusNumber = (unsigned int)v3;
v24 = (unsigned int)v3;
LABEL_28:
InterfaceType = Isa;
goto LABEL_7;
}
return IopWriteAllocatedResourcesToRegistry(DeviceNode, 0i64, 0i64);
}Referenced by:
IopReleaseResources
PnpReallocateResources