ReactOS  0.4.14-dev-317-g96040ec
dos.h File Reference
#include "device.h"
#include "int32.h"
Include dependency graph for dos.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _DOS_FCB
 
struct  _DOS_SYSVARS
 
struct  _DOS_CLOCK_TRANSFER_RECORD
 
struct  _DOS_INPUT_BUFFER
 
struct  _DOS_FIND_FILE_BLOCK
 
struct  _DOS_SDA
 
struct  _DOS_DATA
 
struct  _BIOS_DATA
 

Macros

#define DOS_VERSION   MAKEWORD(5, 00)
 
#define NTDOS_VERSION   MAKEWORD(5, 50)
 
#define DOS_CONFIG_PATH   L"%SystemRoot%\\system32\\CONFIG.NT"
 
#define DOS_COMMAND_INTERPRETER   L"%SystemRoot%\\system32\\COMMAND.COM /k %SystemRoot%\\system32\\AUTOEXEC.NT"
 
#define BIOS_CODE_SEGMENT   0x70
 
#define BIOS_DATA_SEGMENT   0x70
 
#define DOS_CODE_SEGMENT   0x80
 
#define DOS_DATA_SEGMENT   0xA5
 
#define DOS_DATA_OFFSET(x)   FIELD_OFFSET(DOS_DATA, x)
 
#define SYSTEM_ENV_BLOCK   0x600
 
#define SYSTEM_PSP   0x0008
 
#define INVALID_DOS_HANDLE   0xFFFF
 
#define DOS_INPUT_HANDLE   0
 
#define DOS_OUTPUT_HANDLE   1
 
#define DOS_ERROR_HANDLE   2
 
#define DOS_SFT_SIZE   255
 
#define DOS_DIR_LENGTH   64
 
#define NUM_DRIVES   ('Z' - 'A' + 1)
 
#define DOS_CHAR_ATTRIBUTE   0x07
 
#define RegisterDosInt32(IntNumber, IntHandler)
 

Typedefs

typedef struct _DOS_FCB DOS_FCB
 
typedef struct _DOS_FCBPDOS_FCB
 
typedef struct _DOS_SYSVARS DOS_SYSVARS
 
typedef struct _DOS_SYSVARSPDOS_SYSVARS
 
typedef struct _DOS_CLOCK_TRANSFER_RECORD DOS_CLOCK_TRANSFER_RECORD
 
typedef struct _DOS_CLOCK_TRANSFER_RECORDPDOS_CLOCK_TRANSFER_RECORD
 
typedef struct _DOS_INPUT_BUFFER DOS_INPUT_BUFFER
 
typedef struct _DOS_INPUT_BUFFERPDOS_INPUT_BUFFER
 
typedef struct _DOS_FIND_FILE_BLOCK DOS_FIND_FILE_BLOCK
 
typedef struct _DOS_FIND_FILE_BLOCKPDOS_FIND_FILE_BLOCK
 
typedef struct _DOS_SDA DOS_SDA
 
typedef struct _DOS_SDAPDOS_SDA
 
typedef struct _DOS_DATA DOS_DATA
 
typedef struct _DOS_DATAPDOS_DATA
 
typedef struct _BIOS_DATA BIOS_DATA
 
typedef struct _BIOS_DATAPBIOS_DATA
 

Functions

 C_ASSERT (sizeof(BIOS_DATA)==0x100)
 
VOID ConDrvInitialize (VOID)
 
VOID ConDrvCleanup (VOID)
 
CHAR DosReadCharacter (WORD FileHandle, BOOLEAN Echo)
 
BOOLEAN DosCheckInput (VOID)
 
VOID DosPrintCharacter (WORD FileHandle, CHAR Character)
 
BOOLEAN DosBIOSInitialize (VOID)
 
BOOLEAN DosControlBreak (VOID)
 
VOID DosEchoCharacter (CHAR Character)
 
BOOLEAN DosKRNLInitialize (VOID)
 

Variables

PBIOS_DATA BiosData
 
PDOS_DATA DosData
 
PDOS_SYSVARS SysVars
 
PDOS_SDA Sda
 
CALLBACK16 DosContext
 

Macro Definition Documentation

◆ BIOS_CODE_SEGMENT

#define BIOS_CODE_SEGMENT   0x70

Definition at line 30 of file dos.h.

◆ BIOS_DATA_SEGMENT

#define BIOS_DATA_SEGMENT   0x70

Definition at line 31 of file dos.h.

◆ DOS_CHAR_ATTRIBUTE

#define DOS_CHAR_ATTRIBUTE   0x07

Definition at line 49 of file dos.h.

