MiCopyFromUntrustedMemory
NTSTATUS __stdcall MiCopyFromUntrustedMemory(
VOID *Destination,
VOID *UntrustedSource,
UINT64 NumberOfBytes,
UINT64 ChunkSize){
unsigned int v4;
_BYTE *v5;
_BYTE *v6;
unsigned int v7;
unsigned int i;
__int64 v10;
v4 = NumberOfBytes;
v5 = UntrustedSource;
v6 = Destination;
v10 = 0i64;
if( (_DWORD)ChunkSize
|| (((unsigned __int8)Destination | (unsigned __int8)UntrustedSource) & 7) != 0
|| (NumberOfBytes & 7) != 0 )
{
while( v4 )
{
if( (_DWORD)ChunkSize )
{
v7 = ChunkSize;
if( (unsigned int)ChunkSize > v4 )
v7 = 1;
}
else
{
v7 = v4 & 7;
if( (v4 & 7) != 0 )
{
if( ((v7 - 1) & v7) != 0 )
v7 = 1;
}
else
{
v7 = 8;
}
}
if( ((v7 - 1) & (unsigned int)v5) != 0 )
v7 = 1;
switch( v7 )
{
case 1u:
LOBYTE(v10) = *v5;
break;
case 2u:
LOWORD(v10) = *(_WORD *)v5;
break;
case 4u:
LODWORD(v10) = *(_DWORD *)v5;
break;
case 8u:
v10 = *(_QWORD *)v5;
break;
}
for( i = 0; i < v7; ++i )
*v6++ = *((_BYTE *)&v10 + i);
v4 -= v7;
v5 += v7;
}
}
else
{
memmove(Destination, UntrustedSource, NumberOfBytes);
}
return 0;
}Referenced by:
MiDbgCopyMemoryTarget