ReactOS  0.4.14-dev-337-gf981a68
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 
122 typedef struct _DOS_FIND_FILE_BLOCK
123 {
129 
130  /* The following part of the structure is documented */
137 
138 // http://www.ctyme.com/intr/rb-3023.htm
139 typedef struct _DOS_SDA
140 {
145 
146  /* This is where the SDA really starts */
161 
162  /* This part is only valid while in DOS */
237 } DOS_SDA, *PDOS_SDA;
238 
239 /*
240  * DOS kernel data structure
241  */
242 typedef struct _DOS_DATA
243 {
246  WORD DosVersion; // DOS version to report to programs (can be different from the true one)
252 } DOS_DATA, *PDOS_DATA;
253 
254 /*
255  * DOS BIOS data structure at segment 70h
256  */
257 typedef struct _BIOS_DATA
258 {
259  BYTE StartupCode[20]; // 0x00 - 20 bytes: large enough for now!
260 
261 /*
262  * INT 13h (BIOS Disk Services) handler chain support.
263  *
264  * RomBiosInt13: The original INT 13h vector (normally from ROM BIOS).
265  * PrevInt13 : The previous INT 13h vector in the handler chain (initially
266  * initialized with the RomBiosInt13 value; each time some
267  * program calls INT 2Fh, AH=13h, PrevInt13 is updated).
268  *
269  * DOS hooks INT 13h with its own code, then (in normal circumstances) calls
270  * PrevInt13, so that when a program calls INT 13h, the DOS hook is first called,
271  * followed by the previous INT 13h (be it the original or some other hooked one).
272  * DOS may call PrevInt13 directly in some internal operations too.
273  * RomBiosInt13 is intended to be the original INT 13h vector that existed
274  * before DOS was loaded. A particular version of PC-AT's IBM's ROM BIOS
275  * (on systems with model byte FCh and BIOS date "01/10/84" only, see
276  * http://www.ctyme.com/intr/rb-4453.htm for more details) had a bug on disk
277  * reads so that it was patched by DOS, and therefore PrevInt13 was the fixed
278  * INT 13 interrupt (for the other cases, a direct call to RomBiosInt13 is done).
279  *
280  * NOTE: For compatibility with some programs (including virii), PrevInt13 should
281  * be at 0070:00B4, see for more details:
282  * http://repo.hackerzvoice.net/depot_madchat/vxdevl/vdat/tuvd0001.htm
283  * http://vxheaven.org/lib/vsm01.html
284  */
285  BYTE Padding0[0xB0 - /*FIELD_OFFSET(BIOS_DATA, StartupCode)*/ 20];
287  DWORD PrevInt13; // 0xb4
288  BYTE Padding1[0x100 - 0xB8]; // 0xb8
290 
291 C_ASSERT(sizeof(BIOS_DATA) == 0x100);
292 
293 #pragma pack(pop)
294 
295 /* VARIABLES ******************************************************************/
296 
297 extern PBIOS_DATA BiosData;
298 extern PDOS_DATA DosData;
299 extern PDOS_SYSVARS SysVars;
300 extern PDOS_SDA Sda;
301 
302 /* FUNCTIONS ******************************************************************/
303 
304 extern CALLBACK16 DosContext;
305 #define RegisterDosInt32(IntNumber, IntHandler) \
306 do { \
307  ASSERT((0x20 <= IntNumber) && (IntNumber <= 0x2F)); \
308  RegisterInt32(DosContext.TrampolineFarPtr + \
309  DosContext.TrampolineSize + \
310  (IntNumber - 0x20) * Int16To32StubSize, \
311  (IntNumber), (IntHandler), NULL); \
312 } while(0);
313 
316 
317 /*
318  * DOS BIOS Functions
319  * See bios.c
320  */
324 
326 
328 VOID DosEchoCharacter(CHAR Character);
329 
330 /*
331  * DOS Kernel Functions
332  * See dos.c
333  */
335 
336 #endif // _DOS_H_
337 
338 /* EOF */
BYTE Sft[ANYSIZE_ARRAY]
Definition: dos.h:251
WORD LastErrorCode
Definition: dos.h:151
Definition: dos.h:242
DWORD CurrentDirPointer
Definition: dos.h:222
BYTE Reserved4[0x1C]
Definition: dos.h:99
WORD Int21CallerDS
Definition: dos.h:234
BYTE MaxLength
Definition: dos.h:117
BYTE LastErrorLocus
Definition: dos.h:150
BYTE DosCallFlag
Definition: dos.h:208
#define DOS_DIR_LENGTH
Definition: dos.h:47
WORD CurrentPsp
Definition: dos.h:156
BYTE ByteBuffer
Definition: dos.h:193
BYTE LastErrorAction
Definition: dos.h:152
WORD NumDays
Definition: dos.h:179
BYTE CtrlBreakFlag
Definition: dos.h:173
WORD SecondArgument
Definition: dos.h:228
BYTE ErrorMode
Definition: dos.h:147
WORD NetworkPsp
Definition: dos.h:164
HANDLE SearchHandle
Definition: dos.h:128
#define ANYSIZE_ARRAY
Definition: typedefs.h:45
BYTE ParsedFcbExists
Definition: dos.h:211
WORD MemAllocScanStart
Definition: dos.h:103
DWORD PrevCallFrame
Definition: dos.h:236
BYTE InDos
Definition: dos.h:148
CHAR CurrentDirectory[81]
Definition: dos.h:197
CHAR CurrentDirectories[NUM_DRIVES][DOS_DIR_LENGTH]
Definition: dos.h:248
struct _BIOS_DATA * PBIOS_DATA
char CHAR
Definition: xmlstorage.h:175
BYTE DeviceNameFound
Definition: dos.h:206
BYTE PrinterEchoFlag
Definition: dos.h:141
DOS_DRIVER NullDevice
Definition: dos.h:89
struct _DOS_FCB DOS_FCB
BYTE DosStack[384]
Definition: dos.h:250
struct _DOS_DATA DOS_DATA
WORD LastAX
Definition: dos.h:163
WORD ExtMemSize
Definition: dos.h:98
struct _DOS_SYSVARS DOS_SYSVARS
BYTE Unused3
Definition: dos.h:188
WORD FirstArgument
Definition: dos.h:227
BYTE DirectoryFlag
Definition: dos.h:172
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:249
PDOS_SYSVARS SysVars
Definition: dos.c:47
BYTE FileOpenMode
Definition: dos.h:204
BYTE Unused6[8]
Definition: dos.h:200
VOID DosPrintCharacter(WORD FileHandle, CHAR Character)
Definition: bios.c:152
BYTE ExtendedBreakFlag
Definition: dos.h:160
BYTE NumBlockDevices
Definition: dos.h:87
DOS_SDA Sda
Definition: dos.h:247
struct _DOS_CLOCK_TRANSFER_RECORD * PDOS_CLOCK_TRANSFER_RECORD
WORD ErrorCodeTable
Definition: dos.h:191
WORD LastWriteTime
Definition: dos.h:62
BYTE Unused1
Definition: dos.h:175
UCHAR Attributes
Definition: dos.h:131
HANDLE FileHandle
Definition: stats.c:38
struct _DOS_SYSVARS * PDOS_SYSVARS
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude * include
Definition: asm.c:30
BYTE CurrentDrive
Definition: dos.h:159
WORD TransferOffset
Definition: dos.h:230
PDOS_DATA DosData
Definition: dos.c:45
CHAR CurrentSwitchChar
Definition: dos.h:142
BYTE Unused9[38]
Definition: dos.h:231
WORD Int24StackPointer
Definition: dos.h:218
DWORD CriticalErrorDpb
Definition: dos.h:216
BYTE DirSearchAttributes
Definition: dos.h:203
struct _DOS_INPUT_BUFFER DOS_INPUT_BUFFER
WORD Reserved5
Definition: dos.h:101
unsigned char BOOLEAN
DWORD FileSize
Definition: dos.h:134
WORD Int21CallerBX
Definition: dos.h:233
BYTE Reserved2
Definition: dos.h:90
BYTE Unused4
Definition: dos.h:194
BYTE Unused5[53]
Definition: dos.h:196
WORD Int21hReturn
Definition: dos.h:72
WORD UnreadConInput
Definition: dos.h:76
DWORD WorkingSft
Definition: dos.h:232
_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:217
BYTE SpliceFlag
Definition: dos.h:207
WORD MemorySize
Definition: dos.h:169
WORD LastSearchDirEntry
Definition: dos.h:170
DWORD CurrentDirs
Definition: dos.h:85
DOS_CLOCK_TRANSFER_RECORD ClockTransferRecord
Definition: dos.h:192
BOOLEAN DosControlBreak(VOID)
Definition: dos.c:181
WORD FirstMcb
Definition: dos.h:77
BYTE VolumeIDFlag
Definition: dos.h:212
DWORD DriverEntryPoint
Definition: dos.h:185
BYTE Unused7[5]
Definition: dos.h:209
DWORD OemHandler
Definition: dos.h:71
Definition: dos.h:53
BYTE InsertMode
Definition: dos.h:210
BYTE OemNumber
Definition: dos.h:190
BYTE FileFound
Definition: dos.h:205
BYTE ExtendedAttribute
Definition: dos.h:201
BYTE FcbType
Definition: dos.h:202
DWORD CurrentSft
Definition: dos.h:221
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:144
WORD ProgramVersionTable
Definition: dos.h:91
UCHAR AttribMask
Definition: dos.h:126
DOS_RW_REQUEST Request
Definition: dos.h:184
BYTE FileDeletedChar
Definition: dos.h:215
unsigned short WORD
Definition: ntddk_ex.h:93
BYTE ConsoleSwappedFlag
Definition: dos.h:181
unsigned long DWORD
Definition: ntddk_ex.h:95
BYTE UserNumber[3]
Definition: dos.h:189
CHAR FcbRenameDest[12]
Definition: dos.h:199
struct _DOS_DATA * PDOS_DATA
C_ASSERT(sizeof(BIOS_DATA)==0x100)
BYTE DayOfWeek
Definition: dos.h:180
WORD LastComponent
Definition: dos.h:229
CHAR FcbFilename[12]
Definition: dos.h:198
struct _DOS_SDA DOS_SDA
unsigned char UCHAR
Definition: xmlstorage.h:181
BYTE Int24AbortFlag
Definition: dos.h:183
BYTE RecordNumber[3]
Definition: dos.h:65
DWORD CallerFcb
Definition: dos.h:223
BYTE Int28CallOk
Definition: dos.h:182
WORD NetworkMachineNumber
Definition: dos.h:165
BYTE Month
Definition: dos.h:177
CHAR Pattern[11]
Definition: dos.h:125
unsigned char BYTE
Definition: mem.h:68
CALLBACK16 DosContext
Definition: dos.c:40
BYTE NullDriverRoutine[7]
Definition: dos.h:245
VOID ConDrvCleanup(VOID)
Definition: condrv.c:147
BYTE UmbLinked
Definition: dos.h:100
WORD ShareRetryDelay
Definition: dos.h:74
BOOLEAN DosBIOSInitialize(VOID)
Definition: bios.c:221
WORD ErrorLevel
Definition: dos.h:158
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:155
WORD Year
Definition: dos.h:178
WORD FirstFreeMcb
Definition: dos.h:166
DWORD PrevInt13
Definition: dos.h:287
DWORD FileSize
Definition: dos.h:60
WORD SftNumber
Definition: dos.h:224
BYTE AllowFcbBlanks
Definition: dos.h:174
DOS_SYSVARS SysVars
Definition: dos.h:244
BYTE PspCopyType
Definition: dos.h:187
struct _DOS_FIND_FILE_BLOCK DOS_FIND_FILE_BLOCK
BYTE ErrorDrive
Definition: dos.h:149
BYTE Int24FailFlag
Definition: dos.h:171
BOOLEAN DosCheckInput(VOID)
Definition: bios.c:120
WORD Int23StackPointer
Definition: dos.h:157
DWORD FirstSft
Definition: dos.h:81
BYTE StartupCode[20]
Definition: dos.h:259
WORD LastFreeMcb
Definition: dos.h:168
BYTE Unused8[14]
Definition: dos.h:219
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:153
CHAR FileNameBuffer[256]
Definition: dos.h:195
WORD BestFreeMcb
Definition: dos.h:167
WORD UmbChainStart
Definition: dos.h:102
DWORD JftEntry
Definition: dos.h:226
BYTE Padding0[0xB0 - 20]
Definition: dos.h:285
BYTE BootDrive
Definition: dos.h:96
WORD RecordSize
Definition: dos.h:59
BYTE Padding1[0x100 - 0xB8]
Definition: dos.h:288
WORD TempFileHandle
Definition: dos.h:225
DWORD DiskBuffer
Definition: dos.h:75
CHAR DosReadCharacter(WORD FileHandle, BOOLEAN Echo)
Definition: bios.c:85
BYTE TerminationType
Definition: dos.h:213
BYTE DriveNumber
Definition: dos.h:55
BYTE Length
Definition: dos.h:118
BYTE AllocStrategy
Definition: dos.h:143
WORD DosVersion
Definition: dos.h:246
Definition: dos.h:139
BYTE BlockRecord
Definition: dos.h:64
BYTE CreateFileFlag
Definition: dos.h:214
WORD LastWriteDate
Definition: dos.h:61
DWORD FirstDpb
Definition: dos.h:80
DWORD RomBiosInt13
Definition: dos.h:286
DWORD DeviceHeader
Definition: dos.h:220
BYTE Unused2[44]
Definition: dos.h:186
CHAR DriveLetter
Definition: dos.h:124
BOOLEAN DosKRNLInitialize(VOID)
Definition: dos.c:2253
Definition: telnetd.h:64
WORD Unused10
Definition: dos.h:235
DWORD LastErrorPointer
Definition: dos.h:154
WORD Reserved3[2]
Definition: dos.h:93
BYTE DayOfMonth
Definition: dos.h:176
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