MiDbgReadWriteEnclave
INT64 __stdcall MiDbgReadWriteEnclave(
PVOID EnclaveAddress,
PVOID Buffer,
UINT64 AmountToMove,
UINT64 EnclaveIsSource,
UINT64 *ReturnedBytesTransferred){
UINT64 *v5;
unsigned int v6;
UINT64 v7;
char *v8;
char *v9;
__int64 v10;
UINT64 v11;
INT64 result;
unsigned int v13;
UINT64 v14;
UINT64 v15;
v5 = ReturnedBytesTransferred;
v6 = EnclaveIsSource;
ReturnedBytesTransferred = 0i64;
v7 = AmountToMove;
v8 = (char *)Buffer;
v9 = (char *)EnclaveAddress;
*v5 = 0i64;
v10 = (unsigned __int8)EnclaveAddress & 7;
if( ((unsigned __int8)EnclaveAddress & 7) != 0 )
{
v11 = 8 - v10;
if( AmountToMove < 8 - v10 )
v11 = (unsigned int)AmountToMove;
result = MiDbgReadWriteEnclaveUnaligned(EnclaveAddress, Buffer, (unsigned int)v11, EnclaveIsSource);
if( (int)result < 0 )
return result;
v9 += v11;
*v5 = v11;
v8 += v11;
v7 -= v11;
}
v13 = v7 & 7;
v14 = v7 & 7;
v15 = v7 - v14;
if( v15 )
{
if( v6 )
LODWORD(result) = KeDebugReadEnclaveMemory(v9, v8, v15, (UINT64 *)&ReturnedBytesTransferred);
else
LODWORD(result) = KeDebugWriteEnclaveMemory(v9, v8, v15, (UINT64 *)&ReturnedBytesTransferred);
*v5 += (UINT64)ReturnedBytesTransferred;
if( (int)result < 0 )
return(unsigned int)result;
v9 += v15;
v8 += v15;
}
if( v13 )
{
result = MiDbgReadWriteEnclaveUnaligned(v9, v8, v13, v6);
if( (int)result < 0 )
return result;
*v5 += v14;
}
return 0i64;
}Referenced by:
MmCopyVirtualMemory