MiIsSystemVaAllocated

INT64 __stdcall MiIsSystemVaAllocated(){
  unsigned __int64 v0; 
  __int64 v1; 
  INT64 *v2; 
  unsigned __int64 v3; 
  unsigned __int64 v4; 
  INT64 result; 
  INT64 v6; 
  __int64 *v7; 
  __int64 v8; 
  __int64 *v9; 
  bool v10; 
  v2 = MiSystemVaToDynamicBitmap(15i64);
  v3 = (v0 - v2[4]) >> 21;
  v4 = ((__int64)((((v0 + v1 - 1) >> 18) & 0x3FFFFFF8) - ((v0 >> 18) & 0x3FFFFFF8)) >> 3) + 1;
  if( v3 >= *v2 )
    goto LABEL_2;
  if( v4 > 1 )
  {
    if( *v2 - v3 >= v4 )
    {
      v6 = v2[1];
      v7 = (__int64 *)(v6 + 8 * (v3 >> 6));
      v8 = *v7;
      v9 = (__int64 *)(v6 + 8 * ((v4 + v3 - 1) >> 6));
      if( v7 == v9 )
      {
        v10 = ((0xFFFFFFFFFFFFFFFFui64 >> (64 - (unsigned __int8)v4) << v3) & v8) == 0xFFFFFFFFFFFFFFFFui64 >> (64 - (unsigned __int8)v4) << v3;
      }
      else
      {
        if( ((-1i64 << v3) & v8) != -1i64 << v3 )
          goto LABEL_2;
        while( ++v7 != v9 )
        {
          if( *v7 != -1 )
            goto LABEL_2;
        }
        v10 = ((0xFFFFFFFFFFFFFFFFui64 >> ~((unsigned __int8)v4 + (unsigned __int8)v3 - 1)) & *v7) == 0xFFFFFFFFFFFFFFFFui64 >> ~((unsigned __int8)v4 + (unsigned __int8)v3 - 1);
      }
      LOBYTE(result) = v10;
      return(unsigned __int8)result;
    }
  }
  else if( !((__int64)((((v0 + v1 - 1) >> 18) & 0x3FFFFFF8) - ((v0 >> 18) & 0x3FFFFFF8)) >> 3) )
  {
    LOBYTE(result) = _bittest64((const signed __int64 *)v2[1], v3);
    return(unsigned __int8)result;
  }
LABEL_2:
  LOBYTE(result) = 0;
  return(unsigned __int8)result;
}

Referenced by:

MmAllocateSecurePoolMemory
MmFreeSecurePoolMemory