MmMapIoSpace for an application to access a physical address
Application Environment: WinCE500
Virtual addresses are used in applications. If you want to operate on physical addresses
MmMapIoSpace is used to map physical addresses to virtual addresses, for example:
For example, pBaseAddress = (PUCHAR) MmMapIoSpace (ioPhysicalBase, Size, FALSE );
Same as above, accessing the point address of pBaseAddress is the physical address defined by ioPhysicalBase after the access is mapped.
PVOID MmMapIoSpace (
PHYSICAL_ADDRESS PhysicalAddress, parameter 1: physical address to be mapped
ULONG NumberOfBytes, parameter 2: ing address Length
BOOLEAN CacheEnable parameter 3: whether to use cache (uncached must be used in the driver)
);
Unlike OALPAtoVA, MmUnmapIoSpace must be used after MmMapIoSpace is used.
VOID MmUnmapIoSpace (
PVOID BaseAddress, parameter 1: virtual address after ing
ULONG NumberOfBytes parameter 2: ing address Length
);
In general NK driver writing, do not directly use the virtual address in g_oalAddressTable to standardize the programming style. The MmMapIoSpace and MmUnmapIoSpace functions are used in a unified manner.
For example, pBaseAddress = (PUCHAR) MmMapIoSpace (ioPhysicalBase, Size, FALSE );
Same as above, accessing the point address of pBaseAddress is the physical address defined by ioPhysicalBase after the access is mapped.
PVOID MmMapIoSpace (
PHYSICAL_ADDRESS PhysicalAddress, parameter 1: physical address to be mapped
ULONG NumberOfBytes, parameter 2: ing address Length
BOOLEAN CacheEnable parameter 3: whether to use cache (uncached must be used in the driver)
);
Unlike OALPAtoVA, MmUnmapIoSpace must be used after MmMapIoSpace is used.
VOID MmUnmapIoSpace (
PVOID BaseAddress, parameter 1: virtual address after ing
ULONG NumberOfBytes parameter 2: ing address Length
);
In general NK driver writing, do not directly use the virtual address in g_oalAddressTable to standardize the programming style. The MmMapIoSpace and MmUnmapIoSpace functions are used in a unified manner.
MmMapIoSpace is implemented in ceddk, so you only need to link ceddk. lib. Its source code is implemented in:
X: \ WINCE500 \ PUBLIC \ COMMON \ OAK \ DRIVERS \ CEDDK \ DDK_MAP
In the source code, virtualalloc is called to reserve virtual memory, and virtualcopy is used for ing.
Both functions do not require the Kernel permission, so they can be used without Full Kernel.
PS: in non-full kern mode, physical memory ing may fail, but can be called.
You can use setkmode to temporarily enable the ap to enter the kernel mode, and then perform operations on the memory.
In ce5, the AP can do anything the driver can do. You can write a program to access the kernel space, crack the system, or dump or modify the raw data on the flash. But from ce6.