Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Thread definitions |
| 3 | * |
| 4 | * Copyright 1996 Alexandre Julliard |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 5 | * |
| 6 | * This library is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU Lesser General Public |
| 8 | * License as published by the Free Software Foundation; either |
| 9 | * version 2.1 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This library is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * Lesser General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Lesser General Public |
| 17 | * License along with this library; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 19 | */ |
| 20 | |
| 21 | #ifndef __WINE_THREAD_H |
| 22 | #define __WINE_THREAD_H |
| 23 | |
Alexandre Julliard | e37c6e1 | 2003-09-05 23:08:26 +0000 | [diff] [blame] | 24 | #include <stdarg.h> |
| 25 | #include <windef.h> |
| 26 | #include <winbase.h> |
| 27 | #include <winreg.h> |
Alexandre Julliard | 7df1b9e | 2003-08-28 19:57:35 +0000 | [diff] [blame] | 28 | #define WINE_NO_TEB |
Dimitrie O. Paun | 53f9c21 | 2003-08-28 21:43:34 +0000 | [diff] [blame] | 29 | #include <winternl.h> |
| 30 | #include <wine/windef16.h> |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 31 | |
Patrik Stridvall | 6cc47d4 | 2000-03-08 18:26:56 +0000 | [diff] [blame] | 32 | struct _SECURITY_ATTRIBUTES; |
| 33 | struct tagSYSLEVEL; |
Alexandre Julliard | 8611353 | 2000-08-29 03:54:30 +0000 | [diff] [blame] | 34 | struct server_buffer_info; |
Alexandre Julliard | 9e8e5ff | 2002-12-17 21:06:25 +0000 | [diff] [blame] | 35 | struct fiber_data; |
Alexandre Julliard | a11d7b1 | 1998-03-01 20:05:02 +0000 | [diff] [blame] | 36 | |
Alexandre Julliard | aee989a | 2003-08-21 21:34:33 +0000 | [diff] [blame] | 37 | struct debug_info |
| 38 | { |
| 39 | char *str_pos; /* current position in strings buffer */ |
| 40 | char *out_pos; /* current position in output buffer */ |
| 41 | char strings[1024]; /* buffer for temporary strings */ |
| 42 | char output[1024]; /* current output line */ |
| 43 | }; |
| 44 | |
Juergen Schmied | 7434102 | 2000-01-15 22:22:27 +0000 | [diff] [blame] | 45 | /* Thread exception block |
| 46 | |
| 47 | flags in the comment: |
| 48 | 1-- win95 field |
| 49 | d-- win95 debug version |
| 50 | -2- nt field |
| 51 | --3 wine special |
| 52 | --n wine unused |
| 53 | !-- or -!- likely or observed collision |
| 54 | more problems (collected from mailing list): |
| 55 | psapi.dll 0x10/0x30 (expects nt fields) |
| 56 | ie4 0x40 |
| 57 | PESHiELD 0x23/0x30 (win95) |
| 58 | */ |
Alexandre Julliard | 7df1b9e | 2003-08-28 19:57:35 +0000 | [diff] [blame] | 59 | #ifndef WINE_TEB_DEFINED |
| 60 | #define WINE_TEB_DEFINED |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 61 | typedef struct _TEB |
| 62 | { |
Alexandre Julliard | b91e9cb | 2003-08-28 03:44:41 +0000 | [diff] [blame] | 63 | NT_TIB Tib; /* 12- 00 Thread information block */ |
Alexandre Julliard | a45931c | 2004-04-15 05:04:53 +0000 | [diff] [blame] | 64 | PVOID EnvironmentPointer; /* 12- 1c EnvironmentPointer (win95: tib flags + win16 mutex count) */ |
Alexandre Julliard | 02f2813 | 2003-08-27 23:14:29 +0000 | [diff] [blame] | 65 | CLIENT_ID ClientId; /* -2- 20 Process and thread id (win95: debug context) */ |
Juergen Schmied | 7434102 | 2000-01-15 22:22:27 +0000 | [diff] [blame] | 66 | HQUEUE16 queue; /* 1!- 28 Message queue (NT: DWORD ActiveRpcHandle)*/ |
| 67 | WORD pad1; /* --n 2a */ |
Alexandre Julliard | 02f2813 | 2003-08-27 23:14:29 +0000 | [diff] [blame] | 68 | PVOID ThreadLocalStoragePointer; /* 1-- 2c Pointer to TLS array */ |
Alexandre Julliard | 6bc5091 | 2003-05-22 03:44:01 +0000 | [diff] [blame] | 69 | PEB *Peb; /* 12- 30 owning process PEB */ |
Alexandre Julliard | 9e73f55 | 2003-11-25 01:53:23 +0000 | [diff] [blame] | 70 | DWORD LastErrorValue; /* -2- 34 Last error code */ |
Juergen Schmied | 7434102 | 2000-01-15 22:22:27 +0000 | [diff] [blame] | 71 | DWORD exit_code; /* 1-- 38 Termination status */ |
| 72 | WORD teb_sel; /* 1-- 3c Selector to TEB */ |
| 73 | WORD emu_sel; /* 1-n 3e 80387 emulator selector */ |
| 74 | DWORD unknown1; /* --n 40 */ |
| 75 | DWORD unknown2; /* --n 44 */ |
Alexandre Julliard | aee989a | 2003-08-21 21:34:33 +0000 | [diff] [blame] | 76 | DWORD unknown3; /* --n 48 */ |
Juergen Schmied | 7434102 | 2000-01-15 22:22:27 +0000 | [diff] [blame] | 77 | int thread_errno; /* --3 4c Per-thread errno (was: ring0_thread) */ |
| 78 | int thread_h_errno; /* --3 50 Per-thread h_errno (was: ptr to tdbx structure) */ |
Alexandre Julliard | 8824c38e | 2003-10-22 03:26:53 +0000 | [diff] [blame] | 79 | void *stack_base; /* 1-n 54 Stack base (unused) */ |
Alexandre Julliard | 9e8e5ff | 2002-12-17 21:06:25 +0000 | [diff] [blame] | 80 | void *exit_stack; /* 1-n 58 Exit stack */ |
Juergen Schmied | 7434102 | 2000-01-15 22:22:27 +0000 | [diff] [blame] | 81 | void *emu_data; /* --n 5c Related to 80387 emulation */ |
| 82 | DWORD last_error; /* 1-- 60 Last error code */ |
Ulrich Weigand | 7d43bce | 2000-01-30 21:16:45 +0000 | [diff] [blame] | 83 | HANDLE debug_cb; /* 1-n 64 Debugger context block */ |
Juergen Schmied | 7434102 | 2000-01-15 22:22:27 +0000 | [diff] [blame] | 84 | DWORD debug_thread; /* 1-n 68 Thread debugging this one (?) */ |
| 85 | void *pcontext; /* 1-n 6c Thread register context */ |
| 86 | DWORD cur_stack; /* --3 70 Current stack (was: unknown) */ |
| 87 | DWORD ThunkConnect; /* 1-n 74 */ |
| 88 | DWORD NegStackBase; /* 1-n 78 */ |
| 89 | WORD current_ss; /* 1-n 7c Another 16-bit stack selector */ |
| 90 | WORD pad2; /* --n 7e */ |
| 91 | void *ss_table; /* --n 80 Pointer to info about 16-bit stack */ |
Alexandre Julliard | b91e9cb | 2003-08-28 03:44:41 +0000 | [diff] [blame] | 92 | WORD stack_sel; /* --3 84 16-bit stack selector */ |
| 93 | HTASK16 htask16; /* --3 86 Win16 task handle */ |
Juergen Schmied | 7434102 | 2000-01-15 22:22:27 +0000 | [diff] [blame] | 94 | DWORD pad4[15]; /* --n 88 */ |
Juergen Schmied | 79d850f | 2000-06-12 21:56:02 +0000 | [diff] [blame] | 95 | ULONG CurrentLocale; /* -2- C4 */ |
Juergen Schmied | 7434102 | 2000-01-15 22:22:27 +0000 | [diff] [blame] | 96 | DWORD pad5[48]; /* --n C8 */ |
| 97 | DWORD delta_priority; /* 1-n 188 Priority delta */ |
| 98 | DWORD unknown4[7]; /* d-n 18c Unknown */ |
| 99 | void *create_data; /* d-n 1a8 Pointer to creation structure */ |
| 100 | DWORD suspend_count; /* d-n 1ac SuspendThread() counter */ |
Alexandre Julliard | 6281d82 | 2003-11-25 03:42:05 +0000 | [diff] [blame] | 101 | DWORD unknown5[6]; /* --n 1b0 Unknown */ |
Juergen Schmied | 7434102 | 2000-01-15 22:22:27 +0000 | [diff] [blame] | 102 | DWORD sys_count[4]; /* --3 1c8 Syslevel mutex entry counters */ |
Patrik Stridvall | 6cc47d4 | 2000-03-08 18:26:56 +0000 | [diff] [blame] | 103 | struct tagSYSLEVEL *sys_mutex[4]; /* --3 1d8 Syslevel mutex pointers */ |
Juergen Schmied | 7434102 | 2000-01-15 22:22:27 +0000 | [diff] [blame] | 104 | DWORD unknown6[5]; /* --n 1e8 Unknown */ |
| 105 | |
| 106 | /* The following are Wine-specific fields (NT: GDI stuff) */ |
Alexandre Julliard | 66e3183 | 2002-08-15 23:18:47 +0000 | [diff] [blame] | 107 | UINT code_page; /* --3 1fc Thread code page */ |
Alexandre Julliard | 551797b | 2003-02-27 21:11:13 +0000 | [diff] [blame] | 108 | DWORD unused[2]; /* --3 200 Was server buffer */ |
| 109 | DWORD gs_sel; /* --3 208 %gs selector for this thread */ |
Alexandre Julliard | 8859d77 | 2001-03-01 22:13:49 +0000 | [diff] [blame] | 110 | int request_fd; /* --3 20c fd for sending server requests */ |
| 111 | int reply_fd; /* --3 210 fd for receiving server replies */ |
Alexandre Julliard | e5dedb1 | 2001-03-08 01:16:41 +0000 | [diff] [blame] | 112 | int wait_fd[2]; /* --3 214 fd for sleeping server requests */ |
Alexandre Julliard | aee989a | 2003-08-21 21:34:33 +0000 | [diff] [blame] | 113 | struct debug_info *debug_info; /* --3 21c Info for debugstr functions */ |
Alexandre Julliard | e5dedb1 | 2001-03-08 01:16:41 +0000 | [diff] [blame] | 114 | void *pthread_data; /* --3 220 Data for pthread emulation */ |
Michael McCormack | 1c32a46 | 2001-03-22 20:09:34 +0000 | [diff] [blame] | 115 | struct async_private *pending_list; /* --3 224 list of pending async operations */ |
Alexandre Julliard | 4323004 | 2001-05-16 19:52:29 +0000 | [diff] [blame] | 116 | void *driver_data; /* --3 228 Graphics driver private data */ |
Jukka Heinonen | ae90692 | 2003-06-16 01:18:26 +0000 | [diff] [blame] | 117 | DWORD dpmi_vif; /* --3 22c Protected mode virtual interrupt flag */ |
Ove Kaaven | 6e33f63 | 2001-06-21 00:39:34 +0000 | [diff] [blame] | 118 | DWORD vm86_pending; /* --3 230 Data for vm86 mode */ |
| 119 | void *vm86_ptr; /* --3 234 Data for vm86 mode */ |
Juergen Schmied | 7434102 | 2000-01-15 22:22:27 +0000 | [diff] [blame] | 120 | /* here is plenty space for wine specific fields (don't forget to change pad6!!) */ |
| 121 | |
| 122 | /* the following are nt specific fields */ |
Ove Kaaven | 4eb0beb | 2002-01-04 21:57:04 +0000 | [diff] [blame] | 123 | DWORD pad6[624]; /* --n 238 */ |
Juergen Schmied | 7434102 | 2000-01-15 22:22:27 +0000 | [diff] [blame] | 124 | UNICODE_STRING StaticUnicodeString; /* -2- bf8 used by advapi32 */ |
Alexandre Julliard | 20e73d7 | 2003-10-09 04:59:03 +0000 | [diff] [blame] | 125 | WCHAR StaticUnicodeBuffer[261]; /* -2- c00 used by advapi32 */ |
Alexandre Julliard | 02f2813 | 2003-08-27 23:14:29 +0000 | [diff] [blame] | 126 | PVOID DeallocationStack; /* -2- e0c Base of the stack */ |
| 127 | LPVOID TlsSlots[64]; /* -2- e10 Thread local storage */ |
Alexandre Julliard | 2eb5d8b | 2003-09-08 19:02:01 +0000 | [diff] [blame] | 128 | LIST_ENTRY TlsLinks; /* -2- f10 */ |
| 129 | DWORD pad8[1]; /* --n f18 */ |
Juergen Schmied | 7434102 | 2000-01-15 22:22:27 +0000 | [diff] [blame] | 130 | PVOID ReservedForNtRpc; /* -2- f1c used by rpcrt4 */ |
| 131 | DWORD pad9[24]; /* --n f20 */ |
Alexandre Julliard | 02f2813 | 2003-08-27 23:14:29 +0000 | [diff] [blame] | 132 | PVOID ReservedForOle; /* -2- f80 used by ole32 (IErrorInfo*) */ |
Eric Pouech | 64af08e | 2004-05-10 19:58:48 +0000 | [diff] [blame] | 133 | PVOID pad10[4]; /* --n f84 */ |
| 134 | PVOID TlsExpansionSlots; /* -2- f94 */ |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 135 | } TEB; |
Alexandre Julliard | 7df1b9e | 2003-08-28 19:57:35 +0000 | [diff] [blame] | 136 | #endif /* WINE_TEB_DEFINED */ |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 137 | |
Alexandre Julliard | 186b419 | 2004-04-16 00:10:03 +0000 | [diff] [blame] | 138 | |
| 139 | /* The thread information for 16-bit threads */ |
| 140 | /* NtCurrentTeb()->SubSystemTib points to this */ |
| 141 | typedef struct |
| 142 | { |
| 143 | void *unknown; /* 00 unknown */ |
| 144 | UNICODE_STRING *exe_name; /* 04 exe module name */ |
| 145 | |
| 146 | /* the following fields do not exist under Windows */ |
| 147 | UNICODE_STRING exe_str; /* exe name string pointed to by exe_name */ |
Alexandre Julliard | dfcfc98 | 2004-04-16 05:00:46 +0000 | [diff] [blame] | 148 | CURDIR curdir; /* current directory */ |
Alexandre Julliard | 186b419 | 2004-04-16 00:10:03 +0000 | [diff] [blame] | 149 | WCHAR curdir_buffer[MAX_PATH]; |
| 150 | } WIN16_SUBSYSTEM_TIB; |
| 151 | |
Alexandre Julliard | 02e9008 | 1998-01-04 17:49:09 +0000 | [diff] [blame] | 152 | /* scheduler/thread.c */ |
Alexandre Julliard | 9ee9eff | 2001-02-28 05:29:50 +0000 | [diff] [blame] | 153 | extern TEB *THREAD_InitStack( TEB *teb, DWORD stack_size ); |
Alexandre Julliard | 02e9008 | 1998-01-04 17:49:09 +0000 | [diff] [blame] | 154 | |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 155 | #endif /* __WINE_THREAD_H */ |