| 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 |
|
|---|
| 25 | struct _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 */
|
|---|
| 58 | typedef 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 | HANDLE hPostMsgEvent; // Event semaphore to signal message post to MsgWaitForMultipleObjects
|
|---|
| 123 | DWORD dwWakeMask; // Set by MsgWaitForMultipleObjects
|
|---|
| 124 | ULONG hab; // Thread Anchor block
|
|---|
| 125 | ULONG hooks[WH_NB_HOOKS]; //list of hooks for this thread queue
|
|---|
| 126 | ULONG threadId; // Thread ID
|
|---|
| 127 | ULONG hThread; // thread handle
|
|---|
| 128 | ULONG dwSuspend; // suspend count (Suspend/ResumeThread)
|
|---|
| 129 | ULONG exceptFrame; // address of os/2 exception handler frame
|
|---|
| 130 | ULONG newWindow; // Pointer to window object of window that was just created
|
|---|
| 131 | void* pWsockData; // Winsock data pointer (NULL if unused)
|
|---|
| 132 |
|
|---|
| 133 | // used for PM-to-Win32 message translation
|
|---|
| 134 | PVOID pMessageBuffer; // MessageBuffer object
|
|---|
| 135 | // (here typeless due to include conflicts)
|
|---|
| 136 | DWORD dwMsgExtraInfo; // MessageExtraInfo
|
|---|
| 137 | WINDOWPOS wp; // Used by message translation for WM_WINDOWPOSCHANGED
|
|---|
| 138 | ULONG nrOfMsgs; // Usually 1; some PM messages can generated more than 1 win32 msg
|
|---|
| 139 | BOOL fTranslated; // WM_CHAR already translated or not
|
|---|
| 140 | ULONG msgstate; // odd -> dispatchmessage called, even -> not called
|
|---|
| 141 | QMSG os2msg; // original os2 msg (received with Get- or PeekMessage)
|
|---|
| 142 | MSG winmsg; // temporary storage for translated os2 msg (used in DispatchMessage)
|
|---|
| 143 | MSG msg; // Used by message translation to store translated PM message (sent to win32 window proc in pmwindow.cpp)
|
|---|
| 144 | MSG msgWCHAR; // Used to store extra WM_CHAR message generated by TranslateMessage
|
|---|
| 145 | BOOL fWM_SETFOCUS; // set during WM_SETFOCUS message processing
|
|---|
| 146 | HWND hwndFocus; // set during WM_SETFOCUS message processing
|
|---|
| 147 |
|
|---|
| 148 | DWORD pidDebuggee; // process id of debuggee
|
|---|
| 149 | DWORD logfile; // last FILE ptr used for logging (for exception handling in vfprintf)
|
|---|
| 150 | PROCESSTHREAD_SECURITYINFO threadinfo; //used to store security info for thread tokens
|
|---|
| 151 | DWORD lcid; // thread lcid
|
|---|
| 152 | BOOL fIgnoreMsgs; // set to true if waiting in WaitForSingleObject
|
|---|
| 153 |
|
|---|
| 154 | #ifdef DEBUG
|
|---|
| 155 | // used for call stack tracking
|
|---|
| 156 | ULONG dbgCallDepth; // is de-/incremented by ODINWRAP macros
|
|---|
| 157 | PVOID* arrstrCallStack; // keep track of thread's call stack
|
|---|
| 158 | #endif
|
|---|
| 159 | } odin;
|
|---|
| 160 | #endif
|
|---|
| 161 | /* the following are nt specific fields */
|
|---|
| 162 | DWORD pad6[639]; /* --n 21c */
|
|---|
| 163 | } o;
|
|---|
| 164 | UNICODE_STRING StaticUnicodeString; /* -2- bf8 used by advapi32 */
|
|---|
| 165 | USHORT StaticUnicodeBuffer[261]; /* -2- c00 used by advapi32 */
|
|---|
| 166 | DWORD pad7; /* --n e0c */
|
|---|
| 167 | #ifdef __WIN32OS2__
|
|---|
| 168 | LPVOID tls_array[TLS_MINIMUM_AVAILABLE]; /* -2- e10 Thread local storage */
|
|---|
| 169 | #else
|
|---|
| 170 | LPVOID tls_array[64]; /* -2- e10 Thread local storage */
|
|---|
| 171 | #endif
|
|---|
| 172 | DWORD pad8[3]; /* --n f10 */
|
|---|
| 173 | PVOID ReservedForNtRpc; /* -2- f1c used by rpcrt4 */
|
|---|
| 174 | DWORD pad9[24]; /* --n f20 */
|
|---|
| 175 | PVOID ErrorInfo; /* -2- f80 used by ole32 (IErrorInfo*) */
|
|---|
| 176 | } TEB;
|
|---|
| 177 | #pragma pack()
|
|---|
| 178 |
|
|---|
| 179 | /* Thread exception flags */
|
|---|
| 180 | #define TEBF_WIN32 0x0001
|
|---|
| 181 | #define TEBF_TRAP 0x0002
|
|---|
| 182 |
|
|---|
| 183 |
|
|---|
| 184 | /* The pseudo handle value returned by GetCurrentThread */
|
|---|
| 185 | #define CURRENT_THREAD_PSEUDOHANDLE 0xfffffffe
|
|---|
| 186 |
|
|---|
| 187 | #endif /* __WINE_THREAD_H */
|
|---|