PnpDeleteLockedDeviceNodes
__int64 __fastcall PnpDeleteLockedDeviceNodes(
_DEVICE_OBJECT *DeviceObject,
_RELATION_LIST *DeviceRelations,
_PNP_DEVICE_DELETE_TYPE OperationCode,
int ProcessDeviceRelations,
unsigned int Problem,
int ProblemStatus,
_PNP_VETO_TYPE *VetoType,
_UNICODE_STRING *VetoName){
unsigned int v8;
char v9;
_DEVICE_OBJECT *v12;
unsigned int v13;
__int64 v14;
ULONG_PTR v15;
unsigned int v16;
int v17;
__int64 v19;
_DEVICE_OBJECT_LIST *DeviceObjectList;
INT64 v21;
_DEVICE_NODE *v22;
int a2[2];
__int64 a3;
int a4;
char v27;
v27 = ProcessDeviceRelations;
v8 = 0;
v9 = ProcessDeviceRelations;
v12 = DeviceObject;
v13 = 0;
a3 = 0i64;
a4 = 0;
if( DeviceRelations->Sorted )
{
*(_QWORD *)a2 = 1i64;
while( 1 )
{
do
{
if( !IopEnumerateRelations((unsigned int **)DeviceRelations, a2, &a3, &a4, 0i64) )
return v13;
}
while( !a4 && !v9 );
v14 = a3;
v15 = a3 ? *(_QWORD *)(*(_QWORD *)(a3 + 312) + 40i64) : 0i64;
if( Problem == 54 )
break;
if( (_DEVICE_OBJECT *)a3 == v12 )
{
v16 = Problem;
LABEL_10:
v8 = ProblemStatus;
goto LABEL_11;
}
if( a4 != 1 || (v16 = 51, OperationCode == CancelRemoveDevice) )
v16 = 0;
LABEL_11:
if( (unsigned int)(OperationCode - 2) <= 1 )
{
PiUpdateGuestAssignedState(v15, 0);
if( OperationCode == RemoveDevice && (*(_DWORD *)(v15 + 704) & 2) != 0 )
{
v8 = 0;
LABEL_27:
v12 = DeviceObject;
goto LABEL_16;
}
}
v17 = PnpDeleteLockedDeviceNode((_DEVICE_NODE *)v15, OperationCode, v16, v8, VetoType, VetoName);
v8 = 0;
v13 = v17;
if( OperationCode == QueryRemoveDevice && Problem == 54 && v17 == -1073740537 )
{
if( PipIsDeviceInDeviceObjectList(
(INT64 *)DeviceRelations->DeviceObjectList,
*(_QWORD *)(*(_QWORD *)(v15 + 16) + 32i64),
0i64) )
{
*(_DWORD *)(v19 + 704) |= 2u;
}
v13 = 0;
goto LABEL_27;
}
v12 = DeviceObject;
if( v17 < 0 )
{
if( (*(_DWORD *)(v15 + 704) & 4) == 0 )
KeBugCheckEx(0xCAu, 0xDui64, v15, 4ui64, 0i64);
PoFxIdleDevice(*(DEVICE_OBJECT **)(v15 + 32));
*(_DWORD *)(v15 + 704) &= ~4u;
if( a2[0] == 1 && a2[1] )
{
DeviceObjectList = DeviceRelations->DeviceObjectList;
a2[0] = 2;
a2[1] = DeviceObjectList->Count - a2[1];
}
else
{
*(_QWORD *)a2 = 3i64;
}
while( IopEnumerateRelations((unsigned int **)DeviceRelations, a2, &a3, 0i64, 0i64) )
{
if( v14 != a3 )
{
if( a3 )
v22 = *(_DEVICE_NODE **)(*(_QWORD *)(a3 + 312) + 40i64);
else
v22 = 0i64;
PnpDeleteLockedDeviceNode(v22, CancelRemoveDevice, 0i64, v21, VetoType, VetoName);
}
}
return(unsigned int)-2147483608;
}
LABEL_16:
v9 = v27;
}
v16 = 54;
goto LABEL_10;
}
return(unsigned int)-1073741823;
}Referenced by:
PipRemoveDevicesInRelationList
PipSendQueryRemoveIrpAndCheckOpenHandles
PnpProcessQueryRemoveAndEject