a9f5e7d04145753259d47ba46bf8d95dfc4691a2
[reactos.git] / reactos / subsystems / mvdm / ntvdm / dos / dos32krnl / process.h
1 /*
2 * COPYRIGHT: GPLv2 - See COPYING in the top level directory
3 * PROJECT: ReactOS Virtual DOS Machine
4 * FILE: dos/dos32krnl/process.h
5 * PURPOSE: DOS32 Processes
6 * PROGRAMMERS: Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
7 */
8
9 /* DEFINITIONS ****************************************************************/
10
11 #define DOS_CMDLINE_LENGTH 127
12 #define DOS_PROGRAM_NAME_TAG 0x0001
13
14 #define SEGMENT_TO_PSP(seg) ((PDOS_PSP)((ULONG_PTR)BaseAddress + TO_LINEAR((seg), 0)))
15
16 typedef enum
17 {
18 DOS_LOAD_AND_EXECUTE = 0x00,
19 DOS_LOAD_ONLY = 0x01,
20 DOS_LOAD_OVERLAY = 0x03
21 } DOS_EXEC_TYPE;
22
23 #pragma pack(push, 1)
24
25 typedef struct _DOS_PSP
26 {
27 BYTE Exit[2];
28 WORD LastParagraph;
29 BYTE Reserved0[6];
30 DWORD TerminateAddress;
31 DWORD BreakAddress;
32 DWORD CriticalAddress;
33 WORD ParentPsp;
34 BYTE HandleTable[20];
35 WORD EnvBlock;
36 DWORD LastStack;
37 WORD HandleTableSize;
38 DWORD HandleTablePtr;
39 DWORD PreviousPsp;
40 DWORD Reserved1;
41 WORD DosVersion;
42 BYTE Reserved2[14];
43 BYTE FarCall[3];
44 BYTE Reserved3[9];
45 DOS_FCB Fcb;
46 BYTE CommandLineSize;
47 CHAR CommandLine[DOS_CMDLINE_LENGTH];
48 } DOS_PSP, *PDOS_PSP;
49
50 typedef struct _DOS_EXEC_PARAM_BLOCK
51 {
52 union
53 {
54 struct
55 {
56 /* Input variables */
57 WORD Environment;
58 DWORD CommandLine;
59 DWORD FirstFcb;
60 DWORD SecondFcb;
61
62 /* Output variables */
63 DWORD StackLocation;
64 DWORD EntryPoint;
65 };
66
67 struct
68 {
69 WORD Segment;
70 WORD RelocationFactor;
71 } Overlay;
72 };
73 } DOS_EXEC_PARAM_BLOCK, *PDOS_EXEC_PARAM_BLOCK;
74
75 #pragma pack(pop)
76
77 /* VARIABLES ******************************************************************/
78
79 extern WORD CurrentPsp;
80
81 /* FUNCTIONS ******************************************************************/
82
83 VOID DosClonePsp(WORD DestSegment, WORD SourceSegment);
84 VOID DosCreatePsp(WORD Segment, WORD ProgramSize);
85 VOID DosSetProcessContext(WORD Segment);
86
87 DWORD DosLoadExecutable
88 (
89 IN DOS_EXEC_TYPE LoadType,
90 IN LPCSTR ExecutablePath,
91 IN PDOS_EXEC_PARAM_BLOCK Parameters,
92 IN LPCSTR CommandLine OPTIONAL,
93 IN LPCSTR Environment OPTIONAL,
94 IN DWORD ReturnAddress OPTIONAL
95 );
96
97 DWORD DosStartProcess(
98 IN LPCSTR ExecutablePath,
99 IN LPCSTR CommandLine,
100 IN LPCSTR Environment OPTIONAL
101 );
102
103 WORD DosCreateProcess
104 (
105 LPCSTR ProgramName,
106 PDOS_EXEC_PARAM_BLOCK Parameters,
107 DWORD ReturnAddress
108 );
109
110 VOID DosTerminateProcess(WORD Psp, BYTE ReturnCode, WORD KeepResident);