Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Thread definitions |
| 3 | * |
| 4 | * Copyright 1996 Alexandre Julliard |
| 5 | */ |
| 6 | |
| 7 | #ifndef __WINE_THREAD_H |
| 8 | #define __WINE_THREAD_H |
| 9 | |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 10 | #include "config.h" |
Patrik Stridvall | 6cc47d4 | 2000-03-08 18:26:56 +0000 | [diff] [blame] | 11 | |
Juergen Schmied | 7434102 | 2000-01-15 22:22:27 +0000 | [diff] [blame] | 12 | #include "ntdef.h" /* UNICODE_STRING */ |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 13 | #include "wine/windef16.h" |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 14 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 15 | struct _PDB; |
Alexandre Julliard | dd93d25 | 1999-05-09 16:12:19 +0000 | [diff] [blame] | 16 | struct __EXCEPTION_FRAME; |
Patrik Stridvall | 6cc47d4 | 2000-03-08 18:26:56 +0000 | [diff] [blame] | 17 | struct _SECURITY_ATTRIBUTES; |
| 18 | struct tagSYSLEVEL; |
Alexandre Julliard | 8611353 | 2000-08-29 03:54:30 +0000 | [diff] [blame] | 19 | struct server_buffer_info; |
Alexandre Julliard | a11d7b1 | 1998-03-01 20:05:02 +0000 | [diff] [blame] | 20 | |
Juergen Schmied | 7434102 | 2000-01-15 22:22:27 +0000 | [diff] [blame] | 21 | /* Thread exception block |
| 22 | |
| 23 | flags in the comment: |
| 24 | 1-- win95 field |
| 25 | d-- win95 debug version |
| 26 | -2- nt field |
| 27 | --3 wine special |
| 28 | --n wine unused |
| 29 | !-- or -!- likely or observed collision |
| 30 | more problems (collected from mailing list): |
| 31 | psapi.dll 0x10/0x30 (expects nt fields) |
| 32 | ie4 0x40 |
| 33 | PESHiELD 0x23/0x30 (win95) |
| 34 | */ |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 35 | typedef struct _TEB |
| 36 | { |
Juergen Schmied | 7434102 | 2000-01-15 22:22:27 +0000 | [diff] [blame] | 37 | /* start of NT_TIB */ |
| 38 | struct __EXCEPTION_FRAME *except; /* 12- 00 Head of exception handling chain */ |
| 39 | void *stack_top; /* 12- 04 Top of thread stack */ |
| 40 | void *stack_low; /* 12- 08 Stack low-water mark */ |
| 41 | HTASK16 htask16; /* 1-- 0c Win16 task handle */ |
| 42 | WORD stack_sel; /* 1-- 0e 16-bit stack selector */ |
| 43 | DWORD selman_list; /* 1-n 10 Selector manager list */ |
| 44 | DWORD user_ptr; /* 12n 14 User pointer */ |
| 45 | /* end of NT_TIB */ |
| 46 | struct _TEB *self; /* 12- 18 Pointer to this structure */ |
| 47 | WORD tibflags; /* 1!n 1c Flags (NT: EnvironmentPointer) */ |
| 48 | WORD mutex_count; /* 1-n 1e Win16 mutex count */ |
Alexandre Julliard | 114830e | 2000-04-11 20:01:59 +0000 | [diff] [blame] | 49 | void *pid; /* !2- 20 Process id (win95: debug context) */ |
Juergen Schmied | 7434102 | 2000-01-15 22:22:27 +0000 | [diff] [blame] | 50 | void *tid; /* -2- 24 Thread id */ |
| 51 | HQUEUE16 queue; /* 1!- 28 Message queue (NT: DWORD ActiveRpcHandle)*/ |
| 52 | WORD pad1; /* --n 2a */ |
| 53 | LPVOID *tls_ptr; /* 1-- 2c Pointer to TLS array */ |
| 54 | struct _PDB *process; /* 12- 30 owning process (win95: PDB; nt: NTPEB !!) */ |
| 55 | DWORD flags; /* 1-n 34 */ |
| 56 | DWORD exit_code; /* 1-- 38 Termination status */ |
| 57 | WORD teb_sel; /* 1-- 3c Selector to TEB */ |
| 58 | WORD emu_sel; /* 1-n 3e 80387 emulator selector */ |
| 59 | DWORD unknown1; /* --n 40 */ |
| 60 | DWORD unknown2; /* --n 44 */ |
| 61 | void (*startup)(void); /* --3 48 Thread startup routine */ |
| 62 | int thread_errno; /* --3 4c Per-thread errno (was: ring0_thread) */ |
| 63 | int thread_h_errno; /* --3 50 Per-thread h_errno (was: ptr to tdbx structure) */ |
| 64 | void *stack_base; /* 1-- 54 Base of the stack */ |
| 65 | void *signal_stack; /* --3 58 Signal stack (was: exit_stack) */ |
| 66 | void *emu_data; /* --n 5c Related to 80387 emulation */ |
| 67 | DWORD last_error; /* 1-- 60 Last error code */ |
Ulrich Weigand | 7d43bce | 2000-01-30 21:16:45 +0000 | [diff] [blame] | 68 | HANDLE debug_cb; /* 1-n 64 Debugger context block */ |
Juergen Schmied | 7434102 | 2000-01-15 22:22:27 +0000 | [diff] [blame] | 69 | DWORD debug_thread; /* 1-n 68 Thread debugging this one (?) */ |
| 70 | void *pcontext; /* 1-n 6c Thread register context */ |
| 71 | DWORD cur_stack; /* --3 70 Current stack (was: unknown) */ |
| 72 | DWORD ThunkConnect; /* 1-n 74 */ |
| 73 | DWORD NegStackBase; /* 1-n 78 */ |
| 74 | WORD current_ss; /* 1-n 7c Another 16-bit stack selector */ |
| 75 | WORD pad2; /* --n 7e */ |
| 76 | void *ss_table; /* --n 80 Pointer to info about 16-bit stack */ |
| 77 | WORD thunk_ss; /* --n 84 Yet another 16-bit stack selector */ |
| 78 | WORD pad3; /* --n 86 */ |
| 79 | DWORD pad4[15]; /* --n 88 */ |
Juergen Schmied | 79d850f | 2000-06-12 21:56:02 +0000 | [diff] [blame] | 80 | ULONG CurrentLocale; /* -2- C4 */ |
Juergen Schmied | 7434102 | 2000-01-15 22:22:27 +0000 | [diff] [blame] | 81 | DWORD pad5[48]; /* --n C8 */ |
| 82 | DWORD delta_priority; /* 1-n 188 Priority delta */ |
| 83 | DWORD unknown4[7]; /* d-n 18c Unknown */ |
| 84 | void *create_data; /* d-n 1a8 Pointer to creation structure */ |
| 85 | DWORD suspend_count; /* d-n 1ac SuspendThread() counter */ |
| 86 | void *entry_point; /* --3 1b0 Thread entry point (was: unknown) */ |
| 87 | void *entry_arg; /* --3 1b4 Entry point arg (was: unknown) */ |
| 88 | DWORD unknown5[4]; /* --n 1b8 Unknown */ |
| 89 | DWORD sys_count[4]; /* --3 1c8 Syslevel mutex entry counters */ |
Patrik Stridvall | 6cc47d4 | 2000-03-08 18:26:56 +0000 | [diff] [blame] | 90 | struct tagSYSLEVEL *sys_mutex[4]; /* --3 1d8 Syslevel mutex pointers */ |
Juergen Schmied | 7434102 | 2000-01-15 22:22:27 +0000 | [diff] [blame] | 91 | DWORD unknown6[5]; /* --n 1e8 Unknown */ |
| 92 | |
| 93 | /* The following are Wine-specific fields (NT: GDI stuff) */ |
Alexandre Julliard | 8611353 | 2000-08-29 03:54:30 +0000 | [diff] [blame] | 94 | DWORD cleanup; /* --3 1fc Cleanup service handle */ |
| 95 | int socket; /* --3 200 Socket for server communication */ |
| 96 | void *buffer; /* --3 204 Buffer shared with server */ |
| 97 | struct server_buffer_info *buffer_info; /* --3 208 Buffer information */ |
| 98 | void *debug_info; /* --3 20c Info for debugstr functions */ |
| 99 | void *pthread_data; /* --3 210 Data for pthread emulation */ |
Juergen Schmied | 7434102 | 2000-01-15 22:22:27 +0000 | [diff] [blame] | 100 | /* here is plenty space for wine specific fields (don't forget to change pad6!!) */ |
| 101 | |
| 102 | /* the following are nt specific fields */ |
Alexandre Julliard | 8611353 | 2000-08-29 03:54:30 +0000 | [diff] [blame] | 103 | DWORD pad6[633]; /* --n 214 */ |
Juergen Schmied | 7434102 | 2000-01-15 22:22:27 +0000 | [diff] [blame] | 104 | UNICODE_STRING StaticUnicodeString; /* -2- bf8 used by advapi32 */ |
| 105 | USHORT StaticUnicodeBuffer[261]; /* -2- c00 used by advapi32 */ |
| 106 | DWORD pad7; /* --n e0c */ |
| 107 | LPVOID tls_array[64]; /* -2- e10 Thread local storage */ |
| 108 | DWORD pad8[3]; /* --n f10 */ |
| 109 | PVOID ReservedForNtRpc; /* -2- f1c used by rpcrt4 */ |
| 110 | DWORD pad9[24]; /* --n f20 */ |
Juergen Schmied | ec85c6b | 2000-08-03 04:34:59 +0000 | [diff] [blame] | 111 | PVOID ErrorInfo; /* -2- f80 used by ole32 (IErrorInfo*) */ |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 112 | } TEB; |
| 113 | |
Ulrich Weigand | ca1c747 | 1998-11-24 20:47:17 +0000 | [diff] [blame] | 114 | /* Thread exception flags */ |
| 115 | #define TEBF_WIN32 0x0001 |
| 116 | #define TEBF_TRAP 0x0002 |
| 117 | |
Alexandre Julliard | d131a17 | 1999-05-23 20:02:04 +0000 | [diff] [blame] | 118 | /* The per-thread signal stack size */ |
| 119 | #define SIGNAL_STACK_SIZE 16384 |
| 120 | |
Alexandre Julliard | 02e9008 | 1998-01-04 17:49:09 +0000 | [diff] [blame] | 121 | |
| 122 | /* scheduler/thread.c */ |
Alexandre Julliard | 8c21dfc | 2000-05-01 21:21:31 +0000 | [diff] [blame] | 123 | extern void THREAD_Init(void); |
Alexandre Julliard | c192ba2 | 2000-05-29 21:25:10 +0000 | [diff] [blame] | 124 | extern TEB *THREAD_Create( int fd, DWORD stack_size, BOOL alloc_stack16 ); |
Alexandre Julliard | 8c21dfc | 2000-05-01 21:21:31 +0000 | [diff] [blame] | 125 | extern TEB *THREAD_InitStack( TEB *teb, DWORD stack_size, BOOL alloc_stack16 ); |
Alexandre Julliard | 0a860a0 | 1999-06-22 11:43:42 +0000 | [diff] [blame] | 126 | extern BOOL THREAD_IsWin16( TEB *thdb ); |
| 127 | extern TEB *THREAD_IdToTEB( DWORD id ); |
Alexandre Julliard | 02e9008 | 1998-01-04 17:49:09 +0000 | [diff] [blame] | 128 | |
Alexandre Julliard | 0623a6f | 1998-01-18 18:01:49 +0000 | [diff] [blame] | 129 | /* scheduler/sysdeps.c */ |
Alexandre Julliard | 0a860a0 | 1999-06-22 11:43:42 +0000 | [diff] [blame] | 130 | extern int SYSDEPS_SpawnThread( TEB *teb ); |
| 131 | extern void SYSDEPS_SetCurThread( TEB *teb ); |
Alexandre Julliard | 12f29b5 | 2000-03-17 15:16:57 +0000 | [diff] [blame] | 132 | extern void SYSDEPS_ExitThread( int status ) WINE_NORETURN; |
Alexandre Julliard | 0623a6f | 1998-01-18 18:01:49 +0000 | [diff] [blame] | 133 | |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 134 | #endif /* __WINE_THREAD_H */ |