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