MiCreateSparsePfnDatabase

UINT64 __stdcall MiCreateSparsePfnDatabase(_LOADER_PARAMETER_BLOCK *LoaderBlock){
  char *v1; 
  char *v2; 
  int v3; 
  UINT64 v4; 
  UINT64 v5; 
  __int64 v6; 
  unsigned __int64 v7; 
  UINT64 v8; 
  UINT64 v9; 
  v1 = (char *)LoaderBlock + 32;
  v2 = (char *)*((_QWORD *)LoaderBlock + 4);
  v3 = 3;
  v4 = 0i64;
  v5 = -1i64;
  if( v2 == (char *)LoaderBlock + 32 )
    goto LABEL_25;
  v6 = 0x1C5C0C00048i64;
  do
  {
    v7 = *((int *)v2 + 4);
    if( (unsigned int)v7 <= 0x28 && _bittest64(&v6, v7) )
    {
      if( v5 == -1i64 )
        goto LABEL_20;
    }
    else
    {
      if( v5 == -1i64 )
      {
        v5 = *((_QWORD *)v2 + 3);
        v6 = 0x1C5C0C00048i64;
        goto LABEL_19;
      }
      if( v5 + v4 == *((_QWORD *)v2 + 3) )
      {
        if( (v3 == 2 || v3 == 24) && ((_DWORD)v7 == 2 || (_DWORD)v7 == 24) )
        {
LABEL_34:
          v4 += *((_QWORD *)v2 + 4);
          v6 = 0x1C5C0C00048i64;
          goto LABEL_20;
        }
        if( v3 == 2 )
        {
LABEL_14:
          v8 = 0i64;
          goto LABEL_15;
        }
        if( (_DWORD)v7 != 2 && v3 != 24 && (_DWORD)v7 != 24 )
          goto LABEL_34;
      }
    }
    if( v3 == 2 || v3 == 24 )
      goto LABEL_14;
    v8 = 1i64;
LABEL_15:
    if( !(unsigned int)MxMapPfnRange(v5, v4, v8) )
      return 0i64;
    v7 = *((int *)v2 + 4);
    v6 = 0x1C5C0C00048i64;
    if( (unsigned int)v7 > 0x28 || !_bittest64(&v6, v7) )
    {
      v5 = *((_QWORD *)v2 + 3);
LABEL_19:
      v4 = *((_QWORD *)v2 + 4);
      v3 = v7;
      goto LABEL_20;
    }
    v5 = -1i64;
LABEL_20:
    v2 = *(char **)v2;
  }
  while( v2 != v1 );
  if( v5 == -1i64 || (v3 == 2 || v3 == 24 ? (v9 = 0i64) : (v9 = 1i64), (unsigned int)MxMapPfnRange(v5, v4, v9)) )
  {
LABEL_25:
    if( (BasePage == 0x1000000000i64 || (unsigned int)MxMapPfnRange(BasePage, 0x800ui64, 1ui64))
      && (unsigned int)MxMapPfnRange(0x1000000000ui64, 0xFFFFFFFFFFFFFFFFui64, 1ui64) )
    {
      return 1i64;
    }
  }
  return 0i64;
}

Referenced by:

MiCreatePfnDatabase