MiFreeMdlTracker

UINT64 __stdcall MiFreeMdlTracker(MDL *MemoryDescriptorList, UINT64 NumberOfPages){
  _QWORD *Process; 
  __int64 v5; 
  void *v6; 
  _QWORD *v7; 
  struct _KLOCK_QUEUE_HANDLE LockHandle; 
  Process = MemoryDescriptorList->Process;
  memset(&LockHandle, 0, sizeof(LockHandle));
  if( Process || (Process = PsInitialSystemProcess) != 0i64 )
  {
    v5 = Process[193];
    if( v5 )
    {
      v6 = 0i64;
      KeAcquireInStackQueuedSpinLock((UINT64 *)(v5 + 24), &LockHandle);
      v7 = *(_QWORD **)v5;
      while( v7 )
      {
        if( (unsigned __int64)MemoryDescriptorList < v7[3] )
        {
          v7 = (_QWORD *)*v7;
        }
        else
        {
          if( (unsigned __int64)MemoryDescriptorList <= v7[3] )
          {
            v6 = v7;
            MiValidateMdlTracker(v7);
            RtlAvlRemoveNode((unsigned __int64 *)v5, v7);
            *(_QWORD *)(v5 + 16) -= NumberOfPages;
            break;
          }
          v7 = (_QWORD *)v7[1];
        }
      }
      KeReleaseInStackQueuedSpinLockFromDpcLevel(&LockHandle);
      __writecr8(LockHandle.OldIrql);
      if( v6 )
      {
        ExFreeToNPagedLookasideList((NPAGED_LOOKASIDE_LIST *)qword_140C4E780, v6);
      }
      else if( *(_DWORD *)(v5 + 32) )
      {
        KeBugCheckEx(0x76u, 1ui64, (ULONG_PTR)MemoryDescriptorList, Process[160], Process[193]);
      }
    }
  }
  return 1i64;
}

Referenced by:

MmUnlockPages