source: trunk/include/win/thread.h@ 8925

Last change on this file since 8925 was 8925, checked in by sandervl, 23 years ago

added suspend count dword to TEB

File size: 8.6 KB
Line 
1/*
2 * Thread definitions
3 *
4 * Copyright 1996 Alexandre Julliard
5 */
6
7#ifndef __WINE_THREAD_H
8#define __WINE_THREAD_H
9
10#ifdef __WIN32OS2__
11#define TLS_MINIMUM_AVAILABLE 64
12 #ifndef __OS2_H__
13 #include "config.h"
14 #include "winbase.h"
15 #include "winuser.h"
16 #include <ntdef.h>
17 #endif
18 #include <ntdllsec.h> //PROCESSTHREAD_SECURITYINFO struct
19#else
20#include "config.h"
21#include "winbase.h"
22#include "selectors.h" /* for SET_FS */
23#endif
24
25struct _PDB;
26
27#ifndef OS2DEF_INCLUDED
28 /* QMSG structure */
29 typedef struct _QMSG /* qmsg */
30 {
31 HWND hwnd;
32 ULONG msg;
33 ULONG mp1;
34 ULONG mp2;
35 ULONG time;
36 POINTL ptl;
37 ULONG reserved;
38 } QMSG;
39#endif
40
41/* Thread exception block
42
43 flags in the comment:
44 1-- win95 field
45 d-- win95 debug version
46 -2- nt field
47 --3 wine special
48 --n wine unused
49 !-- or -!- likely or observed collision
50 more problems (collected from mailing list):
51 psapi.dll 0x10/0x30 (expects nt fields)
52 ie4 0x40
53 PESHiELD 0x23/0x30 (win95)
54*/
55
56#pragma pack(4)
57/* Thread exception block */
58typedef struct _TEB
59{
60/* start of NT_TIB */
61 void *except; /* 12- 00 Head of exception handling chain */
62 void *stack_top; /* 12- 04 Top of thread stack */
63 void *stack_low; /* 12- 08 Stack low-water mark */
64 HTASK16 htask16; /* 1-- 0c Win16 task handle */
65 WORD stack_sel; /* 1-- 0e 16-bit stack selector */
66 DWORD selman_list; /* 1-n 10 Selector manager list */
67 DWORD user_ptr; /* 12n 14 User pointer */
68/* end of NT_TIB */
69 struct _TEB *self; /* 12- 18 Pointer to this structure */
70 WORD tibflags; /* 1!n 1c Flags (NT: EnvironmentPointer) */
71 WORD mutex_count; /* 1-n 1e Win16 mutex count */
72 void *pid; /* !2- 20 Process id (win95: debug context) */
73 void *tid; /* -2- 24 Thread id */
74 HQUEUE16 queue; /* 1!- 28 Message queue (NT: DWORD ActiveRpcHandle)*/
75 WORD pad1; /* --n 2a */
76 LPVOID *tls_ptr; /* 2c Pointer to TLS array */
77 struct _PDB *process; /* 12- 30 owning process (win95: PDB; nt: NTPEB !!) */
78 DWORD flags; /* 1-n 34 */
79 DWORD exit_code; /* 1-- 38 Termination status */
80 WORD teb_sel; /* 1-- 3c Selector to TEB */
81 WORD emu_sel; /* 1-n 3e 80387 emulator selector */
82 DWORD unknown1; /* --n 40 */
83 DWORD unknown2; /* --n 44 */
84 void (*startup)(void); /* --3 48 Thread startup routine */
85 int thread_errno; /* --3 4c Per-thread errno (was: ring0_thread) */
86 int thread_h_errno; /* --3 50 Per-thread h_errno (was: ptr to tdbx structure) */
87 void *stack_base; /* 1-- 54 Base of the stack */
88 void *signal_stack; /* --3 58 Signal stack (was: exit_stack) */
89 void *emu_data; /* --n 5c Related to 80387 emulation */
90 DWORD last_error; /* 1-- 60 Last error code */
91 HANDLE debug_cb; /* 1-n 64 Debugger context block */
92 DWORD debug_thread; /* 1-n 68 Thread debugging this one (?) */
93 void *pcontext; /* 1-n 6c Thread register context */
94 DWORD cur_stack; /* --3 70 Current stack (was: unknown) */
95 DWORD ThunkConnect; /* 1-n 74 */
96 DWORD NegStackBase; /* 1-n 78 */
97 WORD current_ss; /* 1-n 7c Another 16-bit stack selector */
98 WORD pad2; /* --n 7e */
99 void *ss_table; /* --n 80 Pointer to info about 16-bit stack */
100 WORD thunk_ss; /* --n 84 Yet another 16-bit stack selector */
101 WORD pad3; /* --n 86 */
102 DWORD pad4[15]; /* --n 88 */
103 ULONG CurrentLocale; /* -2- C4 */
104 DWORD pad5[48]; /* --n C8 */
105 DWORD delta_priority; /* 1-n 188 Priority delta */
106 DWORD unknown4[7]; /* d-n 18c Unknown */
107 void *create_data; /* d-n 1a8 Pointer to creation structure */
108 DWORD suspend_count; /* d-n 1ac SuspendThread() counter */
109 void *entry_point; /* --3 1b0 Thread entry point (was: unknown) */
110 void *entry_arg; /* --3 1b4 Entry point arg (was: unknown) */
111 DWORD unknown5[4]; /* --n 1b8 Unknown */
112 DWORD sys_count[4]; /* --3 1c8 Syslevel mutex entry counters */
113 struct tagSYSLEVEL *sys_mutex[4]; /* --3 1d8 Syslevel mutex pointers */
114 DWORD unknown6[5]; /* --n 1e8 Unknown */
115
116 union {
117#ifdef __WIN32OS2__
118 struct {
119 struct _TEB *next;
120 DWORD OrgTIBSel; // Original OS/2 TIB selector (always the same, but let's not assume too much for future compatibility)
121 ULONG hmq; // Thread message queue
122 ULONG hab; // Thread Anchor block
123 ULONG hooks[WH_NB_HOOKS]; //list of hooks for this thread queue
124 ULONG threadId; // Thread ID
125 ULONG hThread; // thread handle
126 ULONG dwSuspend; // suspend count (Suspend/ResumeThread)
127 ULONG exceptFrame; // address of os/2 exception handler frame
128 ULONG newWindow; // Pointer to window object of window that was just created
129 void* pWsockData; // Winsock data pointer (NULL if unused)
130
131 // used for PM-to-Win32 message translation
132 PVOID pMessageBuffer; // MessageBuffer object
133 // (here typeless due to include conflicts)
134 DWORD dwMsgExtraInfo; // MessageExtraInfo
135 WINDOWPOS wp; // Used by message translation for WM_WINDOWPOSCHANGED
136 ULONG nrOfMsgs; // Usually 1; some PM messages can generated more than 1 win32 msg
137 BOOL fTranslated; // WM_CHAR already translated or not
138 ULONG msgstate; // odd -> dispatchmessage called, even -> not called
139 QMSG os2msg; // original os2 msg (received with Get- or PeekMessage)
140 MSG winmsg; // temporary storage for translated os2 msg (used in DispatchMessage)
141 MSG msg; // Used by message translation to store translated PM message (sent to win32 window proc in pmwindow.cpp)
142 MSG msgWCHAR; // Used to store extra WM_CHAR message generated by TranslateMessage
143 BOOL fWM_SETFOCUS; // set during WM_SETFOCUS message processing
144 HWND hwndFocus; // set during WM_SETFOCUS message processing
145
146 DWORD pidDebuggee; // process id of debuggee
147 DWORD logfile; // last FILE ptr used for logging (for exception handling in vfprintf)
148 PROCESSTHREAD_SECURITYINFO threadinfo; //used to store security info for thread tokens
149 DWORD lcid; // thread lcid
150 BOOL fIgnoreMsgs; // set to true if waiting in WaitForSingleObject
151
152#ifdef DEBUG
153 // used for call stack tracking
154 ULONG dbgCallDepth; // is de-/incremented by ODINWRAP macros
155 PVOID* arrstrCallStack; // keep track of thread's call stack
156#endif
157 } odin;
158#endif
159 /* the following are nt specific fields */
160 DWORD pad6[639]; /* --n 21c */
161 } o;
162 UNICODE_STRING StaticUnicodeString; /* -2- bf8 used by advapi32 */
163 USHORT StaticUnicodeBuffer[261]; /* -2- c00 used by advapi32 */
164 DWORD pad7; /* --n e0c */
165#ifdef __WIN32OS2__
166 LPVOID tls_array[TLS_MINIMUM_AVAILABLE]; /* -2- e10 Thread local storage */
167#else
168 LPVOID tls_array[64]; /* -2- e10 Thread local storage */
169#endif
170 DWORD pad8[3]; /* --n f10 */
171 PVOID ReservedForNtRpc; /* -2- f1c used by rpcrt4 */
172 DWORD pad9[24]; /* --n f20 */
173 PVOID ErrorInfo; /* -2- f80 used by ole32 (IErrorInfo*) */
174} TEB;
175#pragma pack()
176
177/* Thread exception flags */
178#define TEBF_WIN32 0x0001
179#define TEBF_TRAP 0x0002
180
181
182/* The pseudo handle value returned by GetCurrentThread */
183#define CURRENT_THREAD_PSEUDOHANDLE 0xfffffffe
184
185#endif /* __WINE_THREAD_H */
Note: See TracBrowser for help on using the repository browser.