Windows Int 21h and NetBIOS Support for DPMI

Last reviewed: February 15, 1996
Article ID: Q65128
The information in this article applies to:
  • Microsoft Windows Software Development Kit versions 3.0 and 3.1

SUMMARY

This article is part of a set of seven articles, collectively called the "Windows Developer's Notes." More information about the contents of the other articles can be found in the Microsoft Knowledge Base article:

   ARTICLE-ID: Q65260
   TITLE     : The Windows Developer's Notes

Download WINDOS.EXE, a self-extracting file, from the Microsoft Software Library (MSL) on the following services:
  • Microsoft Download Service (MSDL)

          Dial (206) 936-6735 to connect to MSDL
          Download WINDOS.EXE (size: 16236 bytes) 
    
  • Internet (anonymous FTP)

          ftp ftp.microsoft.com
          Change to the \SOFTLIB\MSLFILES directory
          Get WINDOS.EXE (size: 16236 bytes) 
    

MORE INFORMATION

This document provides a brief overview of the DOS Protected Mode Interface (DPMI) version 0.9 and information on how to obtain a copy of the specification. It also provides information on Microsoft Windows version 3.0 support for the following:

  • Applications that use DPMI functions whether or not the application is based on Windows
  • MS-DOS interrupts and function requests under Windows in protected mode, and the degree to which they are supported
  • NetBIOS in protected mode

DPMI enables MS-DOS-based applications to access the extended memory of PC architecture computers while maintaining system protection. It also defines a new interface, via software interrupt 31H, that protected-mode applications use to do such things as allocate memory, modify descriptors, and call real-mode software.

Throughout this document and the DPMI specification, the term "real-mode software" is used to refer to code that runs in the low 1-megabyte address space and uses segment:offset addressing. Under Windows version 3.0 in protected mode, so-called real-mode software is actually executed in virtual 8086 mode. However, since virtual 8086 mode is a very close approximation of real mode, both are referred to as "real mode" in this document.

For further information on, or to request a copy of, the DPMI specification, call Intel at (800) 548-4725.

               APPLICATIONS THAT USE DPMI FUNCTIONS

Windows version 3.0 running in 386 enhanced mode supports DPMI version 0.9. Windows version 3.0 running in standard mode supports a subset of DPMI that enables applications to call Terminate-and-Stay-Resident (TSR) programs and device drivers running in real (or virtual 8086) mode. All code that calls DPMI directly should reside in a Dynamic-Link Library (DLL) to ease the porting of the application to other operating environments.

Windows-based applications should only call the following AX values for DPMI version 0.9 functions:

   AX value       Description
   --------       -----------

   0200H          Get real mode interrupt vector
   0201H          Set real mode interrupt vector
   0300H          Simulate real mode interrupt
   0301H          Call real mode procedure with far return frame
   0302H          Call real mode procedure with Iret frame
   0303H          Allocate real mode call-back address
   0304H          Free real mode call-back address

NOTE: The table listed above differs from that in the printed copy of the "Windows 3.00 Developer's Notes" and reflects corrections.

Windows-based applications should NOT use DPMI's MS-DOS memory management functions. The Windows version 3.0 Kernel has two functions, GlobalDOSAlloc() and GlobalDOSFree(), that should be used by Windows applications and DLLs for allocating and freeing MS-DOS addressable memory.

Other than those listed above, no DPMI functions are required for Windows-based applications because the Kernel provides functions for allocating memory, manipulating descriptors, and locking memory. Applications not based on Windows that are running in 386 enhanced mode can use all the DPMI version 0.9 functions, since they are not restricted by the Kernel.

            OTHER APPLICATION PROGRAMMING INTERFACES (APIs)

In general, any software interrupt API that passes parameters in the EAX, EBX, ECX, EDX, ESI, EDI, and EBP registers will work as long as none of the registers contains a selector value. In other words, if a software interrupt API is completely register-based without any pointers, segment registers, or stack parameters, that API should work under Windows in protected mode.

More complex software interrupt APIs require the calling function to use the DPMI translation functions.

     SUPPORT FOR MS-DOS INTERRUPTS UNDER WINDOWS IN PROTECTED MODE

This section discusses support for MS-DOS interrupts and function requests made under Windows in protected mode. This discussion assumes MS-DOS version 3.x or later is being used.

All the MS-DOS interrupts and function requests that are not mentioned in this section should work exactly as documented in "The MS-DOS Encyclopedia."

UNSUPPORTED MS-DOS INTERRUPTS AND FUNCTION REQUESTS

The following MS-DOS interrupts are not supported in protected mode and will fail if called.

   INT         Description
   ---         -----------

   20H         Terminate program
   25H         Absolute disk read
   26H         Absolute disk write
   27H         Terminate and stay resident

The following MS-DOS INT 21H function requests are also not supported in protected mode.

   Function    Description
   --------    -----------

   00H         Terminate process
   0FH         Open file with FCB
   10H         Close file with FCB
   14H         Sequential read
   15H         Sequential write
   16H         Create file with FCB
   21H         Random read
   22H         Random write
   23H         Get file size
   24H         Set relative record
   27H         Random block read
   28H         Random block write
   67H         SetHandleCount

PARTIALLY SUPPORTED MS-DOS INT 21H FUNCTION REQUESTS

The following MS-DOS INT 21H function requests behave differently in protected mode than they do in real mode. To use these function requests, the application might require additional code.

Functions 25H and 35H, Set/Get Interrupt Vector

These functions set and get the protected-mode interrupt vector. They can be used to hook hardware interrupts, such as the timer or keyboard interrupt, as well as to hook software interrupts. Except for INT 23H, INT 24H, and INT 1CH, software interrupts that are issued in real mode are not reflected to protected-mode interrupt handlers. However, all hardware interrupts are reflected to protected-mode interrupt handlers before being reflected to real mode.

Function 38H, Get Country Data

This function returns a 34-byte buffer containing a double word (DWORD) call address at offset 12H that is used for case mapping. The DWORD contains a real-mode address. In order to call the case mapping function, the DPMI translation function to simulate a real-mode FAR call must be used. See the DPMI specification for more details.

Function 44H, Subfunctions 02H, 03H, 04H, and 05H

These I/O control (IOCTL) subfunctions are used to receive data from a device or send data to a device. Since it is not possible to break the transfers automatically into small pieces, the caller should assume that a transfer of greater than 4K will fail unless the address of the buffer is in the low 1 megabyte range.

Function 44H, Subfunction 0CH

Only the minor function codes 45H (Get Iteration Count) and 65H (Set Iteration Count) are supported from protected mode. The extensions of this IOCTL subfunction that are used for code-page switching (minor function codes 4AH, 4CH, 4DH, 6AH, and 6BH) are not supported for protected-mode programs. The DPMI translation functions must be used if it is necessary to use this IOCTL subfunction to switch code pages.

Function 65H, Get Extended Country Information

This function is supported for protected-mode programs. However, all the DWORD parameters returned will contain real-mode addresses. This means that the case-conversion procedure address and all the pointers to tables will contain real-mode segment:offset addresses. The DPMI translation functions must be used to call the case-conversion procedure in real mode.

                          NETBIOS SUPPORT

Windows supports standard NetBIOS calls in protected mode. All the network control blocks and buffers must reside in fixed memory that is page locked. All code that calls NetBIOS directly should reside in a DLL to ease the porting of the application to other operating environments.

Additional information on NetBIOS and DPMI support in Windows network drivers is available in Chapter 6, "Network Support," in the "Microsoft Windows Device Driver Adaptation Guide," which is part of the Microsoft Windows Device Development Kit (DDK). Additional information can be found in the Windows developer's note titled "Developing Network Applications for Windows 3.00," available as article Q65125.


Additional reference words: 3.00 3.10 Windows 3 Developer's Notes softlib
KBCategory: kbprg kbfile
KBSubcategory: KrDpmi


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 15, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.