Removed reference to 'systemname' and added a link to winsite in
[wine/hacks.git] / include / task.h
blob67b80d31f681cbbd872bb7a890177f7e6767c579
1 /*
2 * Task definitions
4 * Copyright 1995 Alexandre Julliard
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.
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.
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
21 #ifndef __WINE_TASK_H
22 #define __WINE_TASK_H
24 #include <windef.h>
25 #include <wine/windef16.h>
27 #include <pshpack1.h>
29 /* Process database (i.e. a normal DOS PSP) */
31 typedef struct
33 WORD int20; /* 00 int 20h instruction */
34 WORD nextParagraph; /* 02 Segment of next paragraph */
35 BYTE reserved1;
36 BYTE dispatcher[5]; /* 05 Long call to DOS */
37 FARPROC16 savedint22 WINE_PACKED; /* 0a Saved int 22h handler */
38 FARPROC16 savedint23 WINE_PACKED; /* 0e Saved int 23h handler */
39 FARPROC16 savedint24 WINE_PACKED; /* 12 Saved int 24h handler */
40 WORD parentPSP; /* 16 Selector of parent PSP */
41 BYTE fileHandles[20]; /* 18 Open file handles */
42 HANDLE16 environment; /* 2c Selector of environment */
43 DWORD saveStack; /* 2e SS:SP on last int21 call */
44 WORD nbFiles; /* 32 Number of file handles */
45 SEGPTR fileHandlesPtr; /* 34 Pointer to file handle table */
46 HANDLE16 hFileHandles; /* 38 Handle to fileHandlesPtr */
47 WORD reserved3[17];
48 BYTE fcb1[16]; /* 5c First FCB */
49 BYTE fcb2[20]; /* 6c Second FCB */
50 BYTE cmdLine[128]; /* 80 Command-line (first byte is len)*/
51 BYTE padding[16]; /* Some apps access beyond the end of the cmd line */
52 } PDB16;
55 /* Segment containing MakeProcInstance() thunks */
56 typedef struct
58 WORD next; /* Selector of next segment */
59 WORD magic; /* Thunks signature */
60 WORD unused;
61 WORD free; /* Head of the free list */
62 WORD thunks[4]; /* Each thunk is 4 words long */
63 } THUNKS;
65 #define THUNK_MAGIC ('P' | ('T' << 8))
67 struct _TEB;
68 struct _WSINFO;
69 struct _NE_MODULE;
71 /* signal proc typedef */
72 typedef void (CALLBACK *USERSIGNALPROC)(HANDLE16, UINT16, UINT16,
73 HINSTANCE16, HQUEUE16);
75 /* Task database. See 'Windows Internals' p. 226.
76 * Note that 16-bit OLE 2 libs like to read it directly
77 * so we have to keep entry offsets as they are.
79 typedef struct _TDB
81 HTASK16 hNext; /* 00 Selector of next TDB */
82 DWORD ss_sp WINE_PACKED; /* 02 Stack pointer of task */
83 WORD nEvents; /* 06 Events for this task */
84 INT16 priority; /* 08 Task priority, -32..15 */
85 WORD unused1; /* 0a */
86 HTASK16 hSelf; /* 0c Selector of this TDB */
87 HANDLE16 hPrevInstance; /* 0e Previous instance of module */
88 DWORD unused2; /* 10 */
89 WORD ctrlword8087; /* 14 80x87 control word */
90 WORD flags; /* 16 Task flags */
91 UINT16 error_mode; /* 18 Error mode (see SetErrorMode)*/
92 WORD version; /* 1a Expected Windows version */
93 HANDLE16 hInstance; /* 1c Instance handle for task */
94 HMODULE16 hModule; /* 1e Module handle */
95 HQUEUE16 hQueue; /* 20 Selector of task queue */
96 HTASK16 hParent; /* 22 Selector of TDB of parent */
97 WORD signal_flags; /* 24 Flags for signal handler */
98 FARPROC16 sighandler WINE_PACKED; /* 26 Signal handler */
99 FARPROC16 userhandler WINE_PACKED; /* 2a USER signal handler */
100 FARPROC16 discardhandler WINE_PACKED; /* 2e Handler for GlobalNotify() */
101 DWORD int0 WINE_PACKED; /* 32 int 0 (divide by 0) handler */
102 DWORD int2 WINE_PACKED; /* 36 int 2 (NMI) handler */
103 DWORD int4 WINE_PACKED; /* 3a int 4 (INTO) handler */
104 DWORD int6 WINE_PACKED; /* 3e int 6 (invalid opc) handler */
105 DWORD int7 WINE_PACKED; /* 42 int 7 (coprocessor) handler */
106 DWORD int3e WINE_PACKED; /* 46 int 3e (80x87 emu) handler */
107 DWORD int75 WINE_PACKED; /* 4a int 75 (80x87 error) handler */
108 DWORD compat_flags WINE_PACKED; /* 4e Compatibility flags */
109 BYTE unused4[2]; /* 52 */
110 struct _TEB *teb; /* 54 Pointer to thread database */
111 BYTE unused5[8]; /* 58 */
112 HANDLE16 hPDB; /* 60 Selector of PDB (i.e. PSP) */
113 SEGPTR dta WINE_PACKED; /* 62 Current DTA */
114 BYTE curdrive; /* 66 Current drive */
115 BYTE curdir[65]; /* 67 Current directory */
116 WORD nCmdShow; /* a8 cmdShow parameter to WinMain */
117 HTASK16 hYieldTo; /* aa Next task to schedule */
118 DWORD dlls_to_init; /* ac Ptr to DLLs to initialize */
119 HANDLE16 hCSAlias; /* b0 Code segment for this TDB */
120 THUNKS thunks WINE_PACKED; /* b2 Make proc instance thunks */
121 WORD more_thunks[6*4]; /* c2 Space for 6 more thunks */
122 BYTE module_name[8]; /* f2 Module name for task */
123 WORD magic; /* fa TDB signature */
124 HANDLE hEvent; /* fc scheduler event handle */
125 PDB16 pdb; /* 100 PDB for this task */
126 } TDB;
128 #define TDB_MAGIC ('T' | ('D' << 8))
130 /* TDB flags */
131 #define TDBF_WINOLDAP 0x0001
132 #define TDBF_OS2APP 0x0008
133 #define TDBF_WIN32 0x0010
135 /* Windows 3.1 USER signals */
136 #define USIG16_TERMINATION 0x0020
137 #define USIG16_DLL_LOAD 0x0040
138 #define USIG16_DLL_UNLOAD 0x0080
139 #define USIG16_GPF 0x0666
142 /* THHOOK Kernel Data Structure */
143 typedef struct _THHOOK
145 HANDLE16 hGlobalHeap; /* 00 (handle BURGERMASTER) */
146 WORD pGlobalHeap; /* 02 (selector BURGERMASTER) */
147 HMODULE16 hExeHead; /* 04 hFirstModule */
148 HMODULE16 hExeSweep; /* 06 (unused) */
149 HANDLE16 TopPDB; /* 08 (handle of KERNEL PDB) */
150 HANDLE16 HeadPDB; /* 0A (first PDB in list) */
151 HANDLE16 TopSizePDB; /* 0C (unused) */
152 HTASK16 HeadTDB; /* 0E hFirstTask */
153 HTASK16 CurTDB; /* 10 hCurrentTask */
154 HTASK16 LoadTDB; /* 12 (unused) */
155 HTASK16 LockTDB; /* 14 hLockedTask */
156 } THHOOK;
158 #include <poppack.h>
160 extern THHOOK *pThhook;
162 extern void TASK_CreateMainTask(void);
163 extern HTASK16 TASK_SpawnTask( struct _NE_MODULE *pModule, WORD cmdShow,
164 LPCSTR cmdline, BYTE len, HANDLE *hThread );
165 extern void TASK_ExitTask(void);
166 extern HTASK16 TASK_GetTaskFromThread( DWORD thread );
167 extern TDB *TASK_GetCurrent(void);
168 extern void TASK_InstallTHHook( THHOOK *pNewThook );
170 #endif /* __WINE_TASK_H */