| 366 | |
| 367 | _IRQL_requires_max_(APC_LEVEL) |
| 368 | PVOID64 GetPhysicalAddress(PVOID VirtualAddress, OPTIONAL PEPROCESS Process) { |
| 369 | if (!Process || Process == PsGetCurrentProcess()) { |
| 370 | return MmIsAddressValid(VirtualAddress) |
| 371 | ? reinterpret_cast<PVOID64>(MmGetPhysicalAddress(VirtualAddress).QuadPart) |
| 372 | : NULL; |
| 373 | } |
| 374 | |
| 375 | KAPC_STATE ApcState; |
| 376 | KeStackAttachProcess(Process, &ApcState); |
| 377 | PVOID64 PhysicalAddress = MmIsAddressValid(VirtualAddress) |
| 378 | ? reinterpret_cast<PVOID64>(MmGetPhysicalAddress(VirtualAddress).QuadPart) |
| 379 | : NULL; |
| 380 | KeUnstackDetachProcess(&ApcState); |
| 381 | return PhysicalAddress; |
| 382 | } |
| 383 | |
| 384 | PVOID GetVirtualForPhysical(PVOID64 PhysicalAddress) { |
| 385 | return MmGetVirtualForPhysical(*reinterpret_cast<PPHYSICAL_ADDRESS>(&PhysicalAddress)); |
no outgoing calls
no test coverage detected