MCPcopy Create free account
hub / github.com/Astronaut00/DoubleDataPointer / WritePhysicalAddress

Function WritePhysicalAddress

Driver/core.cpp:99–117  ·  view source on GitHub ↗

MmMapIoSpaceEx limit is page 4096 byte

Source from the content-addressed store, hash-verified

97
98 //MmMapIoSpaceEx limit is page 4096 byte
99 NTSTATUS WritePhysicalAddress(uint64_t TargetAddress, PVOID lpBuffer, SIZE_T Size, SIZE_T* BytesWritten)
100 {
101 if (!TargetAddress)
102 return STATUS_UNSUCCESSFUL;
103
104 PHYSICAL_ADDRESS AddrToWrite = { 0 };
105 AddrToWrite.QuadPart = TargetAddress;
106
107 PVOID pmapped_mem = MmMapIoSpaceEx(AddrToWrite, Size, PAGE_READWRITE);
108
109 if (!pmapped_mem)
110 return STATUS_UNSUCCESSFUL;
111
112 memcpy(pmapped_mem, lpBuffer, Size);
113
114 *BytesWritten = Size;
115 MmUnmapIoSpace(pmapped_mem, Size);
116 return STATUS_SUCCESS;
117 }
118
119#define PAGE_OFFSET_SIZE 12
120 static const uint64_t PMASK = (~0xfull << 8) & 0xfffffffffull;

Callers 2

WriteVirtualFunction · 0.85
WriteProcessMemoryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected