MiGetPteFromCopyList

UINT64 *__fastcall MiGetPteFromCopyList(UINT64 *a1, INT64 a2, INT64 a3){
  int v6; 
  int v7; 
  __int64 v8; 
  int v9; 
  char *v10; 
  UINT64 *v11; 
  char v12; 
  char v13; 
  INT64 v15; 
  UINT64 v16; 
  INT64 result; 
  int v18; 
  __int64 v19; 
  memset((INT64)&result, 0i64);
  v6 = 2;
  v7 = 1;
  if( a3 == -1 )
    v6 = 1;
  v8 = *(unsigned int *)a1;
  if( (unsigned int)(v8 + v6) > *((_DWORD *)a1 + 1) )
  {
    v15 = *(unsigned int *)a1;
    v18 = 20;
    v16 = a1[2] << 25;
    v19 = 0i64;
    MiInsertTbFlushEntry((INT64)&result, (__int64)(v16 - ((_QWORD)MmGetPteBase() << 25)) >> 16, v15, 0i64);
    MiFlushTbList((__int64)&result);
    v8 = 0i64;
  }
  v9 = 4;
  v10 = (char *)MmGetPfnDb() + 34;
  v11 = (UINT64 *)(a1[2] + 8 * v8);
  *(_DWORD *)a1 = v8 + v6;
  v12 = (unsigned __int8)v10[48 * a2] >> 6;
  if( v12 )
  {
    if( v12 == 2 )
      v9 = 28;
  }
  else
  {
    v9 = 12;
  }
  *v11 = MiMakeValidPte((UINT64)v11, a2, v9 | 0xA0000000);
  if( a3 != -1 )
  {
    v13 = (unsigned __int8)v10[48 * a3] >> 6;
    if( v13 )
    {
      if( v13 == 2 )
        v7 = 25;
    }
    else
    {
      v7 = 9;
    }
    v11[1] = MiMakeValidPte((UINT64)v11, a3, v7 | 0x20000000u);
  }
  return v11;
}

Referenced by:

MiAddPagesToEnclave
MiCopyPage
MiCopyPagesIntoEnclave
MiFillPerSessionProtos
MiSwapStackPage