◆ DOS_CODE_SEGMENT

#define DOS_CODE_SEGMENT   0x80

Definition at line 32 of file dos.h.

◆ DOS_COMMAND_INTERPRETER

#define DOS_COMMAND_INTERPRETER   L"%SystemRoot%\\system32\\COMMAND.COM /k %SystemRoot%\\system32\\AUTOEXEC.NT"

Definition at line 28 of file dos.h.

◆ DOS_CONFIG_PATH

#define DOS_CONFIG_PATH   L"%SystemRoot%\\system32\\CONFIG.NT"

Definition at line 27 of file dos.h.

◆ DOS_DATA_OFFSET

#define DOS_DATA_OFFSET (   x)    FIELD_OFFSET(DOS_DATA, x)

Definition at line 35 of file dos.h.

◆ DOS_DATA_SEGMENT

#define DOS_DATA_SEGMENT   0xA5

Definition at line 33 of file dos.h.

◆ DOS_DIR_LENGTH

#define DOS_DIR_LENGTH   64

Definition at line 47 of file dos.h.

◆ DOS_ERROR_HANDLE

#define DOS_ERROR_HANDLE   2

Definition at line 44 of file dos.h.

◆ DOS_INPUT_HANDLE

#define DOS_INPUT_HANDLE   0

Definition at line 42 of file dos.h.

◆ DOS_OUTPUT_HANDLE

#define DOS_OUTPUT_HANDLE   1

Definition at line 43 of file dos.h.

◆ DOS_SFT_SIZE

#define DOS_SFT_SIZE   255

Definition at line 46 of file dos.h.

◆ DOS_VERSION

#define DOS_VERSION   MAKEWORD(5, 00)

Definition at line 24 of file dos.h.

◆ INVALID_DOS_HANDLE

#define INVALID_DOS_HANDLE   0xFFFF

Definition at line 41 of file dos.h.

◆ NTDOS_VERSION

#define NTDOS_VERSION   MAKEWORD(5, 50)

Definition at line 25 of file dos.h.

◆ NUM_DRIVES

#define NUM_DRIVES   ('Z' - 'A' + 1)

Definition at line 48 of file dos.h.

◆ RegisterDosInt32

#define RegisterDosInt32 (   IntNumber,
  IntHandler 
)
Value:
do { \
ASSERT((0x20 <= IntNumber) && (IntNumber <= 0x2F)); \
RegisterInt32(DosContext.TrampolineFarPtr + \
(IntNumber - 0x20) * Int16To32StubSize, \
(IntNumber), (IntHandler), NULL); \
} while(0);
ULONG TrampolineFarPtr
Definition: callback.h:28
smooth NULL
Definition: ftsmooth.c:416
#define Int16To32StubSize
Definition: int32.h:38
CALLBACK16 DosContext
Definition: dos.c:40
ULONG TrampolineSize
Definition: callback.h:29

Definition at line 305 of file dos.h.

◆ SYSTEM_ENV_BLOCK

#define SYSTEM_ENV_BLOCK   0x600

Definition at line 37 of file dos.h.

◆ SYSTEM_PSP

#define SYSTEM_PSP   0x0008

Definition at line 39 of file dos.h.

Typedef Documentation

◆ BIOS_DATA

◆ DOS_CLOCK_TRANSFER_RECORD

◆ DOS_DATA

◆ DOS_FCB

◆ DOS_FIND_FILE_BLOCK

◆ DOS_INPUT_BUFFER

◆ DOS_SDA

◆ DOS_SYSVARS

◆ PBIOS_DATA

◆ PDOS_CLOCK_TRANSFER_RECORD

◆ PDOS_DATA

◆ PDOS_FCB

◆ PDOS_FIND_FILE_BLOCK

◆ PDOS_INPUT_BUFFER

◆ PDOS_SDA

◆ PDOS_SYSVARS

Function Documentation

◆ C_ASSERT()

