BOOL GetThreadSelectorEntry(hThread, dwSelector, lpSelectorEntry) | |||
HANDLE hThread; | |||
DWORD dwSelector; | |||
LPLDT_ENTRY lpSelectorEntry; |
This function is used to return a descriptor table entry for the specified thread corresponding to the specified selector.
hThread
Supplies a handle to the thread that contains the specified selector. The handle must have been created with THREAD_QUERY_INFORMATION access.
dwSelector
Supplies the selector value to look up. The selector value may be a global selector or a local selector.
lpSelectorEntry
If the specified selector is contained within the thread's descriptor tables, its descriptor table entry is copied into the data structure pointed to by this parameter. This data can be used to compute the linear base address that segment relative addresses refer to.
The return value is TRUE if the operation was successful. In that case, the data structure pointed to by lpSelectorEntry receives a copy of the specified descriptor table entry.
The return value is FALSE or NULL if the operation failed. In that case, more detailed information is available using GetLastError.
This function is only functional on x86 based systems. For non-x86 based systems a value of FALSE is returned.
This function is used by a debugger so that it can convert segment relative addresses to linear virtual address (since this is the only format supported by ReadMemoryProcess and WriteMemoryProcess).
A descriptor table entry has the following structure:
//
// descriptor table entry data structure...
//
typedef struct _LDT_ENTRY {
WORD LimitLow;
WORD BaseLow;
union {
struct {
BYTE BaseMid;
BYTE Flags1; // Declare as bytes to
BYTE Flags2; // avoid alignment Problems.
BYTE BaseHi;
} Bytes;
struct {
DWORD BaseMid : 8;
DWORD Type : 5;
DWORD Dpl : 2;
DWORD Pres : 1;
DWORD LimitHi : 4;
DWORD Sys : 1;
DWORD Reserved_0 : 1;
DWORD Default_Big : 1;
DWORD Granularity : 1;
DWORD BaseHi : 8;
} Bits;
} HighWord;
} LDT_ENTRY, *PLDT_ENTRY;