MCPcopy Create free account
hub / github.com/HoShiMin/Kernel-Bridge / WritePhysicalMemory

Function WritePhysicalMemory

Kernel-Bridge/API/MemoryUtils.cpp:419–446  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

417
418 _IRQL_requires_max_(APC_LEVEL)
419 BOOLEAN WritePhysicalMemory(OUT PVOID64 PhysicalAddress, IN PVOID Buffer, SIZE_T Length, MEMORY_CACHING_TYPE CachingType) {
420 BOOLEAN Status;
421 PVOID VirtualAddress = GetVirtualForPhysical(PhysicalAddress);
422 if (VirtualAddress) {
423 __try {
424 VirtualMemory::CopyMemory(VirtualAddress, Buffer, Length);
425 Status = TRUE;
426 } __except (EXCEPTION_EXECUTE_HANDLER) {
427 Status = FALSE;
428 }
429 } else {
430 Status = FALSE;
431 }
432
433 if (!Status) {
434 PVOID MappedMemory = MapPhysicalMemory(PhysicalAddress, Length, CachingType);
435 if (!MappedMemory) return FALSE;
436 __try {
437 VirtualMemory::CopyMemory(MappedMemory, Buffer, Length);
438 Status = TRUE;
439 } __except (EXCEPTION_EXECUTE_HANDLER) {
440 Status = FALSE;
441 }
442 UnmapPhysicalMemory(MappedMemory, Length);
443 }
444
445 return Status;
446 }
447}
448
449namespace Mdl {

Callers 1

KbWritePhysicalMemoryFunction · 0.85

Calls 4

GetVirtualForPhysicalFunction · 0.85
CopyMemoryFunction · 0.85
MapPhysicalMemoryFunction · 0.85
UnmapPhysicalMemoryFunction · 0.85

Tested by

no test coverage detected