C_ASSERT ( sizeof(BIOS_DATA = =0x100)

◆ ConDrvCleanup()

VOID ConDrvCleanup ( VOID  )

Definition at line 147 of file condrv.c.

148 {
149  if (Con) DosDeleteDevice(Con);
150 }
VOID DosDeleteDevice(PDOS_DEVICE_NODE DeviceNode)
Definition: device.c:419
PDOS_DEVICE_NODE Con
Definition: condrv.c:26

◆ ConDrvInitialize()

VOID ConDrvInitialize ( VOID  )

Definition at line 132 of file condrv.c.

133 {
138  "CON");
139 
145 }
#define DOS_DEVATTR_CON
Definition: device.h:25
WORD NTAPI ConDrvInputStatus(PDOS_DEVICE_NODE Device)
Definition: condrv.c:79
WORD NTAPI ConDrvClose(PDOS_DEVICE_NODE Device)
Definition: condrv.c:124
PDOS_DEVICE_NODE DosCreateDevice(WORD Attributes, PCHAR DeviceName)
Definition: device.c:413
PDOS_DEVICE_GENERIC_ROUTINE OpenRoutine
Definition: device.h:101
PDOS_DEVICE_IO_ROUTINE WriteRoutine
Definition: device.h:98
WORD NTAPI ConDrvReadInput(PDOS_DEVICE_NODE Device, DWORD Buffer, PWORD Length)
Definition: condrv.c:31
PDOS_DEVICE_NODE Con
Definition: condrv.c:26
PDOS_DEVICE_GENERIC_ROUTINE CloseRoutine
Definition: device.h:102
WORD NTAPI ConDrvWriteOutput(PDOS_DEVICE_NODE Device, DWORD Buffer, PWORD Length)
Definition: condrv.c:96
#define DOS_DEVATTR_CHARACTER
Definition: device.h:29
WORD NTAPI ConDrvOpen(PDOS_DEVICE_NODE Device)
Definition: condrv.c:118
PDOS_DEVICE_GENERIC_ROUTINE InputStatusRoutine
Definition: device.h:95
PDOS_DEVICE_IO_ROUTINE ReadRoutine
Definition: device.h:93
#define DOS_DEVATTR_STDOUT
Definition: device.h:22
#define DOS_DEVATTR_STDIN
Definition: device.h:21

Referenced by DosKRNLInitialize().

◆ DosBIOSInitialize()

BOOLEAN DosBIOSInitialize ( VOID  )

setBP(0x091E); // DOS base stack pointer relic value

Definition at line 221 of file bios.c.

222 {
223  FILE *Stream;
224  WCHAR Buffer[256];
225 
226  /* Set the data segment */
228 
229  /* Initialize the global DOS BIOS data area */
231 
232  /* Initialize the DOS BIOS stack */
233  // FIXME: Add a block of fixed size for the stack in BIOS/DOS_DATA instead!
234  setSS(0x0F00);
235  setSP(0x0FF0);
237 
238  /*
239  * Initialize the INT 13h (BIOS Disk Services) handler chain support.
240  *
241  * The INT 13h handler chain is some functionality that allows DOS
242  * to insert disk filter drivers in between the (hooked) INT 13h handler
243  * and its original handler.
244  * Typically, those are:
245  * - filter for detecting disk changes (for floppy disks),
246  * - filter for tracking formatting calls and correcting DMA boundary errors,
247  * - a possible filter to work around a bug in a particular version of PC-AT's
248  * IBM's ROM BIOS (on systems with model byte FCh and BIOS date "01/10/84" only)
249  * (see http://www.ctyme.com/intr/rb-4453.htm for more details).
250  *
251  * This functionality is known to be used by some legitimate programs,
252  * by Windows 3.x, as well as some illegitimate ones (aka. virii).
253  *
254  * See extra information about this support in dos.h
255  */
256  // FIXME: Should be done by the DOS BIOS
259 // RegisterDosInt32(0x13, DosInt13h); // Unused at the moment!
260 
261  //
262  // HERE: Do all hardware initialization needed for DOS
263  //
264 
265  /*
266  * SysInit part...
267  */
268 
269  /* Initialize the DOS kernel (DosInit) */
270  if (!DosKRNLInitialize())
271  {
272  BiosDisplayMessage("Failed to load the DOS kernel! Exiting...\n");
273  return FALSE;
274  }
275 
276  /* DOS kernel loading succeeded, we can finish the initialization */
277 
278  /* Build the system master (pre-) environment block (inherited by the shell) */
279  if (!DosBuildSysEnvBlock())
280  {
281  DosDisplayMessage("An error occurred when setting up the system environment block.\n");
282  }
283 
284  /* TODO: Read CONFIG.NT/SYS */
286  if (Stream != NULL)
287  {
288  while (fgetws(Buffer, ARRAYSIZE(Buffer), Stream))
289  {
290  // TODO: Parse the line
291  }
292  fclose(Stream);
293  }
294 
295  return TRUE;
296 }
#define TRUE
Definition: types.h:120
_Check_return_ _CRTIMP FILE *__cdecl _wfopen(_In_z_ const wchar_t *_Filename, _In_z_ const wchar_t *_Mode)
struct _BIOS_DATA * PBIOS_DATA
VOID WINAPI setDS(USHORT)
Definition: registers.c:515
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define DosDisplayMessage(Format,...)
Definition: dem.h:37
#define SEG_OFF_TO_PTR(seg, off)
Definition: emulator.h:28
VOID WINAPI setSP(USHORT)
Definition: registers.c:351
VOID WINAPI setSS(USHORT)
Definition: registers.c:501
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
BOOLEAN DosKRNLInitialize(VOID)
Definition: dos.c:2253
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR L[]
Definition: oid.c:1250
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
DWORD PrevInt13
Definition: dos.h:287
#define BIOS_DATA_SEGMENT
Definition: dos.h:31
unsigned int * PULONG
Definition: retypes.h:1
wchar_t * fgetws(wchar_t *buf, int bufsize, FILE *file)
Definition: wmain.c:22
BOOLEAN DosBuildSysEnvBlock(VOID)
Definition: bios.c:165
#define DOS_CONFIG_PATH
Definition: dos.h:27
DWORD RomBiosInt13
Definition: dos.h:286
_Inout_opt_ PUNICODE_STRING _Inout_opt_ PUNICODE_STRING Stream
Definition: fltkernel.h:1092
PBIOS_DATA BiosData
Definition: bios.c:42
#define BiosDisplayMessage(Format,...)
Definition: dem.h:33

