MiGetSinglePageToZero

_MMPFN *__fastcall MiGetSinglePageToZero(INT64 a1, RTL_BALANCED_NODE *a2){
  __int64 v3; 
  int v4; 
  unsigned __int64 v5; 
  unsigned int i; 
  ULONG_PTR v7; 
  char *v8; 
  int v9; 
  bool v10; 
  int v11; 
  int ParentValue_high; 
  __int64 v14; 
  ParentValue_high = HIDWORD(a2[10].ParentValue);
  v3 = *(_QWORD *)(a1 + 2184);
  v4 = 0;
  v14 = v3;
  LOBYTE(v5) = 17;
  for( i = 0; i < 2; ++i )
  {
    do
    {
      v7 = *(_QWORD *)(v3 + 40i64 * HIDWORD(a2[10].ParentValue) + 16);
      if( v7 == 0xFFFFFFFFFi64 )
        goto LABEL_6;
      v8 = (char *)MmGetPfnDb() + 48 * v7;
      if( !i && *((__int64 *)v8 + 3) < 0 )
      {
        v4 = 1;
LABEL_6:
        v8 = 0i64;
      }
      if( !v8 )
        goto LABEL_14;
      v5 = (unsigned __int8)MiLockPageInline((INT64)v8);
      if( v7 <= 0xFFFFFFFFFi64
        && (*((_QWORD *)MmGetPfnDb() + 6 * v7 + 5) & 0x4000000000000i64) != 0
        && (v8[34] & 7) == 1
        && (*((_QWORD *)v8 + 5) & 0x1000000000i64) == 0 )
      {
        if( (v8[34] & 8) == 0 )
        {
          v4 = 0;
          break;
        }
        _InterlockedAnd64((volatile signed __int64 *)v8 + 3, 0x7FFFFFFFFFFFFFFFui64);
        __writecr8(v5);
        v8 = 0i64;
LABEL_14:
        v9 = HIDWORD(a2[10].ParentValue) & ~dword_140C4DBC0 | dword_140C4DBC0 & (HIDWORD(a2[10].ParentValue) + 1);
        HIDWORD(a2[10].ParentValue) = v9;
        goto LABEL_15;
      }
      _InterlockedAnd64((volatile signed __int64 *)v8 + 3, 0x7FFFFFFFFFFFFFFFui64);
      __writecr8(v5);
      v9 = HIDWORD(a2[10].ParentValue);
      v8 = 0i64;
LABEL_15:
      v10 = v9 == ParentValue_high;
      v3 = v14;
    }
    while( !v10 );
    if( !v4 )
      break;
    v3 = v14;
  }
  if( !v8 )
    return 0i64;
  if( *((_WORD *)v8 + 16) )
    KeBugCheckEx(0x4Eu, 0x8Dui64, v7, *((unsigned int *)v8 + 8), *((_QWORD *)v8 + 1));
  v11 = MiBeginPageAccessor(a2, (INT64)v8);
  _InterlockedAnd64((volatile signed __int64 *)v8 + 3, 0x7FFFFFFFFFFFFFFFui64);
  __writecr8((unsigned __int8)v5);
  if( v11 )
    return(_MMPFN *)v8;
  else
    return 0i64;
}

Referenced by:

MiGetPagesToZero