MmMapIoSpaceEx limit is page 4096 byte
| 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; |
no outgoing calls
no test coverage detected