Referenced by DosStart().

◆ DosCheckInput()

BOOLEAN DosCheckInput ( VOID  )

Definition at line 120 of file bios.c.

121 {
123 
124  if (Descriptor == NULL)
125  {
126  /* Invalid handle */
127  Sda->LastErrorCode = ERROR_INVALID_HANDLE; // ERROR_FILE_NOT_FOUND
128  return FALSE;
129  }
130 
131  if (Descriptor->DeviceInfo & FILE_INFO_DEVICE)
132  {
133  WORD Result;
135 
136  if (!Node->InputStatusRoutine) return FALSE;
137 
138  Result = Node->InputStatusRoutine(Node);
139  return !(Result & DOS_DEVSTAT_BUSY);
140  }
141  else
142  {
143  DWORD FileSizeHigh;
144  DWORD FileSize = GetFileSize(Descriptor->Win32Handle, &FileSizeHigh);
145  LONG LocationHigh = 0;
146  DWORD Location = SetFilePointer(Descriptor->Win32Handle, 0, &LocationHigh, FILE_CURRENT);
147 
148  return ((Location != FileSize) || (LocationHigh != FileSizeHigh));
149  }
150 }
WORD LastErrorCode
Definition: dos.h:151
#define DOS_INPUT_HANDLE
Definition: dos.h:42
#define FILE_CURRENT
Definition: winbase.h:113
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
DWORD WINAPI DECLSPEC_HOTPATCH SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod)
Definition: fileinfo.c:204
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
PDOS_FILE_DESCRIPTOR DosGetHandleFileDescriptor(WORD DosHandle)
Definition: dosfiles.c:173
#define FILE_INFO_DEVICE
Definition: dosfiles.h:16
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:481
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
PDOS_SDA Sda
Definition: dos.c:48
#define DOS_DEVSTAT_BUSY
Definition: device.h:50
PDOS_DEVICE_NODE DosGetDriverNode(DWORD Driver)
Definition: device.c:305
Definition: dlist.c:348
_In_ PSTORAGE_PROPERTY_ID _Outptr_ PSTORAGE_DESCRIPTOR_HEADER * Descriptor
Definition: classpnp.h:966

Referenced by DosInt21h().

◆ DosControlBreak()

BOOLEAN DosControlBreak ( VOID  )

Definition at line 181 of file dos.c.

182 {
183  setCF(0);
184 
185  /* Print an extra newline */
188 
189  /* Call interrupt 0x23 */
190  Int32Call(&DosContext, 0x23);
191 
192  if (getCF())
193  {
195  return TRUE;
196  }
197 
198  return FALSE;
199 }
#define DOS_OUTPUT_HANDLE
Definition: dos.h:43
WORD CurrentPsp
Definition: dos.h:156
#define TRUE
Definition: types.h:120
VOID Int32Call(IN PCALLBACK16 Context, IN BYTE IntNumber)
Definition: int32.c:151
VOID DosPrintCharacter(WORD FileHandle, CHAR Character)
Definition: bios.c:152
CALLBACK16 DosContext
Definition: dos.c:40
VOID WINAPI setCF(ULONG)
Definition: registers.c:573
PDOS_SDA Sda
Definition: dos.c:48
VOID DosTerminateProcess(WORD Psp, BYTE ReturnCode, WORD KeepResident)
Definition: process.c:873
ULONG WINAPI getCF(VOID)
Definition: registers.c:566

