public static LdtEntry GetThreadSelectorEntry(SafeMemoryHandle threadHandle, uint selector)
{
// Check if the handle is valid
HandleManipulator.ValidateAsArgument(threadHandle, "threadHandle");
// Get the selector entry
LdtEntry entry;
if (NativeMethods.GetThreadSelectorEntry(threadHandle, selector, out entry))
return entry;
// Else couldn't get the selector entry, throws an exception
throw new Win32Exception(string.Format("Couldn't get the selector entry for this selector: {0}.", selector));
}