MiWriteEnclavePte
INT64 __stdcall MiWriteEnclavePte(PVOID BugCheckParameter1, INT64 a2){
__int64 v2;
int v3;
int v4;
__int64 v5;
INT64 v8;
char *v9;
UINT8 v10;
INT64 result;
INT64 v12;
BOOL v13;
INT64 v14;
INT64 v15;
int v16;
v4 = v3;
v5 = v2;
v8 = *((_QWORD *)KeGetCurrentThread() + 23) + 1664i64;
v9 = (char *)MmGetPteBase() + (((unsigned __int64)BugCheckParameter1 >> 9) & 0x7FFFFFFFF8i64);
if( v16 )
{
v10 = MiLockWorkingSetShared(v8);
MiMakeSystemAddressValid((UINT64)BugCheckParameter1, 0i64, (*(_DWORD *)(v5 + 48) >> 12) & 0x3F, v10, 0);
}
else
{
v10 = 17;
}
if( v4 )
{
LOBYTE(result) = MiWriteValidPteNewProtection((INT64 *)BugCheckParameter1, a2);
}
else
{
v12 = MI_READ_PTE_LOCK_FREE((INT64)BugCheckParameter1);
v13 = MiPteInShadowRange((UINT64)BugCheckParameter1);
v14 = 1i64;
if( v13 && (*(_DWORD *)(*((_QWORD *)KeGetCurrentThread() + 23) + 2172i64) & 0x1000) != 0 && (a2 & 1) != 0 )
a2 |= 0x8000000000000000ui64;
*(_QWORD *)BugCheckParameter1 = a2;
v15 = 0i64;
if( v12 )
{
if( (v12 & 0xC00) == 2048 )
v14 = 0i64;
}
else
{
v15 = 1i64;
}
result = v14 | (unsigned int)v15;
if( result )
result = MiUpdateAwePageTable((UINT64)v9, v14, v15);
}
if( v16 )
{
MiUnlockPageTableInternal(v8, (UINT64)v9);
return MiUnlockWorkingSetShared(v8, v10);
}
return result;
}Referenced by:
MiAddPagesToEnclave
MiCopyPagesIntoEnclave
MiProtectEnclavePages