Referenced by DosInt21h(), and DosReadLineBuffered().

◆ DosEchoCharacter()

VOID DosEchoCharacter ( CHAR  Character)

Definition at line 48 of file bios.c.

49 {
50  switch (Character)
51  {
52  case '\0':
53  {
54  /* Nothing */
55  break;
56  }
57 
58  case '\b':
59  {
60  /* Erase the character */
64  break;
65  }
66 
67  default:
68  {
69  /*
70  * Check if this is a special character
71  * NOTE: \r and \n are handled by the underlying driver!
72  */
73  if (Character < 0x20 && Character != '\r' && Character != '\n')
74  {
76  Character += 'A' - 1;
77  }
78 
79  /* Echo the character */
81  }
82  }
83 }
#define DOS_OUTPUT_HANDLE
Definition: dos.h:43
VOID DosPrintCharacter(WORD FileHandle, CHAR Character)
Definition: bios.c:152

Referenced by DosReadCharacter(), DosReadFile(), and DosReadLineBuffered().

◆ DosKRNLInitialize()

BOOLEAN DosKRNLInitialize ( VOID  )

Definition at line 2253 of file dos.c.

2254 {
2255  UCHAR i;
2256  PDOS_SFT Sft;
2257  LPSTR Path;
2258  BOOLEAN Success = TRUE;
2259  DWORD dwRet;
2261  CHAR DosDirectory[DOS_DIR_LENGTH];
2262 
2263  static const BYTE NullDriverRoutine[] =
2264  {
2265  /* Strategy routine entry */
2266  0x26, // mov [Request.Status], DOS_DEVSTAT_DONE
2267  0xC7,
2268  0x47,
2272 
2273  /* Interrupt routine entry */
2274  0xCB, // retf
2275  };
2276 
2277  /* Set the data segment */
2279 
2280  /* Initialize the global DOS data area */
2282  RtlZeroMemory(DosData, sizeof(*DosData));
2283 
2284  /* Initialize the DOS stack */
2286  setSP(DOS_DATA_OFFSET(DosStack) + sizeof(DosData->DosStack) - sizeof(WORD));
2287 
2288  /* Initialize the list of lists */
2289  SysVars = &DosData->SysVars;
2290  RtlZeroMemory(SysVars, sizeof(*SysVars));
2292  SysVars->CurrentDirs = MAKELONG(DOS_DATA_OFFSET(CurrentDirectories),
2294  /*
2295  * The last drive can be redefined with the LASTDRIVE command.
2296  * At the moment, set the real maximum possible, 'Z'.
2297  */
2298  SysVars->NumLocalDrives = 'Z' - 'A' + 1; // See #define NUM_DRIVES in dos.h
2299 
2300  /* The boot drive is initialized to the %SYSTEMDRIVE% value */
2301  // NOTE: Using the NtSystemRoot system variable might be OS-specific...
2302  SysVars->BootDrive = RtlUpcaseUnicodeChar(SharedUserData->NtSystemRoot[0]) - 'A' + 1;
2303 
2304  /* Initialize the NUL device driver */
2305  SysVars->NullDevice.Link = 0xFFFFFFFF;
2307  // Offset from within the DOS data segment
2308  SysVars->NullDevice.StrategyRoutine = DOS_DATA_OFFSET(NullDriverRoutine);
2309  // Hardcoded to the RETF inside StrategyRoutine
2312  sizeof(SysVars->NullDevice.DeviceName),
2313  ' ');
2316  NullDriverRoutine,
2317  sizeof(NullDriverRoutine));
2318 
2319  /* Default DOS version to report */
2321 
2322  /* Initialize the swappable data area */
2323  Sda = &DosData->Sda;
2324  RtlZeroMemory(Sda, sizeof(*Sda));
2325 
2326  /* Get the current directory and convert it to a DOS path */
2328  if (dwRet == 0)
2329  {
2330  Success = FALSE;
2331  DPRINT1("GetCurrentDirectoryA failed (Error: %u)\n", GetLastError());
2332  }
2333  else if (dwRet > sizeof(CurrentDirectory))
2334  {
2335  Success = FALSE;
2336  DPRINT1("Current directory too long (%d > MAX_PATH) for GetCurrentDirectoryA\n", dwRet);
2337  }
2338 
2339  if (Success)
2340  {
2341  dwRet = GetShortPathNameA(CurrentDirectory, DosDirectory, sizeof(DosDirectory));
2342  if (dwRet == 0)
2343  {
2344  Success = FALSE;
2345  DPRINT1("GetShortPathNameA failed (Error: %u)\n", GetLastError());
2346  }
2347  else if (dwRet > sizeof(DosDirectory))
2348  {
2349  Success = FALSE;
2350  DPRINT1("Short path too long (%d > DOS_DIR_LENGTH) for GetShortPathNameA\n", dwRet);
2351  }
2352  }
2353 
2354  if (!Success)
2355  {
2356  /* We failed, use the boot drive instead */
2357  DosDirectory[0] = SysVars->BootDrive + 'A' - 1;
2358  DosDirectory[1] = ':';
2359  DosDirectory[2] = '\\';
2360  DosDirectory[3] = '\0';
2361  }
2362 
2363  /* Set the current drive */
2364  Sda->CurrentDrive = RtlUpperChar(DosDirectory[0]) - 'A';
2365 
2366  /* Get the directory part of the path and set the current directory */
2367  Path = strchr(DosDirectory, '\\');
2368  if (Path != NULL)
2369  {
2370  Path++; // Skip the backslash
2372  }
2373  else
2374  {
2376  }
2377 
2378  /* Set the current PSP to the system PSP */
2380 
2381  /* Initialize the SFT */
2383  Sft->Link = 0xFFFFFFFF;
2385 
2386  for (i = 0; i < Sft->NumDescriptors; i++)
2387  {
2388  /* Clear the file descriptor entry */
2390  }
2391 
2392  /* Initialize memory management */
2394 
2395  /* Initialize the callback context */
2397 
2398  /* Register the DOS 32-bit Interrupts */
2399  RegisterDosInt32(0x20, DosInt20h );
2400  RegisterDosInt32(0x21, DosInt21h );
2401 // RegisterDosInt32(0x22, DosInt22h ); // Termination
2402  RegisterDosInt32(0x23, DosBreakInterrupt); // Ctrl-C / Ctrl-Break
2403 // RegisterDosInt32(0x24, DosInt24h ); // Critical Error
2404  RegisterDosInt32(0x25, DosAbsoluteRead ); // Absolute Disk Read
2405  RegisterDosInt32(0x26, DosAbsoluteWrite ); // Absolute Disk Write
2406  RegisterDosInt32(0x27, DosInt27h ); // Terminate and Stay Resident
2407  RegisterDosInt32(0x28, DosIdle ); // DOS Idle Interrupt
2408  RegisterDosInt32(0x29, DosFastConOut ); // DOS 2+ Fast Console Output
2409  RegisterDosInt32(0x2F, DosInt2Fh ); // Multiplex Interrupt
2410 
2411  /* Unimplemented DOS interrupts */
2412  RegisterDosInt32(0x2A, DosInt2Ah); // DOS Critical Sections / Network
2413 // RegisterDosInt32(0x2E, NULL); // COMMAND.COM "Reload Transient"
2414 // COMMAND.COM adds support for INT 2Fh, AX=AE00h and AE01h "Installable Command - Installation Check & Execute"
2415 // COMMAND.COM adds support for INT 2Fh, AX=5500h "COMMAND.COM Interface"
2416 
2417  /* Reserved DOS interrupts */
2418  RegisterDosInt32(0x2B, NULL);
2419  RegisterDosInt32(0x2C, NULL);
2420  RegisterDosInt32(0x2D, NULL);
2421 
2422  /* Initialize country data */
2424 
2425  /* Load the CON driver */
2426  ConDrvInitialize();
2427 
2428  /* Load the XMS driver (HIMEM) */
2429  XmsInitialize();
2430 
2431  /* Load the EMS driver */
2433  {
2434  DosDisplayMessage("Could not initialize EMS. EMS will not be available.\n"
2435  "Page frame segment or number of EMS pages invalid.\n");
2436  }
2437 
2438  /* Finally initialize the UMBs */
2439  DosInitializeUmb();
2440 
2441  return TRUE;
2442 }
#define DOS_DATA_OFFSET(x)
Definition: dos.h:35
VOID DosInitializeMemory(VOID)
Definition: memory.c:665
#define DOS_DIR_LENGTH
Definition: dos.h:47
WORD CurrentPsp
Definition: dos.h:156
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
VOID WINAPI DosFastConOut(LPWORD Stack)
Definition: dos.c:2079
DWORD Link
Definition: device.h:110
#define LOBYTE(W)
Definition: jmemdos.c:487
CHAR DeviceName[MAX_DEVICE_NAME]
Definition: device.h:117
WCHAR CurrentDirectory[1024]
Definition: chkdsk.c:74
VOID WINAPI DosInt2Fh(LPWORD Stack)
Definition: dos.c:2116
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
CHAR CurrentDirectories[NUM_DRIVES][DOS_DIR_LENGTH]
Definition: dos.h:248
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
VOID InitializeContext(IN PCALLBACK16 Context, IN USHORT Segment, IN USHORT Offset)
Definition: callback.c:60
char CHAR
Definition: xmlstorage.h:175
VOID WINAPI setDS(USHORT)
Definition: registers.c:515
DOS_DRIVER NullDevice
Definition: dos.h:89
VOID WINAPI DosInt20h(LPWORD Stack)
Definition: dos.c:201
BYTE DosStack[384]
Definition: dos.h:250
#define HIBYTE(W)
Definition: jmemdos.c:486
VOID WINAPI DosInt21h(LPWORD Stack)
Definition: dos.c:210
DOS_FILE_DESCRIPTOR FileDescriptors[ANYSIZE_ARRAY]
Definition: dosfiles.h:68
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define EMS_SEGMENT
Definition: emsdrv.h:16
char * LPSTR
Definition: xmlstorage.h:182
#define DosDisplayMessage(Format,...)
Definition: dem.h:37
VOID DosInitializeUmb(VOID)
Definition: memory.c:582
NTSYSAPI WCHAR NTAPI RtlUpcaseUnicodeChar(WCHAR Source)
#define SEG_OFF_TO_PTR(seg, off)
Definition: emulator.h:28
#define EMS_TOTAL_PAGES
Definition: emsdrv.h:24
#define RegisterDosInt32(IntNumber, IntHandler)
Definition: dos.h:305
DOS_SDA Sda
Definition: dos.h:247
PDOS_DATA DosData
Definition: dos.c:45
VOID WINAPI DosInt2Ah(LPWORD Stack)
Definition: dos.c:2111
VOID WINAPI DosIdle(LPWORD Stack)
Definition: dos.c:2070
VOID WINAPI setSP(USHORT)
Definition: registers.c:351
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define DOS_CODE_SEGMENT
Definition: dos.h:32
BYTE CurrentDrive
Definition: dos.h:159
VOID WINAPI DosAbsoluteWrite(LPWORD Stack)
Definition: dos.c:2041
WORD InterruptRoutine
Definition: device.h:113
#define DOS_VERSION
Definition: dos.h:24
VOID WINAPI setSS(USHORT)
Definition: registers.c:501
CALLBACK16 DosContext
Definition: dos.c:40
#define DOS_SFT_SIZE
Definition: dos.h:46
#define MAKELONG(a, b)
Definition: typedefs.h:248
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define FAR_POINTER(x)
Definition: emulator.h:31
DWORD CurrentDirs
Definition: dos.h:85
BOOLEAN DosCountryInitialize(VOID)
Definition: country.c:236
#define DOS_DATA_SEGMENT
Definition: dos.h:33
BOOLEAN EmsDrvInitialize(USHORT Segment, ULONG TotalPages)
Definition: emsdrv.c:767
DWORD WINAPI GetShortPathNameA(IN LPCSTR lpszLongPath, OUT LPSTR lpszShortPath, IN DWORD cchBuffer)
Definition: path.c:1751
#define MAX_PATH
Definition: compat.h:26
unsigned short WORD
Definition: ntddk_ex.h:93
VOID WINAPI DosInt27h(LPWORD Stack)
Definition: dos.c:2061
unsigned long DWORD
Definition: ntddk_ex.h:95
struct _DOS_DATA * PDOS_DATA
VOID ConDrvInitialize(VOID)
Definition: condrv.c:132
NTSYSAPI CHAR NTAPI RtlUpperChar(CHAR Character)
#define SharedUserData
unsigned char UCHAR
Definition: xmlstorage.h:181
#define DOS_DEVATTR_NUL
Definition: device.h:23
VOID WINAPI DosBreakInterrupt(LPWORD Stack)
Definition: dos.c:2015
unsigned char BYTE
Definition: mem.h:68
PDOS_SDA Sda
Definition: dos.c:48
VOID WINAPI DosAbsoluteRead(LPWORD Stack)
Definition: dos.c:2021
BYTE NullDriverRoutine[7]
Definition: dos.h:245
#define DOS_DEVSTAT_DONE
Definition: device.h:49
BYTE NumLocalDrives
Definition: dos.h:88
struct _DOS_SFT * PDOS_SFT
Status
Definition: gdiplustypes.h:24
WORD DeviceAttributes
Definition: device.h:111
#define DOS_DEVATTR_CHARACTER
Definition: device.h:29
PRTL_UNICODE_STRING_BUFFER Path
WORD NumDescriptors
Definition: dosfiles.h:67
DOS_SYSVARS SysVars
Definition: dos.h:244
PDOS_SYSVARS SysVars
Definition: dos.c:47
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2145
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
#define SYSTEM_PSP
Definition: dos.h:39
DWORD FirstSft
Definition: dos.h:81
char * strchr(const char *String, int ch)
Definition: utclib.c:501
#define DPRINT1
Definition: precomp.h:8
BYTE BootDrive
Definition: dos.h:96
VOID XmsInitialize(VOID)
Definition: himem.c:796
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
WORD DosVersion
Definition: dos.h:246
WORD StrategyRoutine
Definition: device.h:112
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:593
DWORD Link
Definition: dosfiles.h:66

