-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.cpp
More file actions
31 lines (26 loc) · 774 Bytes
/
Copy pathutils.cpp
File metadata and controls
31 lines (26 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "utils.hpp"
extern "C" {
NTSYSAPI
PVOID
NTAPI
MmGetVirtualForPhysical(
IN PHYSICAL_ADDRESS PhysicalAddress
);
}
namespace Utils {
ULONG64 PhysicalToVirtual(ULONG64 physicalAddress) {
PHYSICAL_ADDRESS physAddr;
physAddr.QuadPart = physicalAddress;
PVOID virtualAddr = MmGetVirtualForPhysical(physAddr);
return reinterpret_cast<ULONG64>(virtualAddr);
}
NTSTATUS ReadVirtualMemory(ULONG64 address, PVOID buffer, SIZE_T size) {
__try {
RtlCopyMemory(buffer, reinterpret_cast<PVOID>(address), size);
return STATUS_SUCCESS;
}
__except (EXCEPTION_EXECUTE_HANDLER) {
return STATUS_ACCESS_VIOLATION;
}
}
}