blob: a4fc2007282fad9bbb6663559a372f814ab005c8 [file] [log] [blame]
Alexandre Julliard58199531994-04-21 01:20:00 +00001/*
2 * Task definitions
Alexandre Julliard594997c1995-04-30 10:05:20 +00003 *
4 * Copyright 1995 Alexandre Julliard
Alexandre Julliard0799c1a2002-03-09 23:29:33 +00005 *
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
Alexandre Julliard58199531994-04-21 01:20:00 +000019 */
20
Alexandre Julliardc6c09441997-01-12 18:32:19 +000021#ifndef __WINE_TASK_H
22#define __WINE_TASK_H
Alexandre Julliard58199531994-04-21 01:20:00 +000023
Jim Aston2e1cafa1999-03-14 16:35:05 +000024#include "windef.h"
Alexandre Julliard83f52d12000-09-26 22:20:14 +000025#include "wine/windef16.h"
Alexandre Julliard7cc9c0c1994-06-15 15:45:11 +000026
Patrik Stridvallc7a8dde1999-04-25 12:36:53 +000027#include "pshpack1.h"
Alexandre Julliard58199531994-04-21 01:20:00 +000028
Alexandre Julliard594997c1995-04-30 10:05:20 +000029 /* Process database (i.e. a normal DOS PSP) */
Alexandre Julliard58199531994-04-21 01:20:00 +000030
Alexandre Julliard594997c1995-04-30 10:05:20 +000031typedef struct
32{
Alexandre Julliardca22b331996-07-12 19:02:39 +000033 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 */
Ove Kaaven7c4bee52000-10-17 00:33:02 +000043 DWORD saveStack; /* 2e SS:SP on last int21 call */
Alexandre Julliardca22b331996-07-12 19:02:39 +000044 WORD nbFiles; /* 32 Number of file handles */
45 SEGPTR fileHandlesPtr; /* 34 Pointer to file handle table */
Alexandre Julliardc6c09441997-01-12 18:32:19 +000046 HANDLE16 hFileHandles; /* 38 Handle to fileHandlesPtr */
47 WORD reserved3[17];
Alexandre Julliardca22b331996-07-12 19:02:39 +000048 BYTE fcb1[16]; /* 5c First FCB */
49 BYTE fcb2[20]; /* 6c Second FCB */
50 BYTE cmdLine[128]; /* 80 Command-line (first byte is len)*/
Alexandre Julliard3bf623d1998-10-25 10:20:31 +000051 BYTE padding[16]; /* Some apps access beyond the end of the cmd line */
Alexandre Julliarda3960291999-02-26 11:11:13 +000052} PDB16;
Alexandre Julliard58199531994-04-21 01:20:00 +000053
Alexandre Julliard58199531994-04-21 01:20:00 +000054
Alexandre Julliard594997c1995-04-30 10:05:20 +000055 /* Segment containing MakeProcInstance() thunks */
56typedef struct
57{
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;
64
65#define THUNK_MAGIC ('P' | ('T' << 8))
66
Alexandre Julliard0a860a01999-06-22 11:43:42 +000067struct _TEB;
Alexandre Julliard670cdc41997-08-24 16:00:30 +000068struct _WSINFO;
Alexandre Julliardc7c217b1998-04-13 12:21:30 +000069struct _NE_MODULE;
Alexandre Julliard594997c1995-04-30 10:05:20 +000070
Alexandre Julliard77b99181997-09-14 17:17:23 +000071 /* signal proc typedef */
Patrik Stridvallf94462f2002-01-31 23:22:07 +000072typedef void (CALLBACK *USERSIGNALPROC)(HANDLE16, UINT16, UINT16,
Alexandre Julliard77b99181997-09-14 17:17:23 +000073 HINSTANCE16, HQUEUE16);
74
Alexandre Julliard670cdc41997-08-24 16:00:30 +000075 /* Task database. See 'Windows Internals' p. 226.
Vincent Béron9a624912002-05-31 23:06:46 +000076 * Note that 16-bit OLE 2 libs like to read it directly
77 * so we have to keep entry offsets as they are.
Alexandre Julliard670cdc41997-08-24 16:00:30 +000078 */
Alexandre Julliard77b99181997-09-14 17:17:23 +000079typedef struct _TDB
Alexandre Julliard594997c1995-04-30 10:05:20 +000080{
Alexandre Julliard18f92e71996-07-17 20:02:21 +000081 HTASK16 hNext; /* 00 Selector of next TDB */
Alexandre Julliardd37eb361997-07-20 16:23:21 +000082 DWORD ss_sp WINE_PACKED; /* 02 Stack pointer of task */
Alexandre Julliard18f92e71996-07-17 20:02:21 +000083 WORD nEvents; /* 06 Events for this task */
Alexandre Julliard9ea19e51997-01-01 17:29:55 +000084 INT16 priority; /* 08 Task priority, -32..15 */
85 WORD unused1; /* 0a */
Alexandre Julliard18f92e71996-07-17 20:02:21 +000086 HTASK16 hSelf; /* 0c Selector of this TDB */
87 HANDLE16 hPrevInstance; /* 0e Previous instance of module */
Alexandre Julliard3db94ef1997-09-28 17:43:24 +000088 DWORD unused2; /* 10 */
Alexandre Julliard18f92e71996-07-17 20:02:21 +000089 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 */
Alexandre Julliardf1aa3031996-08-05 17:42:43 +000098 FARPROC16 sighandler WINE_PACKED; /* 26 Signal handler */
Ulrich Weigandc44ab1f1999-09-20 18:48:29 +000099 FARPROC16 userhandler WINE_PACKED; /* 2a USER signal handler */
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000100 FARPROC16 discardhandler WINE_PACKED; /* 2e Handler for GlobalNotify() */
Alexandre Julliard18f92e71996-07-17 20:02:21 +0000101 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 */
Alexandre Julliard9ea19e51997-01-01 17:29:55 +0000109 BYTE unused4[2]; /* 52 */
Alexandre Julliard0a860a01999-06-22 11:43:42 +0000110 struct _TEB *teb; /* 54 Pointer to thread database */
Ove Kaavenf45608f1999-10-23 16:53:34 +0000111 BYTE unused5[8]; /* 58 */
Alexandre Julliard18f92e71996-07-17 20:02:21 +0000112 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 */
Ulrich Weiganded490031999-06-06 14:47:50 +0000124 HANDLE hEvent; /* fc scheduler event handle */
125 PDB16 pdb; /* 100 PDB for this task */
Alexandre Julliard594997c1995-04-30 10:05:20 +0000126} TDB;
127
128#define TDB_MAGIC ('T' | ('D' << 8))
129
130 /* TDB flags */
131#define TDBF_WINOLDAP 0x0001
132#define TDBF_OS2APP 0x0008
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000133#define TDBF_WIN32 0x0010
Alexandre Julliard594997c1995-04-30 10:05:20 +0000134
Ulrich Weigande392a0c1999-04-01 11:44:52 +0000135 /* 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
Alexandre Julliard77b99181997-09-14 17:17:23 +0000140
Alexandre Julliard642d3131998-07-12 19:29:36 +0000141
142 /* THHOOK Kernel Data Structure */
143typedef struct _THHOOK
144{
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;
157
Patrik Stridvallc7a8dde1999-04-25 12:36:53 +0000158#include "poppack.h"
Alexandre Julliard594997c1995-04-30 10:05:20 +0000159
Alexandre Julliard642d3131998-07-12 19:29:36 +0000160extern THHOOK *pThhook;
161
Alexandre Julliard9ee9eff2001-02-28 05:29:50 +0000162extern void TASK_CreateMainTask(void);
Alexandre Julliard7c4b1402001-07-30 19:01:01 +0000163extern HTASK16 TASK_SpawnTask( struct _NE_MODULE *pModule, WORD cmdShow,
164 LPCSTR cmdline, BYTE len, HANDLE *hThread );
Alexandre Julliard4e951ea2000-11-08 22:47:53 +0000165extern void TASK_ExitTask(void);
Alexandre Julliard9ea19e51997-01-01 17:29:55 +0000166extern HTASK16 TASK_GetNextTask( HTASK16 hTask );
Alexandre Julliard3e7497f2001-04-04 00:19:55 +0000167extern TDB *TASK_GetPtr( HTASK16 hTask );
168extern TDB *TASK_GetCurrent(void);
Alexandre Julliard642d3131998-07-12 19:29:36 +0000169extern void TASK_InstallTHHook( THHOOK *pNewThook );
Ulrich Weigandc44ab1f1999-09-20 18:48:29 +0000170extern void TASK_CallTaskSignalProc( UINT16 uCode, HANDLE16 hTaskOrModule );
Alexandre Julliard2787be81995-05-22 18:23:01 +0000171
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000172#endif /* __WINE_TASK_H */