http://bugs.winehq.org/show_bug.cgi?id=27708
Summary: GetThreadSelectorEntry fails Product: Wine Version: 1.2.2 Platform: x86 OS/Version: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: ntdll AssignedTo: wine-bugs@winehq.org ReportedBy: nitsuja-@hotmail.com
Created an attachment (id=35459) --> (http://bugs.winehq.org/attachment.cgi?id=35459) binary (and source code) of the test case
When a program calls GetThreadSelectorEntry after creating a process, it fails in Wine (returns FALSE and sets lasterror to 5), but succeeds in Windows. This is a problem for a program I made which needs this function to work, so I've boiled it down to a tiny test case which still fails in the same way, and is attached. When run on Windows, this exe brings up a messagebox saying "ALL OK", but when run on Wine, it says "ERROR: GetThreadSelectorEntry failed". Here's the source code:
#define WIN32_LEAN_AND_MEAN #define _WIN32_WINNT 0x0500 #include <windows.h> void AssertSuccess(BOOL success, const char* errorMessage);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { // it doesn't matter which exe I start, so for this example I use the current exe path CHAR filename[MAX_PATH]; GetModuleFileName(NULL, filename, MAX_PATH); STARTUPINFO startupInfo = {sizeof(STARTUPINFO)}; PROCESS_INFORMATION processInfo = {}; BOOL success = CreateProcess(filename, NULL, NULL, NULL, FALSE, CREATE_SUSPENDED | DEBUG_PROCESS, NULL, NULL, &startupInfo, &processInfo); AssertSuccess(success, "ERROR: CreateProcess failed.\n"); HANDLE hThread = processInfo.hThread;
CONTEXT context; context.ContextFlags = CONTEXT_SEGMENTS; success = GetThreadContext(hThread, &context); AssertSuccess(success, "ERROR: GetThreadContext failed.\n");
LDT_ENTRY ldtEntry; success = GetThreadSelectorEntry(hThread, context.SegFs, &ldtEntry); AssertSuccess(success, "ERROR: GetThreadSelectorEntry failed.\n");
if(success) MessageBox(NULL, "ALL OK.", "DONE", MB_ICONASTERISK);
return success ? 0 : -1; }
void AssertSuccess(BOOL success, const char* errorMessage) { if(!success) MessageBox(NULL, errorMessage, "ERROR", MB_ICONERROR); }