INFO: Overview of the Windows 95 Virtual Address Space Layout
This article was previously published under Q125691
This article has been archived. It is offered "as is" and will no longer be updated.
The virtual memory management mechanism in Microsoft Windows 95 makes itpossible to execute Win32-based, 16-bit-based, and MS-DOS-basedapplications simultaneously. To accomplish this, the virtual memory manageruses a virtual address space layout that is considerably different fromthat used by Microsoft Windows version 3.x and that is slightly differentfrom that used by Microsoft Windows NT. Although the differences fromWindows NT are slight, they are important.
The memory manager in Windows 95 uses paging and 32-bit linear addressingto provide a full 32-bit virtual address space that has a maximum size offour gigabytes (GB). This four-GB address space is partitioned by thememory manager into four major sections, known as arenas, that are used fordifferent types of applications and parts of the system. The first arena,from zero to four megabytes (MB) exists for compatibility with applicationsbased on Windows version 3.1x and MS-DOS. The next arena, from four MB totwo GB, is the private address space for each Win32 process. The thirdarena, from two to three GB, is a shared address space that contains memorymapped files and the 16-bit components. Finally, the fourth arena, fromthree to four GB, is reserved for the system's use.
The following diagram shows the overall virtual address space layout usedin Windows 95. The Compatibility Arena holds the current virtual machineand other software. Each Win32 process gets its own private address spacein which to execute. The Private Arena contains the currently executingWin32 process's private address space. All 16-bit-based applications andDLLs, including the 16-bit Windows system components, reside in the SharedArena. Finally, the Reserved System Arena is used to store all ring-0 codesuch as the virtual machine manager and virtual device drivers. It is notaccessible by either 16-bit-based or Win32-based applications.
+---------------------------------+ 4 Gigabytes | | | Reserved System Arena | | (Holds ring-0 components) | | | |---------------------------------| 3 Gigabytes | | | Shared Arena | | | | | |---------------------------------| 2 Gigabytes | | | Private Arena | | (Holds address space of | | currently executing | | Win32 process) | | | +---------------------------------+ 4 Megabytes | 16-bit/MS-DOS | | Compatibility Arena | +---------------------------------+ 0 Gigabytes
Each arena has a specific purpose and is described in detail below.
16-bit/MS-DOS Compatibility Arena
The first four megabytes of the system's address space is reserved by thesystem and is accessible to 16-bit and MS-DOS software for compatibility.The current virtual machine occupies the lowest megabyte of this area. Theremaining three megabytes are mostly empty space but may contain MS-DOSdevice drivers and Terminate & Stay Resident (TSR) programs.
The 16-bt/MS-DOS Compatibility Arena is not accessible to Win32 processesfor reading or writing. This means Win32 processes may may not allocatememory, load DLLs, or be loaded below the four megabyte (MB) address.
The private arena holds the private address space of the currentlyexecuting Win32 process. Because every Win32 process gets its own addressspace, the contents of this arena will depend upon which process iscurrently executing. The memory manager maps the pages of a process'sprivate address space so that other processes cannot access it and corruptthe process. The process's code, data, and dynamically-allocated memory allexist in the private address space.
With the exception of the system's shared DLLs (USER32.DLL, GDI32.DLL, andKERNEL32.DLL), all DLLs loaded by the process are mapped into the process'sprivate address space. Windows extension DLLs such as SHELL32.DLL,COMCTL32.DLL, and COMDLG32.DLL are not system shared DLLs and are mappedinto the process's private address space.
Because console applications are Win32-based applications without graphicaluser interfaces, they too get their own private address spaces, as do Win32graphical user interface (GUI) applications.
The minimum load address for a Win32 process in Windows 95 is four MBbecause the first four megabytes are reserved for the Compatibility Arena.
The shared arena is unique to Windows 95. This arena contains componentsthat must be mapped into every process's address space. All of the pages inthis arena are mapped identically in every process.
The 16-bit global heap, which contains all 16-bit-based applications, DLLs,and 16-bit system DLLs, resides in the shared arena. The Win32 sharedsystem DLLs (USER32.DLL, GDI32.DLL, and KERNEL32.DLL) are also located inthe shared arena.
Unlike the Reserved System Arena, the shared arena is readable and writableby Win32 and 16-bit processes alike. This doesn't mean they are free to getmemory directly from this address space. All 16-bit-based applications andDLLs actually are located in the 16-bit global heap, so they allocatememory from the 16-bit global heap; when this heap needs to be grown,KRNL386.EXE gets the memory from the shared arena.
Win32 processes may not allocate memory directly from the shared arena, butthey always use it for mapping views of file mappings. Unlike Windows NT,where views of file mappings always are placed in the private addressspace, Windows 95 holds views of file mappings in the shared arena.
The DOS Protected Mode Interface (DPMI) server's memory pool is located inthe Shared Arena. Thus, calls to the DPMI server to allocate memory willresult in memory that is globally accessible.
Sometimes, a virtual device driver (VxD) may need to map a buffer passed toit by a Win32 process into globally accessible memory so that the buffercan be accessed even if the process isn't in context. By calling_LinPageLock virtual machine manager service with the PAGEMAPGLOBAL flag, aVxD can obtain a linear address in the shared arena that corresponds to thebuffer passed to it by the Win32 process.
Reserved System Arena
The reserved system contains the code and data of all ring-0 componentssuch as the virtual machine manager, DOS extender, DPMI server, and virtualdevice drivers. This arena is used exclusively by ring-0 components and notaddressable by ring 3 code, such as MS-DOS-based, 16-bit-based, andWin32-based applications and DLLs.
4.00 layout memory virtual
Article ID: 125691 - Last Review: 10/26/2013 02:19:00 - Revision: 3.0
Microsoft Win32 Application Programming Interface
- kbnosurvey kbarchive kbinfo KB125691