diff --git a/dlls/kernel/ne_module.c b/dlls/kernel/ne_module.c index 151dc15a763..94b8fc88c7e 100644 --- a/dlls/kernel/ne_module.c +++ b/dlls/kernel/ne_module.c @@ -1463,6 +1463,8 @@ DWORD NE_StartTask(void) context.SegCs = GlobalHandleToSel16(pSegTable[pModule->cs - 1].hSeg); context.SegDs = GlobalHandleToSel16(pTask->hInstance); context.SegEs = pTask->hPDB; + context.SegFs = wine_get_fs(); + context.SegGs = wine_get_gs(); context.Eip = pModule->ip; context.Ebx = pModule->stack_size; context.Ecx = pModule->heap_size; diff --git a/dlls/kernel/ne_segment.c b/dlls/kernel/ne_segment.c index 0a16d8955b5..b60fcd9ec48 100644 --- a/dlls/kernel/ne_segment.c +++ b/dlls/kernel/ne_segment.c @@ -670,14 +670,14 @@ static BOOL NE_InitDLL( NE_MODULE *pModule ) context.Ecx = heap; context.Edi = hInst; - context.SegDs = ds; - context.SegEs = ds; /* who knows ... */ - - context.SegCs = SEL(pSegTable[pModule->cs-1].hSeg); + context.SegDs = ds; + context.SegEs = ds; /* who knows ... */ + context.SegFs = wine_get_fs(); + context.SegGs = wine_get_gs(); + context.SegCs = SEL(pSegTable[pModule->cs-1].hSeg); context.Eip = pModule->ip; context.Ebp = OFFSETOF(NtCurrentTeb()->cur_stack) + (WORD)&((STACK16FRAME*)0)->bp; - pModule->cs = 0; /* Don't initialize it twice */ TRACE_(dll)("Calling LibMain, cs:ip=%04lx:%04lx ds=%04lx di=%04x cx=%04x\n", context.SegCs, context.Eip, context.SegDs, @@ -775,7 +775,8 @@ static void NE_CallDllEntryPoint( NE_MODULE *pModule, DWORD dwReason ) memset( &context, 0, sizeof(context) ); context.SegDs = ds; context.SegEs = ds; /* who knows ... */ - + context.SegFs = wine_get_fs(); + context.SegGs = wine_get_gs(); context.SegCs = HIWORD(entryPoint); context.Eip = LOWORD(entryPoint); context.Ebp = OFFSETOF( NtCurrentTeb()->cur_stack ) diff --git a/dlls/kernel/system.c b/dlls/kernel/system.c index 634f104f68e..ed0525c605a 100644 --- a/dlls/kernel/system.c +++ b/dlls/kernel/system.c @@ -169,8 +169,10 @@ static void call_timer_proc16( WORD timer ) CONTEXT86 context; FARPROC16 proc = SYS_Timers[timer-1].callback16; - memset( &context, '\0', sizeof(context) ); + memset( &context, 0, sizeof(context) ); + context.SegFs = wine_get_fs(); + context.SegGs = wine_get_gs(); context.SegCs = SELECTOROF( proc ); context.Eip = OFFSETOF( proc ); context.Ebp = OFFSETOF( NtCurrentTeb()->cur_stack ) diff --git a/dlls/kernel/thunk.c b/dlls/kernel/thunk.c index a4ebdba4ac3..b9f275828e1 100644 --- a/dlls/kernel/thunk.c +++ b/dlls/kernel/thunk.c @@ -349,6 +349,8 @@ void WINAPI QT_Thunk( CONTEXT86 *context ) memcpy(&context16,context,sizeof(context16)); + context16.SegFs = wine_get_fs(); + context16.SegGs = wine_get_gs(); context16.SegCs = HIWORD(context->Edx); context16.Eip = LOWORD(context->Edx); /* point EBP to the STACK16FRAME on the stack @@ -478,6 +480,8 @@ void WINAPI FT_Thunk( CONTEXT86 *context ) memcpy(&context16,context,sizeof(context16)); + context16.SegFs = wine_get_fs(); + context16.SegGs = wine_get_gs(); context16.SegCs = HIWORD(callTarget); context16.Eip = LOWORD(callTarget); context16.Ebp = OFFSETOF( NtCurrentTeb()->cur_stack ) @@ -690,6 +694,8 @@ void WINAPI Common32ThkLS( CONTEXT86 *context ) memcpy(&context16,context,sizeof(context16)); + context16.SegFs = wine_get_fs(); + context16.SegGs = wine_get_gs(); context16.Edi = LOWORD(context->Ecx); context16.SegCs = HIWORD(context->Eax); context16.Eip = LOWORD(context->Eax); @@ -747,6 +753,8 @@ void WINAPI OT_32ThkLSF( CONTEXT86 *context ) memcpy(&context16,context,sizeof(context16)); + context16.SegFs = wine_get_fs(); + context16.SegGs = wine_get_gs(); context16.SegCs = HIWORD(context->Edx); context16.Eip = LOWORD(context->Edx); context16.Ebp = OFFSETOF( NtCurrentTeb()->cur_stack ) diff --git a/dlls/winedos/int31.c b/dlls/winedos/int31.c index c39f424a971..838b17c2f06 100644 --- a/dlls/winedos/int31.c +++ b/dlls/winedos/int31.c @@ -590,8 +590,8 @@ static void StartPM( CONTEXT86 *context ) pm_ctx.Edx = cs; pm_ctx.SegDs = ds; pm_ctx.SegEs = es; - pm_ctx.SegFs = 0; - pm_ctx.SegGs = 0; + pm_ctx.SegFs = wine_get_fs(); + pm_ctx.SegGs = wine_get_gs(); pm_ctx.EFlags &= ~V86_FLAG; TRACE("DOS program is now entering %d-bit protected mode\n", diff --git a/windows/winproc.c b/windows/winproc.c index 085b1eb7e3b..7516f51549e 100644 --- a/windows/winproc.c +++ b/windows/winproc.c @@ -252,8 +252,10 @@ static LRESULT WINAPI WINPROC_CallWndProc16( WNDPROC16 proc, HWND16 hwnd, /* Window procedures want ax = hInstance, ds = es = ss */ - memset(&context, '\0', sizeof(context)); + memset(&context, 0, sizeof(context)); context.SegDs = context.SegEs = SELECTOROF(teb->cur_stack); + context.SegFs = wine_get_fs(); + context.SegGs = wine_get_gs(); if (!(context.Eax = GetWindowWord( HWND_32(hwnd), GWL_HINSTANCE ))) context.Eax = context.SegDs; context.SegCs = SELECTOROF(proc); context.Eip = OFFSETOF(proc);