Referenced by DosBIOSInitialize().

◆ DosPrintCharacter()

VOID DosPrintCharacter ( WORD  FileHandle,
CHAR  Character 
)

Definition at line 152 of file bios.c.

153 {
155 
156  Sda->ByteBuffer = Character;
157 
158  /* Use the file writing function */
161  1,
162  &BytesWritten);
163 }
#define DOS_DATA_OFFSET(x)
Definition: dos.h:35
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesWritten
Definition: fltkernel.h:1293
BYTE ByteBuffer
Definition: dos.h:193
HANDLE FileHandle
Definition: stats.c:38
#define MAKELONG(a, b)
Definition: typedefs.h:248
#define DOS_DATA_SEGMENT
Definition: dos.h:33
unsigned short WORD
Definition: ntddk_ex.h:93
PDOS_SDA Sda
Definition: dos.c:48
WORD DosWriteFile(WORD FileHandle, DWORD Buffer, WORD Count, LPWORD BytesWritten)
Definition: dosfiles.c:915

Referenced by DosCharPrint(), DosControlBreak(), DosEchoCharacter(), and DosInt21h().

◆ DosReadCharacter()

CHAR DosReadCharacter ( WORD  FileHandle,
BOOLEAN  Echo 
)

Definition at line 85 of file bios.c.

