Microsoft KB Archive/326162

= INFO: Address Space Layout of a Windows CE Process =

Article ID: 326162

Article Last Modified on 9/24/2003

-

APPLIES TO


 * Microsoft Windows CE Palm-size PC 2.01 software
 * Microsoft Internet Explorer 4.0 128-Bit Edition
 * Microsoft Windows CE 3.0 for the Handheld PC

-



This article was previously published under Q326162



SUMMARY
This article describes the 32-MB address space layout for a Microsoft Windows CE 3.0 process. It includes information about where DLLs are located and where the application (EXE) code is located. The article also describes the location of heaps and stacks.



MORE INFORMATION
Windows CE is a 32-bit operating system. The address space of the whole system ranges from 0 to 4 GB, with the largest value for a 32-bit address. The address range from 2 GB to 4 GB is reserved for the system.

The address space that ranges from 0 to 1 GB + 32 MB is additionally divided into 33 different sections. These sections are named &quot;process slots,&quot; with slot 0 at the bottom and slot 32 at the top. Slot 0 is used for the active process.

Each process on Windows CE maintains 32 MB of address space for DLLs, stacks, heaps, and other allocations. The 32-MB area that starts with address 0x02000000 is reserved for ROM-based DLLs that are designated as execute in place (XIP) functionality.


 * DLLs that load from RAM by the process follow the ROM-based DLLs.
 * Any free address space that is available to the process follows next.
 * The heap or heaps are present in the address space.
 * The stack or stacks are next
 * The sections for the EXE module reside lowest in the process address space. These addresses start at 64 kilobytes (KB) with address 0x00010000.
 * The system reserves the address range from 0 to 64 KB.

The order where heaps and stacks appear as described earlier is generally for simple applications. In a more complex application that has run for a while, the heaps and the stacks can appear in various orders and anywhere in the 32-MB address space that is free address space. This includes the region where ROM DLLs are designated.

When the heap manager must increase the size of the heap, it calls the VirtualAlloc function with the IpAddress parameter of NULL. For an application that uses a lot of memory and address space, Windows CE increases the size of the heap anywhere it can find free address space. That includes the region where the ROM DLLs are designated.

When an application creates a thread, Windows CE allocates a stack for the thread that uses VirtualAlloc. Again, Windows CE allocates the stack anywhere it can find free address space for the process that owns the thread.

