blob: 5635dacb967fef920965026460040f5f288e6315 [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 Julliard7cc9c0c1994-06-15 15:45:11 +000011
Patrik Stridvallc7a8dde1999-04-25 12:36:53 +000012#include "pshpack1.h"
Alexandre Julliard58199531994-04-21 01:20:00 +000013
Alexandre Julliard594997c1995-04-30 10:05:20 +000014 /* Process database (i.e. a normal DOS PSP) */
Alexandre Julliard58199531994-04-21 01:20:00 +000015
Alexandre Julliard594997c1995-04-30 10:05:20 +000016typedef struct
17{
Alexandre Julliardca22b331996-07-12 19:02:39 +000018 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 Julliardc6c09441997-01-12 18:32:19 +000031 HANDLE16 hFileHandles; /* 38 Handle to fileHandlesPtr */
32 WORD reserved3[17];
Alexandre Julliardca22b331996-07-12 19:02:39 +000033 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 Julliard3bf623d1998-10-25 10:20:31 +000036 BYTE padding[16]; /* Some apps access beyond the end of the cmd line */
Alexandre Julliarda3960291999-02-26 11:11:13 +000037} PDB16;
Alexandre Julliard58199531994-04-21 01:20:00 +000038
Alexandre Julliard58199531994-04-21 01:20:00 +000039
Alexandre Julliard594997c1995-04-30 10:05:20 +000040 /* Segment containing MakeProcInstance() thunks */
41typedef 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 Julliard0a860a01999-06-22 11:43:42 +000052struct _TEB;
Alexandre Julliard670cdc41997-08-24 16:00:30 +000053struct _WSINFO;
Alexandre Julliardc7c217b1998-04-13 12:21:30 +000054struct _NE_MODULE;
Alexandre Julliard594997c1995-04-30 10:05:20 +000055
Alexandre Julliard77b99181997-09-14 17:17:23 +000056 /* signal proc typedef */
Francois Gougetae41e8c2000-06-11 20:07:58 +000057typedef void CALLBACK (*USERSIGNALPROC)(HANDLE16, UINT16, UINT16,
Alexandre Julliard77b99181997-09-14 17:17:23 +000058 HINSTANCE16, HQUEUE16);
59
Alexandre Julliard670cdc41997-08-24 16:00:30 +000060 /* 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 Julliard77b99181997-09-14 17:17:23 +000064typedef struct _TDB
Alexandre Julliard594997c1995-04-30 10:05:20 +000065{
Alexandre Julliard18f92e71996-07-17 20:02:21 +000066 HTASK16 hNext; /* 00 Selector of next TDB */
Alexandre Julliardd37eb361997-07-20 16:23:21 +000067 DWORD ss_sp WINE_PACKED; /* 02 Stack pointer of task */
Alexandre Julliard18f92e71996-07-17 20:02:21 +000068 WORD nEvents; /* 06 Events for this task */
Alexandre Julliard9ea19e51997-01-01 17:29:55 +000069 INT16 priority; /* 08 Task priority, -32..15 */
70 WORD unused1; /* 0a */
Alexandre Julliard18f92e71996-07-17 20:02:21 +000071 HTASK16 hSelf; /* 0c Selector of this TDB */
72 HANDLE16 hPrevInstance; /* 0e Previous instance of module */
Alexandre Julliard3db94ef1997-09-28 17:43:24 +000073 DWORD unused2; /* 10 */
Alexandre Julliard18f92e71996-07-17 20:02:21 +000074 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 Julliardf1aa3031996-08-05 17:42:43 +000083 FARPROC16 sighandler WINE_PACKED; /* 26 Signal handler */
Ulrich Weigandc44ab1f1999-09-20 18:48:29 +000084 FARPROC16 userhandler WINE_PACKED; /* 2a USER signal handler */
Alexandre Julliardbf9130a1996-10-13 17:45:47 +000085 FARPROC16 discardhandler WINE_PACKED; /* 2e Handler for GlobalNotify() */
Alexandre Julliard18f92e71996-07-17 20:02:21 +000086 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 Julliard9ea19e51997-01-01 17:29:55 +000094 BYTE unused4[2]; /* 52 */
Alexandre Julliard0a860a01999-06-22 11:43:42 +000095 struct _TEB *teb; /* 54 Pointer to thread database */
Ove Kaavenf45608f1999-10-23 16:53:34 +000096 BYTE unused5[8]; /* 58 */
Alexandre Julliard18f92e71996-07-17 20:02:21 +000097 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 Weiganded490031999-06-06 14:47:50 +0000109 HANDLE hEvent; /* fc scheduler event handle */
110 PDB16 pdb; /* 100 PDB for this task */
Alexandre Julliard594997c1995-04-30 10:05:20 +0000111} TDB;
112
113#define TDB_MAGIC ('T' | ('D' << 8))
114
115 /* TDB flags */
116#define TDBF_WINOLDAP 0x0001
117#define TDBF_OS2APP 0x0008
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000118#define TDBF_WIN32 0x0010
Alexandre Julliard594997c1995-04-30 10:05:20 +0000119
Ulrich Weigande392a0c1999-04-01 11:44:52 +0000120 /* 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 Julliard77b99181997-09-14 17:17:23 +0000125
Alexandre Julliard642d3131998-07-12 19:29:36 +0000126
127 /* THHOOK Kernel Data Structure */
128typedef 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 Stridvallc7a8dde1999-04-25 12:36:53 +0000143#include "poppack.h"
Alexandre Julliard594997c1995-04-30 10:05:20 +0000144
Alexandre Julliard642d3131998-07-12 19:29:36 +0000145extern THHOOK *pThhook;
146
Alexandre Julliardc192ba22000-05-29 21:25:10 +0000147extern BOOL TASK_Create( struct _NE_MODULE *pModule, UINT16 cmdShow,
148 struct _TEB *teb, LPCSTR cmdline, BYTE len );
Ulrich Weigand93b23d71999-03-22 10:35:44 +0000149extern void TASK_KillTask( HTASK16 hTask );
Alexandre Julliard9ea19e51997-01-01 17:29:55 +0000150extern HTASK16 TASK_GetNextTask( HTASK16 hTask );
Ulrich Weiganded490031999-06-06 14:47:50 +0000151extern void TASK_Reschedule(void);
Alexandre Julliard642d3131998-07-12 19:29:36 +0000152extern void TASK_InstallTHHook( THHOOK *pNewThook );
Ulrich Weigandc44ab1f1999-09-20 18:48:29 +0000153extern void TASK_CallTaskSignalProc( UINT16 uCode, HANDLE16 hTaskOrModule );
Alexandre Julliard2787be81995-05-22 18:23:01 +0000154
Alexandre Julliarda3960291999-02-26 11:11:13 +0000155extern HQUEUE16 WINAPI SetThreadQueue16( DWORD thread, HQUEUE16 hQueue );
156extern HQUEUE16 WINAPI GetThreadQueue16( DWORD thread );
157extern VOID WINAPI SetFastQueue16( DWORD thread, HANDLE hQueue );
158extern HANDLE WINAPI GetFastQueue16( void );
Ulrich Weigand89b93bf1998-12-24 15:15:00 +0000159
160
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000161#endif /* __WINE_TASK_H */