IopRemoveDevice
NTSTATUS __stdcall IopRemoveDevice(DEVICE_OBJECT *TargetDevice, UINT64 IrpMinorCode){
int v2;
int v3;
__int64 v5;
DEVICE_OBJECT *v6;
PWCHAR v7;
NTSTATUS v8;
struct _DMA_ADAPTER *v9;
__int64 v10;
unsigned __int64 v11;
__int128 v13;
_BYTE result[80];
PVOID P;
v2 = 0;
v3 = IrpMinorCode;
v13 = 0i64;
if( TargetDevice )
v5 = *(_QWORD *)(*((_QWORD *)TargetDevice + 39) + 40i64);
else
v5 = 0i64;
P = 0i64;
PiPnpRtlBeginOperation((__int64 **)&P);
if( v3 == 2 )
IopUncacheInterfaceInformation(TargetDevice, 1ui64);
memset((INT64)result, 0i64);
result[0] = 27;
result[1] = v3;
if( PnpFindMountableDevice(TargetDevice) )
{
v2 = 1;
PnpLockMountableDevice(TargetDevice);
v6 = (DEVICE_OBJECT *)PnpMarkDeviceForRemove((ULONG_PTR)TargetDevice, 1, (ULONG_PTR *)&v13);
PnpUnlockMountableDevice(TargetDevice);
}
else
{
v6 = TargetDevice;
}
if( v3 == 2 || v3 == 23 )
{
if( (*(_DWORD *)(v5 + 400) & 8) != 0 )
{
PipClearDevNodeUserFlags(v5, 8);
IopDecDisableableDepends((_DEVICE_NODE *)v5);
}
if( v3 == 2 )
{
PiSwProcessParentRemoveIrp(TargetDevice);
PiSwStopDestroy(v7);
}
}
v8 = IopSynchronousCall(v6, (IO_STACK_LOCATION *)result, 3221225659i64, 0i64, 0i64);
if( v2 )
{
PnpLockMountableDevice(TargetDevice);
if( (unsigned int)(v3 - 2) <= 1 )
PnpMarkDeviceForRemove((ULONG_PTR)TargetDevice, 0, (ULONG_PTR *)&v13);
v9 = (struct _DMA_ADAPTER *)*((_QWORD *)&v13 + 1);
if( *((_QWORD *)&v13 + 1) )
{
IopDecrementDeviceObjectHandleCount(*((_DEVICE_OBJECT **)&v13 + 1));
HalPutDmaAdapter(v9);
}
PnpUnlockMountableDevice(TargetDevice);
if( (v3 != 1 || v8 < 0) && v3 != 23 )
{
LABEL_21:
if( v3 != 2 )
goto LABEL_26;
goto LABEL_22;
}
v8 = IopInvalidateVolumesForDevice(TargetDevice);
}
if( v3 != 23 )
goto LABEL_21;
LABEL_22:
PoFxAbandonDevice((_DEVICE_NODE *)v5);
*(_DWORD *)(v5 + 156) = 0;
if( v3 == 2 )
{
PipClearDevNodeFlags((_DEVICE_NODE *)v5, 0x1008ui64);
v10 = *(_QWORD *)(v5 + 648);
if( v10 )
{
if( (v10 & 1) != 0 )
{
v11 = v10 & 0xFFFFFFFFFFFFFFFEui64;
*(_QWORD *)(v5 + 648) = v11;
--*(_DWORD *)(v11 + 656);
}
}
}
LABEL_26:
if( P )
PiPnpRtlEndOperation(P);
return v8;
}Referenced by:
PnpDeleteLockedDeviceNode
PnpDisableDevice
PnpQueryRemoveLockedDeviceNode
PnpRemoveLockedDeviceNode
PnpSurpriseRemoveLockedDeviceNode