Commit 47f62a40 authored by Alexandre Julliard's avatar Alexandre Julliard

Set %fs and %gs in the register context to their current value when

calling 16-bit code.
parent 83d6e26b
...@@ -1463,6 +1463,8 @@ DWORD NE_StartTask(void) ...@@ -1463,6 +1463,8 @@ DWORD NE_StartTask(void)
context.SegCs = GlobalHandleToSel16(pSegTable[pModule->cs - 1].hSeg); context.SegCs = GlobalHandleToSel16(pSegTable[pModule->cs - 1].hSeg);
context.SegDs = GlobalHandleToSel16(pTask->hInstance); context.SegDs = GlobalHandleToSel16(pTask->hInstance);
context.SegEs = pTask->hPDB; context.SegEs = pTask->hPDB;
context.SegFs = wine_get_fs();
context.SegGs = wine_get_gs();
context.Eip = pModule->ip; context.Eip = pModule->ip;
context.Ebx = pModule->stack_size; context.Ebx = pModule->stack_size;
context.Ecx = pModule->heap_size; context.Ecx = pModule->heap_size;
......
...@@ -672,12 +672,12 @@ static BOOL NE_InitDLL( NE_MODULE *pModule ) ...@@ -672,12 +672,12 @@ static BOOL NE_InitDLL( NE_MODULE *pModule )
context.Edi = hInst; context.Edi = hInst;
context.SegDs = ds; context.SegDs = ds;
context.SegEs = ds; /* who knows ... */ context.SegEs = ds; /* who knows ... */
context.SegFs = wine_get_fs();
context.SegGs = wine_get_gs();
context.SegCs = SEL(pSegTable[pModule->cs-1].hSeg); context.SegCs = SEL(pSegTable[pModule->cs-1].hSeg);
context.Eip = pModule->ip; context.Eip = pModule->ip;
context.Ebp = OFFSETOF(NtCurrentTeb()->cur_stack) + (WORD)&((STACK16FRAME*)0)->bp; context.Ebp = OFFSETOF(NtCurrentTeb()->cur_stack) + (WORD)&((STACK16FRAME*)0)->bp;
pModule->cs = 0; /* Don't initialize it twice */ pModule->cs = 0; /* Don't initialize it twice */
TRACE_(dll)("Calling LibMain, cs:ip=%04lx:%04lx ds=%04lx di=%04x cx=%04x\n", TRACE_(dll)("Calling LibMain, cs:ip=%04lx:%04lx ds=%04lx di=%04x cx=%04x\n",
context.SegCs, context.Eip, context.SegDs, context.SegCs, context.Eip, context.SegDs,
...@@ -775,7 +775,8 @@ static void NE_CallDllEntryPoint( NE_MODULE *pModule, DWORD dwReason ) ...@@ -775,7 +775,8 @@ static void NE_CallDllEntryPoint( NE_MODULE *pModule, DWORD dwReason )
memset( &context, 0, sizeof(context) ); memset( &context, 0, sizeof(context) );
context.SegDs = ds; context.SegDs = ds;
context.SegEs = ds; /* who knows ... */ context.SegEs = ds; /* who knows ... */
context.SegFs = wine_get_fs();
context.SegGs = wine_get_gs();
context.SegCs = HIWORD(entryPoint); context.SegCs = HIWORD(entryPoint);
context.Eip = LOWORD(entryPoint); context.Eip = LOWORD(entryPoint);
context.Ebp = OFFSETOF( NtCurrentTeb()->cur_stack ) context.Ebp = OFFSETOF( NtCurrentTeb()->cur_stack )
......
...@@ -169,8 +169,10 @@ static void call_timer_proc16( WORD timer ) ...@@ -169,8 +169,10 @@ static void call_timer_proc16( WORD timer )
CONTEXT86 context; CONTEXT86 context;
FARPROC16 proc = SYS_Timers[timer-1].callback16; 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.SegCs = SELECTOROF( proc );
context.Eip = OFFSETOF( proc ); context.Eip = OFFSETOF( proc );
context.Ebp = OFFSETOF( NtCurrentTeb()->cur_stack ) context.Ebp = OFFSETOF( NtCurrentTeb()->cur_stack )
......
...@@ -349,6 +349,8 @@ void WINAPI QT_Thunk( CONTEXT86 *context ) ...@@ -349,6 +349,8 @@ void WINAPI QT_Thunk( CONTEXT86 *context )
memcpy(&context16,context,sizeof(context16)); memcpy(&context16,context,sizeof(context16));
context16.SegFs = wine_get_fs();
context16.SegGs = wine_get_gs();
context16.SegCs = HIWORD(context->Edx); context16.SegCs = HIWORD(context->Edx);
context16.Eip = LOWORD(context->Edx); context16.Eip = LOWORD(context->Edx);
/* point EBP to the STACK16FRAME on the stack /* point EBP to the STACK16FRAME on the stack
...@@ -478,6 +480,8 @@ void WINAPI FT_Thunk( CONTEXT86 *context ) ...@@ -478,6 +480,8 @@ void WINAPI FT_Thunk( CONTEXT86 *context )
memcpy(&context16,context,sizeof(context16)); memcpy(&context16,context,sizeof(context16));
context16.SegFs = wine_get_fs();
context16.SegGs = wine_get_gs();
context16.SegCs = HIWORD(callTarget); context16.SegCs = HIWORD(callTarget);
context16.Eip = LOWORD(callTarget); context16.Eip = LOWORD(callTarget);
context16.Ebp = OFFSETOF( NtCurrentTeb()->cur_stack ) context16.Ebp = OFFSETOF( NtCurrentTeb()->cur_stack )
...@@ -690,6 +694,8 @@ void WINAPI Common32ThkLS( CONTEXT86 *context ) ...@@ -690,6 +694,8 @@ void WINAPI Common32ThkLS( CONTEXT86 *context )
memcpy(&context16,context,sizeof(context16)); memcpy(&context16,context,sizeof(context16));
context16.SegFs = wine_get_fs();
context16.SegGs = wine_get_gs();
context16.Edi = LOWORD(context->Ecx); context16.Edi = LOWORD(context->Ecx);
context16.SegCs = HIWORD(context->Eax); context16.SegCs = HIWORD(context->Eax);
context16.Eip = LOWORD(context->Eax); context16.Eip = LOWORD(context->Eax);
...@@ -747,6 +753,8 @@ void WINAPI OT_32ThkLSF( CONTEXT86 *context ) ...@@ -747,6 +753,8 @@ void WINAPI OT_32ThkLSF( CONTEXT86 *context )
memcpy(&context16,context,sizeof(context16)); memcpy(&context16,context,sizeof(context16));
context16.SegFs = wine_get_fs();
context16.SegGs = wine_get_gs();
context16.SegCs = HIWORD(context->Edx); context16.SegCs = HIWORD(context->Edx);
context16.Eip = LOWORD(context->Edx); context16.Eip = LOWORD(context->Edx);
context16.Ebp = OFFSETOF( NtCurrentTeb()->cur_stack ) context16.Ebp = OFFSETOF( NtCurrentTeb()->cur_stack )
......
...@@ -590,8 +590,8 @@ static void StartPM( CONTEXT86 *context ) ...@@ -590,8 +590,8 @@ static void StartPM( CONTEXT86 *context )
pm_ctx.Edx = cs; pm_ctx.Edx = cs;
pm_ctx.SegDs = ds; pm_ctx.SegDs = ds;
pm_ctx.SegEs = es; pm_ctx.SegEs = es;
pm_ctx.SegFs = 0; pm_ctx.SegFs = wine_get_fs();
pm_ctx.SegGs = 0; pm_ctx.SegGs = wine_get_gs();
pm_ctx.EFlags &= ~V86_FLAG; pm_ctx.EFlags &= ~V86_FLAG;
TRACE("DOS program is now entering %d-bit protected mode\n", TRACE("DOS program is now entering %d-bit protected mode\n",
......
...@@ -252,8 +252,10 @@ static LRESULT WINAPI WINPROC_CallWndProc16( WNDPROC16 proc, HWND16 hwnd, ...@@ -252,8 +252,10 @@ static LRESULT WINAPI WINPROC_CallWndProc16( WNDPROC16 proc, HWND16 hwnd,
/* Window procedures want ax = hInstance, ds = es = ss */ /* 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.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; if (!(context.Eax = GetWindowWord( HWND_32(hwnd), GWL_HINSTANCE ))) context.Eax = context.SegDs;
context.SegCs = SELECTOROF(proc); context.SegCs = SELECTOROF(proc);
context.Eip = OFFSETOF(proc); context.Eip = OFFSETOF(proc);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment