MiPageFileLargestBitmapsRun

NTSTATUS __stdcall MiPageFileLargestBitmapsRun(_MMPAGING_FILE *PagingFile){
  volatile int *p_SpinLock; 
  unsigned int v3; 
  unsigned __int64 v4; 
  unsigned __int64 Root; 
  _RTL_BALANCED_NODE *v6; 
  unsigned __int64 v7; 
  unsigned __int64 v8; 
  unsigned __int64 i; 
  unsigned int MaximumRunLengthInBitmaps; 

  p_SpinLock = &PagingFile->SpinLock;
  v3 = 0;
  v4 = (unsigned __int8)ExAcquireSpinLockShared((INT64 *)&PagingFile->SpinLock);
  Root = (unsigned __int64)PagingFile->BitmapsCacheLengthTree.Root;
  if( (PagingFile->BitmapsCacheLengthTree._bf_0 & 1) != 0 && Root )
    Root ^= (unsigned __int64)&PagingFile->BitmapsCacheLengthTree;
  v6 = 0i64;
  while( Root )
  {
    if( *(_DWORD *)(Root + 52) == -1 )
    {
      if( !*(_DWORD *)(Root + 48) )
        goto LABEL_13;
      v7 = *(_QWORD *)Root;
      v6 = (_RTL_BALANCED_NODE *)Root;
    }
    else
    {
      v7 = *(_QWORD *)(Root + 8);
    }
    if( (PagingFile->BitmapsCacheLengthTree._bf_0 & 1) != 0 && v7 )
      Root ^= v7;
    else
      Root = v7;
  }
  Root = (unsigned __int64)v6;
LABEL_13:
  v8 = *(_QWORD *)Root;
  if( *(_QWORD *)Root )
  {
    for( ; *(_QWORD *)(v8 + 8); v8 = *(_QWORD *)(v8 + 8) )
      ;
  }
  else
  {
    for( i = *(_QWORD *)(Root + 16); ; i = *(_QWORD *)(v8 + 16) )
    {
      v8 = i & 0xFFFFFFFFFFFFFFFCui64;
      if( !v8 || *(_QWORD *)(v8 + 8) == Root )
        break;
      Root = v8;
    }
  }
  if( v8 )
    v3 = *(_DWORD *)(v8 + 52);
  MaximumRunLengthInBitmaps = PagingFile->MaximumRunLengthInBitmaps;
  if( v3 > MaximumRunLengthInBitmaps )
    MaximumRunLengthInBitmaps = v3;
  ExReleaseSpinLockSharedFromDpcLevel(p_SpinLock);
  __writecr8(v4);
  return MaximumRunLengthInBitmaps;
}

Referenced by:

MiFindBestOutswapPagefile
MiFindFreePageFileSpace
MiGatherPagefilePages
MiGetKernelStackSwapSupport
MiTrimUnusedPageFileRegionsWorker