MiDbgCopyMemory
INT64 __stdcall MiDbgCopyMemory(
UINT64 UntrustedAddress,
VOID *Buffer,
UINT64 NumberOfBytes,
UINT64 ChunkSize,
UINT64 Flags){
unsigned int v5;
UINT64 v6;
unsigned int v8;
int v10;
int v11;
unsigned int v12;
__int64 v13;
int v14;
UINT64 v15;
unsigned int v16;
unsigned int v17;
PHYSICAL_ADDRESS PhysicalAddress;
UINT64 v19;
_HARDWARE_PTE Opaque;
__int128 v21;
__int64 Context[2];
int v23;
unsigned int v24;
int v25;
unsigned int v26;
v5 = ChunkSize;
v6 = (unsigned int)NumberOfBytes;
v8 = Flags;
Opaque = 0i64;
v21 = 0i64;
v26 = 0;
if( !(_DWORD)NumberOfBytes )
return 3221225713i64;
v10 = Flags & 2;
if( (Flags & 0x40) != 0 && ((Flags & 2) != 0 || (Flags & 1) == 0 || (Flags & 4) == 0) )
return 3221225714i64;
v12 = KeIsUserVaAccessAllowed(0i64) ? 2 : 0;
if( v14 )
{
if( v11 || KeGetCurrentIrql() <= 1u )
{
UntrustedAddress = MiDbgTranslatePhysicalAddress(UntrustedAddress, Flags, (__int64)&v21);
if( !UntrustedAddress )
return 3221225473i64;
LABEL_42:
v10 = v8 & 2;
if( (v10 | 4) == 4 && KeSmapEnabled )
__stac();
if( (v8 & 1) != 0 )
{
LODWORD(v19) = MiDbgWriteCheck((PVOID)UntrustedAddress, &Opaque, v15);
UntrustedAddress = v19;
if( !v19 )
{
v17 = -1073741585;
LABEL_26:
if( (v10 | 4) == 4 && v12 < 2 && KeSmapEnabled )
__clac();
if( (v12 & 1) != 0 )
MiDbgReleaseAddress((PVOID)UntrustedAddress, &Opaque, v8);
if( v10 )
MiDbgUnTranslatePhysicalAddress((int *)&v21);
return v17;
}
v12 |= 1u;
goto LABEL_49;
}
goto LABEL_24;
}
return 3221225714i64;
}
if( v11 )
{
if( MmIsAddressValidEx(UntrustedAddress) )
{
if( (Flags & 0x40) == 0 )
goto LABEL_42;
PhysicalAddress = MmGetPhysicalAddress((PVOID)UntrustedAddress);
UntrustedAddress = MiDbgTranslatePhysicalAddress(PhysicalAddress.QuadPart, Flags, (__int64)&v21);
if( UntrustedAddress )
{
v8 = Flags | 2;
goto LABEL_42;
}
return(unsigned int)-1073741823;
}
else
{
return(unsigned int)-1073741585;
}
}
if( KeGetCurrentIrql() > 1u )
return 3221225714i64;
if( UntrustedAddress < 0xFFFF800000000000ui64 )
{
if( (Flags & 1) != 0 )
{
ProbeForWrite((VOID *)UntrustedAddress, v6, (unsigned int)v6);
}
else
{
if( (((_DWORD)v6 - 1) & (unsigned int)UntrustedAddress) != 0 )
ExRaiseDatatypeMisalignment();
if( UntrustedAddress + v6 > 0x7FFFFFFF0000i64 || UntrustedAddress + v6 < UntrustedAddress )
MEMORY[0x7FFFFFFF0000] = 0;
}
if( (Flags & 1) != 0 )
{
LABEL_49:
MiCopyToUntrustedMemory((VOID *)UntrustedAddress, Buffer, (unsigned int)v6, v5);
goto LABEL_25;
}
LABEL_24:
v16 = MiCopyFromUntrustedMemory(Buffer, (VOID *)UntrustedAddress, (unsigned int)v6, v5);
LABEL_25:
v17 = v16;
goto LABEL_26;
}
Context[0] = UntrustedAddress;
v23 = v6;
Context[1] = v13;
v24 = v5;
v25 = Flags;
KeGenericCallDpc((PKDEFERRED_ROUTINE)MiDbgCopyMemoryTarget, Context);
return v26;
}Referenced by:
MmDbgCopyMemory