blob: 81ac6eace716b1fe85e9edfda38ef461b782dde6 [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 Julliard58199531994-04-21 01:20:00 +00005 */
6
Alexandre Julliardc6c09441997-01-12 18:32:19 +00007#ifndef __WINE_TASK_H
8#define __WINE_TASK_H
Alexandre Julliard58199531994-04-21 01:20:00 +00009
Jim Aston2e1cafa1999-03-14 16:35:05 +000010#include "windef.h"
Alexandre Julliard83f52d12000-09-26 22:20:14 +000011#include "wine/windef16.h"
Alexandre Julliard7cc9c0c1994-06-15 15:45:11 +000012
Patrik Stridvallc7a8dde1999-04-25 12:36:53 +000013#include "pshpack1.h"
Alexandre Julliard58199531994-04-21 01:20:00 +000014
Alexandre Julliard594997c1995-04-30 10:05:20 +000015 /* Process database (i.e. a normal DOS PSP) */
Alexandre Julliard58199531994-04-21 01:20:00 +000016
Alexandre Julliard594997c1995-04-30 10:05:20 +000017typedef struct
18{
Alexandre Julliardca22b331996-07-12 19:02:39 +000019 WORD int20; /* 00 int 20h instruction */
20 WORD nextParagraph; /* 02 Segment of next paragraph */
21 BYTE reserved1;
22 BYTE dispatcher[5]; /* 05 Long call to DOS */
23 FARPROC16 savedint22 WINE_PACKED; /* 0a Saved int 22h handler */
24 FARPROC16 savedint23 WINE_PACKED; /* 0e Saved int 23h handler */
25 FARPROC16 savedint24 WINE_PACKED; /* 12 Saved int 24h handler */
26 WORD parentPSP; /* 16 Selector of parent PSP */
27 BYTE fileHandles[20]; /* 18 Open file handles */
28 HANDLE16 environment; /* 2c Selector of environment */
Ove Kaaven7c4bee52000-10-17 00:33:02 +000029 DWORD saveStack; /* 2e SS:SP on last int21 call */
Alexandre Julliardca22b331996-07-12 19:02:39 +000030 WORD nbFiles; /* 32 Number of file handles */
31 SEGPTR fileHandlesPtr; /* 34 Pointer to file handle table */
Alexandre Julliardc6c09441997-01-12 18:32:19 +000032 HANDLE16 hFileHandles; /* 38 Handle to fileHandlesPtr */
33 WORD reserved3[17];
Alexandre Julliardca22b331996-07-12 19:02:39 +000034 BYTE fcb1[16]; /* 5c First FCB */
35 BYTE fcb2[20]; /* 6c Second FCB */
36 BYTE cmdLine[128]; /* 80 Command-line (first byte is len)*/
Alexandre Julliard3bf623d1998-10-25 10:20:31 +000037 BYTE padding[16]; /* Some apps access beyond the end of the cmd line */
Alexandre Julliarda3960291999-02-26 11:11:13 +000038} PDB16;
Alexandre Julliard58199531994-04-21 01:20:00 +000039
Alexandre Julliard58199531994-04-21 01:20:00 +000040
Alexandre Julliard594997c1995-04-30 10:05:20 +000041 /* Segment containing MakeProcInstance() thunks */
42typedef struct
43{
44 WORD next; /* Selector of next segment */
45 WORD magic; /* Thunks signature */
46 WORD unused;
47 WORD free; /* Head of the free list */
48 WORD thunks[4]; /* Each thunk is 4 words long */
49} THUNKS;
50
51#define THUNK_MAGIC ('P' | ('T' << 8))
52
Alexandre Julliard0a860a01999-06-22 11:43:42 +000053struct _TEB;
Alexandre Julliard670cdc41997-08-24 16:00:30 +000054struct _WSINFO;
Alexandre Julliardc7c217b1998-04-13 12:21:30 +000055struct _NE_MODULE;
Alexandre Julliard594997c1995-04-30 10:05:20 +000056
Alexandre Julliard77b99181997-09-14 17:17:23 +000057 /* signal proc typedef */
Francois Gougetae41e8c2000-06-11 20:07:58 +000058typedef void CALLBACK (*USERSIGNALPROC)(HANDLE16, UINT16, UINT16,
Alexandre Julliard77b99181997-09-14 17:17:23 +000059 HINSTANCE16, HQUEUE16);
60
Alexandre Julliard670cdc41997-08-24 16:00:30 +000061 /* Task database. See 'Windows Internals' p. 226.
62 * Note that 16-bit OLE 2 libs like to read it directly
63 * so we have to keep entry offsets as they are.
64 */
Alexandre Julliard77b99181997-09-14 17:17:23 +000065typedef struct _TDB
Alexandre Julliard594997c1995-04-30 10:05:20 +000066{
Alexandre Julliard18f92e71996-07-17 20:02:21 +000067 HTASK16 hNext; /* 00 Selector of next TDB */
Alexandre Julliardd37eb361997-07-20 16:23:21 +000068 DWORD ss_sp WINE_PACKED; /* 02 Stack pointer of task */
Alexandre Julliard18f92e71996-07-17 20:02:21 +000069 WORD nEvents; /* 06 Events for this task */
Alexandre Julliard9ea19e51997-01-01 17:29:55 +000070 INT16 priority; /* 08 Task priority, -32..15 */
71 WORD unused1; /* 0a */
Alexandre Julliard18f92e71996-07-17 20:02:21 +000072 HTASK16 hSelf; /* 0c Selector of this TDB */
73 HANDLE16 hPrevInstance; /* 0e Previous instance of module */
Alexandre Julliard3db94ef1997-09-28 17:43:24 +000074 DWORD unused2; /* 10 */
Alexandre Julliard18f92e71996-07-17 20:02:21 +000075 WORD ctrlword8087; /* 14 80x87 control word */
76 WORD flags; /* 16 Task flags */
77 UINT16 error_mode; /* 18 Error mode (see SetErrorMode)*/
78 WORD version; /* 1a Expected Windows version */
79 HANDLE16 hInstance; /* 1c Instance handle for task */
80 HMODULE16 hModule; /* 1e Module handle */
81 HQUEUE16 hQueue; /* 20 Selector of task queue */
82 HTASK16 hParent; /* 22 Selector of TDB of parent */
83 WORD signal_flags; /* 24 Flags for signal handler */
Alexandre Julliardf1aa3031996-08-05 17:42:43 +000084 FARPROC16 sighandler WINE_PACKED; /* 26 Signal handler */
Ulrich Weigandc44ab1f1999-09-20 18:48:29 +000085 FARPROC16 userhandler WINE_PACKED; /* 2a USER signal handler */
Alexandre Julliardbf9130a1996-10-13 17:45:47 +000086 FARPROC16 discardhandler WINE_PACKED; /* 2e Handler for GlobalNotify() */
Alexandre Julliard18f92e71996-07-17 20:02:21 +000087 DWORD int0 WINE_PACKED; /* 32 int 0 (divide by 0) handler */
88 DWORD int2 WINE_PACKED; /* 36 int 2 (NMI) handler */
89 DWORD int4 WINE_PACKED; /* 3a int 4 (INTO) handler */
90 DWORD int6 WINE_PACKED; /* 3e int 6 (invalid opc) handler */
91 DWORD int7 WINE_PACKED; /* 42 int 7 (coprocessor) handler */
92 DWORD int3e WINE_PACKED; /* 46 int 3e (80x87 emu) handler */
93 DWORD int75 WINE_PACKED; /* 4a int 75 (80x87 error) handler */
94 DWORD compat_flags WINE_PACKED; /* 4e Compatibility flags */
Alexandre Julliard9ea19e51997-01-01 17:29:55 +000095 BYTE unused4[2]; /* 52 */
Alexandre Julliard0a860a01999-06-22 11:43:42 +000096 struct _TEB *teb; /* 54 Pointer to thread database */
Ove Kaavenf45608f1999-10-23 16:53:34 +000097 BYTE unused5[8]; /* 58 */
Alexandre Julliard18f92e71996-07-17 20:02:21 +000098 HANDLE16 hPDB; /* 60 Selector of PDB (i.e. PSP) */
99 SEGPTR dta WINE_PACKED; /* 62 Current DTA */
100 BYTE curdrive; /* 66 Current drive */
101 BYTE curdir[65]; /* 67 Current directory */
102 WORD nCmdShow; /* a8 cmdShow parameter to WinMain */
103 HTASK16 hYieldTo; /* aa Next task to schedule */
104 DWORD dlls_to_init; /* ac Ptr to DLLs to initialize */
105 HANDLE16 hCSAlias; /* b0 Code segment for this TDB */
106 THUNKS thunks WINE_PACKED; /* b2 Make proc instance thunks */
107 WORD more_thunks[6*4]; /* c2 Space for 6 more thunks */
108 BYTE module_name[8]; /* f2 Module name for task */
109 WORD magic; /* fa TDB signature */
Ulrich Weiganded490031999-06-06 14:47:50 +0000110 HANDLE hEvent; /* fc scheduler event handle */
111 PDB16 pdb; /* 100 PDB for this task */
Alexandre Julliard594997c1995-04-30 10:05:20 +0000112} TDB;
113
114#define TDB_MAGIC ('T' | ('D' << 8))
115
116 /* TDB flags */
117#define TDBF_WINOLDAP 0x0001
118#define TDBF_OS2APP 0x0008
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000119#define TDBF_WIN32 0x0010
Alexandre Julliard594997c1995-04-30 10:05:20 +0000120
Ulrich Weigande392a0c1999-04-01 11:44:52 +0000121 /* Windows 3.1 USER signals */
122#define USIG16_TERMINATION 0x0020
123#define USIG16_DLL_LOAD 0x0040
124#define USIG16_DLL_UNLOAD 0x0080
125#define USIG16_GPF 0x0666
Alexandre Julliard77b99181997-09-14 17:17:23 +0000126
Alexandre Julliard642d3131998-07-12 19:29:36 +0000127
128 /* THHOOK Kernel Data Structure */
129typedef struct _THHOOK
130{
131 HANDLE16 hGlobalHeap; /* 00 (handle BURGERMASTER) */
132 WORD pGlobalHeap; /* 02 (selector BURGERMASTER) */
133 HMODULE16 hExeHead; /* 04 hFirstModule */
134 HMODULE16 hExeSweep; /* 06 (unused) */
135 HANDLE16 TopPDB; /* 08 (handle of KERNEL PDB) */
136 HANDLE16 HeadPDB; /* 0A (first PDB in list) */
137 HANDLE16 TopSizePDB; /* 0C (unused) */
138 HTASK16 HeadTDB; /* 0E hFirstTask */
139 HTASK16 CurTDB; /* 10 hCurrentTask */
140 HTASK16 LoadTDB; /* 12 (unused) */
141 HTASK16 LockTDB; /* 14 hLockedTask */
142} THHOOK;
143
Patrik Stridvallc7a8dde1999-04-25 12:36:53 +0000144#include "poppack.h"
Alexandre Julliard594997c1995-04-30 10:05:20 +0000145
Alexandre Julliard642d3131998-07-12 19:29:36 +0000146extern THHOOK *pThhook;
147
Alexandre Julliard9ee9eff2001-02-28 05:29:50 +0000148extern void TASK_CreateMainTask(void);
Alexandre Julliard7c4b1402001-07-30 19:01:01 +0000149extern HTASK16 TASK_SpawnTask( struct _NE_MODULE *pModule, WORD cmdShow,
150 LPCSTR cmdline, BYTE len, HANDLE *hThread );
Alexandre Julliard4e951ea2000-11-08 22:47:53 +0000151extern void TASK_ExitTask(void);
Alexandre Julliard9ea19e51997-01-01 17:29:55 +0000152extern HTASK16 TASK_GetNextTask( HTASK16 hTask );
Alexandre Julliard3e7497f2001-04-04 00:19:55 +0000153extern TDB *TASK_GetPtr( HTASK16 hTask );
154extern TDB *TASK_GetCurrent(void);
Alexandre Julliard642d3131998-07-12 19:29:36 +0000155extern void TASK_InstallTHHook( THHOOK *pNewThook );
Ulrich Weigandc44ab1f1999-09-20 18:48:29 +0000156extern void TASK_CallTaskSignalProc( UINT16 uCode, HANDLE16 hTaskOrModule );
Alexandre Julliard2787be81995-05-22 18:23:01 +0000157
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000158#endif /* __WINE_TASK_H */