[4] | 1 | /*
|
---|
| 2 | * Thread definitions
|
---|
| 3 | *
|
---|
| 4 | * Copyright 1996 Alexandre Julliard
|
---|
| 5 | */
|
---|
| 6 |
|
---|
| 7 | #ifndef __WINE_THREAD_H
|
---|
| 8 | #define __WINE_THREAD_H
|
---|
| 9 |
|
---|
[1067] | 10 | #ifdef __WIN32OS2__
|
---|
[2203] | 11 | #define TLS_MINIMUM_AVAILABLE 64
|
---|
[1067] | 12 | #ifndef __OS2_H__
|
---|
| 13 | #include "config.h"
|
---|
| 14 | #include "winbase.h"
|
---|
[4657] | 15 | #include "winuser.h"
|
---|
| 16 | #include <ntdef.h>
|
---|
[1067] | 17 | #endif
|
---|
[2326] | 18 | #include <ntdllsec.h> //PROCESSTHREAD_SECURITYINFO struct
|
---|
[1067] | 19 | #else
|
---|
[4] | 20 | #include "config.h"
|
---|
| 21 | #include "winbase.h"
|
---|
[1067] | 22 | #include "selectors.h" /* for SET_FS */
|
---|
[281] | 23 | #endif
|
---|
| 24 |
|
---|
[4] | 25 | struct _PDB;
|
---|
| 26 |
|
---|
[3522] | 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 |
|
---|
[4657] | 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 |
|
---|
[5014] | 56 | #pragma pack(4)
|
---|
[4657] | 57 | /* Thread exception block */
|
---|
| 58 | typedef struct _TEB
|
---|
[4] | 59 | {
|
---|
[4657] | 60 | /* start of NT_TIB */
|
---|
[5014] | 61 | void *except; /* 12- 00 Head of exception handling chain */
|
---|
[4657] | 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 */
|
---|
[10012] | 68 | /* end of NT_TIB */
|
---|
[4657] | 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 {
|
---|
[281] | 117 | #ifdef __WIN32OS2__
|
---|
[4657] | 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
|
---|
[8951] | 122 | HANDLE hPostMsgEvent; // Event semaphore to signal message post to MsgWaitForMultipleObjects
|
---|
| 123 | DWORD dwWakeMask; // Set by MsgWaitForMultipleObjects
|
---|
[4657] | 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
|
---|
[8925] | 128 | ULONG dwSuspend; // suspend count (Suspend/ResumeThread)
|
---|
[4657] | 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)
|
---|
[10012] | 132 |
|
---|
[6830] | 133 | // used for PM-to-Win32 message translation
|
---|
| 134 | PVOID pMessageBuffer; // MessageBuffer object
|
---|
| 135 | // (here typeless due to include conflicts)
|
---|
[7618] | 136 | DWORD dwMsgExtraInfo; // MessageExtraInfo
|
---|
[4657] | 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
|
---|
[10012] | 145 |
|
---|
[4657] | 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
|
---|
[4941] | 150 | BOOL fIgnoreMsgs; // set to true if waiting in WaitForSingleObject
|
---|
[10079] | 151 | BOOL fWaitMessage; // set if blocked in WaitMessage
|
---|
[10435] | 152 | BOOL fWaitMessageSuspend;
|
---|
[9927] | 153 |
|
---|
[10012] | 154 | CONTEXT context; // thread context
|
---|
[10318] | 155 | USHORT savedopcode; // saved instruction
|
---|
[9927] | 156 | LPVOID lpAlias; // alias
|
---|
| 157 | DWORD dwAliasOffset; // offset
|
---|
[10012] | 158 |
|
---|
| 159 | /** @name Special message handling.
|
---|
| 160 | * @{ */
|
---|
| 161 | /** WM_COPYDATA - Must keep it around while it's being processed.
|
---|
| 162 | * Freeing it upon the arrival. Nested WM_COPYDATA isn't supported.
|
---|
| 163 | */
|
---|
| 164 | void * pWM_COPYDATA;
|
---|
| 165 | //@}
|
---|
| 166 |
|
---|
[10435] | 167 | /** Thread Id of the thread is attached to this threads input queue.
|
---|
| 168 | * If 0 then no thread is attached. See AttachThreadInput() for details. */
|
---|
| 169 | unsigned tidAttachedInputThread;
|
---|
| 170 |
|
---|
[6830] | 171 | #ifdef DEBUG
|
---|
| 172 | // used for call stack tracking
|
---|
[7326] | 173 | ULONG dbgCallDepth; // is de-/incremented by ODINWRAP macros
|
---|
| 174 | PVOID* arrstrCallStack; // keep track of thread's call stack
|
---|
[6830] | 175 | #endif
|
---|
[4657] | 176 | } odin;
|
---|
[281] | 177 | #endif
|
---|
[4657] | 178 | /* the following are nt specific fields */
|
---|
[5014] | 179 | DWORD pad6[639]; /* --n 21c */
|
---|
[4657] | 180 | } o;
|
---|
| 181 | UNICODE_STRING StaticUnicodeString; /* -2- bf8 used by advapi32 */
|
---|
| 182 | USHORT StaticUnicodeBuffer[261]; /* -2- c00 used by advapi32 */
|
---|
| 183 | DWORD pad7; /* --n e0c */
|
---|
[125] | 184 | #ifdef __WIN32OS2__
|
---|
[4657] | 185 | LPVOID tls_array[TLS_MINIMUM_AVAILABLE]; /* -2- e10 Thread local storage */
|
---|
| 186 | #else
|
---|
| 187 | LPVOID tls_array[64]; /* -2- e10 Thread local storage */
|
---|
[125] | 188 | #endif
|
---|
[4657] | 189 | DWORD pad8[3]; /* --n f10 */
|
---|
| 190 | PVOID ReservedForNtRpc; /* -2- f1c used by rpcrt4 */
|
---|
| 191 | DWORD pad9[24]; /* --n f20 */
|
---|
| 192 | PVOID ErrorInfo; /* -2- f80 used by ole32 (IErrorInfo*) */
|
---|
| 193 | } TEB;
|
---|
| 194 | #pragma pack()
|
---|
[4] | 195 |
|
---|
[4657] | 196 | /* Thread exception flags */
|
---|
| 197 | #define TEBF_WIN32 0x0001
|
---|
| 198 | #define TEBF_TRAP 0x0002
|
---|
| 199 |
|
---|
| 200 |
|
---|
[4] | 201 | /* The pseudo handle value returned by GetCurrentThread */
|
---|
| 202 | #define CURRENT_THREAD_PSEUDOHANDLE 0xfffffffe
|
---|
| 203 |
|
---|
| 204 | #endif /* __WINE_THREAD_H */
|
---|