Release 960705
[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 #ifndef WINELIB
13 #pragma pack(1)
14 #endif
15
16   /* Process database (i.e. a normal DOS PSP) */
17
18 typedef struct
19 {
20     WORD   int20;                   /* 00 int 20h instruction */
21     WORD   nextParagraph;           /* 02 Segment of next paragraph */
22     BYTE   reserved1;
23     BYTE   dispatcher[5];           /* 05 Long call to DOS */
24     SEGPTR savedint22 WINE_PACKED;  /* 0a Saved int 22h handler */
25     SEGPTR savedint23 WINE_PACKED;  /* 0e Saved int 23h handler */
26     SEGPTR savedint24 WINE_PACKED;  /* 12 Saved int 24h handler */
27     WORD   parentPSP;               /* 16 Selector of parent PSP */
28     BYTE   fileHandles[20];         /* 18 Open file handles */
29     HANDLE environment;             /* 2c Selector of environment */
30     WORD   reserved2[2];
31     WORD   nbFiles;                 /* 32 Number of file handles */
32     SEGPTR fileHandlesPtr;          /* 34 Pointer to file handle table */
33     WORD   reserved3[18];
34     BYTE   fcb1[16];                /* 5c First FCB */
35     BYTE   fcb2[20];                /* 6c Second FCB */
36     BYTE   cmdLine[128];            /* 80 Command-line (first byte is len) */
37 } PDB;
38
39
40   /* Segment containing MakeProcInstance() thunks */
41 typedef 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
52
53   /* Task database. See 'Windows Internals' p. 226 */
54 typedef struct
55 {
56     HTASK   hNext;                      /* Selector of next TDB */
57     WORD    sp;                         /* Stack pointer of task */
58     WORD    ss;                         /* Stack segment of task */
59     WORD    nEvents;                    /* Events for this task */
60     char    priority;                   /* Task priority, between -32 and 15 */
61     BYTE    unused1;
62     HGLOBAL hStack32;                   /* Handle to 32-bit stack */
63     HTASK   hSelf;                      /* Selector of this TDB */
64     HANDLE  hPrevInstance;              /* Previous instance of the module */
65     DWORD   esp;                        /* 32-bit stack pointer */
66     WORD    ctrlword8087;               /* 80x87 control word */
67     WORD    flags;                      /* Task flags */
68     UINT    error_mode;                 /* Error mode (see SetErrorMode) */
69     WORD    version;                    /* Expected Windows version */
70     HANDLE  hInstance;                  /* Instance handle for this task */
71     HMODULE hModule;                    /* Module handle */
72     HQUEUE  hQueue;                     /* Selector of task message queue */
73     HTASK   hParent;                    /* Selector of TDB of parent task */
74     WORD    signal_flags;               /* Flags related to signal handler */
75     DWORD   sighandler WINE_PACKED;     /* Signal handler */
76     DWORD   userhandler WINE_PACKED;    /* USER signal handler */
77     DWORD   discardhandler WINE_PACKED; /* Handler for GlobalDiscard() */
78     DWORD   int0 WINE_PACKED;           /* int 0 (divide by zero) handler */
79     DWORD   int2 WINE_PACKED;           /* int 2 (NMI) handler */
80     DWORD   int4 WINE_PACKED;           /* int 4 (INTO) handler */
81     DWORD   int6 WINE_PACKED;           /* int 6 (invalid opcode) handler */
82     DWORD   int7 WINE_PACKED;           /* int 7 (coprocessor) handler */
83     DWORD   int3e WINE_PACKED;          /* int 3e (80x87 emulator) handler */
84     DWORD   int75 WINE_PACKED;          /* int 75 (80x87 error) handler */
85     DWORD   compat_flags WINE_PACKED;   /* Compatibility flags */
86     BYTE    unused4[14];
87     HANDLE  hPDB;                       /* Selector of PDB (i.e. PSP) */
88     SEGPTR  dta WINE_PACKED;            /* Current DTA */
89     BYTE    curdrive;                   /* Current drive */
90     BYTE    curdir[65];                 /* Current directory */
91     WORD    nCmdShow;                   /* cmdShow parameter to WinMain */
92     HTASK   hYieldTo;                   /* Next task to schedule */
93     DWORD   dlls_to_init;               /* Ptr to list of DLL to initialize */
94     HANDLE  hCSAlias;                   /* Code segment alias for this TDB */
95     THUNKS  thunks WINE_PACKED;         /* Make proc instance thunks */
96     WORD    more_thunks[6*4];           /* Space for 6 more thunks */
97     BYTE    module_name[8];             /* Module name for task */
98     WORD    magic;                      /* TDB signature */
99     DWORD   unused7;
100     PDB     pdb;                        /* 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_WIN32S     0x0010
109
110 #ifndef WINELIB
111 #pragma pack(4)
112 #endif
113
114 extern BOOL TASK_Init(void);
115 extern HTASK TASK_CreateTask( HMODULE hModule, HANDLE hInstance,
116                               HANDLE hPrevInstance, HANDLE hEnvironment,
117                               char *cmdLine, WORD cmdShow );
118 extern void TASK_KillCurrentTask( int exitCode );
119
120 #endif /* _WINE_TASK_H */