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