Article ID: 103950
Article Last Modified on 7/16/2004
//********************************************************************
// DPMISetSelectorLimit()
//
// This function sets a selector limit using DPMI Function AX=0008h
//(Set Segment Limit). This function is necessary if the segment size
// is greater than 1 MB because SetSelectorLimit() does not correctly
// set selector sizes greater than 1 MB.
//
// Segments that are larger than 1MB are actually page granular,
// meaning that in the descriptor, the limit field is actually
// stored as the number of 4K pages rather than bytes. When you
// specify a limit greater than 1MB, this function rounds it up
// to the nearest page boundary.
//
// No matter the size of the segment, this function always accepts
// selector limits in number of bytes, never pages. The conversion
// between bytes and pages is handled internally.
//
// Note that this function takes a segment limit, which is one less
// than the number of bytes in the segment.
//
//********************************************************************
BOOL DPMISetSelectorLimit (UINT selector, DWORD dwLimit)
{
BOOL bRetVal=TRUE;
// If the limit is >= 1MB, you need to make the limit a multiple of
// the page size or DPMISetSelectorLimit will fail.
if( dwLimit >= 0x100000 )
dwLimit |= 0x0FFF;
_asm
{
mov ax, 0008h
mov bx, selector
mov cx, word ptr [dwLimit+2]
mov dx, word ptr [dwLimit]
int 31h
jnc success
mov bRetVal, FALSE
success:
}
return bRetVal;
}
Additional query words: gp-fault gpf uae gp fault
Keywords: kb16bitonly KB103950