MiWaitForFreePage

VOID __stdcall MiWaitForFreePage(_MI_PARTITION *Partition, UINT64 HardFaultBehaviorWaitOk){
  UINT64 *v3; 
  int v4; 
  UINT64 v5; 
  _DWORD *v6; 
  int v7; 
  UINT64 v8; 
  UINT8 v9; 
  UINT8 v10; 
  IRP *Timeout; 
  struct _KLOCK_QUEUE_HANDLE LockHandle; 
  INT64 result[14]; 
  memset(&LockHandle, 0, sizeof(LockHandle));
  v3 = (UINT64 *)((char *)Partition + 4928);
  v4 = *((_DWORD *)KeGetCurrentThread() + 325) & 2;
  v5 = v4 != 0 ? 34 : 160;
  v6 = (_DWORD *)((char *)Partition + (-(__int64)(v4 != 0) & 0xFFFFFFFFFFFFFFE0ui64) + 4968);
  KeAcquireInStackQueuedSpinLock((UINT64 *)Partition + 616, &LockHandle);
  v7 = v6[6];
  while( !(unsigned int)MiSufficientAvailablePages((INT64)Partition, v5) )
  {
    KeResetEvent(v6, v8, v9, v10, Timeout);
    KeReleaseInStackQueuedSpinLockFromDpcLevel(&LockHandle);
    __writecr8(LockHandle.OldIrql);
    MiObtainFreePages(Partition);
    if( *((_QWORD *)Partition + 54) )
    {
      memset((INT64)result, 0i64);
      result[1] = *((_QWORD *)Partition + 22);
      VslpEnterIumSecureMode(2u, 253, 0i64, (INT64)result);
    }
    if( KeWaitForSingleObject(v6, WrFreePage, 0, 0, (PLARGE_INTEGER)&MiNoPagesTimeout) == 258 && v7 == v6[6] )
      MiNoPagesLastChance(Partition, (unsigned int)v5);
    v7 = v6[6];
    KeAcquireInStackQueuedSpinLock(v3, &LockHandle);
  }
  KeReleaseInStackQueuedSpinLockFromDpcLevel(&LockHandle);
  __writecr8(LockHandle.OldIrql);
}

Referenced by:

MiAllocateDriverPage
MiAllocateKernelStackPages
MiAllocateTopLevelPage
MiBuildForkPte
MiCopyOnWriteCheckConditions
MiDoneWithThisPageGetAnother
MiFillPerSessionProtos
MiGetSystemPage
MiHandleForkTransitionPte
MiMakeOutswappedPageResident
MiMakePageAvoidRead
MiSplitDirectMapPage
MiSwitchToTransition
MiWalkPageTablesRecursively
MmAccessFault
MmAllocateIndependentPagesEx