Running Nonnative Applications in Windows 2000 Professional

MS-DOS and Win16 (which is built on MS-DOS) are emulated by VDMs, not subsystems. Unlike the subsystems, the VDMs are not server processes. Instead, they run as 32-bit applications on the Win32 subsystem. They emulate the source code of MS-DOS version 5.0, minus the file system support. In addition, the Win16 VDM has two extra layers of memory that are loaded to enable it to use the Windows user interface. These layers are shaded in Figure B.2, a diagram of VDM virtual memory usage. A description of each layer of memory follows.

Cc939094.fnic02(en-us,TechNet.10).gif

Figure B.2 VDM Memory Map

Instruction Execution Unit

For Windows 2000 running on a computer other than an x 86-based processor, the Instruction Execution Unit emulates the Intel 80486 instruction set, which lets the computer run the binary application.

On an x 86-based computer, the Instruction Execution Unit acts as a trap handler , which captures instructions that cause hardware traps and then transfers control to the code that handles them. A VDM on an x 86-based processor supports enhanced-mode applications .

32-bit MS-DOS Emulation

The 32-bit MS-DOS emulation layer emulates the DOS Protected Mode Interface (DPMI) and 32-bit memory access. Calls made to MS-DOS-level functions for extended and expanded memory are replaced in this layer with Windows 2000 memory calls. Windows 2000 then makes conversions so that the 16-bit application sees segmented memory as it normally would.

Device Drivers

Windows 2000 device drivers are a special type of dynamic load library (DLL) that assists in virtualizing hardware. The V x Ds support communication (COM) ports, line printers (LPTs), video cards, the system timer, and other standard hardware. Windows 2000 drivers are dynamically loaded, so that new drivers can be written to support other, nonstandard devices. In addition, a call to a 16-bit MS-DOS driver or terminate-and-stay-resident (TSR) program can be relayed in a VDM through the thunking process (which transforms calls between 16-bit and 32-bit formats) to a Windows 2000 driver to communicate with the Windows 2000 kernel.

This arrangement provides the functionality for compatibility with Microsoft Windows 3. x –based and MS-DOS-based applications, consistent with the design of Windows 2000. It avoids the unrestricted access to hardware that occurs in MS-DOS and sometimes in Windows 3. x .

The 16-bit MS-DOS-based virtual device drivers that are designed as kernel drivers for MS-DOS-based versions of Windows (Windows 3. x , Windows 95, and Windows 98) are not compatible with Windows 2000 drivers and are not supported under Windows 2000. For more information about device compatibility, see Device Driver Requirements later in this chapter.

32-bit WOW Translation

The WOW (Win16-on-Win32) layer consists of 32-bit window manager code and Graphics Device Interface (GDI) code that translates 16-bit segmented addresses into 32-bit flat addresses.

A 16-bit application cannot call a 32-bit application programming interface (API). When an application calls a 16-bit API, the call goes to a stub routine , which in turn calls a 32-bit API. The 32-bit API performs the required action, and the result is transformed into the format expected by the 16-bit API stub, which returns the result to the application. This transformation is an example of thunking.

Heap

This area of memory holds code and data segments for 16-bit applications and DLLs, temporarily stored while programs are executing. This is a portion of memory whose existence or size cannot be determined until the VDM is running. In a Win16 VDM, this space is controlled by the Win16 kernel (Krnl386.exe) and contains Win16 global memory objects as well as objects allocated with the 16-bit GLOBALALLOC( ) parameter. In an MS-DOS VDM, the space is given to extended memory specification (XMS) memory , managed by the Himem.sys file.

Windows 3.1 Kernel

The Windows 3.1 emulation layer provides the functionality of the Windows 3.1 kernel and 16-bit API stubs. This is the layer that issues the 16-bit segmented addresses that are translated into 32-bit flat addresses by the WOW layer.

Applications

The 16-bit application or applications that are being processed in the VDM resides in this layer.

16-bit MS-DOS Emulation

The 16-bit MS-DOS emulation layer contains all the information to emulate basic input/output system (BIOS) calls and tables.

Show: