FILE: Windows Int 21h and NetBIOS Support for DPMI

This article was previously published under Q65128
This article has been archived. It is offered "as is" and will no longer be updated.
This article is part of a set of seven articles, collectively called the"Windows Developer's Notes." More information about the contents of theother articles can be found in the Microsoft Knowledge Base article:
65260The Windows Developer's Notes
More information
The following file is available for download from the Microsoft Download Center:
For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:
119591 How to Obtain Microsoft Support Files from Online Services
Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file.

This document provides a brief overview of the DOS Protected ModeInterface (DPMI) version 0.9 and information on how to obtain a copyof the specification. It also provides information on MicrosoftWindows 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 PCarchitecture computers while maintaining system protection. It alsodefines a new interface, via software interrupt 31H, thatprotected-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 low1-megabyte address space and uses segment:offset addressing. UnderWindows version 3.0 in protected mode, so-called real-mode software isactually executed in virtual 8086 mode. However, since virtual 8086mode is a very close approximation of real mode, both are referred toas "real mode" in this document.

For further information on, or to request a copy of, the DPMIspecification, call Intel at (800) 548-4725.
=======================================================================               APPLICATIONS THAT USE DPMI FUNCTIONS=======================================================================Windows version 3.0 running in 386 enhanced mode supports DPMI version0.9. Windows version 3.0 running in standard mode supports a subset ofDPMI 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 aDynamic-Link Library (DLL) to ease the porting of the application toother operating environments.Windows-based applications should only call the following AX values forDPMI 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 addressNOTE: The table listed above differs from that in the printed copy ofthe "Windows 3.00 Developer's Notes" and reflects corrections.Windows-based applications should NOT use DPMI's MS-DOS memory managementfunctions. The Windows version 3.0 Kernel has two functions,GlobalDOSAlloc() and GlobalDOSFree(), that should be used by Windowsapplications and DLLs for allocating and freeing MS-DOS addressablememory.Other than those listed above, no DPMI functions are required forWindows-based applications because the Kernel provides functions forallocating memory, manipulating descriptors, and locking memory.Applications not based on Windows that are running in 386 enhanced mode canuse all the DPMI version 0.9 functions, since they are not restricted bythe Kernel.=======================================================================            OTHER APPLICATION PROGRAMMING INTERFACES (APIs)=======================================================================In general, any software interrupt API that passes parameters in theEAX, EBX, ECX, EDX, ESI, EDI, and EBP registers will work as long asnone of the registers contains a selector value. In other words, if asoftware interrupt API is completely register-based without anypointers, segment registers, or stack parameters, that API should workunder Windows in protected mode.More complex software interrupt APIs require the calling function touse the DPMI translation functions.=======================================================================     SUPPORT FOR MS-DOS INTERRUPTS UNDER WINDOWS IN PROTECTED MODE=======================================================================This section discusses support for MS-DOS interrupts and functionrequests made under Windows in protected mode. This discussion assumesMS-DOS version 3.x or later is being used.All the MS-DOS interrupts and function requests that are not mentionedin this section should work exactly as documented in "The MS-DOSEncyclopedia."UNSUPPORTED MS-DOS INTERRUPTS AND FUNCTION REQUESTS===================================================The following MS-DOS interrupts are not supported in protected modeand will fail if called.   INT         Description   ---         -----------   20H         Terminate program   25H         Absolute disk read   26H         Absolute disk write   27H         Terminate and stay residentThe following MS-DOS INT 21H function requests are also not supportedin 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         SetHandleCountPARTIALLY SUPPORTED MS-DOS INT 21H FUNCTION REQUESTS====================================================The following MS-DOS INT 21H function requests behave differently inprotected mode than they do in real mode. To use these functionrequests, the application might require additional code.Functions 25H and 35H, Set/Get Interrupt Vector-----------------------------------------------These functions set and get the protected-mode interrupt vector. Theycan be used to hook hardware interrupts, such as the timer or keyboardinterrupt, as well as to hook software interrupts. Except for INT 23H,INT 24H, and INT 1CH, software interrupts that are issued in real modeare not reflected to protected-mode interrupt handlers. However, allhardware interrupts are reflected to protected-mode interrupt handlersbefore 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. TheDWORD contains a real-mode address. In order to call the case mappingfunction, the DPMI translation function to simulate a real-mode FARcall 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 adevice or send data to a device. Since it is not possible to break thetransfers automatically into small pieces, the caller should assumethat a transfer of greater than 4K will fail unless the address of thebuffer is in the low 1 megabyte range.Function 44H, Subfunction 0CH-----------------------------Only the minor function codes 45H (Get Iteration Count) and 65H (SetIteration Count) are supported from protected mode. The extensions ofthis IOCTL subfunction that are used for code-page switching (minorfunction codes 4AH, 4CH, 4DH, 6AH, and 6BH) are not supported forprotected-mode programs. The DPMI translation functions must be usedif 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, allthe DWORD parameters returned will contain real-mode addresses. Thismeans that the case-conversion procedure address and all the pointersto tables will contain real-mode segment:offset addresses. The DPMItranslation functions must be used to call the case-conversionprocedure in real mode.=======================================================================                          NETBIOS SUPPORT=======================================================================Windows supports standard NetBIOS calls in protected mode. All thenetwork control blocks and buffers must reside in fixed memory that ispage locked. All code that calls NetBIOS directly should reside in aDLL to ease the porting of the application to other operatingenvironments.Additional information on NetBIOS and DPMI support in Windows networkdrivers is available in Chapter 6, "Network Support," in the"Microsoft Windows Device Driver Adaptation Guide," which is part ofthe Microsoft Windows Device Development Kit (DDK). Additionalinformation can be found in the Windows developer's note titled"Developing Network Applications for Windows 3.00," available asarticle Q65125.				
Windows 3 Developer's Notes

Article ID: 65128 - Last Review: 10/26/2013 06:38:00 - Revision: 4.0

  • Microsoft Windows Software Development Kit 3.0
  • Microsoft Windows Software Development Kit 3.1
  • kbnosurvey kbarchive kbfile KB65128