MiGetPagesRemainingInResidentPage

INT64 __fastcall MiGetPagesRemainingInResidentPage(INT64 a1, INT64 *a2, INT64 *a3){
  INT64 v6; 
  _MMPFN *v7; 
  int PfnPageSizeIndex; 
  unsigned int v9; 
  int v10; 
  int v11; 
  __int64 v12; 
  INT64 v14; 
  INT64 v15; 
  LODWORD(v14) = 0;
  LODWORD(v15) = 0;
  v6 = (a1 - (__int64)MmGetPfnDb()) / 48;
  if( (KiBugCheckActive & 3) != 0 )
  {
    v7 = MiGetBaseResidentPageForBugCheck((_MMPFN *)a1);
    if( v7 )
    {
      PfnPageSizeIndex = MiGetPfnPageSizeIndex((INT64)v7);
    }
    else
    {
      v9 = *(unsigned __int8 *)(a1 + 34);
      PfnPageSizeIndex = 3;
    }
    v10 = v9 >> 6;
    v11 = v9 & 7;
  }
  else
  {
    PfnPageSizeIndex = MiGetPfnPageSizeIndexUnsynchronized(a1, &v14, &v15);
    v11 = v14;
    v10 = v15;
  }
  if( PfnPageSizeIndex == 3 )
    v12 = 1i64;
  else
    v12 = MiLargePageSizes[PfnPageSizeIndex];
  *(_DWORD *)a2 = v11;
  *(_DWORD *)a3 = v10;
  return v12 + (v6 & ~(v12 - 1)) - v6;
}

Referenced by:

MiAddPhysicalPagesToCrashDump