IopIncrementDeviceObjectRefCount
NTSTATUS __stdcall IopIncrementDeviceObjectRefCount(_DEVICE_OBJECT *DeviceObject, UINT8 LockRequired){
unsigned __int8 CurrentIrql;
KSPIN_LOCK_QUEUE *v4;
KSPIN_LOCK_QUEUE *v5;
NTSTATUS v6;
_KSPIN_LOCK_QUEUE *v7;
_KSPIN_LOCK_QUEUE *Next;
void *v10;
if( LockRequired )
{
CurrentIrql = KeGetCurrentIrql();
__writecr8(2ui64);
v4 = (KSPIN_LOCK_QUEUE *)(*((_QWORD *)KeGetPcr() + 5) + 160i64);
v5 = (KSPIN_LOCK_QUEUE *)_InterlockedExchange64((volatile __int64 *)v4->Lock, (__int64)v4);
if( v5 )
KxWaitForLockOwnerShip(v4, v5);
v6 = ++*((_DWORD *)DeviceObject + 1);
v7 = (_KSPIN_LOCK_QUEUE *)(*((_QWORD *)KeGetPcr() + 5) + 160i64);
_m_prefetchw(v7);
Next = v7->Next;
if( !v7->Next )
{
if( v7 == (_KSPIN_LOCK_QUEUE *)_InterlockedCompareExchange64(
(volatile signed __int64 *)v7->Lock,
0i64,
(signed __int64)v7) )
{
LABEL_6:
__writecr8(CurrentIrql);
goto LABEL_7;
}
Next = KxWaitForLockChainValid(v7);
}
v7->Next = 0i64;
_InterlockedXor64((volatile signed __int64 *)&Next->Lock, 1ui64);
goto LABEL_6;
}
v6 = ++*((_DWORD *)DeviceObject + 1);
LABEL_7:
if( v6 <= 0 )
{
v10 = (void *)*((_QWORD *)DeviceObject + 1);
if( v10 )
{
IoAddTriageDumpDataBlock(v10, 0x150ui64);
IoAddTriageDumpDataBlock(
*(PVOID *)(*((_QWORD *)DeviceObject + 1) + 64i64),
*(unsigned __int16 *)(*((_QWORD *)DeviceObject + 1) + 56i64));
}
KeBugCheckEx(0x18u, 0i64, (ULONG_PTR)DeviceObject, 6ui64, *((int *)DeviceObject + 1));
}
return v6;
}Referenced by:
IoCreateStreamFileObjectEx2
IoRegisterFileSystem
IopCompleteUnloadOrDelete
IopDeleteFile
IopMountVolume
IopShutdownBaseFileSystems
PnpMarkDeviceForRemove