Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Task definitions |
Alexandre Julliard | 594997c | 1995-04-30 10:05:20 +0000 | [diff] [blame] | 3 | * |
| 4 | * Copyright 1995 Alexandre Julliard |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 7 | #ifndef __WINE_TASK_H |
| 8 | #define __WINE_TASK_H |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 9 | |
Jim Aston | 2e1cafa | 1999-03-14 16:35:05 +0000 | [diff] [blame] | 10 | #include "windef.h" |
Alexandre Julliard | 7cc9c0c | 1994-06-15 15:45:11 +0000 | [diff] [blame] | 11 | |
Patrik Stridvall | c7a8dde | 1999-04-25 12:36:53 +0000 | [diff] [blame] | 12 | #include "pshpack1.h" |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 13 | |
Alexandre Julliard | 594997c | 1995-04-30 10:05:20 +0000 | [diff] [blame] | 14 | /* Process database (i.e. a normal DOS PSP) */ |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 15 | |
Alexandre Julliard | 594997c | 1995-04-30 10:05:20 +0000 | [diff] [blame] | 16 | typedef struct |
| 17 | { |
Alexandre Julliard | ca22b33 | 1996-07-12 19:02:39 +0000 | [diff] [blame] | 18 | WORD int20; /* 00 int 20h instruction */ |
| 19 | WORD nextParagraph; /* 02 Segment of next paragraph */ |
| 20 | BYTE reserved1; |
| 21 | BYTE dispatcher[5]; /* 05 Long call to DOS */ |
| 22 | FARPROC16 savedint22 WINE_PACKED; /* 0a Saved int 22h handler */ |
| 23 | FARPROC16 savedint23 WINE_PACKED; /* 0e Saved int 23h handler */ |
| 24 | FARPROC16 savedint24 WINE_PACKED; /* 12 Saved int 24h handler */ |
| 25 | WORD parentPSP; /* 16 Selector of parent PSP */ |
| 26 | BYTE fileHandles[20]; /* 18 Open file handles */ |
| 27 | HANDLE16 environment; /* 2c Selector of environment */ |
| 28 | WORD reserved2[2]; |
| 29 | WORD nbFiles; /* 32 Number of file handles */ |
| 30 | SEGPTR fileHandlesPtr; /* 34 Pointer to file handle table */ |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 31 | HANDLE16 hFileHandles; /* 38 Handle to fileHandlesPtr */ |
| 32 | WORD reserved3[17]; |
Alexandre Julliard | ca22b33 | 1996-07-12 19:02:39 +0000 | [diff] [blame] | 33 | BYTE fcb1[16]; /* 5c First FCB */ |
| 34 | BYTE fcb2[20]; /* 6c Second FCB */ |
| 35 | BYTE cmdLine[128]; /* 80 Command-line (first byte is len)*/ |
Alexandre Julliard | 3bf623d | 1998-10-25 10:20:31 +0000 | [diff] [blame] | 36 | BYTE padding[16]; /* Some apps access beyond the end of the cmd line */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 37 | } PDB16; |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 38 | |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 39 | |
Alexandre Julliard | 594997c | 1995-04-30 10:05:20 +0000 | [diff] [blame] | 40 | /* Segment containing MakeProcInstance() thunks */ |
| 41 | typedef struct |
| 42 | { |
| 43 | WORD next; /* Selector of next segment */ |
| 44 | WORD magic; /* Thunks signature */ |
| 45 | WORD unused; |
| 46 | WORD free; /* Head of the free list */ |
| 47 | WORD thunks[4]; /* Each thunk is 4 words long */ |
| 48 | } THUNKS; |
| 49 | |
| 50 | #define THUNK_MAGIC ('P' | ('T' << 8)) |
| 51 | |
Alexandre Julliard | 0a860a0 | 1999-06-22 11:43:42 +0000 | [diff] [blame] | 52 | struct _TEB; |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 53 | struct _WSINFO; |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 54 | struct _NE_MODULE; |
Alexandre Julliard | 594997c | 1995-04-30 10:05:20 +0000 | [diff] [blame] | 55 | |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 56 | /* signal proc typedef */ |
Francois Gouget | ae41e8c | 2000-06-11 20:07:58 +0000 | [diff] [blame] | 57 | typedef void CALLBACK (*USERSIGNALPROC)(HANDLE16, UINT16, UINT16, |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 58 | HINSTANCE16, HQUEUE16); |
| 59 | |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 60 | /* Task database. See 'Windows Internals' p. 226. |
| 61 | * Note that 16-bit OLE 2 libs like to read it directly |
| 62 | * so we have to keep entry offsets as they are. |
| 63 | */ |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 64 | typedef struct _TDB |
Alexandre Julliard | 594997c | 1995-04-30 10:05:20 +0000 | [diff] [blame] | 65 | { |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 66 | HTASK16 hNext; /* 00 Selector of next TDB */ |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 67 | DWORD ss_sp WINE_PACKED; /* 02 Stack pointer of task */ |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 68 | WORD nEvents; /* 06 Events for this task */ |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 69 | INT16 priority; /* 08 Task priority, -32..15 */ |
| 70 | WORD unused1; /* 0a */ |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 71 | HTASK16 hSelf; /* 0c Selector of this TDB */ |
| 72 | HANDLE16 hPrevInstance; /* 0e Previous instance of module */ |
Alexandre Julliard | 3db94ef | 1997-09-28 17:43:24 +0000 | [diff] [blame] | 73 | DWORD unused2; /* 10 */ |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 74 | WORD ctrlword8087; /* 14 80x87 control word */ |
| 75 | WORD flags; /* 16 Task flags */ |
| 76 | UINT16 error_mode; /* 18 Error mode (see SetErrorMode)*/ |
| 77 | WORD version; /* 1a Expected Windows version */ |
| 78 | HANDLE16 hInstance; /* 1c Instance handle for task */ |
| 79 | HMODULE16 hModule; /* 1e Module handle */ |
| 80 | HQUEUE16 hQueue; /* 20 Selector of task queue */ |
| 81 | HTASK16 hParent; /* 22 Selector of TDB of parent */ |
| 82 | WORD signal_flags; /* 24 Flags for signal handler */ |
Alexandre Julliard | f1aa303 | 1996-08-05 17:42:43 +0000 | [diff] [blame] | 83 | FARPROC16 sighandler WINE_PACKED; /* 26 Signal handler */ |
Ulrich Weigand | c44ab1f | 1999-09-20 18:48:29 +0000 | [diff] [blame] | 84 | FARPROC16 userhandler WINE_PACKED; /* 2a USER signal handler */ |
Alexandre Julliard | bf9130a | 1996-10-13 17:45:47 +0000 | [diff] [blame] | 85 | FARPROC16 discardhandler WINE_PACKED; /* 2e Handler for GlobalNotify() */ |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 86 | DWORD int0 WINE_PACKED; /* 32 int 0 (divide by 0) handler */ |
| 87 | DWORD int2 WINE_PACKED; /* 36 int 2 (NMI) handler */ |
| 88 | DWORD int4 WINE_PACKED; /* 3a int 4 (INTO) handler */ |
| 89 | DWORD int6 WINE_PACKED; /* 3e int 6 (invalid opc) handler */ |
| 90 | DWORD int7 WINE_PACKED; /* 42 int 7 (coprocessor) handler */ |
| 91 | DWORD int3e WINE_PACKED; /* 46 int 3e (80x87 emu) handler */ |
| 92 | DWORD int75 WINE_PACKED; /* 4a int 75 (80x87 error) handler */ |
| 93 | DWORD compat_flags WINE_PACKED; /* 4e Compatibility flags */ |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 94 | BYTE unused4[2]; /* 52 */ |
Alexandre Julliard | 0a860a0 | 1999-06-22 11:43:42 +0000 | [diff] [blame] | 95 | struct _TEB *teb; /* 54 Pointer to thread database */ |
Ove Kaaven | f45608f | 1999-10-23 16:53:34 +0000 | [diff] [blame] | 96 | BYTE unused5[8]; /* 58 */ |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 97 | HANDLE16 hPDB; /* 60 Selector of PDB (i.e. PSP) */ |
| 98 | SEGPTR dta WINE_PACKED; /* 62 Current DTA */ |
| 99 | BYTE curdrive; /* 66 Current drive */ |
| 100 | BYTE curdir[65]; /* 67 Current directory */ |
| 101 | WORD nCmdShow; /* a8 cmdShow parameter to WinMain */ |
| 102 | HTASK16 hYieldTo; /* aa Next task to schedule */ |
| 103 | DWORD dlls_to_init; /* ac Ptr to DLLs to initialize */ |
| 104 | HANDLE16 hCSAlias; /* b0 Code segment for this TDB */ |
| 105 | THUNKS thunks WINE_PACKED; /* b2 Make proc instance thunks */ |
| 106 | WORD more_thunks[6*4]; /* c2 Space for 6 more thunks */ |
| 107 | BYTE module_name[8]; /* f2 Module name for task */ |
| 108 | WORD magic; /* fa TDB signature */ |
Ulrich Weigand | ed49003 | 1999-06-06 14:47:50 +0000 | [diff] [blame] | 109 | HANDLE hEvent; /* fc scheduler event handle */ |
| 110 | PDB16 pdb; /* 100 PDB for this task */ |
Alexandre Julliard | 594997c | 1995-04-30 10:05:20 +0000 | [diff] [blame] | 111 | } TDB; |
| 112 | |
| 113 | #define TDB_MAGIC ('T' | ('D' << 8)) |
| 114 | |
| 115 | /* TDB flags */ |
| 116 | #define TDBF_WINOLDAP 0x0001 |
| 117 | #define TDBF_OS2APP 0x0008 |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 118 | #define TDBF_WIN32 0x0010 |
Alexandre Julliard | 594997c | 1995-04-30 10:05:20 +0000 | [diff] [blame] | 119 | |
Ulrich Weigand | e392a0c | 1999-04-01 11:44:52 +0000 | [diff] [blame] | 120 | /* Windows 3.1 USER signals */ |
| 121 | #define USIG16_TERMINATION 0x0020 |
| 122 | #define USIG16_DLL_LOAD 0x0040 |
| 123 | #define USIG16_DLL_UNLOAD 0x0080 |
| 124 | #define USIG16_GPF 0x0666 |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 125 | |
Alexandre Julliard | 642d313 | 1998-07-12 19:29:36 +0000 | [diff] [blame] | 126 | |
| 127 | /* THHOOK Kernel Data Structure */ |
| 128 | typedef struct _THHOOK |
| 129 | { |
| 130 | HANDLE16 hGlobalHeap; /* 00 (handle BURGERMASTER) */ |
| 131 | WORD pGlobalHeap; /* 02 (selector BURGERMASTER) */ |
| 132 | HMODULE16 hExeHead; /* 04 hFirstModule */ |
| 133 | HMODULE16 hExeSweep; /* 06 (unused) */ |
| 134 | HANDLE16 TopPDB; /* 08 (handle of KERNEL PDB) */ |
| 135 | HANDLE16 HeadPDB; /* 0A (first PDB in list) */ |
| 136 | HANDLE16 TopSizePDB; /* 0C (unused) */ |
| 137 | HTASK16 HeadTDB; /* 0E hFirstTask */ |
| 138 | HTASK16 CurTDB; /* 10 hCurrentTask */ |
| 139 | HTASK16 LoadTDB; /* 12 (unused) */ |
| 140 | HTASK16 LockTDB; /* 14 hLockedTask */ |
| 141 | } THHOOK; |
| 142 | |
Patrik Stridvall | c7a8dde | 1999-04-25 12:36:53 +0000 | [diff] [blame] | 143 | #include "poppack.h" |
Alexandre Julliard | 594997c | 1995-04-30 10:05:20 +0000 | [diff] [blame] | 144 | |
Alexandre Julliard | 642d313 | 1998-07-12 19:29:36 +0000 | [diff] [blame] | 145 | extern THHOOK *pThhook; |
| 146 | |
Alexandre Julliard | c192ba2 | 2000-05-29 21:25:10 +0000 | [diff] [blame] | 147 | extern BOOL TASK_Create( struct _NE_MODULE *pModule, UINT16 cmdShow, |
| 148 | struct _TEB *teb, LPCSTR cmdline, BYTE len ); |
Ulrich Weigand | 93b23d7 | 1999-03-22 10:35:44 +0000 | [diff] [blame] | 149 | extern void TASK_KillTask( HTASK16 hTask ); |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 150 | extern HTASK16 TASK_GetNextTask( HTASK16 hTask ); |
Ulrich Weigand | ed49003 | 1999-06-06 14:47:50 +0000 | [diff] [blame] | 151 | extern void TASK_Reschedule(void); |
Alexandre Julliard | 642d313 | 1998-07-12 19:29:36 +0000 | [diff] [blame] | 152 | extern void TASK_InstallTHHook( THHOOK *pNewThook ); |
Ulrich Weigand | c44ab1f | 1999-09-20 18:48:29 +0000 | [diff] [blame] | 153 | extern void TASK_CallTaskSignalProc( UINT16 uCode, HANDLE16 hTaskOrModule ); |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 154 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 155 | extern HQUEUE16 WINAPI SetThreadQueue16( DWORD thread, HQUEUE16 hQueue ); |
| 156 | extern HQUEUE16 WINAPI GetThreadQueue16( DWORD thread ); |
| 157 | extern VOID WINAPI SetFastQueue16( DWORD thread, HANDLE hQueue ); |
| 158 | extern HANDLE WINAPI GetFastQueue16( void ); |
Ulrich Weigand | 89b93bf | 1998-12-24 15:15:00 +0000 | [diff] [blame] | 159 | |
| 160 | |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 161 | #endif /* __WINE_TASK_H */ |