IopDropIrp

VOID __stdcall IopDropIrp(_IRP *Irp, _FILE_OBJECT *FileObject){
  INT64 v2; 
  _MDL *v5; 
  _MDL *Next; 
  struct _DMA_ADAPTER *v7; 
  _LIST_ENTRY **p_Blink; 
  signed __int64 v9; 
  bool v10; 
  signed __int64 v11; 
  ULONG_PTR BugCheckParameter4; 
  if( (*((_DWORD *)Irp + 4) & 0x20) != 0 )
    ExFreePoolWithTag(*((PVOID *)Irp + 3), 0);
  v5 = (_MDL *)*((_QWORD *)Irp + 1);
  if( v5 )
  {
    do
    {
      Next = v5->Next;
      IoFreeMdl(v5);
      v5 = Next;
    }
    while( Next );
  }
  v7 = (struct _DMA_ADAPTER *)*((_QWORD *)Irp + 10);
  if( v7 && FileObject && (*((_DWORD *)Irp + 4) & 4) == 0 )
    HalPutDmaAdapter(v7);
  if( (*((_DWORD *)Irp + 4) & 0x2000) != 0 )
    IopDequeueIrpFromFileObject(Irp, FileObject);
  if( FileObject )
  {
    if( (*((_DWORD *)Irp + 4) & 0x80u) == 0 )
    {
      p_Blink = &FileObject[-1].Event.Header.WaitListHead.Blink;
      ObpTraceObjectDereferenceIfActive(
        (INT64)&FileObject[-1].Event.Header.WaitListHead.Blink,
        (_BYTE *)1,
        1953261124i64,
        v2,
        BugCheckParameter4);
      v9 = _InterlockedExchangeAdd64(
             (volatile signed __int64 *)&FileObject[-1].Event.Header.WaitListHead.Blink,
             0xFFFFFFFFFFFFFFFFui64);
      v10 = v9 <= 1;
      v11 = v9 - 1;
      if( v10 )
      {
        if( p_Blink[1] )
          KeBugCheckEx(
            0x18u,
            ObTypeIndexTable[(unsigned __int8)ObHeaderCookie ^ *((unsigned __int8 *)p_Blink + 24) ^ (unsigned __int64)BYTE1(p_Blink)],
            (ULONG_PTR)FileObject,
            6ui64,
            (ULONG_PTR)p_Blink[1]);
        if( v11 < 0 )
          KeBugCheckEx(0x18u, 0i64, (ULONG_PTR)FileObject, 5ui64, v11);
        ObpDeferObjectDeletion((INT64)&FileObject[-1].Event.Header.WaitListHead.Blink);
      }
    }
  }
  if( (*((_DWORD *)Irp + 4) & 0x8000) == 0 || !(unsigned int)IopInterlockedAdd((UINT64 *)Irp + 11, 0xFFFFFFFFi64) )
    IoFreeIrp(Irp);
}

Referenced by:

IoRemoveIoCompletion
IopFreeCompletionListPackets
IopfCompleteRequest