Developer knowledge network · moderated exchange

UnreliableCode-Community

Community für Entwicklerforschung, Reverse Engineering und Codierung

Knowledge indexLive
4Categories
919Threads
2.8KBeiträge
Tutorial

Physical Memory Page Mapping via MmMapIoSpace and PML4 translation

kernel_komrade
Driver Dev
MEMBER
Vertreter: 145
Beitrittsdatum: Feb 2019
Beiträge: 26
Danke: 45
Vor 1 Monaten · Jul 9, 2026 7:47 AM
#1

To read physical RAM without relying on virtual page table CR3 contexts:

C
NTSTATUS ReadPhysicalAddress(PHYSICAL_ADDRESS physAddr, PVOID buffer, SIZE_T size) {
    PVOID pMapped = MmMapIoSpace(physAddr, size, MmNonCached);
    if (!pMapped) return STATUS_INSUFFICIENT_RESOURCES;
    RtlCopyMemory(buffer, pMapped, size);
    MmUnmapIoSpace(pMapped, size);
    return STATUS_SUCCESS;
}

Physical addresses are immutable across thread context switches, making physical memory mapping 100% immune to virtual CR3 directory base swapping.

dma_ghost
DMA Guru
MEMBER
Vertreter: 115
Beitrittsdatum: Jan 2020
Beiträge: 12
Danke: 83
Vor 1 Monaten · Jul 9, 2026 9:49 AM
#2

This is identical to how PCIe DMA hardware reads memory. Physical RAM mapping is the cleanest kernel read technique.

hypervisor_hank
Kernel Wizard
MEMBER
Vertreter: 108
Beitrittsdatum: Feb 2020
Beiträge: 17
Danke: 44
Vor 1 Monaten · Jul 9, 2026 5:44 PM
#3

Make sure you don't map non-existent physical addresses to avoid BugCheck 0x3B.