Commit 4ce433d8 authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Move the %gs register to the ntdll_thread_regs structure.

parent a19e3eeb
...@@ -136,14 +136,15 @@ static inline struct ntdll_thread_data *ntdll_get_thread_data(void) ...@@ -136,14 +136,15 @@ static inline struct ntdll_thread_data *ntdll_get_thread_data(void)
/* thread registers, stored in NtCurrentTeb()->SpareBytes1 */ /* thread registers, stored in NtCurrentTeb()->SpareBytes1 */
struct ntdll_thread_regs struct ntdll_thread_regs
{ {
DWORD fs; /* TEB selector */ DWORD fs; /* 00 TEB selector */
DWORD dr0; /* debug registers */ DWORD gs; /* 04 libc selector; update winebuild if you move this! */
DWORD dr1; DWORD dr0; /* 08 debug registers */
DWORD dr2; DWORD dr1; /* 0c */
DWORD dr3; DWORD dr2; /* 10 */
DWORD dr6; DWORD dr3; /* 14 */
DWORD dr7; DWORD dr6; /* 18 */
DWORD spare[3]; /* change this if you add fields! */ DWORD dr7; /* 1c */
DWORD spare[2]; /* 20 change this if you add fields! */
}; };
static inline struct ntdll_thread_regs *ntdll_get_thread_regs(void) static inline struct ntdll_thread_regs *ntdll_get_thread_regs(void)
......
...@@ -675,7 +675,7 @@ inline static void *init_handler( const SIGCONTEXT *sigcontext, WORD *fs, WORD * ...@@ -675,7 +675,7 @@ inline static void *init_handler( const SIGCONTEXT *sigcontext, WORD *fs, WORD *
* SS is still non-system segment. This is why both CS and SS * SS is still non-system segment. This is why both CS and SS
* are checked. * are checked.
*/ */
wine_set_gs( teb->gs_sel ); wine_set_gs( thread_regs->gs );
stack = teb->WOW32Reserved; stack = teb->WOW32Reserved;
} }
#ifdef __HAVE_VM86 #ifdef __HAVE_VM86
......
...@@ -53,12 +53,11 @@ typedef struct _TEB ...@@ -53,12 +53,11 @@ typedef struct _TEB
PVOID SystemReserved2[10]; /* 1d4 */ PVOID SystemReserved2[10]; /* 1d4 */
/* The following are Wine-specific fields (NT: GdiTebBatch) */ /* The following are Wine-specific fields (NT: GdiTebBatch) */
DWORD gs_sel; /* 1fc %gs selector for this thread */ DWORD num_async_io; /* 1fc number of pending async I/O in the server */
ULONG_PTR num_async_io; /* 200 number of pending async I/O in the server */ ULONG_PTR dpmi_vif; /* 200 protected mode virtual interrupt flag */
DWORD dpmi_vif; /* 204 protected mode virtual interrupt flag */ DWORD vm86_pending; /* 204 data for vm86 mode */
DWORD vm86_pending; /* 208 data for vm86 mode */
/* here is plenty space for wine specific fields (don't forget to change pad6!!) */ /* here is plenty space for wine specific fields (don't forget to change pad6!!) */
DWORD pad6[308]; /* 20c */ DWORD pad6[309]; /* 208 */
ULONG gdiRgn; /* 6dc */ ULONG gdiRgn; /* 6dc */
ULONG gdiPen; /* 6e0 */ ULONG gdiPen; /* 6e0 */
......
...@@ -32,6 +32,9 @@ ...@@ -32,6 +32,9 @@
#include "build.h" #include "build.h"
/* fix this if the ntdll_thread_regs structure is changed */
#define GS_OFFSET 0x1b0 /* STRUCTOFFSET(TEB,SpareBytes1) + STRUCTOFFSET(ntdll_thread_regs,gs) */
static void function_header( FILE *outfile, const char *name ) static void function_header( FILE *outfile, const char *name )
{ {
fprintf( outfile, "\n\t.align %d\n", get_alignment(4) ); fprintf( outfile, "\n\t.align %d\n", get_alignment(4) );
...@@ -150,7 +153,7 @@ static void BuildCallFrom16Core( FILE *outfile, int reg_func, int thunk ) ...@@ -150,7 +153,7 @@ static void BuildCallFrom16Core( FILE *outfile, int reg_func, int thunk )
else else
fprintf( outfile, "\tmovw %s, %%fs\n", asm_name("CallTo16_TebSelector") ); fprintf( outfile, "\tmovw %s, %%fs\n", asm_name("CallTo16_TebSelector") );
fprintf( outfile, "\t.byte 0x64\n\tmov (%d),%%gs\n", STRUCTOFFSET(TEB,gs_sel) ); fprintf( outfile, "\t.byte 0x64\n\tmov (%d),%%gs\n", GS_OFFSET );
/* Translate STACK16FRAME base to flat offset in %edx */ /* Translate STACK16FRAME base to flat offset in %edx */
fprintf( outfile, "\tmovw %%ss, %%dx\n" ); fprintf( outfile, "\tmovw %%ss, %%dx\n" );
...@@ -393,7 +396,7 @@ static void BuildCallTo16Core( FILE *outfile, int reg_func ) ...@@ -393,7 +396,7 @@ static void BuildCallTo16Core( FILE *outfile, int reg_func )
fprintf( outfile, "\tpushl %%ebx\n" ); fprintf( outfile, "\tpushl %%ebx\n" );
fprintf( outfile, "\tpushl %%esi\n" ); fprintf( outfile, "\tpushl %%esi\n" );
fprintf( outfile, "\tpushl %%edi\n" ); fprintf( outfile, "\tpushl %%edi\n" );
fprintf( outfile, "\t.byte 0x64\n\tmov %%gs,(%d)\n", STRUCTOFFSET(TEB,gs_sel) ); fprintf( outfile, "\t.byte 0x64\n\tmov %%gs,(%d)\n", GS_OFFSET );
/* Setup exception frame */ /* Setup exception frame */
fprintf( outfile, "\t.byte 0x64\n\tpushl (%d)\n", STACKOFFSET ); fprintf( outfile, "\t.byte 0x64\n\tpushl (%d)\n", STACKOFFSET );
...@@ -542,7 +545,7 @@ static void BuildRet16Func( FILE *outfile ) ...@@ -542,7 +545,7 @@ static void BuildRet16Func( FILE *outfile )
fprintf( outfile, "\t.byte 0x2e\n\tmov %s", asm_name("CallTo16_TebSelector") ); fprintf( outfile, "\t.byte 0x2e\n\tmov %s", asm_name("CallTo16_TebSelector") );
fprintf( outfile, "-%s,%%fs\n", asm_name("__wine_call16_start") ); fprintf( outfile, "-%s,%%fs\n", asm_name("__wine_call16_start") );
fprintf( outfile, "\t.byte 0x64\n\tmov (%d),%%gs\n", STRUCTOFFSET(TEB,gs_sel) ); fprintf( outfile, "\t.byte 0x64\n\tmov (%d),%%gs\n", GS_OFFSET );
/* Restore the 32-bit stack */ /* Restore the 32-bit stack */
......
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