Release 960712
[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     WORD      reserved3[18];
32     BYTE      fcb1[16];                /* 5c First FCB */
33     BYTE      fcb2[20];                /* 6c Second FCB */
34     BYTE      cmdLine[128];            /* 80 Command-line (first byte is len)*/
35 } PDB;
36
37
38   /* Segment containing MakeProcInstance() thunks */
39 typedef struct
40 {
41     WORD  next;       /* Selector of next segment */
42     WORD  magic;      /* Thunks signature */
43     WORD  unused;
44     WORD  free;       /* Head of the free list */
45     WORD  thunks[4];  /* Each thunk is 4 words long */
46 } THUNKS;
47
48 #define THUNK_MAGIC  ('P' | ('T' << 8))
49
50
51   /* Task database. See 'Windows Internals' p. 226 */
52 typedef struct
53 {
54     HTASK   hNext;                      /* Selector of next TDB */
55     WORD    sp;                         /* Stack pointer of task */
56     WORD    ss;                         /* Stack segment of task */
57     WORD    nEvents;                    /* Events for this task */
58     char    priority;                   /* Task priority, between -32 and 15 */
59     BYTE    unused1;
60     HGLOBAL hStack32;                   /* Handle to 32-bit stack */
61     HTASK   hSelf;                      /* Selector of this TDB */
62     HANDLE  hPrevInstance;              /* Previous instance of the module */
63     DWORD   esp;                        /* 32-bit stack pointer */
64     WORD    ctrlword8087;               /* 80x87 control word */
65     WORD    flags;                      /* Task flags */
66     UINT    error_mode;                 /* Error mode (see SetErrorMode) */
67     WORD    version;                    /* Expected Windows version */
68     HANDLE  hInstance;                  /* Instance handle for this task */
69     HMODULE hModule;                    /* Module handle */
70     HQUEUE  hQueue;                     /* Selector of task message queue */
71     HTASK   hParent;                    /* Selector of TDB of parent task */
72     WORD    signal_flags;               /* Flags related to signal handler */
73     DWORD   sighandler WINE_PACKED;     /* Signal handler */
74     DWORD   userhandler WINE_PACKED;    /* USER signal handler */
75     DWORD   discardhandler WINE_PACKED; /* Handler for GlobalDiscard() */
76     DWORD   int0 WINE_PACKED;           /* int 0 (divide by zero) handler */
77     DWORD   int2 WINE_PACKED;           /* int 2 (NMI) handler */
78     DWORD   int4 WINE_PACKED;           /* int 4 (INTO) handler */
79     DWORD   int6 WINE_PACKED;           /* int 6 (invalid opcode) handler */
80     DWORD   int7 WINE_PACKED;           /* int 7 (coprocessor) handler */
81     DWORD   int3e WINE_PACKED;          /* int 3e (80x87 emulator) handler */
82     DWORD   int75 WINE_PACKED;          /* int 75 (80x87 error) handler */
83     DWORD   compat_flags WINE_PACKED;   /* Compatibility flags */
84     BYTE    unused4[14];
85     HANDLE  hPDB;                       /* Selector of PDB (i.e. PSP) */
86     SEGPTR  dta WINE_PACKED;            /* Current DTA */
87     BYTE    curdrive;                   /* Current drive */
88     BYTE    curdir[65];                 /* Current directory */
89     WORD    nCmdShow;                   /* cmdShow parameter to WinMain */
90     HTASK   hYieldTo;                   /* Next task to schedule */
91     DWORD   dlls_to_init;               /* Ptr to list of DLL to initialize */
92     HANDLE  hCSAlias;                   /* Code segment alias for this TDB */
93     THUNKS  thunks WINE_PACKED;         /* Make proc instance thunks */
94     WORD    more_thunks[6*4];           /* Space for 6 more thunks */
95     BYTE    module_name[8];             /* Module name for task */
96     WORD    magic;                      /* TDB signature */
97     DWORD   unused7;
98     PDB     pdb;                        /* PDB for this task */
99 } TDB;
100
101 #define TDB_MAGIC    ('T' | ('D' << 8))
102
103   /* TDB flags */
104 #define TDBF_WINOLDAP   0x0001
105 #define TDBF_OS2APP     0x0008
106 #define TDBF_WIN32S     0x0010
107
108 #pragma pack(4)
109
110 extern BOOL TASK_Init(void);
111 extern HTASK TASK_CreateTask( HMODULE hModule, HANDLE hInstance,
112                               HANDLE hPrevInstance, HANDLE hEnvironment,
113                               char *cmdLine, WORD cmdShow );
114 extern void TASK_KillCurrentTask( int exitCode );
115
116 #endif /* _WINE_TASK_H */