86 {
89  WORD OldDeviceInfo;
90 
91  /* Find the standard input descriptor and switch it to binary mode */
93  if (Descriptor)
94  {
95  OldDeviceInfo = Descriptor->DeviceInfo;
96  Descriptor->DeviceInfo |= FILE_INFO_BINARY;
97  }
98 
99  Sda->ByteBuffer = '\0';
100  DPRINT("DosReadCharacter\n");
101 
102  /* Use the file reading function */
105  1,
106  &BytesRead);
107 
108  /* Check if we should echo and the file is actually the CON device */
109  if (Echo && Descriptor && Descriptor->DeviceInfo & FILE_INFO_DEVICE)
110  {
111  /* Echo the character */
113  }
114 
115  /* Restore the old mode and return the character */
116  if (Descriptor) Descriptor->DeviceInfo = OldDeviceInfo;
117  return Sda->ByteBuffer;
118 }
#define DOS_DATA_OFFSET(x)
Definition: dos.h:35
BYTE ByteBuffer
Definition: dos.h:193
WORD DosReadFile(WORD FileHandle, DWORD Buffer, WORD Count, LPWORD BytesRead)
Definition: dosfiles.c:768
#define FILE_INFO_BINARY
Definition: dosfiles.h:15
HANDLE FileHandle
Definition: stats.c:38
#define MAKELONG(a, b)
Definition: typedefs.h:248
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
PDOS_FILE_DESCRIPTOR DosGetHandleFileDescriptor(WORD DosHandle)
Definition: dosfiles.c:173
#define DOS_DATA_SEGMENT
Definition: dos.h:33
#define FILE_INFO_DEVICE
Definition: dosfiles.h:16
unsigned short WORD
Definition: ntddk_ex.h:93
PDOS_SDA Sda
Definition: dos.c:48
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesRead
Definition: fltkernel.h:1255
Definition: telnetd.h:64
VOID DosEchoCharacter(CHAR Character)
Definition: bios.c:48
_In_ PSTORAGE_PROPERTY_ID _Outptr_ PSTORAGE_DESCRIPTOR_HEADER * Descriptor
Definition: classpnp.h:966

Referenced by DosInt21h().

Variable Documentation

◆ BiosData

PBIOS_DATA BiosData

Definition at line 42 of file bios.c.

Referenced by DosBIOSInitialize(), DosInt2Fh(), PciScanBus(), and PPBridge_SaveCurrentSettings().

◆ DosContext

◆ DosData

◆ Sda

◆ SysVars