ReactOS 0.4.15-dev-7953-g1f49173
dos.h
Go to the documentation of this file.
1/*
2 * COPYRIGHT: GPL - See COPYING in the top level directory
3 * PROJECT: ReactOS Virtual DOS Machine
4 * FILE: subsystems/mvdm/ntvdm/dos/dos32krnl/dos.h
5 * PURPOSE: DOS32 Kernel
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 "device.h"
15
16 #include "int32.h"
17
18/* DEFINES ********************************************************************/
19
20//
21// We are DOS 5.00 (reported by INT 21h, AH=30h)
22// and DOS 5.50 (reported by INT 21h, AX=3306h) for Windows NT Compatibility
23//
24#define DOS_VERSION MAKEWORD(5, 00)
25#define NTDOS_VERSION MAKEWORD(5, 50)
26
27#define DOS_CONFIG_PATH L"%SystemRoot%\\system32\\CONFIG.NT"
28#define DOS_COMMAND_INTERPRETER L"%SystemRoot%\\system32\\COMMAND.COM /k %SystemRoot%\\system32\\AUTOEXEC.NT"
29
30#define BIOS_CODE_SEGMENT 0x70
31#define BIOS_DATA_SEGMENT 0x70
32#define DOS_CODE_SEGMENT 0x80
33#define DOS_DATA_SEGMENT 0xA5
34
35#define DOS_DATA_OFFSET(x) FIELD_OFFSET(DOS_DATA, x)
36
37#define SYSTEM_ENV_BLOCK 0x600 // FIXME: Should be dynamically initialized!
38
39#define SYSTEM_PSP 0x0008
40
41#define INVALID_DOS_HANDLE 0xFFFF
42#define DOS_INPUT_HANDLE 0
43#define DOS_OUTPUT_HANDLE 1
44#define DOS_ERROR_HANDLE 2
45
46#define DOS_SFT_SIZE 255 // Value of the 'FILES=' command; maximum 255
47#define DOS_DIR_LENGTH 64
48#define NUM_DRIVES ('Z' - 'A' + 1)
49#define DOS_CHAR_ATTRIBUTE 0x07
50
51#pragma pack(push, 1)
52
53typedef struct _DOS_FCB
54{
67
68// http://www.ctyme.com/intr/rb-2983.htm
69typedef struct _DOS_SYSVARS
70{
78
79 /* This is where the SYSVARS really start */
80 DWORD FirstDpb; // 0x00
81 DWORD FirstSft; // 0x04
84 BYTE Reserved0[6]; // 0x10
86 BYTE Reserved1[6]; // 0x1a
88 BYTE NumLocalDrives; // 0x21 - Set by LASTDRIVE
90 BYTE Reserved2; // 0x34
93 WORD Reserved3[2]; // 0x3b
94 WORD BuffersNumber; // 0x3f - 'x' parameter in "BUFFERS=x,y" command
95 WORD BuffersLookaheadNumber; // 0x41 - 'y' parameter in "BUFFERS=x,y" command
96 BYTE BootDrive; // 0x43
99 BYTE Reserved4[0x1C]; // 0x47
100 BYTE UmbLinked; // 0x63 - 0/1: UMB chain (un)linked to MCB chain
102 WORD UmbChainStart; // 0x66 - Segment of the first UMB MCB
103 WORD MemAllocScanStart; // 0x68 - Segment where allocation scan starts
105
107{
114
115typedef struct _DOS_INPUT_BUFFER
116{
121
131{
132 /* The 21 first bytes (0x00 to 0x14 included) are reserved */
136 DWORD Unused; // FIXME: We must NOT store a Win32 handle here!
137 HANDLE SearchHandle; // Instead we should use an ID and helpers to map it to Win32.
138
139 /* The following part of the structure is documented */
146
147// http://www.ctyme.com/intr/rb-3023.htm
148typedef struct _DOS_SDA
149{
154
155 /* This is where the SDA really starts */
170
171 /* This part is only valid while in DOS */
247
248/*
249 * DOS kernel data structure
250 */
251typedef struct _DOS_DATA
252{
255 WORD DosVersion; // DOS version to report to programs (can be different from the true one)
262
263/*
264 * DOS BIOS data structure at segment 70h
265 */
266typedef struct _BIOS_DATA
267{
268 BYTE StartupCode[20]; // 0x00 - 20 bytes: large enough for now!
269
270/*
271 * INT 13h (BIOS Disk Services) handler chain support.
272 *
273 * RomBiosInt13: The original INT 13h vector (normally from ROM BIOS).
274 * PrevInt13 : The previous INT 13h vector in the handler chain (initially
275 * initialized with the RomBiosInt13 value; each time some
276 * program calls INT 2Fh, AH=13h, PrevInt13 is updated).
277 *
278 * DOS hooks INT 13h with its own code, then (in normal circumstances) calls
279 * PrevInt13, so that when a program calls INT 13h, the DOS hook is first called,
280 * followed by the previous INT 13h (be it the original or some other hooked one).
281 * DOS may call PrevInt13 directly in some internal operations too.
282 * RomBiosInt13 is intended to be the original INT 13h vector that existed
283 * before DOS was loaded. A particular version of PC-AT's IBM's ROM BIOS
284 * (on systems with model byte FCh and BIOS date "01/10/84" only, see
285 * http://www.ctyme.com/intr/rb-4453.htm for more details) had a bug on disk
286 * reads so that it was patched by DOS, and therefore PrevInt13 was the fixed
287 * INT 13 interrupt (for the other cases, a direct call to RomBiosInt13 is done).
288 *
289 * NOTE: For compatibility with some programs (including virii), PrevInt13 should
290 * be at 0070:00B4, see for more details:
291 * http://repo.hackerzvoice.net/depot_madchat/vxdevl/vdat/tuvd0001.htm
292 * http://vxheaven.org/lib/vsm01.html
293 */
294 BYTE Padding0[0xB0 - /*FIELD_OFFSET(BIOS_DATA, StartupCode)*/ 20];
297 BYTE Padding1[0x100 - 0xB8]; // 0xb8
299
300C_ASSERT(sizeof(BIOS_DATA) == 0x100);
301
302#pragma pack(pop)
303
304/* VARIABLES ******************************************************************/
305
306extern PBIOS_DATA BiosData;
307extern PDOS_DATA DosData;
308extern PDOS_SYSVARS SysVars;
309extern PDOS_SDA Sda;
310
311/* FUNCTIONS ******************************************************************/
312
314#define RegisterDosInt32(IntNumber, IntHandler) \
315do { \
316 ASSERT((0x20 <= IntNumber) && (IntNumber <= 0x2F)); \
317 RegisterInt32(DosContext.TrampolineFarPtr + \
318 DosContext.TrampolineSize + \
319 (IntNumber - 0x20) * Int16To32StubSize, \
320 (IntNumber), (IntHandler), NULL); \
321} while(0);
322
325
326/*
327 * DOS BIOS Functions
328 * See bios.c
329 */
333
335
337VOID DosEchoCharacter(CHAR Character);
338
339/*
340 * DOS Kernel Functions
341 * See dos.c
342 */
344
345#endif // _DOS_H_
346
347/* EOF */
unsigned char BOOLEAN
Definition: bufpool.h:45
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude * include
Definition: asm.c:31
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1231
#define C_ASSERT(e)
Definition: intsafe.h:73
#define _Null_terminated_
Definition: ms_sal.h:640
BYTE Padding0[0xB0 - 20]
Definition: dos.h:294
DWORD PrevInt13
Definition: dos.h:296
DWORD RomBiosInt13
Definition: dos.h:295
BYTE StartupCode[20]
Definition: dos.h:268
BYTE Padding1[0x100 - 0xB8]
Definition: dos.h:297
Definition: dos.h:252
DOS_SYSVARS SysVars
Definition: dos.h:253
DOS_SDA Sda
Definition: dos.h:256
WORD DosVersion
Definition: dos.h:255
BYTE DosStack[384]
Definition: dos.h:259
CHAR CurrentDirectories[NUM_DRIVES][DOS_DIR_LENGTH]
Definition: dos.h:257
BYTE Sft[ANYSIZE_ARRAY]
Definition: dos.h:260
BYTE UnreadConInputBuffer[128]
Definition: dos.h:258
BYTE NullDriverRoutine[7]
Definition: dos.h:254
Definition: dos.h:54
WORD BlockNumber
Definition: dos.h:58
WORD LastWriteDate
Definition: dos.h:61
BYTE BlockRecord
Definition: dos.h:64
CHAR FileExt[3]
Definition: dos.h:57
DWORD FileSize
Definition: dos.h:60
WORD LastWriteTime
Definition: dos.h:62
BYTE DriveNumber
Definition: dos.h:55
WORD RecordSize
Definition: dos.h:59
BYTE RecordNumber[3]
Definition: dos.h:65
HANDLE SearchHandle
Definition: dos.h:137
UCHAR AttribMask
Definition: dos.h:135
CHAR DriveLetter
Definition: dos.h:133
UCHAR Attributes
Definition: dos.h:140
CHAR Pattern[11]
Definition: dos.h:134
DWORD FileSize
Definition: dos.h:143
BYTE MaxLength
Definition: dos.h:117
BYTE Length
Definition: dos.h:118
Definition: dos.h:149
CHAR FileNameBuffer[256]
Definition: dos.h:204
WORD Int23StackPointer
Definition: dos.h:166
BYTE CtrlBreakFlag
Definition: dos.h:182
BYTE OemNumber
Definition: dos.h:199
DWORD CriticalErrorDpb
Definition: dos.h:225
DOS_CLOCK_TRANSFER_RECORD ClockTransferRecord
Definition: dos.h:201
BYTE Month
Definition: dos.h:186
WORD LastSearchDirEntry
Definition: dos.h:179
BYTE FcbType
Definition: dos.h:211
BYTE FileDeletedChar
Definition: dos.h:224
BYTE Int24AbortFlag
Definition: dos.h:192
BYTE DirectoryFlag
Definition: dos.h:181
BYTE Int24FailFlag
Definition: dos.h:180
WORD SftNumber
Definition: dos.h:233
BYTE ErrorDrive
Definition: dos.h:158
BYTE ParsedFcbExists
Definition: dos.h:220
DWORD WorkingSft
Definition: dos.h:241
WORD Unused10
Definition: dos.h:244
WORD ErrorLevel
Definition: dos.h:167
BYTE SpliceFlag
Definition: dos.h:216
BYTE InsertMode
Definition: dos.h:219
WORD ErrorCodeTable
Definition: dos.h:200
BYTE Unused1
Definition: dos.h:184
WORD FirstFreeMcb
Definition: dos.h:175
WORD LastErrorCode
Definition: dos.h:160
BYTE Unused5[53]
Definition: dos.h:205
BYTE LastErrorClass
Definition: dos.h:162
WORD CurrentPsp
Definition: dos.h:165
DWORD JftEntry
Definition: dos.h:235
BYTE Unused9[38]
Definition: dos.h:240
BYTE PrinterEchoFlag
Definition: dos.h:150
BYTE AllowFcbBlanks
Definition: dos.h:183
WORD BestFreeMcb
Definition: dos.h:176
BYTE ByteBuffer
Definition: dos.h:202
BYTE DirSearchAttributes
Definition: dos.h:212
CHAR CurrentDirectory[81]
Definition: dos.h:206
BYTE Unused8[14]
Definition: dos.h:228
BYTE CreateFileFlag
Definition: dos.h:223
BYTE UserNumber[3]
Definition: dos.h:198
BYTE DosCallFlag
Definition: dos.h:217
WORD LastFreeMcb
Definition: dos.h:177
WORD TransferOffset
Definition: dos.h:239
DWORD CallerFcb
Definition: dos.h:232
WORD NumDays
Definition: dos.h:188
CHAR CurrentSwitchChar
Definition: dos.h:151
BYTE PspCopyType
Definition: dos.h:196
BYTE DayOfMonth
Definition: dos.h:185
DWORD CurrentSft
Definition: dos.h:230
WORD MemorySize
Definition: dos.h:178
BYTE Unused3
Definition: dos.h:197
BYTE Unused7[5]
Definition: dos.h:218
DWORD DeviceHeader
Definition: dos.h:229
BYTE DayOfWeek
Definition: dos.h:189
BYTE ConsoleSwappedFlag
Definition: dos.h:190
BYTE VolumeIDFlag
Definition: dos.h:221
BYTE ExtendedBreakFlag
Definition: dos.h:169
WORD NetworkPsp
Definition: dos.h:173
BYTE DeviceNameFound
Definition: dos.h:215
BYTE AllocStrategy
Definition: dos.h:152
WORD TempFileHandle
Definition: dos.h:234
WORD Int21CallerDS
Definition: dos.h:243
BYTE Unused2[44]
Definition: dos.h:195
BYTE TerminationType
Definition: dos.h:222
DWORD PrevCallFrame
Definition: dos.h:245
BYTE LastErrorAction
Definition: dos.h:161
BYTE ExtendedAttribute
Definition: dos.h:210
DWORD LastErrorPointer
Definition: dos.h:163
WORD LastAX
Definition: dos.h:172
BYTE FileFound
Definition: dos.h:214
BYTE FileOpenMode
Definition: dos.h:213
DWORD DiskTransferArea
Definition: dos.h:164
BYTE Unused0[28]
Definition: dos.h:153
BYTE Int28CallOk
Definition: dos.h:191
BYTE Unused6[8]
Definition: dos.h:209
CHAR FcbFilename[12]
Definition: dos.h:207
DWORD CurrentDirPointer
Definition: dos.h:231
WORD NetworkMachineNumber
Definition: dos.h:174
DOS_RW_REQUEST Request
Definition: dos.h:193
BYTE ErrorMode
Definition: dos.h:156
CHAR FcbRenameDest[12]
Definition: dos.h:208
WORD Int21CallerBX
Definition: dos.h:242
DWORD UserRegistersStack
Definition: dos.h:226
WORD Year
Definition: dos.h:187
BYTE LastErrorLocus
Definition: dos.h:159
WORD Int24StackPointer
Definition: dos.h:227
BYTE Unused4
Definition: dos.h:203
WORD LastComponent
Definition: dos.h:238
BYTE CurrentDrive
Definition: dos.h:168
WORD SecondArgument
Definition: dos.h:237
BYTE InDos
Definition: dos.h:157
WORD FirstArgument
Definition: dos.h:236
DWORD DriverEntryPoint
Definition: dos.h:194
DWORD FirstDpb
Definition: dos.h:80
WORD Reserved3[2]
Definition: dos.h:93
WORD UnreadConInput
Definition: dos.h:76
BYTE UseDwordMoves
Definition: dos.h:97
WORD Reserved5
Definition: dos.h:101
DWORD ActiveCon
Definition: dos.h:83
WORD MemAllocScanStart
Definition: dos.h:103
WORD FirstMcb
Definition: dos.h:77
WORD ProgramVersionTable
Definition: dos.h:91
BYTE Reserved0[6]
Definition: dos.h:84
WORD ShareRetryDelay
Definition: dos.h:74
BYTE Reserved4[0x1C]
Definition: dos.h:99
DWORD CurrentDirs
Definition: dos.h:85
DWORD OemHandler
Definition: dos.h:71
BYTE NumBlockDevices
Definition: dos.h:87
WORD ShareRetryCount
Definition: dos.h:73
WORD UmbChainStart
Definition: dos.h:102
WORD Int21hReturn
Definition: dos.h:72
BYTE NumLocalDrives
Definition: dos.h:88
WORD BuffersLookaheadNumber
Definition: dos.h:95
WORD BuffersNumber
Definition: dos.h:94
DWORD SetVerTable
Definition: dos.h:92
DWORD FirstSft
Definition: dos.h:81
BYTE Reserved1[6]
Definition: dos.h:86
DWORD ActiveClock
Definition: dos.h:82
WORD ExtMemSize
Definition: dos.h:98
BYTE BootDrive
Definition: dos.h:96
DOS_DRIVER NullDevice
Definition: dos.h:89
BYTE UmbLinked
Definition: dos.h:100
DWORD DiskBuffer
Definition: dos.h:75
BYTE Reserved2
Definition: dos.h:90
#define NUM_DRIVES
Definition: dos.h:48
struct _DOS_DATA * PDOS_DATA
PBIOS_DATA BiosData
Definition: bios.c:42
struct _DOS_SDA DOS_SDA
CHAR DosReadCharacter(WORD FileHandle, BOOLEAN Echo)
Definition: bios.c:85
struct _DOS_FCB * PDOS_FCB
PDOS_SYSVARS SysVars
Definition: dos.c:47
BOOLEAN DosControlBreak(VOID)
Definition: dos.c:181
BOOLEAN DosKRNLInitialize(VOID)
Definition: dos.c:2264
struct _DOS_SYSVARS * PDOS_SYSVARS
struct _BIOS_DATA BIOS_DATA
struct _DOS_CLOCK_TRANSFER_RECORD DOS_CLOCK_TRANSFER_RECORD
VOID DosEchoCharacter(CHAR Character)
Definition: bios.c:48
struct _BIOS_DATA * PBIOS_DATA
struct _DOS_FIND_FILE_BLOCK DOS_FIND_FILE_BLOCK
PDOS_SDA Sda
Definition: dos.c:48
struct _DOS_DATA DOS_DATA
VOID DosPrintCharacter(WORD FileHandle, CHAR Character)
Definition: bios.c:152
struct _DOS_FCB DOS_FCB
struct _DOS_SYSVARS DOS_SYSVARS
struct _DOS_INPUT_BUFFER DOS_INPUT_BUFFER
struct _DOS_CLOCK_TRANSFER_RECORD * PDOS_CLOCK_TRANSFER_RECORD
BOOLEAN DosCheckInput(VOID)
Definition: bios.c:120
VOID ConDrvCleanup(VOID)
Definition: condrv.c:147
PDOS_DATA DosData
Definition: dos.c:45
CALLBACK16 DosContext
Definition: dos.c:40
struct _DOS_FIND_FILE_BLOCK * PDOS_FIND_FILE_BLOCK
struct _DOS_INPUT_BUFFER * PDOS_INPUT_BUFFER
BOOLEAN DosBIOSInitialize(VOID)
Definition: bios.c:221
VOID ConDrvInitialize(VOID)
Definition: condrv.c:132
#define DOS_DIR_LENGTH
Definition: dos.h:47
struct _DOS_SDA * PDOS_SDA
@ Echo
Definition: telnetd.h:64
#define ANYSIZE_ARRAY
Definition: typedefs.h:46
_Reserved_ PVOID Reserved
Definition: winddi.h:3974
unsigned char UCHAR
Definition: xmlstorage.h:181
char CHAR
Definition: xmlstorage.h:175
unsigned char BYTE
Definition: xxhash.c:193