MmMapIoSpace and MmUnMapIoSpace

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.