Alexandre Julliard : ntdll: Move the plaform-specific thread data to the SystemReserved2 TEB field.

Alexandre Julliard julliard at winehq.org
Wed Jul 19 16:05:33 CDT 2017


Module: wine
Branch: master
Commit: 9e59362ae3d6b52418a7f3519688faea78c280ac
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=9e59362ae3d6b52418a7f3519688faea78c280ac

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Wed Jul 19 15:20:42 2017 +0200

ntdll: Move the plaform-specific thread data to the SystemReserved2 TEB field.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/signal_i386.c   | 28 +++++++++++++++++-----------
 dlls/ntdll/signal_x86_64.c |  4 ++--
 include/winternl.h         |  4 ++--
 tools/winebuild/relay.c    |  4 ++--
 4 files changed, 23 insertions(+), 17 deletions(-)

diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c
index 96d7d26..2301ba4 100644
--- a/dlls/ntdll/signal_i386.c
+++ b/dlls/ntdll/signal_i386.c
@@ -531,25 +531,31 @@ enum i386_trap_code
 
 struct x86_thread_data
 {
-    DWORD              dr0;           /* 1bc Debug registers */
-    DWORD              dr1;           /* 1c0 */
-    DWORD              dr2;           /* 1c4 */
-    DWORD              dr3;           /* 1c8 */
-    DWORD              dr6;           /* 1cc */
-    DWORD              dr7;           /* 1d0 */
     DWORD              fs;            /* 1d4 TEB selector */
     DWORD              gs;            /* 1d8 libc selector; update winebuild if you move this! */
-    void              *vm86_ptr;      /* 1dc data for vm86 mode */
-    int                __pad[7];      /* 1e0 space for ntdll_thread_data (FIXME) */
+    DWORD              dr0;           /* 1dc debug registers */
+    DWORD              dr1;           /* 1e0 */
+    DWORD              dr2;           /* 1e4 */
+    DWORD              dr3;           /* 1e8 */
+    DWORD              dr6;           /* 1ec */
+    DWORD              dr7;           /* 1f0 */
+    void              *exit_frame;    /* 1f4 exit frame pointer */
+#ifdef __HAVE_VM86
+    void              *vm86_ptr;      /* 1f8 data for vm86 mode */
     WINE_VM86_TEB_INFO vm86;          /* 1fc vm86 private data */
-    void              *exit_frame;    /* 204 exit frame pointer */
+#endif
+    /* the ntdll_thread_data structure follows here */
 };
 
-C_ASSERT( offsetof( TEB, SpareBytes1 ) + offsetof( struct x86_thread_data, gs ) == 0x1d8 );
+C_ASSERT( offsetof( TEB, SystemReserved2 ) + offsetof( struct x86_thread_data, gs ) == 0x1d8 );
+#ifdef __HAVE_VM86
+C_ASSERT( offsetof( TEB, SystemReserved2 ) + offsetof( struct x86_thread_data, vm86 ) ==
+          offsetof( TEB, GdiTebBatch ) + offsetof( struct ntdll_thread_data, __vm86 ));
+#endif
 
 static inline struct x86_thread_data *x86_thread_data(void)
 {
-    return (struct x86_thread_data *)NtCurrentTeb()->SpareBytes1;
+    return (struct x86_thread_data *)NtCurrentTeb()->SystemReserved2;
 }
 
 /* Exception record for handling exceptions happening inside exception handlers */
diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c
index 4f0df97..f0127f7 100644
--- a/dlls/ntdll/signal_x86_64.c
+++ b/dlls/ntdll/signal_x86_64.c
@@ -313,11 +313,11 @@ struct amd64_thread_data
     void     *exit_frame;    /* exit frame pointer */
 };
 
-C_ASSERT( sizeof(struct amd64_thread_data) <= sizeof(((TEB *)0)->SpareBytes1) );
+C_ASSERT( sizeof(struct amd64_thread_data) <= sizeof(((TEB *)0)->SystemReserved2) );
 
 static inline struct amd64_thread_data *amd64_thread_data(void)
 {
-    return (struct amd64_thread_data *)NtCurrentTeb()->SpareBytes1;
+    return (struct amd64_thread_data *)NtCurrentTeb()->SystemReserved2;
 }
 
 /***********************************************************************
diff --git a/include/winternl.h b/include/winternl.h
index 9dd9fb1..df20da5 100644
--- a/include/winternl.h
+++ b/include/winternl.h
@@ -328,8 +328,8 @@ typedef struct _TEB
     PVOID                        SystemReserved1[54];               /* 0cc/0110 used for kernel32 private data in Wine */
     LONG                         ExceptionCode;                     /* 1a4/02c0 */
     ACTIVATION_CONTEXT_STACK     ActivationContextStack;            /* 1a8/02c8 */
-    BYTE                         SpareBytes1[24];                   /* 1bc/02e8 used for ntdll private data in Wine */
-    PVOID                        SystemReserved2[10];               /* 1d4/0300 used for ntdll private data in Wine */
+    BYTE                         SpareBytes1[24];                   /* 1bc/02e8 */
+    PVOID                        SystemReserved2[10];               /* 1d4/0300 used for ntdll platform-specific private data in Wine */
     GDI_TEB_BATCH                GdiTebBatch;                       /* 1fc/0350 used for ntdll private data in Wine */
     HANDLE                       gdiRgn;                            /* 6dc/0838 */
     HANDLE                       gdiPen;                            /* 6e0/0840 */
diff --git a/tools/winebuild/relay.c b/tools/winebuild/relay.c
index e9228a0..1cc6465 100644
--- a/tools/winebuild/relay.c
+++ b/tools/winebuild/relay.c
@@ -33,8 +33,8 @@
 /* offset of the stack pointer relative to %fs:(0) */
 #define STACKOFFSET 0xc0  /* FIELD_OFFSET(TEB,WOW32Reserved) */
 
-/* fix this if the ntdll_thread_regs structure is changed */
-#define GS_OFFSET  0x1d8  /* FIELD_OFFSET(TEB,SpareBytes1) + FIELD_OFFSET(ntdll_thread_data,gs) */
+/* fix this if the x86_thread_data structure is changed */
+#define GS_OFFSET  0x1d8  /* FIELD_OFFSET(TEB,SystemReserved2) + FIELD_OFFSET(struct x86_thread_data,gs) */
 
 #define DPMI_VIF_OFFSET      (0x1fc + 0) /* FIELD_OFFSET(TEB,GdiTebBatch) + FIELD_OFFSET(WINE_VM86_TEB_INFO,dpmi_vif) */
 #define VM86_PENDING_OFFSET  (0x1fc + 4) /* FIELD_OFFSET(TEB,GdiTebBatch) + FIELD_OFFSET(WINE_VM86_TEB_INFO,vm86_pending) */




More information about the wine-cvs mailing list