thread.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /*
  2. * Thread definitions
  3. *
  4. * Copyright 1996 Alexandre Julliard
  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
  19. */
  20. #ifndef __WINE_THREAD_H
  21. #define __WINE_THREAD_H
  22. #include <stdarg.h>
  23. #include <windef.h>
  24. #include <winbase.h>
  25. #include <winreg.h>
  26. #define WINE_NO_TEB
  27. #include <winternl.h>
  28. #include <wine/windef16.h>
  29. struct _SECURITY_ATTRIBUTES;
  30. struct tagSYSLEVEL;
  31. struct server_buffer_info;
  32. struct fiber_data;
  33. struct debug_info
  34. {
  35. char *str_pos; /* current position in strings buffer */
  36. char *out_pos; /* current position in output buffer */
  37. char strings[1024]; /* buffer for temporary strings */
  38. char output[1024]; /* current output line */
  39. };
  40. /* Thread exception block
  41. flags in the comment:
  42. 1-- win95 field
  43. d-- win95 debug version
  44. -2- nt field
  45. --3 wine special
  46. --n wine unused
  47. !-- or -!- likely or observed collision
  48. more problems (collected from mailing list):
  49. psapi.dll 0x10/0x30 (expects nt fields)
  50. ie4 0x40
  51. PESHiELD 0x23/0x30 (win95)
  52. */
  53. #ifndef WINE_TEB_DEFINED
  54. #define WINE_TEB_DEFINED
  55. typedef struct _TEB
  56. {
  57. NT_TIB Tib; /* 12- 00 Thread information block */
  58. PVOID EnvironmentPointer; /* 12- 1c EnvironmentPointer (win95: tib flags + win16 mutex count) */
  59. CLIENT_ID ClientId; /* -2- 20 Process and thread id (win95: debug context) */
  60. HQUEUE16 queue; /* 1!- 28 Message queue (NT: DWORD ActiveRpcHandle)*/
  61. WORD pad1; /* --n 2a */
  62. PVOID ThreadLocalStoragePointer; /* 1-- 2c Pointer to TLS array */
  63. PEB *Peb; /* 12- 30 owning process PEB */
  64. DWORD LastErrorValue; /* -2- 34 Last error code */
  65. DWORD exit_code; /* 1-- 38 Termination status */
  66. WORD teb_sel; /* 1-- 3c Selector to TEB */
  67. WORD emu_sel; /* 1-n 3e 80387 emulator selector */
  68. DWORD unknown1; /* --n 40 */
  69. DWORD unknown2; /* --n 44 */
  70. DWORD unknown3; /* --n 48 */
  71. int thread_errno; /* --3 4c Per-thread errno (was: ring0_thread) */
  72. int thread_h_errno; /* --3 50 Per-thread h_errno (was: ptr to tdbx structure) */
  73. void *stack_base; /* 1-n 54 Stack base (unused) */
  74. void *exit_stack; /* 1-n 58 Exit stack */
  75. void *emu_data; /* --n 5c Related to 80387 emulation */
  76. DWORD last_error; /* 1-- 60 Last error code */
  77. HANDLE debug_cb; /* 1-n 64 Debugger context block */
  78. DWORD debug_thread; /* 1-n 68 Thread debugging this one (?) */
  79. void *pcontext; /* 1-n 6c Thread register context */
  80. DWORD cur_stack; /* --3 70 Current stack (was: unknown) */
  81. DWORD ThunkConnect; /* 1-n 74 */
  82. DWORD NegStackBase; /* 1-n 78 */
  83. WORD current_ss; /* 1-n 7c Another 16-bit stack selector */
  84. WORD pad2; /* --n 7e */
  85. void *ss_table; /* --n 80 Pointer to info about 16-bit stack */
  86. WORD stack_sel; /* --3 84 16-bit stack selector */
  87. HTASK16 htask16; /* --3 86 Win16 task handle */
  88. DWORD pad4[15]; /* --n 88 */
  89. ULONG CurrentLocale; /* -2- C4 */
  90. DWORD pad5[48]; /* --n C8 */
  91. DWORD delta_priority; /* 1-n 188 Priority delta */
  92. DWORD unknown4[7]; /* d-n 18c Unknown */
  93. void *create_data; /* d-n 1a8 Pointer to creation structure */
  94. DWORD suspend_count; /* d-n 1ac SuspendThread() counter */
  95. DWORD unknown5[6]; /* --n 1b0 Unknown */
  96. DWORD sys_count[4]; /* --3 1c8 Syslevel mutex entry counters */
  97. struct tagSYSLEVEL *sys_mutex[4]; /* --3 1d8 Syslevel mutex pointers */
  98. DWORD unknown6[5]; /* --n 1e8 Unknown */
  99. /* The following are Wine-specific fields (NT: GDI stuff) */
  100. UINT code_page; /* --3 1fc Thread code page */
  101. DWORD unused[2]; /* --3 200 Was server buffer */
  102. DWORD gs_sel; /* --3 208 %gs selector for this thread */
  103. int request_fd; /* --3 20c fd for sending server requests */
  104. int reply_fd; /* --3 210 fd for receiving server replies */
  105. int wait_fd[2]; /* --3 214 fd for sleeping server requests */
  106. struct debug_info *debug_info; /* --3 21c Info for debugstr functions */
  107. void *pthread_data; /* --3 220 Data for pthread emulation */
  108. DWORD num_async_io; /* --3 224 number of pending async I/O in the server */
  109. void *driver_data; /* --3 228 Graphics driver private data */
  110. DWORD dpmi_vif; /* --3 22c Protected mode virtual interrupt flag */
  111. DWORD vm86_pending; /* --3 230 Data for vm86 mode */
  112. void *vm86_ptr; /* --3 234 Data for vm86 mode */
  113. /* here is plenty space for wine specific fields (don't forget to change pad6!!) */
  114. /* the following are nt specific fields */
  115. DWORD pad6[623]; /* --n 238 */
  116. ULONG LastStatusValue; /* -2- bf4 */
  117. UNICODE_STRING StaticUnicodeString; /* -2- bf8 used by advapi32 */
  118. WCHAR StaticUnicodeBuffer[261]; /* -2- c00 used by advapi32 */
  119. PVOID DeallocationStack; /* -2- e0c Base of the stack */
  120. LPVOID TlsSlots[64]; /* -2- e10 Thread local storage */
  121. LIST_ENTRY TlsLinks; /* -2- f10 */
  122. DWORD pad8[1]; /* --n f18 */
  123. PVOID ReservedForNtRpc; /* -2- f1c used by rpcrt4 */
  124. DWORD pad9[24]; /* --n f20 */
  125. PVOID ReservedForOle; /* -2- f80 used by ole32 (IErrorInfo*) */
  126. PVOID pad10[4]; /* --n f84 */
  127. PVOID TlsExpansionSlots; /* -2- f94 */
  128. } TEB;
  129. #endif /* WINE_TEB_DEFINED */
  130. /* The thread information for 16-bit threads */
  131. /* NtCurrentTeb()->SubSystemTib points to this */
  132. typedef struct
  133. {
  134. void *unknown; /* 00 unknown */
  135. UNICODE_STRING *exe_name; /* 04 exe module name */
  136. /* the following fields do not exist under Windows */
  137. UNICODE_STRING exe_str; /* exe name string pointed to by exe_name */
  138. CURDIR curdir; /* current directory */
  139. WCHAR curdir_buffer[MAX_PATH];
  140. } WIN16_SUBSYSTEM_TIB;
  141. /* scheduler/thread.c */
  142. extern TEB *THREAD_InitStack( TEB *teb, DWORD stack_size );
  143. #endif /* __WINE_THREAD_H */