ReactOS  0.4.15-dev-4857-g47842d7
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 
53 typedef struct _DOS_FCB
54 {
66 } DOS_FCB, *PDOS_FCB;
67 
68 // http://www.ctyme.com/intr/rb-2983.htm
69 typedef struct _DOS_SYSVARS
70 {
78 
79  /* This is where the SYSVARS really start */
80  DWORD FirstDpb; // 0x00
81  DWORD FirstSft; // 0x04
82  DWORD ActiveClock; // 0x08
83  DWORD ActiveCon; // 0x0c
84  BYTE Reserved0[6]; // 0x10
85  DWORD CurrentDirs; // 0x16
86  BYTE Reserved1[6]; // 0x1a
88  BYTE NumLocalDrives; // 0x21 - Set by LASTDRIVE
90  BYTE Reserved2; // 0x34
92  DWORD SetVerTable; // 0x37
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
98  WORD ExtMemSize; // 0x45
99  BYTE Reserved4[0x1C]; // 0x47
100  BYTE UmbLinked; // 0x63 - 0/1: UMB chain (un)linked to MCB chain
101  WORD Reserved5; // 0x64
102  WORD UmbChainStart; // 0x66 - Segment of the first UMB MCB
103  WORD MemAllocScanStart; // 0x68 - Segment where allocation scan starts
105 
107 {
114 
115 typedef struct _DOS_INPUT_BUFFER
116 {
121 
130 typedef struct _DOS_FIND_FILE_BLOCK
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
148 typedef struct _DOS_SDA
149 {
154 
155  /* This is where the SDA really starts */
170 
171  /* This part is only valid while in DOS */
246 } DOS_SDA, *PDOS_SDA;
247 
248 /*
249  * DOS kernel data structure
250  */
251 typedef struct _DOS_DATA
252 {
255  WORD DosVersion; // DOS version to report to programs (can be different from the true one)
261 } DOS_DATA, *PDOS_DATA;
262 
263 /*
264  * DOS BIOS data structure at segment 70h
265  */
266 typedef 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];
296  DWORD PrevInt13; // 0xb4
297  BYTE Padding1[0x100 - 0xB8]; // 0xb8
299 
300 C_ASSERT(sizeof(BIOS_DATA) == 0x100);
301 
302 #pragma pack(pop)
303 
304 /* VARIABLES ******************************************************************/
305 
306 extern PBIOS_DATA BiosData;
307 extern PDOS_DATA DosData;
308 extern PDOS_SYSVARS SysVars;
309 extern PDOS_SDA Sda;
310 
311 /* FUNCTIONS ******************************************************************/
312 
313 extern CALLBACK16 DosContext;
314 #define RegisterDosInt32(IntNumber, IntHandler) \
315 do { \
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 
337 VOID DosEchoCharacter(CHAR Character);
338 
339 /*
340  * DOS Kernel Functions
341  * See dos.c
342  */
344 
345 #endif // _DOS_H_
346 
347 /* EOF */
BYTE Sft[ANYSIZE_ARRAY]
Definition: dos.h:260
WORD LastErrorCode
Definition: dos.h:160
Definition: dos.h:251
DWORD CurrentDirPointer
Definition: dos.h:231
BYTE Reserved4[0x1C]
Definition: dos.h:99
WORD Int21CallerDS
Definition: dos.h:243
BYTE MaxLength
Definition: dos.h:117
BYTE LastErrorLocus
Definition: dos.h:159
BYTE DosCallFlag
Definition: dos.h:217
#define DOS_DIR_LENGTH
Definition: dos.h:47
WORD CurrentPsp
Definition: dos.h:165
BYTE ByteBuffer
Definition: dos.h:202
BYTE LastErrorAction
Definition: dos.h:161
WORD NumDays
Definition: dos.h:188
BYTE CtrlBreakFlag
Definition: dos.h:182
WORD SecondArgument
Definition: dos.h:237
BYTE ErrorMode
Definition: dos.h:156
WORD NetworkPsp
Definition: dos.h:173
HANDLE SearchHandle
Definition: dos.h:137
#define ANYSIZE_ARRAY
Definition: typedefs.h:46
BYTE ParsedFcbExists
Definition: dos.h:220
WORD MemAllocScanStart
Definition: dos.h:103
DWORD PrevCallFrame
Definition: dos.h:245
BYTE InDos
Definition: dos.h:157
CHAR CurrentDirectory[81]
Definition: dos.h:206
CHAR CurrentDirectories[NUM_DRIVES][DOS_DIR_LENGTH]
Definition: dos.h:257
struct _BIOS_DATA * PBIOS_DATA
char CHAR
Definition: xmlstorage.h:175
BYTE DeviceNameFound
Definition: dos.h:215
BYTE PrinterEchoFlag
Definition: dos.h:150
DOS_DRIVER NullDevice
Definition: dos.h:89
struct _DOS_FCB DOS_FCB
BYTE DosStack[384]
Definition: dos.h:259
struct _DOS_DATA DOS_DATA
WORD LastAX
Definition: dos.h:172
WORD ExtMemSize
Definition: dos.h:98
struct _DOS_SYSVARS DOS_SYSVARS
BYTE Unused3
Definition: dos.h:197
WORD FirstArgument
Definition: dos.h:236
BYTE DirectoryFlag
Definition: dos.h:181
struct _DOS_SDA * PDOS_SDA
struct _BIOS_DATA BIOS_DATA
BYTE Reserved1[6]
Definition: dos.h:86
WORD ShareRetryCount
Definition: dos.h:73
BYTE UnreadConInputBuffer[128]
Definition: dos.h:258
PDOS_SYSVARS SysVars
Definition: dos.c:47
BYTE FileOpenMode
Definition: dos.h:213
BYTE Unused6[8]
Definition: dos.h:209
VOID DosPrintCharacter(WORD FileHandle, CHAR Character)
Definition: bios.c:152
BYTE ExtendedBreakFlag
Definition: dos.h:169
BYTE NumBlockDevices
Definition: dos.h:87
DOS_SDA Sda
Definition: dos.h:256
struct _DOS_CLOCK_TRANSFER_RECORD * PDOS_CLOCK_TRANSFER_RECORD
WORD ErrorCodeTable
Definition: dos.h:200
WORD LastWriteTime
Definition: dos.h:62
BYTE Unused1
Definition: dos.h:184
UCHAR Attributes
Definition: dos.h:140
struct _DOS_SYSVARS * PDOS_SYSVARS
BYTE CurrentDrive
Definition: dos.h:168
WORD TransferOffset
Definition: dos.h:239
PDOS_DATA DosData
Definition: dos.c:45
CHAR CurrentSwitchChar
Definition: dos.h:151
BYTE Unused9[38]
Definition: dos.h:240
WORD Int24StackPointer
Definition: dos.h:227
DWORD CriticalErrorDpb
Definition: dos.h:225
BYTE DirSearchAttributes
Definition: dos.h:212
struct _DOS_INPUT_BUFFER DOS_INPUT_BUFFER
#define _Null_terminated_
Definition: ms_sal.h:640
WORD Reserved5
Definition: dos.h:101
unsigned char BOOLEAN
DWORD FileSize
Definition: dos.h:143
WORD Int21CallerBX
Definition: dos.h:242
BYTE Reserved2
Definition: dos.h:90
BYTE Unused4
Definition: dos.h:203
BYTE Unused5[53]
Definition: dos.h:205
WORD Int21hReturn
Definition: dos.h:72
WORD UnreadConInput
Definition: dos.h:76
DWORD WorkingSft
Definition: dos.h:241
_Reserved_ PVOID Reserved
Definition: winddi.h:3974
DWORD ActiveCon
Definition: dos.h:83
Definition: bufpool.h:45
WORD BlockNumber
Definition: dos.h:58
struct _DOS_INPUT_BUFFER * PDOS_INPUT_BUFFER
DWORD ActiveClock
Definition: dos.h:82
DWORD UserRegistersStack
Definition: dos.h:226
BYTE SpliceFlag
Definition: dos.h:216
WORD MemorySize
Definition: dos.h:178
WORD LastSearchDirEntry
Definition: dos.h:179
DWORD CurrentDirs
Definition: dos.h:85
DOS_CLOCK_TRANSFER_RECORD ClockTransferRecord
Definition: dos.h:201
BOOLEAN DosControlBreak(VOID)
Definition: dos.c:181
WORD FirstMcb
Definition: dos.h:77
BYTE VolumeIDFlag
Definition: dos.h:221
DWORD DriverEntryPoint
Definition: dos.h:194
BYTE Unused7[5]
Definition: dos.h:218
DWORD OemHandler
Definition: dos.h:71
Definition: dos.h:53
BYTE InsertMode
Definition: dos.h:219
BYTE OemNumber
Definition: dos.h:199
BYTE FileFound
Definition: dos.h:214
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude * include
Definition: asm.c:30
BYTE ExtendedAttribute
Definition: dos.h:210
BYTE FcbType
Definition: dos.h:211
DWORD CurrentSft
Definition: dos.h:230
struct _DOS_FCB * PDOS_FCB
struct _DOS_FIND_FILE_BLOCK * PDOS_FIND_FILE_BLOCK
VOID DosEchoCharacter(CHAR Character)
Definition: bios.c:48
WORD BuffersLookaheadNumber
Definition: dos.h:95
BYTE Unused0[28]
Definition: dos.h:153
WORD ProgramVersionTable
Definition: dos.h:91
UCHAR AttribMask
Definition: dos.h:135
DOS_RW_REQUEST Request
Definition: dos.h:193
BYTE FileDeletedChar
Definition: dos.h:224
unsigned short WORD
Definition: ntddk_ex.h:93
BYTE ConsoleSwappedFlag
Definition: dos.h:190
unsigned long DWORD
Definition: ntddk_ex.h:95
BYTE UserNumber[3]
Definition: dos.h:198
CHAR FcbRenameDest[12]
Definition: dos.h:208
struct _DOS_DATA * PDOS_DATA
C_ASSERT(sizeof(BIOS_DATA)==0x100)
BYTE DayOfWeek
Definition: dos.h:189
WORD LastComponent
Definition: dos.h:238
CHAR FcbFilename[12]
Definition: dos.h:207
struct _DOS_SDA DOS_SDA
unsigned char UCHAR
Definition: xmlstorage.h:181
BYTE Int24AbortFlag
Definition: dos.h:192
BYTE RecordNumber[3]
Definition: dos.h:65
DWORD CallerFcb
Definition: dos.h:232
BYTE Int28CallOk
Definition: dos.h:191
WORD NetworkMachineNumber
Definition: dos.h:174
BYTE Month
Definition: dos.h:186
CHAR Pattern[11]
Definition: dos.h:134
CALLBACK16 DosContext
Definition: dos.c:40
BYTE NullDriverRoutine[7]
Definition: dos.h:254
VOID ConDrvCleanup(VOID)
Definition: condrv.c:147
BYTE UmbLinked
Definition: dos.h:100
WORD ShareRetryDelay
Definition: dos.h:74
unsigned char BYTE
Definition: xxhash.c:193
BOOLEAN DosBIOSInitialize(VOID)
Definition: bios.c:221
WORD ErrorLevel
Definition: dos.h:167
BYTE NumLocalDrives
Definition: dos.h:88
DWORD SetVerTable
Definition: dos.h:92
CHAR FileExt[3]
Definition: dos.h:57
VOID ConDrvInitialize(VOID)
Definition: condrv.c:132
DWORD DiskTransferArea
Definition: dos.h:164
WORD Year
Definition: dos.h:187
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1230
WORD FirstFreeMcb
Definition: dos.h:175
DWORD PrevInt13
Definition: dos.h:296
DWORD FileSize
Definition: dos.h:60
WORD SftNumber
Definition: dos.h:233
BYTE AllowFcbBlanks
Definition: dos.h:183
DOS_SYSVARS SysVars
Definition: dos.h:253
BYTE PspCopyType
Definition: dos.h:196
struct _DOS_FIND_FILE_BLOCK DOS_FIND_FILE_BLOCK
BYTE ErrorDrive
Definition: dos.h:158
BYTE Int24FailFlag
Definition: dos.h:180
BOOLEAN DosCheckInput(VOID)
Definition: bios.c:120
WORD Int23StackPointer
Definition: dos.h:166
DWORD FirstSft
Definition: dos.h:81
BYTE StartupCode[20]
Definition: dos.h:268
WORD LastFreeMcb
Definition: dos.h:177
BYTE Unused8[14]
Definition: dos.h:228
struct _DOS_CLOCK_TRANSFER_RECORD DOS_CLOCK_TRANSFER_RECORD
WORD BuffersNumber
Definition: dos.h:94
BYTE UseDwordMoves
Definition: dos.h:97
BYTE LastErrorClass
Definition: dos.h:162
CHAR FileNameBuffer[256]
Definition: dos.h:204
WORD BestFreeMcb
Definition: dos.h:176
WORD UmbChainStart
Definition: dos.h:102
DWORD JftEntry
Definition: dos.h:235
BYTE Padding0[0xB0 - 20]
Definition: dos.h:294
BYTE BootDrive
Definition: dos.h:96
WORD RecordSize
Definition: dos.h:59
BYTE Padding1[0x100 - 0xB8]
Definition: dos.h:297
WORD TempFileHandle
Definition: dos.h:234
DWORD DiskBuffer
Definition: dos.h:75
CHAR DosReadCharacter(WORD FileHandle, BOOLEAN Echo)
Definition: bios.c:85
BYTE TerminationType
Definition: dos.h:222
BYTE DriveNumber
Definition: dos.h:55
BYTE Length
Definition: dos.h:118
BYTE AllocStrategy
Definition: dos.h:152
WORD DosVersion
Definition: dos.h:255
Definition: dos.h:148
BYTE BlockRecord
Definition: dos.h:64
BYTE CreateFileFlag
Definition: dos.h:223
WORD LastWriteDate
Definition: dos.h:61
DWORD FirstDpb
Definition: dos.h:80
DWORD RomBiosInt13
Definition: dos.h:295
DWORD DeviceHeader
Definition: dos.h:229
BYTE Unused2[44]
Definition: dos.h:195
CHAR DriveLetter
Definition: dos.h:133
BOOLEAN DosKRNLInitialize(VOID)
Definition: dos.c:2264
Definition: telnetd.h:64
WORD Unused10
Definition: dos.h:244
DWORD LastErrorPointer
Definition: dos.h:163
WORD Reserved3[2]
Definition: dos.h:93
BYTE DayOfMonth
Definition: dos.h:185
BYTE Reserved0[6]
Definition: dos.h:84
PDOS_SDA Sda
Definition: dos.c:48
PBIOS_DATA BiosData
Definition: bios.c:42
#define NUM_DRIVES
Definition: dos.h:48