Author: hbelusca Date: Thu May 7 01:23:33 2015 New Revision: 67589
URL: http://svn.reactos.org/svn/reactos?rev=67589&view=rev Log: [NTVDM] - Improvement/Usability: when a DOS app is started in a separate console, print its full path as it's done in Windows. - Stubplement a LoadGlobalSettings function for NTVDM so that it will be able to grab user settings from the registry. - Move DOS-only related variables AcceptCommands, CommandThread and SessionId to where they belong. I will rework ConsoleCtrlHandler to make it more elegant in the future (DOS-agnostic). - Remove the useless ENTER-key-up hack.
Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dem.c trunk/reactos/subsystems/mvdm/ntvdm/dos/dem.h trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/process.c trunk/reactos/subsystems/mvdm/ntvdm/ntvdm.c trunk/reactos/subsystems/mvdm/ntvdm/ntvdm.h trunk/reactos/subsystems/mvdm/ntvdm/vddsup.c
Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dem.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/d... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/dos/dem.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dem.c [iso-8859-1] Thu May 7 01:23:33 2015 @@ -274,6 +274,14 @@ } #endif
+/* PUBLIC VARIABLES ***********************************************************/ + +#ifndef STANDALONE +BOOLEAN AcceptCommands = TRUE; +HANDLE CommandThread = NULL; +ULONG SessionId = 0; +#endif + /* PUBLIC FUNCTIONS ***********************************************************/
// @@ -422,6 +430,8 @@ DWORD Result; CHAR ApplicationName[MAX_PATH]; CHAR CommandLine[DOS_CMDLINE_LENGTH]; +#else + INT i; #endif
DPRINT("DosStart\n"); @@ -436,6 +446,19 @@ DosMouseInitialize();
#ifndef STANDALONE + + /* Parse the command line arguments */ + for (i = 1; i < NtVdmArgc; i++) + { + if (wcsncmp(NtVdmArgv[i], L"-i", 2) == 0) + { + /* This is the session ID */ + SessionId = wcstoul(NtVdmArgv[i] + 2, NULL, 10); + + /* The VDM hasn't been started from a console, so quit when the task is done */ + AcceptCommands = FALSE; + } + }
/* Create the GetNextVDMCommand thread */ CommandThread = CreateThread(NULL, 0, &CommandThreadProc, NULL, 0, NULL);
Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dem.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/d... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/dos/dem.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dem.h [iso-8859-1] Thu May 7 01:23:33 2015 @@ -24,6 +24,14 @@ #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) + +/* VARIABLES ******************************************************************/ + +#ifndef STANDALONE +extern BOOLEAN AcceptCommands; +extern HANDLE CommandThread; +extern ULONG SessionId; +#endif
/* FUNCTIONS ******************************************************************/
Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/process.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/d... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/process.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/process.c [iso-8859-1] Thu May 7 01:23:33 2015 @@ -641,16 +641,13 @@
if (Result != ERROR_SUCCESS) goto Quit;
+ /* Update console title if we run in a separate console */ + if (SessionId != 0) + SetConsoleTitleA(ExecutablePath); + /* Attach to the console */ ConsoleAttach(); VidBiosAttachToConsole(); - - // HACK: Simulate a ENTER key release scancode on the PS/2 port because - // some apps expect to read a key release scancode (> 0x80) when they - // are started. - // (hbelusca 2 May 2015: I'm not sure it's really useful. See r65012) - // IOWriteB(PS2_CONTROL_PORT, 0xD2); // Next write is for the first PS/2 port - // IOWriteB(PS2_DATA_PORT, 0x80 | 0x1C); // ENTER key release
/* Start simulation */ SetEvent(VdmTaskEvent);
Modified: trunk/reactos/subsystems/mvdm/ntvdm/ntvdm.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/ntvdm... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/ntvdm.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/ntvdm.c [iso-8859-1] Thu May 7 01:23:33 2015 @@ -23,13 +23,6 @@ static HANDLE ConsoleInput = INVALID_HANDLE_VALUE; static HANDLE ConsoleOutput = INVALID_HANDLE_VALUE; static DWORD OrgConsoleInputMode, OrgConsoleOutputMode; - -// For DOS -#ifndef STANDALONE -BOOLEAN AcceptCommands = TRUE; -HANDLE CommandThread = NULL; -ULONG SessionId = 0; -#endif
HANDLE VdmTaskEvent = NULL;
@@ -258,13 +251,19 @@ WINAPI ConsoleCtrlHandler(DWORD ControlType) { +// HACK: Should be removed! +#ifndef STANDALONE +extern BOOLEAN AcceptCommands; +extern HANDLE CommandThread; +#endif + switch (ControlType) { case CTRL_LAST_CLOSE_EVENT: { if (WaitForSingleObject(VdmTaskEvent, 0) == WAIT_TIMEOUT) { - /* Exit immediately */ + /* Nothing runs, so exit immediately */ #ifndef STANDALONE if (CommandThread) TerminateThread(CommandThread, 0); #endif @@ -273,7 +272,7 @@ #ifndef STANDALONE else { - /* Stop accepting new commands */ + /* A command is running, let it run, but stop accepting new commands */ AcceptCommands = FALSE; } #endif @@ -434,9 +433,60 @@ DPRINT1("Focus events not handled\n"); }
+static BOOL +LoadGlobalSettings(VOID) +{ +// FIXME: These strings should be localized. +#define ERROR_MEMORYVDD L"Insufficient memory to load installable Virtual Device Drivers." +#define ERROR_REGVDD L"Virtual Device Driver format in the registry is invalid." +#define ERROR_LOADVDD L"An installable Virtual Device Driver failed Dll initialization." + + BOOL Success = TRUE; + LONG Error = 0; + + HKEY hNTVDMKey; + LPCWSTR NTVDMKeyName = L"SYSTEM\CurrentControlSet\Control\NTVDM"; + + /* Try to open the NTVDM registry key */ + Error = RegOpenKeyExW(HKEY_LOCAL_MACHINE, + NTVDMKeyName, + 0, + KEY_QUERY_VALUE, + &hNTVDMKey); + if (Error == ERROR_FILE_NOT_FOUND) + { + /* If the key just doesn't exist, don't do anything else */ + return TRUE; + } + else if (Error != ERROR_SUCCESS) + { + /* The key exists but there was an access error: display an error and quit */ + DisplayMessage(ERROR_REGVDD); + return FALSE; + } + + /* + * Now we can do: + * - CPU core choice + * - Video choice + * - Sound choice + * - Mem? + * - ... + * - Standalone mode? + * - Debug settings + */ + +// Quit: + RegCloseKey(hNTVDMKey); + return Success; +} + INT wmain(INT argc, WCHAR *argv[]) { + NtVdmArgc = argc; + NtVdmArgv = argv; + #ifdef STANDALONE
if (argc < 2) @@ -446,28 +496,10 @@ return 0; }
-#else - - INT i; - WCHAR *endptr; - - /* Parse the command line arguments */ - for (i = 1; i < argc; i++) - { - if (wcsncmp(argv[i], L"-i", 2) == 0) - { - /* This is the session ID */ - SessionId = wcstoul(argv[i] + 2, &endptr, 10); - - /* The VDM hasn't been started from a console, so quit when the task is done */ - AcceptCommands = FALSE; - } - } - -#endif - - NtVdmArgc = argc; - NtVdmArgv = argv; +#endif + + /* Load global VDM settings */ + LoadGlobalSettings();
DPRINT1("\n\n\nNTVDM - Starting...\n\n\n");
Modified: trunk/reactos/subsystems/mvdm/ntvdm/ntvdm.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/ntvdm... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/ntvdm.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/ntvdm.h [iso-8859-1] Thu May 7 01:23:33 2015 @@ -54,12 +54,6 @@
/* FUNCTIONS ******************************************************************/
-#ifndef STANDALONE -extern BOOLEAN AcceptCommands; -extern HANDLE CommandThread; -extern ULONG SessionId; -#endif - extern HANDLE VdmTaskEvent;
// Command line of NTVDM
Modified: trunk/reactos/subsystems/mvdm/ntvdm/vddsup.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/vddsu... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/vddsup.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/vddsup.c [iso-8859-1] Thu May 7 01:23:33 2015 @@ -234,6 +234,7 @@
static BOOL LoadInstallableVDD(VOID) { +// FIXME: These strings should be localized. #define ERROR_MEMORYVDD L"Insufficient memory to load installable Virtual Device Drivers." #define ERROR_REGVDD L"Virtual Device Driver format in the registry is invalid." #define ERROR_LOADVDD L"An installable Virtual Device Driver failed Dll initialization."