#include "utils.h"
#include "dem.h"
+#include "dos/dos32krnl/device.h"
+#include "dos/dos32krnl/process.h"
#include "cpu/bop.h"
#include "bios/bios.h"
/**/extern BYTE CurrentDrive;/**/
-/* DEFINES ********************************************************************/
-
-/* BOP Identifiers */
-#define BOP_LOAD_DOS 0x2B // DOS Loading and Initializing BOP. In parameter (following bytes) we take a NULL-terminated string indicating the name of the DOS kernel file.
-#define BOP_START_DOS 0x2C // DOS Starting BOP. In parameter (following bytes) we take a NULL-terminated string indicating the name of the DOS kernel file.
-#define BOP_DOS 0x50 // DOS System BOP (for NTIO.SYS and NTDOS.SYS)
-#define BOP_CMD 0x54 // DOS Command Interpreter BOP (for COMMAND.COM)
-
/* PRIVATE FUNCTIONS **********************************************************/
static VOID WINAPI DosSystemBop(LPWORD Stack)
break;
}
+ /* Call 32-bit Driver Strategy Routine */
+ case BOP_DRV_STRATEGY:
+ {
+ DeviceStrategyBop();
+ break;
+ }
+
+ /* Call 32-bit Driver Interrupt Routine */
+ case BOP_DRV_INTERRUPT:
+ {
+ DeviceInterruptBop();
+ break;
+ }
+
default:
{
DPRINT1("Unknown DOS System BOP Function: 0x%02X\n", FuncNum);
{
case 0x08: // Launch external command
{
-#define CMDLINE_LENGTH 1024
-
BOOL Result;
DWORD dwExitCode;
LPSTR Command = (LPSTR)SEG_OFF_TO_PTR(getDS(), getSI());
- LPSTR CmdPtr = Command;
- CHAR CommandLine[CMDLINE_LENGTH] = "";
+ CHAR CmdLine[sizeof("cmd.exe /c ") + DOS_CMDLINE_LENGTH + 1] = "";
+ LPSTR CmdLinePtr;
+ ULONG CmdLineLen;
STARTUPINFOA StartupInfo;
PROCESS_INFORMATION ProcessInformation;
- /* NULL-terminate the command line by removing the return carriage character */
- while (*CmdPtr && *CmdPtr != '\r') CmdPtr++;
- *CmdPtr = '\0';
-
- DPRINT1("CMD Run Command '%s'\n", Command);
-
/* Spawn a user-defined 32-bit command preprocessor */
- /* Build the command line */
// FIXME: Use COMSPEC env var!!
- strcpy(CommandLine, "cmd.exe /c ");
- strcat(CommandLine, Command);
+ CmdLinePtr = CmdLine;
+ strcpy(CmdLinePtr, "cmd.exe /c ");
+ CmdLinePtr += strlen(CmdLinePtr);
+
+ /* Build a Win32-compatible command-line */
+ CmdLineLen = min(strlen(Command), sizeof(CmdLine) - strlen(CmdLinePtr) - 1);
+ RtlCopyMemory(CmdLinePtr, Command, CmdLineLen);
+ CmdLinePtr[CmdLineLen] = '\0';
+
+ /* Remove any trailing return carriage character and NULL-terminate the command line */
+ while (*CmdLinePtr && *CmdLinePtr != '\r' && *CmdLinePtr != '\n') CmdLinePtr++;
+ *CmdLinePtr = '\0';
+
+ DPRINT1("CMD Run Command '%s' ('%s')\n", Command, CmdLine);
RtlZeroMemory(&StartupInfo, sizeof(StartupInfo));
RtlZeroMemory(&ProcessInformation, sizeof(ProcessInformation));
VidBiosDetachFromConsole();
Result = CreateProcessA(NULL,
- CommandLine,
+ CmdLine,
NULL,
NULL,
TRUE,
&ProcessInformation);
if (Result)
{
- DPRINT1("Command '%s' launched successfully\n", Command);
+ DPRINT1("Command '%s' ('%s') launched successfully\n", Command, CmdLine);
/* Wait for process termination */
WaitForSingleObject(ProcessInformation.hProcess, INFINITE);
}
else
{
- DPRINT1("Failed when launched command '%s'\n");
+ DPRINT1("Failed when launched command '%s' ('%s')\n", Command, CmdLine);
dwExitCode = GetLastError();
}
PVOID Env = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, EnvSize);
UNREFERENCED_PARAMETER(Parameter);
- ASSERT(Env != NULL);
+ ASSERT(Env);
do
{
CommandInfo.Env = Env = RtlReAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, Env, EnvSize);
/* Repeat the request */
+ CommandInfo.VDMState |= VDM_FLAG_RETRY;
goto Command;
}
}
/* Start the process from the command line */
- DPRINT1("Starting '%s' ('%s')...\n", AppName, CmdLine);
+ DPRINT1("Starting '%s' ('%.*s')...\n",
+ AppName,
+ CommandInfo.CmdLen >= 2 ? CommandInfo.CmdLen - 2 /* Display the command line without the terminating 0d 0a */
+ : CommandInfo.CmdLen,
+ CmdLine);
Result = DosStartProcess(AppName, CmdLine, Env);
if (Result != ERROR_SUCCESS)
{
/* Start the process from the command line */
DPRINT1("Starting '%s' ('%s')...\n", ApplicationName, CommandLine);
- Result = DosStartProcess(ApplicationName,
- CommandLine,
+ Result = DosStartProcess(ApplicationName, CommandLine,
SEG_OFF_TO_PTR(SYSTEM_ENV_BLOCK, 0));
if (Result != ERROR_SUCCESS)
{