b832c954c452f3cdc8b222a003f89fdc3dd9ac03
[reactos.git] / subsystems / ntvdm / dos.h
1 /*
2 * COPYRIGHT: GPL - See COPYING in the top level directory
3 * PROJECT: ReactOS Virtual DOS Machine
4 * FILE: dos.h
5 * PURPOSE: VDM DOS Kernel (header file)
6 * PROGRAMMERS: Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
7 */
8
9 #ifndef _DOS_H_
10 #define _DOS_H_
11
12 /* INCLUDES *******************************************************************/
13
14 #include "ntvdm.h"
15
16 /* DEFINES ********************************************************************/
17
18 #define DOS_VERSION MAKEWORD(6, 0)
19 #define DOS_CONFIG_PATH L"%SystemRoot%\\system32\\CONFIG.NT"
20 #define DOS_COMMAND_INTERPRETER L"%SystemRoot%\\system32\\COMMAND.COM /k %SystemRoot%\\system32\\AUTOEXEC.NT"
21 #define FIRST_MCB_SEGMENT 0x1000
22 #define USER_MEMORY_SIZE 0x8FFFF
23 #define SYSTEM_PSP 0x08
24 #define SYSTEM_ENV_BLOCK 0x800
25 #define INVALID_DOS_HANDLE 0xFFFF
26 #define DOS_SFT_SIZE 255
27 #define SEGMENT_TO_MCB(seg) ((PDOS_MCB)((ULONG_PTR)BaseAddress + TO_LINEAR((seg), 0)))
28 #define SEGMENT_TO_PSP(seg) ((PDOS_PSP)((ULONG_PTR)BaseAddress + TO_LINEAR((seg), 0)))
29
30 #pragma pack(push, 1)
31
32 typedef struct _DOS_MCB
33 {
34 CHAR BlockType;
35 WORD OwnerPsp;
36 WORD Size;
37 BYTE Unused[3];
38 CHAR Name[8];
39 } DOS_MCB, *PDOS_MCB;
40
41 typedef struct _DOS_FCB
42 {
43 BYTE DriveNumber;
44 CHAR FileName[8];
45 CHAR FileExt[3];
46 WORD BlockNumber;
47 WORD RecordSize;
48 DWORD FileSize;
49 WORD LastWriteDate;
50 WORD LastWriteTime;
51 BYTE Reserved[8];
52 BYTE BlockRecord;
53 BYTE RecordNumber[3];
54 } DOS_FCB, *PDOS_FCB;
55
56 typedef struct _DOS_PSP
57 {
58 BYTE Exit[2];
59 WORD MemSize;
60 BYTE Reserved0[6];
61 DWORD TerminateAddress;
62 DWORD BreakAddress;
63 DWORD CriticalAddress;
64 WORD ParentPsp;
65 BYTE HandleTable[20];
66 WORD EnvBlock;
67 DWORD LastStack;
68 WORD HandleTableSize;
69 DWORD HandleTablePtr;
70 DWORD PreviousPsp;
71 DWORD Reserved1;
72 WORD DosVersion;
73 BYTE Reserved2[14];
74 BYTE FarCall[3];
75 BYTE Reserved3[9];
76 DOS_FCB Fcb;
77 BYTE CommandLineSize;
78 CHAR CommandLine[127];
79 } DOS_PSP, *PDOS_PSP;
80
81 typedef struct _DOS_INPUT_BUFFER
82 {
83 BYTE MaxLength, Length;
84 CHAR Buffer[ANYSIZE_ARRAY];
85 } DOS_INPUT_BUFFER, *PDOS_INPUT_BUFFER;
86
87 #pragma pack(pop)
88
89 /* FUNCTIONS ******************************************************************/
90
91 WORD DosAllocateMemory(WORD Size, WORD *MaxAvailable);
92 BOOLEAN DosResizeMemory(WORD BlockData, WORD NewSize, WORD *MaxAvailable);
93 BOOLEAN DosFreeMemory(WORD BlockData);
94 WORD DosCreateFile(LPWORD Handle, LPCSTR FilePath, WORD Attributes);
95 WORD DosOpenFile(LPWORD Handle, LPCSTR FilePath, BYTE AccessMode);
96 WORD DosReadFile(WORD FileHandle, LPVOID Buffer, WORD Count, LPWORD BytesRead);
97 WORD DosWriteFile(WORD FileHandle, LPVOID Buffer, WORD Count, LPWORD BytesWritten);
98 VOID DosInitializePsp(WORD PspSegment, LPCSTR CommandLine, WORD ProgramSize, WORD Environment);
99 BOOLEAN DosCreateProcess(LPCSTR CommandLine, WORD EnvBlock);
100 VOID DosTerminateProcess(WORD Psp, BYTE ReturnCode);
101 CHAR DosReadCharacter();
102 VOID DosPrintCharacter(CHAR Character);
103 VOID DosInt20h(WORD CodeSegment);
104 VOID DosInt21h(WORD CodeSegment);
105 VOID DosBreakInterrupt();
106 BOOLEAN DosInitialize();
107
108 #endif
109
110 /* EOF */
111