91 LPCSTR DosKernelFileName =
"ntdos.sys";
93 ULONG ulDosKernelSize = 0;
95 DPRINT1(
"You are loading Windows NT DOS!\n");
98 hDosKernel =
FileOpen(DosKernelFileName, &ulDosKernelSize);
99 if (hDosKernel ==
NULL)
goto Quit;
111 DPRINT1(
"Windows NT DOS file '%s' loading %s at %04X:%04X, size 0x%X (Error: %u).\n",
113 (
Success ?
"succeeded" :
"failed"),
125 BiosDisplayMessage(
"Windows NT DOS kernel file '%s' loading failed (Error: %u). The VDM will shut down.\n",
163 DPRINT1(
"Unknown DOS System BOP Function: 0x%02X\n", FuncNum);
207 if (ComSpecInfo->
ComSpecPsp == Psp)
return ComSpecInfo;
298 DPRINT1(
"CmdStartProcess -- DS:DX = %04X:%04X (DataStruct = 0x%p)\n",
311 DPRINT1(
"Exit DOS from start-app BOP\n");
345 DPRINT1(
"Calling GetNextVDMCommand in CmdStartProcess: wait for new VDM task...\n");
348 DPRINT1(
"CmdStartProcess - GetNextVDMCommand failed, retrying... last error = %d\n",
GetLastError());
361 DisplayMessage(
L"An unrecoverable failure happened from start-app BOP; exiting DOS.");
368 DPRINT1(
"CmdStartProcess - GetNextVDMCommand succeeded, start app...\n");
374 DPRINT1(
"Exit DOS from start-app BOP\n");
383 if (CmdLen >= 2 &&
CmdLine[CmdLen - 2] ==
'\r')
427 strcpy(CmdLinePtr,
"cmd.exe /c ");
428 CmdLinePtr +=
strlen(CmdLinePtr);
433 CmdLinePtr[CmdLineLen] =
'\0';
436 while (*CmdLinePtr && *CmdLinePtr !=
'\r' && *CmdLinePtr !=
'\n') CmdLinePtr++;
522 if ((ComSpecInfo && ComSpecInfo->
Terminated) ||
527 DPRINT1(
"Exit DOS from ExitCode (prologue)!\n");
541 DPRINT1(
"Calling GetNextVDMCommand 32bit end of VDM task\n");
543 DPRINT1(
"GetNextVDMCommand 32bit end of VDM task success = %s, last error = %d\n",
Success ?
"true" :
"false",
GetLastError());
551 DPRINT1(
"GetNextVDMCommand end-of-app, this is for a new VDM task - CmdLen = %d, AppLen = %d, PifLen = %d\n",
560 DPRINT1(
"GetNextVDMCommand end-of-app, the app stopped\n");
566 DPRINT1(
"Not our 32-bit app, retrying...\n");
575 DPRINT1(
"Exit DOS from ExitCode wait!\n");
757 DPRINT1(
"Unknown DOS CMD Interpreter BOP Function: 0x%02X\n", FuncNum);
764#ifndef COMSPEC_FULLY_EXTERNAL
768#include "command_com.h"
785 if (ComSpecPsp) *ComSpecPsp = 0;
788#ifndef COMSPEC_FULLY_EXTERNAL
798 "H:\\DOS_tests\\CMDCMD.COM",
802 Permanent ?
"/P" :
"",
846 StartupInfo.
cb =
sizeof(StartupInfo);
856 DPRINT1(
"Calling GetNextVDMCommand reenter++\n");
869 DosStartProc32->Environment,
905 DPRINT1(
"Calling GetNextVDMCommand reenter--\n");
951 if (CommandThread ==
NULL)
970 DPRINT1(
"Calling GetNextVDMCommand 32bit for possible new VDM task...\n");
980 DPRINT1(
"GetNextVDMCommand 32bit, this is for a new VDM task - CmdLen = %d, AppLen = %d, PifLen = %d\n",
1022 DPRINT1(
"GetNextVDMCommand 32bit, 32-bit app stopped\n");
1027 DPRINT1(
"Not our 32-bit app, retrying...\n");
1044 DPRINT1(
"32-bit app stopped\n");
1094 CHAR DosKernelFileName[] =
"";
1096 DPRINT(
"DosBootsectorInitialize\n");
1102 Address +=
sizeof(DosKernelFileName);
1136 DPRINT(
"DosInitialize('%s')\n", DosBiosFileName);
1148 if (DosBiosFileName[0] !=
'\0')
1152 ULONG ulDosBiosSize = 0;
1155 hDosBios =
FileOpen(DosBiosFileName, &ulDosBiosSize);
1156 if (hDosBios ==
NULL)
goto Quit;
1164 DPRINT1(
"DOS BIOS file '%s' loading %s at %04X:%04X, size 0x%X (Error: %u).\n",
1166 (
Success ?
"succeeded" :
"failed"),
1177 BiosDisplayMessage(
"DOS BIOS file '%s' loading failed (Error: %u). The VDM will shut down.\n",
1420 FindData->dwFileAttributes =
NT_TO_DOS_FA(FindData->dwFileAttributes);
1430 if (*FindData->cAlternateFileName)
1433 *
ShortName = FindData->cAlternateFileName;
1443 BOOLEAN IsNameLegal, SpacesInName;
1449 RtlInitEmptyUnicodeString(&FileNameU, FileNameBufferU,
sizeof(FileNameBufferU));
1456 if (!IsNameLegal || SpacesInName)
1459 DPRINT1(
"'%.*s' is %s 8.3 filename %s spaces\n",
1460 _countof(FindData->cFileName), FindData->cFileName,
1461 (IsNameLegal ?
"a valid" :
"an invalid"), (SpacesInName ?
"with" :
"without"));
1464 if (IsNameLegal && !SpacesInName)
1472 DPRINT1(
"No short 8.3 filename available for '%.*s'\n",
1473 _countof(FindData->cFileName), FindData->cFileName);
1531 DPRINT1(
"demFileFindFirst: Volume label attribute is UNIMPLEMENTED!\n");
1532 AttribMask &= ~FA_VOLID;
1565 : FindData.nFileSizeLow;
1622 : FindData.nFileSizeLow;
static const CHAR FileNameA[]
PRTL_UNICODE_STRING_BUFFER Path
ACPI_SIZE strlen(const char *String)
char * strcpy(char *DstString, const char *SrcString)
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
INT __cdecl DisplayMessage(_In_opt_ HWND hWnd, _In_ UINT uType, _In_opt_ PCWSTR pszTitle, _In_opt_ PCWSTR pszFormatMessage,...)
WCHAR CurrentDirectory[1024]
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
VOID RegisterBop(BYTE BopCode, EMULATOR_BOP_PROC BopHandler)
_In_ PSCSI_REQUEST_BLOCK _Out_ NTSTATUS _Inout_ BOOLEAN * Retry
static LIST_ENTRY ComSpecInfoList
static VOID WINAPI DosSystemBop(LPWORD Stack)
static COMSPEC_INFO RootCmd
static DWORD WINAPI CommandThreadProc(LPVOID Parameter)
DWORD WINAPI demFileFindFirst(_Out_ PVOID pFindFileData, _In_ PCSTR FileName, _In_ WORD AttribMask)
static CHAR CurDirectory[MAX_PATH]
BOOLEAN DosShutdown(BOOLEAN Immediate)
struct _NEXT_CMD * PNEXT_CMD
DWORD WINAPI demFileFindNext(_Inout_ PVOID pFindFileData)
static VOID RemoveComSpecInfo(PCOMSPEC_INFO ComSpecInfo)
UCHAR WINAPI demGetPhysicalDriveType(IN UCHAR DriveNumber)
struct _COMSPEC_INFO * PCOMSPEC_INFO
static VOID WINAPI DosInitialize(LPWORD Stack)
static PCOMSPEC_INFO FindComSpecInfoByPsp(WORD Psp)
static VOID DosProcessConsoleAttach(VOID)
static VOID CmdStartProcess(VOID)
static VOID WINAPI DosCmdInterpreterBop(LPWORD Stack)
static CHAR Desktop[MAX_PATH]
BOOL WINAPI demIsShortPathName(IN LPCSTR Path, IN BOOL Unknown)
static VOID CmdSetExitCode(VOID)
DWORD WINAPI demFileDelete(IN LPCSTR FileName)
static BYTE Bootsector2[]
static VDM_COMMAND_INFO CommandInfo
static DWORD ReentrancyCount
struct _DOS_START_PROC32 DOS_START_PROC32
static CHAR Title[MAX_PATH]
static VOID InsertComSpecInfo(PCOMSPEC_INFO ComSpecInfo)
VOID Dem_BiosCharPrint(CHAR Character)
static CHAR AppName[MAX_PATH]
VOID DosBootsectorInitialize(VOID)
static VOID DemLoadNTDOSKernel(VOID)
static CHAR CmdLine[MAX_PATH]
DWORD DosStartProcess32(IN LPCSTR ExecutablePath, IN LPCSTR CommandLine, IN LPCSTR Environment OPTIONAL, IN DWORD ReturnAddress OPTIONAL, IN BOOLEAN StartComSpec)
static VOID CmdStartExternalCommand(VOID)
static BOOLEAN dempIsFileMatch(_Inout_ PWIN32_FIND_DATAA FindData, _In_ WORD AttribMask, _Out_ PCSTR *ShortName)
Helper for demFileFindFirst() and demFileFindNext(). Returns TRUE if a file matches the DOS attribute...
static BYTE Bootsector1[]
struct _COMSPEC_INFO COMSPEC_INFO
static VOID WINAPI DosStart(LPWORD Stack)
static DWORD DosStartComSpec(IN BOOLEAN Permanent, IN LPCSTR Environment OPTIONAL, IN DWORD ReturnAddress OPTIONAL, OUT PWORD ComSpecPsp OPTIONAL)
VOID DosCharPrint(CHAR Character)
static VOID DosProcessConsoleDetach(VOID)
DWORD WINAPI demSetCurrentDirectoryGetDrive(IN LPCSTR CurrentDirectory, OUT PUCHAR DriveNumber)
static CHAR PifFile[MAX_PATH]
static VOID CmdStartComSpec32(VOID)
struct _DOS_START_PROC32 * PDOS_START_PROC32
DWORD WINAPI demClientErrorEx(IN HANDLE FileHandle, IN CHAR Unknown, IN BOOL Flag)
struct _NEXT_CMD NEXT_CMD
#define BiosDisplayMessage(Format,...)
#define DosDisplayMessage(Format,...)
#define NT_TO_DOS_FA(Attrs)
Convert Win32/NT file attributes to DOS format.
#define INVALID_HANDLE_VALUE
#define WideCharToMultiByte
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleTitleA(LPCSTR lpConsoleTitle)
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
HANDLE WINAPI FindFirstFileA(IN LPCSTR lpFileName, OUT LPWIN32_FIND_DATAA lpFindFileData)
BOOL WINAPI FindClose(HANDLE hFindFile)
BOOL WINAPI FindNextFileA(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAA lpFindFileData)
BOOL WINAPI GetExitCodeProcess(IN HANDLE hProcess, IN LPDWORD lpExitCode)
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessA(LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
DWORD WINAPI ResumeThread(IN HANDLE hThread)
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
BOOL WINAPI GetExitCodeThread(IN HANDLE hThread, OUT LPDWORD lpExitCode)
BOOL WINAPI FileTimeToDosDateTime(IN CONST FILETIME *lpFileTime, OUT LPWORD lpFatDate, OUT LPWORD lpFatTime)
BOOL WINAPI GetBinaryTypeA(IN LPCSTR lpApplicationName, OUT LPDWORD lpBinaryType)
VOID WINAPI ExitVDM(BOOL IsWow, ULONG iWowTask)
BOOL WINAPI GetNextVDMCommand(PVDM_COMMAND_INFO CommandData)
VOID EmulatorTerminate(VOID)
VOID EmulatorResume(VOID)
#define TO_LINEAR(seg, off)
#define MEM_ALIGN_UP(ptr, align)
#define REAL_TO_PHYS(ptr)
#define SEG_OFF_TO_PTR(seg, off)
#define RemoveEntryList(Entry)
#define InsertHeadList(ListHead, Entry)
#define IsListEmpty(ListHead)
IN PDCB IN POEM_STRING IN PUNICODE_STRING IN OUT POEM_STRING ShortName
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
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
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
BOOLEAN NTAPI RtlIsNameLegalDOS8Dot3(_In_ PUNICODE_STRING Name, _Inout_opt_ POEM_STRING OemName, _Inout_opt_ PBOOLEAN NameContainsSpaces)
NTSYSAPI PVOID WINAPI RtlReAllocateHeap(HANDLE, ULONG, PVOID, SIZE_T)
VOID Int32Call(IN PCALLBACK16 Context, IN BYTE IntNumber)
PVOID PVOID PWCHAR PVOID Environment
BOOLEAN DosMouseInitialize(VOID)
#define DOSDEVICE_DRIVE_UNKNOWN
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
#define RTL_SIZEOF_THROUGH_FIELD(type, field)
#define UNREFERENCED_PARAMETER(P)
NTSTRSAFEAPI RtlStringCchCopyA(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cchDest, _In_ NTSTRSAFE_PCSTR pszSrc)
_Check_return_ _CRTIMP int __cdecl wcsncmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
#define VDM_FLAG_FIRST_TASK
#define VDM_FLAG_DONT_WAIT
#define VDM_INC_REENTER_COUNT
#define VDM_DEC_REENTER_COUNT
#define VDM_GET_FIRST_COMMAND
#define VDM_FLAG_NESTED_TASK
PULONG MinorVersion OPTIONAL
base of all file and directory entries
_Null_terminated_ CHAR FileName[13]
PCOMSPEC_INFO ComSpecInfo
LPSTR Environment OPTIONAL
struct _LIST_ENTRY * Blink
struct _LIST_ENTRY * Flink
VOID InitializeContext(IN PCALLBACK16 Context, IN USHORT Segment, IN USHORT Offset)
VOID DosPrintCharacter(WORD FileHandle, CHAR Character)
BOOLEAN DosBIOSInitialize(VOID)
VOID DeviceInterruptBop(VOID)
VOID DeviceStrategyBop(VOID)
#define BOP_DRV_INTERRUPT
#define BIOS_CODE_SEGMENT
#define DOS_OUTPUT_HANDLE
struct _DOS_FIND_FILE_BLOCK * PDOS_FIND_FILE_BLOCK
DWORD DosLoadExecutableInternal(IN DOS_EXEC_TYPE LoadType, IN LPBYTE ExeBuffer, IN DWORD ExeBufferSize, IN LPCSTR ExePath, IN PDOS_EXEC_PARAM_BLOCK Parameters, IN LPCSTR CommandLine OPTIONAL, IN LPCSTR Environment OPTIONAL, IN DWORD ReturnAddress OPTIONAL)
DWORD DosLoadExecutable(IN DOS_EXEC_TYPE LoadType, IN LPCSTR ExecutablePath, IN PDOS_EXEC_PARAM_BLOCK Parameters, IN LPCSTR CommandLine OPTIONAL, IN LPCSTR Environment OPTIONAL, IN DWORD ReturnAddress OPTIONAL)
#define DOS_CMDLINE_LENGTH
HANDLE FileOpen(IN PCSTR FileName, OUT PULONG FileSize OPTIONAL)
VOID FileClose(IN HANDLE FileHandle)
BOOLEAN FileLoadByHandle(IN HANDLE FileHandle, IN PVOID Location, IN ULONG FileSize, OUT PULONG BytesRead)
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define CONTAINING_RECORD(address, type, field)
VOID WINAPI setBX(USHORT)
USHORT WINAPI getIP(VOID)
USHORT WINAPI getBX(VOID)
USHORT WINAPI getDS(VOID)
USHORT WINAPI getSI(VOID)
USHORT WINAPI getDX(VOID)
VOID WINAPI setSP(USHORT)
USHORT WINAPI getAX(VOID)
VOID WINAPI setCS(USHORT)
USHORT WINAPI getES(VOID)
USHORT WINAPI getDI(VOID)
USHORT WINAPI getCS(VOID)
USHORT WINAPI getSP(VOID)
VOID WINAPI setAX(USHORT)
ULONG WINAPI getEFLAGS(VOID)
VOID WINAPI setIP(USHORT)
USHORT WINAPI getSS(VOID)
VOID VidBiosAttachToConsole(VOID)
VOID VidBiosDetachFromConsole(VOID)
#define DEFAULT_ATTRIBUTE
#define BIOS_VIDEO_INTERRUPT
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
DWORD WINAPI GetLastError(void)
#define CREATE_DEFAULT_ERROR_MODE
#define ERROR_BAD_EXE_FORMAT
_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
_Inout_opt_ PVOID Parameter