Windows 32 Descriptor API
This is the programmer's interface for the WIN32DES.DLL application extention.  If you do not have it, please don't try to run this functions.  They will probably not work.  Also, it's better if you load this using LoadLibrary rather than as a 'static' DLL.  The reason is because when the DLL initializes, it performs several checks, to make sure the program can access the GDT and the LDT.  If it can't for some reason, or the information comes out garbled (meaning the LDTR or GDTR pointers don't match up), the DLL will unload itself and return an error to your program.

GetDescriptor            Selector:DWORD, lpDescriptor:DWORD

This function retrieves a descriptor from the given selector value.  The value of lpDescriptor must be a valid pointer to an 8 byte descriptor structure (listed below).  This function automatically determines the correct descriptor table to read from.  Returns 0 if an invalid selector was given.
GetDescriptorFromIndex        SelectorIndex:DWORD, Table:DWORD, lpDescriptor:DWORD
This function works similarly to GetDescriptor, with two obvious differences.  First, it retrieves a selector based on it's index, not the actual selector itself.  For instance, the selector 01CFh has an index of 0039h.  However, since there are two descriptor tables, and since 0039h is ambigious, Table is needed to identify the current table.  If Table = 1, then the selector is located in the LDT, otherwise it is located in the GDT.  Returns 0 if an invalid selector was given.
GetLimitFromSelector           Selector:DWORD
This retrieves a limit fromt the given selector.  Unless you are using a high level language, this function is slow and unnecessary. Assembly language programmers can use LSL EAX,Selector for an identical result.  (Afterall, it's what the function itself does!)  The value returned is the exact descriptor length in bytes.
GetLimitFromDescriptor        lpDescriptor:DWORD
This function retrieves a limit from the given descriptor.  The value in lpDescriptor must point to a valid descriptor structure.  Value returned is the exact descriptor length in bytes.
GetBaseFromSelector            Selector:DWORD
This function retrieves the base address of the given selector.  Selector must be a valid selector number.
GetBaseFromDescriptor        lpDescriptor:DWORD
This function retrieves the base address of the given segment, which is pointed to by the descriptor.  See the Intel specification for more details.
GetAccessFromSelector        Selector:DWORD
This function retrieves the access rights from the given selector.  The access rights are always given as a 16 bit word, and in the structure listed below.
GetAccessFromDescriptor    lpDescriptor:DWORD
This function retrieves the access rights from a given desciptor.  The access rights are always given in a 16 bit word, and in the structure listed below.
GetLDT                                lpDescriptor:DWORD
This function retrieves the descriptor of the current LDT.  The value of lpDescriptor must be a pointer to a valid descriptor structure.
Structures
Descriptor        STRUCT
 
LimitLow dw ?
BaseLow dw ?
BaseMid db ?
Access db ?
LimitHigh db ?
BaseHigh db ?
Descriptor        ENDS

AccessRights

 
Bit 0 Segment has been accessed
Bit 1 Read/Write
Bit 2 Expandable/Conforming
Bit 3 Executable
Bit 4 Segment type
Bits 5 & 6 Privilage level (ring #)
Bit 7 Present in memory
Bits 8-11 Unused
Bit 12 OS Defined
Bit 13 Unknown
Bit 14 32 bit segment
Bit 15 Granularity