Release 970720
[wine] / include / task.h
1 /*
2  * Task definitions
3  *
4  * Copyright 1995 Alexandre Julliard
5  */
6
7 #ifndef __WINE_TASK_H
8 #define __WINE_TASK_H
9
10 #include "wintypes.h"
11
12 #pragma pack(1)
13
14   /* Process database (i.e. a normal DOS PSP) */
15
16 typedef struct
17 {
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 */
31     HANDLE16  hFileHandles;            /* 38 Handle to fileHandlesPtr */
32     WORD      reserved3[17];
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)*/
36 } PDB;
37
38
39   /* Segment containing MakeProcInstance() thunks */
40 typedef struct
41 {
42     WORD  next;       /* Selector of next segment */
43     WORD  magic;      /* Thunks signature */
44     WORD  unused;
45     WORD  free;       /* Head of the free list */
46     WORD  thunks[4];  /* Each thunk is 4 words long */
47 } THUNKS;
48
49 #define THUNK_MAGIC  ('P' | ('T' << 8))
50
51 struct _THDB;
52
53   /* Task database. See 'Windows Internals' p. 226 */
54 typedef struct
55 {
56     HTASK16   hNext;                      /* 00 Selector of next TDB */
57     DWORD     ss_sp WINE_PACKED;          /* 02 Stack pointer of task */
58     WORD      nEvents;                    /* 06 Events for this task */
59     INT16     priority;                   /* 08 Task priority, -32..15 */
60     WORD      unused1;                    /* 0a */
61     HTASK16   hSelf;                      /* 0c Selector of this TDB */
62     HANDLE16  hPrevInstance;              /* 0e Previous instance of module */
63     DWORD     esp;                        /* 10 32-bit stack pointer */
64     WORD      ctrlword8087;               /* 14 80x87 control word */
65     WORD      flags;                      /* 16 Task flags */
66     UINT16    error_mode;                 /* 18 Error mode (see SetErrorMode)*/
67     WORD      version;                    /* 1a Expected Windows version */
68     HANDLE16  hInstance;                  /* 1c Instance handle for task */
69     HMODULE16 hModule;                    /* 1e Module handle */
70     HQUEUE16  hQueue;                     /* 20 Selector of task queue */
71     HTASK16   hParent;                    /* 22 Selector of TDB of parent */
72     WORD      signal_flags;               /* 24 Flags for signal handler */
73     FARPROC16 sighandler WINE_PACKED;     /* 26 Signal handler */
74     FARPROC16 userhandler WINE_PACKED;    /* 2a USER signal handler */
75     FARPROC16 discardhandler WINE_PACKED; /* 2e Handler for GlobalNotify() */
76     DWORD     int0 WINE_PACKED;           /* 32 int 0 (divide by 0) handler */
77     DWORD     int2 WINE_PACKED;           /* 36 int 2 (NMI) handler */
78     DWORD     int4 WINE_PACKED;           /* 3a int 4 (INTO) handler */
79     DWORD     int6 WINE_PACKED;           /* 3e int 6 (invalid opc) handler */
80     DWORD     int7 WINE_PACKED;           /* 42 int 7 (coprocessor) handler */
81     DWORD     int3e WINE_PACKED;          /* 46 int 3e (80x87 emu) handler */
82     DWORD     int75 WINE_PACKED;          /* 4a int 75 (80x87 error) handler */
83     DWORD     compat_flags WINE_PACKED;   /* 4e Compatibility flags */
84     BYTE      unused4[2];                 /* 52 */
85     struct _THDB *thdb;                   /* 54 Pointer to thread database */
86     BYTE      unused5[8];                 /* 58 */
87     HANDLE16  hPDB;                       /* 60 Selector of PDB (i.e. PSP) */
88     SEGPTR    dta WINE_PACKED;            /* 62 Current DTA */
89     BYTE      curdrive;                   /* 66 Current drive */
90     BYTE      curdir[65];                 /* 67 Current directory */
91     WORD      nCmdShow;                   /* a8 cmdShow parameter to WinMain */
92     HTASK16   hYieldTo;                   /* aa Next task to schedule */
93     DWORD     dlls_to_init;               /* ac Ptr to DLLs to initialize */
94     HANDLE16  hCSAlias;                   /* b0 Code segment for this TDB */
95     THUNKS    thunks WINE_PACKED;         /* b2 Make proc instance thunks */
96     WORD      more_thunks[6*4];           /* c2 Space for 6 more thunks */
97     BYTE      module_name[8];             /* f2 Module name for task */
98     WORD      magic;                      /* fa TDB signature */
99     DWORD     unused7;                    /* fc */
100     PDB       pdb;                        /* 100 PDB for this task */
101 } TDB;
102
103 #define TDB_MAGIC    ('T' | ('D' << 8))
104
105   /* TDB flags */
106 #define TDBF_WINOLDAP   0x0001
107 #define TDBF_OS2APP     0x0008
108 #define TDBF_WIN32      0x0010
109
110 #pragma pack(4)
111
112 extern BOOL32 TASK_Init(void);
113 extern HTASK16 TASK_CreateTask( HMODULE16 hModule, HINSTANCE16 hInstance,
114                                 HINSTANCE16 hPrevInstance,
115                                 HANDLE16 hEnvironment, LPCSTR cmdLine,
116                                 UINT16 cmdShow );
117 extern void TASK_KillCurrentTask( INT16 exitCode );
118 extern HTASK16 TASK_GetNextTask( HTASK16 hTask );
119
120 #endif /* __WINE_TASK_H */