This DPMI 0.9 Specification is hosted by Tenberry Software, Inc.
8. Descriptor Management Services, Continued
[Next Section] *
[Previous Section] *
[DPMI Index]
[Tenberry Home]
* [Software Quality]
* [DOS/4G]
* [DOS/4GW]
* [DOS/16M]
8.3 Segment to Descriptor
This function is used to convert real mode segments
into descriptors that are addressable by protected mode
programs.
To Call
AX = 0002h
BX = Real mode segment address
Returns
If function was successful:
Carry flag is clear.
AX = Selector mapped to real mode segment
If function was not successful:
Carry flag is set.
Programmer's Notes
- Since this function involves descriptor management,
it will be rarely needed in 32-bit programs.
- Multiple calls to this function with the same
segment will return the same selector.
- Descriptors created by this function should never
be modified or freed. For this reason, you should
use this function sparingly. If your program
needs to examine various real mode addresses using
the same selector you should allocate a descriptor
and change the base using the Set Segment Base
Address function instead of using this function.
- The descriptor's limit will be set to 64K.
- The intent of this function is to allow programs
easy access to commonly used real mode segments
such as 40h and A000h. Do not use this service to
obtain descriptors to private data areas.
Code Sample:
The following function compiles with Watcom C/C++ version 11.0 or later,
and Microsoft Visual C/C++ version 4.0 or later:
// allocate one descriptor
int dpmiSegmentToDescriptor(unsigned short realSegment, // real-mode segment address
dpmiSelector *pSel) // (returned) the resulting selector
{
int result; // zero if int 31h succeeds
unsigned short errorCode; // error code from DPMI host
__asm {
mov bx, realSegment // the real-mode segment to map
mov eax, 0x002 // call dpmi host to do mapping
int 0x31
mov errorCode, ax // save error code from DPMI, if any
sbb eax, eax // record success/failure flag
mov result, eax
}
// if the dpmi call failed, return the dpmi error code
if (result != 0)
return errorCode;
// if we succeeded, AX contained the selector
*pSel = (dpmiSelector) errorCode;
// indicate success
return 0;
}
[Next Section] *
[Previous Section] *
[DPMI Index]
[Tenberry Home]
* [Software Quality]
* [DOS/4G]
* [DOS/4GW]
* [DOS/16M]
This HTML edition of the DPMI 0.9 Specification is hosted by
Tenberry Software, Inc.,
makers of the
DOS/16M and
the DOS/4G
family of DOS extenders.
Page last modified 2003.1.28,
<webmaster@tenberry.com>