https://git.reactos.org/?p=reactos.git;a=commitdiff;h=25c7e1a8d049932380fb1…
commit 25c7e1a8d049932380fb101bf413142dd058d723
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Sat Dec 16 21:48:17 2017 +0100
[VFD] Import the VFD project (Virtual Floppy Drive) which allows creating virtual
floppy drives in ReactOS and mount images on them.
Only the cmd got imported. The GUI interface may come later on.
Note that, as for vcdrom, the driver is left disabled and you need to explicitely
start it through vfd command line interface.
CORE-14090
---
modules/rosapps/CMakeLists.txt | 1 +
.../rosapps/applications/cmdutils/CMakeLists.txt | 1 +
.../applications/cmdutils/vfdcmd/CMakeLists.txt | 10 +
.../rosapps/applications/cmdutils/vfdcmd/vfdcmd.c | 3498 ++++++++++++++++++++
.../rosapps/applications/cmdutils/vfdcmd/vfdcmd.rc | 6 +
.../rosapps/applications/cmdutils/vfdcmd/vfdcmd.rs | 49 +
.../rosapps/applications/cmdutils/vfdcmd/vfdmsg.mc | 1596 +++++++++
modules/rosapps/drivers/CMakeLists.txt | 1 +
modules/rosapps/drivers/vfd/CMakeLists.txt | 19 +
modules/rosapps/drivers/vfd/imports.h | 357 ++
modules/rosapps/drivers/vfd/vfd_reg.inf | 7 +
modules/rosapps/drivers/vfd/vfddbg.c | 1799 ++++++++++
modules/rosapps/drivers/vfd/vfddbg.h | 79 +
modules/rosapps/drivers/vfd/vfddev.c | 407 +++
modules/rosapps/drivers/vfd/vfddrv.c | 523 +++
modules/rosapps/drivers/vfd/vfddrv.h | 357 ++
modules/rosapps/drivers/vfd/vfddrv.rc | 30 +
modules/rosapps/drivers/vfd/vfdfmt.c | 234 ++
modules/rosapps/drivers/vfd/vfdimg.c | 527 +++
modules/rosapps/drivers/vfd/vfdioctl.c | 591 ++++
modules/rosapps/drivers/vfd/vfdlink.c | 226 ++
modules/rosapps/drivers/vfd/vfdmnt.c | 665 ++++
modules/rosapps/drivers/vfd/vfdpnp.c | 474 +++
modules/rosapps/drivers/vfd/vfdrdwr.c | 357 ++
modules/rosapps/include/CMakeLists.txt | 1 +
modules/rosapps/include/vfd/CMakeLists.txt | 0
modules/rosapps/include/vfd/vfdapi.h | 324 ++
modules/rosapps/include/vfd/vfdio.h | 393 +++
modules/rosapps/include/vfd/vfdtypes.h | 77 +
modules/rosapps/include/vfd/vfdver.h | 72 +
modules/rosapps/include/vfd/vfdver.rc | 79 +
modules/rosapps/lib/CMakeLists.txt | 1 +
modules/rosapps/lib/vfdlib/CMakeLists.txt | 33 +
modules/rosapps/lib/vfdlib/res/config.ico | Bin 0 -> 1078 bytes
modules/rosapps/lib/vfdlib/res/image.ico | Bin 0 -> 1078 bytes
modules/rosapps/lib/vfdlib/res/vfd.ico | Bin 0 -> 1078 bytes
modules/rosapps/lib/vfdlib/vfdctl.c | 3272 ++++++++++++++++++
modules/rosapps/lib/vfdlib/vfdfat.c | 205 ++
modules/rosapps/lib/vfdlib/vfdguiopen.c | 562 ++++
modules/rosapps/lib/vfdlib/vfdguirc.h | 47 +
modules/rosapps/lib/vfdlib/vfdguisave.c | 529 +++
modules/rosapps/lib/vfdlib/vfdguitip.c | 354 ++
modules/rosapps/lib/vfdlib/vfdguiut.c | 581 ++++
modules/rosapps/lib/vfdlib/vfdlib.c | 184 +
modules/rosapps/lib/vfdlib/vfdlib.h | 185 ++
modules/rosapps/lib/vfdlib/vfdlib.rc | 219 ++
modules/rosapps/lib/vfdlib/vfdlib.rs | 83 +
modules/rosapps/lib/vfdlib/vfdlib.spec | 55 +
modules/rosapps/lib/vfdlib/vfdmsg_lib.mc | 523 +++
modules/rosapps/lib/vfdlib/vfdshcfact.cpp | 126 +
modules/rosapps/lib/vfdlib/vfdshcfact.h | 42 +
modules/rosapps/lib/vfdlib/vfdshext.cpp | 235 ++
modules/rosapps/lib/vfdlib/vfdshext.h | 99 +
modules/rosapps/lib/vfdlib/vfdshguid.h | 17 +
modules/rosapps/lib/vfdlib/vfdshmenu.cpp | 597 ++++
modules/rosapps/lib/vfdlib/vfdshprop.cpp | 434 +++
modules/rosapps/lib/vfdlib/vfdshutil.cpp | 419 +++
modules/rosapps/lib/vfdlib/vfdzip.c | 422 +++
58 files changed, 21984 insertions(+)
diff --git a/modules/rosapps/CMakeLists.txt b/modules/rosapps/CMakeLists.txt
index 7ffa0b4d85..58a32c1c18 100644
--- a/modules/rosapps/CMakeLists.txt
+++ b/modules/rosapps/CMakeLists.txt
@@ -1,6 +1,7 @@
add_subdirectory(applications)
add_subdirectory(demos)
add_subdirectory(drivers)
+add_subdirectory(include)
add_subdirectory(lib)
add_subdirectory(templates)
diff --git a/modules/rosapps/applications/cmdutils/CMakeLists.txt
b/modules/rosapps/applications/cmdutils/CMakeLists.txt
index 843b2c5be5..6d5488d30a 100644
--- a/modules/rosapps/applications/cmdutils/CMakeLists.txt
+++ b/modules/rosapps/applications/cmdutils/CMakeLists.txt
@@ -6,5 +6,6 @@ add_subdirectory(tee)
add_subdirectory(touch)
add_subdirectory(uptime)
add_subdirectory(vcdcli)
+add_subdirectory(vfdcmd)
add_subdirectory(winspool_print)
add_subdirectory(y)
diff --git a/modules/rosapps/applications/cmdutils/vfdcmd/CMakeLists.txt
b/modules/rosapps/applications/cmdutils/vfdcmd/CMakeLists.txt
new file mode 100644
index 0000000000..fa653f1818
--- /dev/null
+++ b/modules/rosapps/applications/cmdutils/vfdcmd/CMakeLists.txt
@@ -0,0 +1,10 @@
+
+add_message_headers(ANSI vfdmsg.mc)
+
+include_directories(${REACTOS_SOURCE_DIR}/modules/rosapps/include/vfd)
+add_executable(vfdcmd vfdcmd.c vfdcmd.rc)
+set_module_type(vfdcmd win32cui)
+add_importlibs(vfdcmd advapi32 vfd user32 msvcrt kernel32 ntdll)
+add_dependencies(vfdcmd vfdmsg)
+set_target_properties(vfdcmd PROPERTIES OUTPUT_NAME "vfd")
+add_cd_file(TARGET vfdcmd DESTINATION reactos/system32 FOR all)
diff --git a/modules/rosapps/applications/cmdutils/vfdcmd/vfdcmd.c
b/modules/rosapps/applications/cmdutils/vfdcmd/vfdcmd.c
new file mode 100644
index 0000000000..8cd40bfd93
--- /dev/null
+++ b/modules/rosapps/applications/cmdutils/vfdcmd/vfdcmd.c
@@ -0,0 +1,3498 @@
+/*
+ vfdcmd.c
+
+ Virtual Floppy Drive for Windows
+ Driver control program (console version)
+
+ Copyright (C) 2003-2008 Ken Kato
+*/
+
+#ifdef __cplusplus
+#pragma message(__FILE__": Compiled as C++ for testing purpose.")
+#endif // __cplusplus
+
+#define WIN32_LEAN_AND_MEAN
+#define _CRTDBG_MAP_ALLOC
+#include <windows.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <crtdbg.h>
+
+#ifndef INVALID_FILE_ATTRIBUTES
+#define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
+#endif // INVALID_FILE_ATTRIBUTES
+
+#include "vfdtypes.h"
+#include "vfdapi.h"
+#include "vfdver.h"
+#include "vfdmsg.h"
+
+//
+// current driver state
+//
+static DWORD driver_state = VFD_NOT_INSTALLED;
+
+//
+// interactive flag
+//
+static const char *help_progname = "VFD.EXE ";
+
+//
+// command functions return value
+//
+#define VFD_OK 0
+#define VFD_NG 1
+
+//
+// operation mode
+//
+#define OPERATION_ASK 0 // ask user on error
+#define OPERATION_QUIT 1 // quits on error
+#define OPERATION_FORCE 2 // force on error
+
+//
+// invalid target number
+//
+#define TARGET_NONE (ULONG)-1
+
+//
+// command processing functions
+//
+typedef int (*cmdfnc)(const char **args);
+
+static int Install(const char **args);
+static int Remove(const char **args);
+static int Config(const char **args);
+static int Start(const char **args);
+static int Stop(const char **args);
+static int Shell(const char **args);
+static int Open(const char **args);
+static int Close(const char **args);
+static int Save(const char **args);
+static int Protect(const char **args);
+static int Format(const char **args);
+static int Link(const char **args);
+static int Unlink(const char **args);
+static int Status(const char **args);
+static int Help(const char **args);
+static int Version(const char **args);
+
+//
+// Command table
+//
+static const struct {
+ char *cmd; // command string
+ int max_args; // maximum allowed number of argc
+ cmdfnc func; // command processing function
+ DWORD hint; // command hint message id
+}
+Commands[] = {
+ {"INSTALL", 2, Install, MSG_HINT_INSTALL},
+ {"REMOVE", 1, Remove, MSG_HINT_REMOVE },
+ {"CONFIG", 1, Config, MSG_HINT_CONFIG },
+ {"START", 0, Start, MSG_HINT_START },
+ {"STOP", 1, Stop, MSG_HINT_STOP },
+ {"SHELL", 1, Shell, MSG_HINT_SHELL },
+ {"OPEN", 6, Open, MSG_HINT_OPEN },
+ {"CLOSE", 2, Close, MSG_HINT_CLOSE },
+ {"SAVE", 3, Save, MSG_HINT_SAVE, },
+ {"PROTECT", 2, Protect, MSG_HINT_PROTECT},
+ {"FORMAT", 2, Format, MSG_HINT_FORMAT },
+ {"LINK", 3, Link, MSG_HINT_LINK },
+ {"ULINK", 1, Unlink, MSG_HINT_ULINK },
+ {"STATUS", 0, Status, MSG_HINT_STATUS },
+ {"HELP", 1, Help, MSG_HELP_HELP },
+ {"?", 1, Help, MSG_HELP_HELP },
+ {"VERSION", 0, Version, MSG_HINT_VERSION},
+ {0, 0, 0, 0}
+};
+
+//
+// Help message table
+//
+static const struct {
+ char *keyword; // help keyword
+ DWORD help; // help message id
+}
+HelpMsg[] = {
+ {"GENERAL", MSG_HELP_GENERAL},
+ {"CONSOLE", MSG_HELP_CONSOLE},
+ {"INSTALL", MSG_HELP_INSTALL},
+ {"REMOVE", MSG_HELP_REMOVE },
+ {"CONFIG", MSG_HELP_CONFIG },
+ {"START", MSG_HELP_START },
+ {"STOP", MSG_HELP_STOP },
+ {"SHELL", MSG_HELP_SHELL },
+ {"OPEN", MSG_HELP_OPEN },
+ {"CLOSE", MSG_HELP_CLOSE },
+ {"SAVE", MSG_HELP_SAVE },
+ {"PROTECT", MSG_HELP_PROTECT},
+ {"FORMAT", MSG_HELP_FORMAT },
+ {"LINK", MSG_HELP_LINK },
+ {"ULINK", MSG_HELP_ULINK },
+ {"STATUS", MSG_HELP_STATUS },
+ {"HELP", MSG_HELP_HELP },
+ {"VERSION", MSG_HINT_VERSION},
+ {0, 0}
+};
+
+//
+// local functions
+//
+static int InteractiveConsole();
+static int ProcessCommandLine(int argc, const char **args);
+static int ParseCommand(const char *cmd);
+static int ParseHelpTopic(const char *topic);
+static int CheckDriver();
+static int InputChar(ULONG msg, PCSTR ans);
+static void PrintImageInfo(HANDLE hDevice);
+static void PrintDriveLetter(HANDLE hDevice, ULONG nDrive);
+static void PrintMessage(UINT msg, ...);
+static BOOL ConsolePager(char *pBuffer, BOOL bReset);
+static const char *SystemError(DWORD err);
+static void ConvertPathCase(char *src, char *dst);
+
+//
+// utility macro
+//
+#define IS_WINDOWS_NT() ((GetVersion() & 0xff) < 5)
+
+//
+// main
+//
+int main(int argc, const char **argv)
+{
+#ifdef _DEBUG
+
+ // output vfd.exe command reference text
+
+ if (*(argv + 1) && !_stricmp(*(argv + 1), "doc")) {
+ int idx = 0;
+ char *buf = "";
+
+ printf("\r\n VFD.EXE Command Reference\r\n");
+
+ while (HelpMsg[idx].keyword) {
+ int len = strlen(HelpMsg[idx].keyword);
+
+ printf(
+ "\r\n\r\n"
+ "====================\r\n"
+ "%*s\r\n"
+ "====================\r\n"
+ "\r\n",
+ (20 + len) / 2, HelpMsg[idx].keyword);
+
+ FormatMessage(
+ FORMAT_MESSAGE_FROM_HMODULE |
+ FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_ARGUMENT_ARRAY,
+ NULL, HelpMsg[idx].help, 0,
+ (LPTSTR)&buf, 0, (va_list *)&help_progname);
+
+ printf("%s", buf);
+
+ LocalFree(buf);
+
+ idx++;
+ }
+
+ return 0;
+ }
+#endif
+
+ // Reports memory leaks at process termination
+
+ _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
+
+ // Check the operating system version
+
+ if (!VfdIsValidPlatform()) {
+ PrintMessage(MSG_WRONG_PLATFORM);
+ return VFD_NG;
+ }
+
+ if (argc < 2) {
+ // If no parameter is given, enter the interactive mode
+
+ return InteractiveConsole();
+ }
+ else {
+ // Perform a single operation
+
+ return ProcessCommandLine(argc - 1, argv + 1);
+ }
+}
+
+//
+// VFD interactive console
+//
+int InteractiveConsole()
+{
+ char input[1024]; // user input buffer
+
+ int argc; // number of args in the user input
+ char *args[10]; // args to pass to command functions
+
+ char sepa; // argument separator
+ char *p; // work pointer
+
+ // Disable the system default Ctrl+C handler
+
+ SetConsoleCtrlHandler(NULL, TRUE);
+
+ // Set the console title
+
+ SetConsoleTitle(VFD_PRODUCT_DESC);
+
+ // print version information and the console hint text
+
+ Version(NULL);
+
+ PrintMessage(MSG_CONSOLE_HINT);
+
+ // set interactive flag to exclude "VFD.EXE" from help text
+
+ help_progname = "";
+
+ // process user input
+
+ for (;;) {
+
+ // print the prompt
+
+ printf("[VFD] ");
+ fflush(stdout);
+
+ // read user input
+
+ fflush(stdin);
+ p = fgets(input, sizeof(input), stdin);
+
+ if (p == NULL) {
+
+ // most likely <ctrl+c>
+
+ printf("exit\n");
+ break;
+ }
+
+ // skip leading blank characters
+
+ while (*p == ' ' || *p == '\t' || *p == '\n') {
+ p++;
+ }
+
+ if (*p == '\0') {
+
+ // empty input
+
+ continue;
+ }
+
+ // handle external commands
+
+ if (!_strnicmp(p, "dir", 3) ||
+ !_strnicmp(p, "attrib", 6)) {
+
+ // special cases - frequently used commands
+ // pass these to system() even without '.'
+
+ system(p);
+ printf("\n");
+ continue;
+ }
+ else if (*p == '.') {
+
+ // external command
+
+ system(p + 1);
+ printf("\n");
+ continue;
+ }
+
+ // split the input line into parameters (10 parameters max)
+
+ argc = 0;
+ ZeroMemory(args, sizeof(args));
+
+ do {
+ // top of a parameter
+
+ args[argc++] = p;
+
+ // is the parameter quoted?
+
+ if (*p == '\"' || *p == '\'') {
+ sepa = *(p++);
+ }
+ else {
+ sepa = ' ';
+ }
+
+ // search the end of the parameter
+
+ while (*p && *p != '\n') {
+ if (sepa == ' ') {
+ if (*p == '\t' || *p == ' ') {
+ break; // tail of a non-quoted parameter
+ }
+ }
+ else {
+ if (*p == sepa) {
+ sepa = ' '; // close quote
+ }
+ }
+ p++;
+ }
+
+ // terminate the parameter
+
+ if (*p) {
+ *(p++) = '\0';
+ }
+
+ // skip trailing blank characters
+
+ while (*p == ' ' || *p == '\t' || *p == '\n') {
+ p++;
+ }
+
+ if (*p == '\0') {
+
+ // end of the input line - no more args
+
+ break;
+ }
+ }
+ while (argc < sizeof(args) / sizeof(args[0]));
+
+ // check the first parameter for special commands
+
+ if (!_stricmp(args[0], "exit") ||
+ !_stricmp(args[0], "quit") ||
+ !_stricmp(args[0], "bye")) {
+
+ // exit command
+
+ break;
+ }
+ else if (!_stricmp(args[0], "cd") ||
+ !_stricmp(args[0], "chdir")) {
+
+ // internal change directory command
+
+ if (args[1]) {
+ char path[MAX_PATH];
+ int i;
+
+ // ignore the /d option (of the standard cd command)
+
+ if (_stricmp(args[1], "/d")) {
+ i = 1;
+ }
+ else {
+ i = 2;
+ }
+
+ p = args[i];
+
+ if (*p == '\"' || *p == '\'') {
+
+ // the parameter is quoted -- remove quotations
+
+ p++;
+
+ while (*p && *p != *args[i]) {
+ p++;
+ }
+
+ args[i]++; // skip a leading quote
+ *p = '\0'; // remove a trailing quote
+ }
+ else {
+
+ // the parameter is not quoted
+ // -- concatenate params to allow spaces in unquoted path
+
+ while (i < argc - 1) {
+ *(args[i] + strlen(args[i])) = ' ';
+ i++;
+ }
+ }
+
+ // Match the case of the path to the name on the disk
+
+ ConvertPathCase(p, path);
+
+ if (!SetCurrentDirectory(path)) {
+ DWORD ret = GetLastError();
+
+ if (ret == ERROR_FILE_NOT_FOUND) {
+ ret = ERROR_PATH_NOT_FOUND;
+ }
+
+ printf("%s", SystemError(ret));
+ }
+ }
+ else {
+ if (!GetCurrentDirectory(sizeof(input), input)) {
+ printf("%s", SystemError(GetLastError()));
+ }
+ else {
+ printf("%s\n", input);
+ }
+ }
+ }
+ else if (isalpha(*args[0]) &&
+ *(args[0] + 1) == ':' &&
+ *(args[0] + 2) == '\0') {
+
+ // internal change drive command
+
+ *args[0] = (char)toupper(*args[0]);
+ *(args[0] + 2) = '\\';
+ *(args[0] + 3) = '\0';
+
+ if (!SetCurrentDirectory(args[0])) {
+ printf("%s", SystemError(GetLastError()));
+ }
+ }
+ else {
+
+ // perform the requested VFD command
+
+ ProcessCommandLine(argc, (const char **)args);
+ }
+
+ printf("\n");
+ }
+
+ return VFD_OK;
+}
+
+//
+// process a single command
+//
+int ProcessCommandLine(int argc, const char **args)
+{
+ int cmd;
+ DWORD ret;
+
+ //
+ // Decide a command to perform
+ //
+ cmd = ParseCommand(*args);
+
+ if (cmd < 0) {
+
+ // no matching command
+
+ return VFD_NG;
+ }
+
+ if (*(++args) &&
+ (!strcmp(*args, "/?") ||
+ !_stricmp(*args, "/h"))) {
+
+ // print a short hint for the command
+
+ PrintMessage(Commands[cmd].hint);
+ return VFD_NG;
+ }
+
+ if (--argc > Commands[cmd].max_args) {
+
+ // too many parameters for the command
+
+ PrintMessage(MSG_TOO_MANY_ARGS);
+ PrintMessage(Commands[cmd].hint);
+ return VFD_NG;
+ }
+
+ // Get the current driver state
+
+ ret = VfdGetDriverState(&driver_state);
+
+ if (ret != ERROR_SUCCESS) {
+ PrintMessage(MSG_GET_STAT_NG);
+ printf("%s", SystemError(ret));
+ return VFD_NG;
+ }
+
+ // Perform the requested operation
+
+ return (*Commands[cmd].func)(args);
+}
+
+//
+// Install the Virtual Floppy Driver
+// Command Line Parameters:
+// (optional) driver file path - default to executive's dir
+// (optional) auto start switch - default to demand start
+//
+int Install(const char **args)
+{
+ const char *install_path = NULL;
+ DWORD start_type = SERVICE_DEMAND_START;
+
+ DWORD ret;
+
+ // process parameters
+
+ while (args && *args) {
+
+ if (!_stricmp(*args, "/a") ||
+ !_stricmp(*args, "/auto")) {
+
+ if (start_type != SERVICE_DEMAND_START) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+/*
+ if (IS_WINDOWS_NT()) {
+
+ // On Windows NT, SYSTEM start drivers must be placed
+ // under the winnt\system32 directory. Since I don't
+ // care to handle driver file copying, I use the AUTO
+ // start method for Windows NT.
+
+ start_type = SERVICE_AUTO_START;
+ }
+ else {
+
+ // On Windows XP, the VFD driver must be running when
+ // the shell starts -- otherwise the shell doesn't
+ // recognize the VFD drives. Since Windows XP allows
+ // SYSTEM start drivers to be placed in any local
+ // directories, I use the SYSTEM start method here.
+ //
+ // This is not an issue when the driver is started
+ // manually because in that case VFD.EXE and VFDWIN.EXE
+ // notify the shell of the VFD drives.
+ //
+ // On Windows 2000 both SYSTEM and AUTO work fine.
+
+ start_type = SERVICE_SYSTEM_START;
+ }
+*/
+ // On second thought -- Win2K / XP mount manager assigns
+ // arbitrary drive letters to all drives it finds during
+ // the system start up. There is no way to prevent it
+ // until the driver is fully PnP compatible, so I'd settle
+ // for AUTO start for the time being.
+
+ start_type = SERVICE_AUTO_START;
+ }
+ else if (**args == '/') {
+ PrintMessage(MSG_UNKNOWN_OPTION, *args);
+ PrintMessage(MSG_HINT_INSTALL, help_progname);
+ return VFD_NG;
+ }
+ else {
+ if (install_path) {
+ PrintMessage(MSG_DUPLICATE_ARGS, "path");
+ return VFD_NG;
+ }
+
+ install_path = *args;
+ }
+
+ args++;
+ }
+
+ // already installed?
+
+ if (driver_state != VFD_NOT_INSTALLED) {
+ PrintMessage(MSG_DRIVER_EXISTS);
+ return VFD_NG;
+ }
+
+ // install the driver
+
+ ret = VfdInstallDriver(
+ install_path,
+ start_type);
+
+ if (ret != ERROR_SUCCESS) {
+ PrintMessage(MSG_INSTALL_NG);
+ printf("%s", SystemError(ret));
+ return VFD_NG;
+ }
+
+ // Get the latest driver state
+
+ ret = VfdGetDriverState(&driver_state);
+
+ if (ret != ERROR_SUCCESS) {
+ PrintMessage(MSG_GET_STAT_NG);
+ printf("%s", SystemError(ret));
+ return VFD_NG;
+ }
+
+ // operation successfull
+
+ PrintMessage(MSG_INSTALL_OK);
+
+ return VFD_OK;
+}
+
+//
+// Remove Virtual Floppy Driver from system
+// Command Line Parameters:
+// [/F | /FORCE | /Q | /QUIT]
+// /F forces remove operation if the driver cannot be stopped
+// /Q quits remove operation if the driver cannot be stopped
+//
+int Remove(const char **args)
+{
+ int mode = OPERATION_ASK;
+ const char *stop_params[] = { NULL, NULL };
+ DWORD ret;
+ int idx;
+
+ // parse parameters
+
+ while (args && *args) {
+
+ if (!_stricmp(*args, "/f") ||
+ !_stricmp(*args, "/force")) {
+
+ if (mode != OPERATION_ASK) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ mode = OPERATION_FORCE;
+ stop_params[0] = *args;
+ }
+ else if (!_stricmp(*args, "/q") ||
+ !_stricmp(*args, "/quit")) {
+
+ if (mode != OPERATION_ASK) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ mode = OPERATION_QUIT;
+ stop_params[0] = *args;
+ }
+ else {
+ PrintMessage(MSG_UNKNOWN_OPTION, *args);
+ PrintMessage(MSG_HINT_REMOVE, help_progname);
+ return VFD_NG;
+ }
+
+ args++;
+ }
+
+ // ensure the driver is installed
+
+ if (driver_state == VFD_NOT_INSTALLED) {
+ PrintMessage(MSG_NOT_INSTALLED);
+ return VFD_NG;
+ }
+
+ // ensure the driver is stopped
+
+ if (driver_state == SERVICE_RUNNING) {
+
+ // Try to stop with the same command line option (/F or /Q)
+
+ while (Stop(stop_params) != VFD_OK) {
+
+ // stop failed
+
+ if (mode == OPERATION_FORCE) {
+ PrintMessage(MSG_REMOVE_FORCE);
+ break;
+ }
+ else if (mode == OPERATION_QUIT) {
+ PrintMessage(MSG_REMOVE_QUIT);
+ return VFD_NG;
+ }
+ else {
+ int c;
+
+ PrintMessage(MSG_REMOVE_WARN);
+
+ c = InputChar(MSG_RETRY_FORCE_CANCEL, "rfc");
+
+ if (c == 'f') { // force
+ break;
+ }
+ else if (c == 'c') { // cancel
+ return VFD_NG;
+ }
+ }
+ }
+ }
+
+ // remove the driver
+
+ ret = VfdRemoveDriver();
+
+ if (ret != ERROR_SUCCESS) {
+ PrintMessage(MSG_REMOVE_NG);
+ printf("%s", SystemError(ret));
+ return VFD_NG;
+ }
+
+ // Wait for the driver to be actually removed for 3 secs Max.
+
+ for (idx = 0; idx < 10; idx++) {
+
+ ret = VfdGetDriverState(&driver_state);
+
+ if (ret != ERROR_SUCCESS) {
+ PrintMessage(MSG_GET_STAT_NG);
+ printf("%s", SystemError(ret));
+ return VFD_NG;
+ }
+
+ if (driver_state == VFD_NOT_INSTALLED) {
+ break;
+ }
+
+ Sleep(300);
+ }
+
+ if (driver_state != VFD_NOT_INSTALLED) {
+ PrintMessage(MSG_REMOVE_PENDING);
+ return VFD_NG;
+ }
+
+ // operation successful
+
+ PrintMessage(MSG_REMOVE_OK);
+
+ return VFD_OK;
+}
+
+//
+// Configure the Virtual Floppy Driver
+// Command Line Parameters:
+// /auto, /manual
+//
+int Config(const char **args)
+{
+ DWORD start_type = SERVICE_DISABLED;
+ DWORD ret;
+
+ while (args && *args) {
+ if (!_stricmp(*args, "/a") ||
+ !_stricmp(*args, "/auto")) {
+
+ if (start_type != SERVICE_DISABLED) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ start_type = SERVICE_AUTO_START;
+ }
+ else if (!_stricmp(*args, "/m") ||
+ !_stricmp(*args, "/manual")) {
+
+ if (start_type != SERVICE_DISABLED) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ start_type = SERVICE_DEMAND_START;
+ }
+ else {
+ PrintMessage(MSG_UNKNOWN_OPTION, *args);
+ PrintMessage(MSG_HINT_CONFIG, help_progname);
+ return VFD_NG;
+ }
+
+ args++;
+ }
+
+ if (start_type == SERVICE_DISABLED) {
+ // no parameter is specified
+ PrintMessage(MSG_HINT_CONFIG, help_progname);
+ return VFD_NG;
+ }
+
+ // ensure that the driver is installed
+
+ if (driver_state == VFD_NOT_INSTALLED) {
+ PrintMessage(MSG_NOT_INSTALLED);
+ return VFD_NG;
+ }
+
+ // ensure that the driver is up to date
+
+ if (CheckDriver() != VFD_OK) {
+ return VFD_NG;
+ }
+
+ // configure the driver
+
+ ret = VfdConfigDriver(start_type);
+
+ if (ret != ERROR_SUCCESS) {
+ PrintMessage(MSG_CONFIG_NG);
+ printf("%s", SystemError(ret));
+ return VFD_NG;
+ }
+
+ // operation successfull
+
+ PrintMessage(MSG_CONFIG_OK);
+
+ return VFD_OK;
+}
+
+//
+// Start the Virtual Floppy Driver
+// Command Line Parameters: None
+//
+int Start(const char **args)
+{
+ DWORD ret;
+
+ UNREFERENCED_PARAMETER(args);
+
+ // ensure that the driver is installed
+
+ if (driver_state == VFD_NOT_INSTALLED &&
+ Install(NULL) != VFD_OK) {
+ return VFD_NG;
+ }
+
+ // ensure that the driver is up to date
+
+ if (CheckDriver() != VFD_OK) {
+ return VFD_NG;
+ }
+
+ // ensure that the driver is not running
+
+ if (driver_state == SERVICE_RUNNING) {
+ PrintMessage(MSG_ALREADY_RUNNING);
+ return VFD_NG;
+ }
+
+ // start the driver
+
+ ret = VfdStartDriver(&driver_state);
+
+ if (ret != ERROR_SUCCESS) {
+ PrintMessage(MSG_START_NG);
+ printf("%s", SystemError(ret));
+ return VFD_NG;
+ }
+
+ // operation successfull
+
+ PrintMessage(MSG_START_OK);
+
+ return VFD_OK;
+}
+
+//
+// Stop the Virtual Floppy Driver
+// Command Line Parameters:
+// /FORCE | /F Forces the operation on error
+// /QUIT | /Q Quits the operation on error
+//
+int Stop(const char **args)
+{
+ int mode = OPERATION_ASK;
+ const char *close_params[] = { "*", NULL, NULL };
+ DWORD ret;
+
+ while (args && *args) {
+ if (!_stricmp(*args, "/f") ||
+ !_stricmp(*args, "/force")) {
+
+ if (mode != OPERATION_ASK) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ mode = OPERATION_FORCE;
+
+ // parameter to pass to the Close() function
+ close_params[1] = *args;
+ }
+ else if (!_stricmp(*args, "/q") ||
+ !_stricmp(*args, "/quit")) {
+
+ if (mode != OPERATION_ASK) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ mode = OPERATION_QUIT;
+
+ // parameter to pass to the Close() function
+ close_params[1] = *args;
+ }
+ else {
+ PrintMessage(MSG_UNKNOWN_OPTION, *args);
+ PrintMessage(MSG_HINT_STOP, help_progname);
+ return VFD_NG;
+ }
+
+ args++;
+ }
+
+ // ensure that the driver is installed
+
+ if (driver_state == VFD_NOT_INSTALLED) {
+ PrintMessage(MSG_NOT_INSTALLED);
+ return VFD_NG;
+ }
+
+ // ensure that the driver is running
+
+ if (driver_state == SERVICE_STOPPED) {
+ PrintMessage(MSG_NOT_STARTED);
+ return VFD_NG;
+ }
+
+ // ensure that all drives are empty
+
+ if (driver_state == SERVICE_RUNNING) {
+
+ // Try to close drives with the same operation mode (/F or /Q)
+
+ while (Close(close_params) != VFD_OK) {
+
+ // close failed
+
+ if (mode == OPERATION_FORCE) {
+ PrintMessage(MSG_STOP_FORCE);
+ break;
+ }
+ else if (mode == OPERATION_QUIT) {
+ PrintMessage(MSG_STOP_QUIT);
+ return VFD_NG;
+ }
+ else {
+ int c;
+
+ PrintMessage(MSG_STOP_WARN);
+
+ c = InputChar(MSG_RETRY_FORCE_CANCEL, "rfc");
+
+ if (c == 'f') { // force
+ break;
+ }
+ else if (c == 'c') { // cancel
+ return VFD_NG;
+ }
+ }
+ }
+ }
+
+ // stop the driver
+
+ ret = VfdStopDriver(&driver_state);
+
+ if (ret != ERROR_SUCCESS) {
+ PrintMessage(MSG_STOP_NG);
+ printf("%s", SystemError(ret));
+ return VFD_NG;
+ }
+
+ if (driver_state != SERVICE_STOPPED) {
+ PrintMessage(MSG_STOP_PENDING);
+ return VFD_NG;
+ }
+
+ // operation successful
+
+ PrintMessage(MSG_STOP_OK);
+
+ return VFD_OK;
+}
+
+//
+// Enable / Disable the shell extension
+// Command Line Parameters:
+// (optional) /ON or /OFF
+//
+int Shell(const char **args)
+{
+ DWORD ret;
+
+ ret = VfdCheckHandlers();
+
+ if (ret != ERROR_SUCCESS &&
+ ret != ERROR_PATH_NOT_FOUND &&
+ ret != ERROR_FILE_NOT_FOUND) {
+ PrintMessage(MSG_GET_SHELLEXT_NG);
+ printf("%s", SystemError(ret));
+ return VFD_NG;
+ }
+
+ if (args && *args) {
+ if (_stricmp(*args, "/on") == 0) {
+ if (ret != ERROR_SUCCESS) {
+ ret = VfdRegisterHandlers();
+
+ if (ret != ERROR_SUCCESS) {
+ PrintMessage(MSG_SET_SHELLEXT_NG);
+ printf("%s", SystemError(ret));
+ return VFD_NG;
+ }
+ }
+ }
+ else if (_stricmp(*args, "/off") == 0) {
+ if (ret == ERROR_SUCCESS) {
+ ret = VfdUnregisterHandlers();
+
+ if (ret != ERROR_SUCCESS) {
+ PrintMessage(MSG_SET_SHELLEXT_NG);
+ printf("%s", SystemError(ret));
+ return VFD_NG;
+ }
+ }
+ }
+ else {
+ PrintMessage(MSG_UNKNOWN_OPTION, *args);
+ PrintMessage(MSG_HINT_SHELL, help_progname);
+ return VFD_NG;
+ }
+
+ ret = VfdCheckHandlers();
+ }
+
+ if (ret == ERROR_PATH_NOT_FOUND ||
+ ret == ERROR_FILE_NOT_FOUND) {
+ PrintMessage(MSG_SHELLEXT_DISABLED);
+ }
+ else if (ret == ERROR_SUCCESS) {
+ PrintMessage(MSG_SHELLEXT_ENABLED);
+ }
+ else {
+ PrintMessage(MSG_GET_SHELLEXT_NG);
+ printf("%s", SystemError(ret));
+ return VFD_NG;
+ }
+
+ return VFD_OK;
+}
+
+//
+// Open an image file to a Virtual Floppy Drive
+// Command Line Parameters:
+// [drive:] [file] [/NEW] [/RAM] [/P | /W]
+// [/size] [/media] [/F | /FORCE | /Q | /QUIT]
+
+int Open(const char **args)
+{
+ int mode = OPERATION_ASK;
+ BOOL create = FALSE;
+ ULONG target = TARGET_NONE;
+ PCSTR file_name = NULL;
+ VFD_DISKTYPE disk_type = VFD_DISKTYPE_FILE;
+ CHAR protect = '\0';
+ VFD_MEDIA media_type = VFD_MEDIA_NONE;
+ BOOL five_inch = FALSE;
+ VFD_FLAGS media_flags = 0;
+ HANDLE hDevice;
+ CHAR letter;
+ DWORD ret;
+
+ // process parameters
+
+ while (args && *args) {
+
+ if (!_stricmp(*args, "/f") ||
+ !_stricmp(*args, "/force")) {
+
+ if (mode != OPERATION_ASK) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ mode = OPERATION_FORCE;
+ }
+ else if (!_stricmp(*args, "/q") ||
+ !_stricmp(*args, "/quit")) {
+
+ if (mode != OPERATION_ASK) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ mode = OPERATION_QUIT;
+ }
+
+ else if (!_stricmp(*args, "/new")) {
+
+ if (create) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ create = TRUE;
+ }
+
+ // Disk type options
+
+ else if (_stricmp(*args, "/ram") == 0) {
+
+ if (disk_type != VFD_DISKTYPE_FILE) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ disk_type = VFD_DISKTYPE_RAM;
+ }
+
+ // Protect options
+ else if (_stricmp(*args, "/p") == 0 ||
+ _stricmp(*args, "/w") == 0) {
+
+ if (protect) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ protect = (CHAR)toupper(*(*args + 1));
+ }
+
+ // media size options
+
+ else if (strcmp(*args, "/160") == 0) {
+ if (media_type) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ media_type = VFD_MEDIA_F5_160;
+ }
+ else if (strcmp(*args, "/180") == 0) {
+ if (media_type) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ media_type = VFD_MEDIA_F5_180;
+ }
+ else if (strcmp(*args, "/320") == 0) {
+ if (media_type) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ media_type = VFD_MEDIA_F5_320;
+ }
+ else if (strcmp(*args, "/360") == 0) {
+ if (media_type) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ media_type = VFD_MEDIA_F5_360;
+ }
+ else if (strcmp(*args, "/640") == 0) {
+ if (media_type) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ media_type = VFD_MEDIA_F3_640;
+ }
+ else if (strcmp(*args, "/720") == 0) {
+ if (media_type) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ media_type = VFD_MEDIA_F3_720;
+ }
+ else if (strcmp(*args, "/820") == 0) {
+ if (media_type) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ media_type = VFD_MEDIA_F3_820;
+ }
+ else if (strcmp(*args, "/120") == 0 ||
+ strcmp(*args, "/1.20") == 0) {
+ if (media_type) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ media_type = VFD_MEDIA_F3_1P2;
+ }
+ else if (strcmp(*args, "/144") == 0 ||
+ strcmp(*args, "/1.44") == 0) {
+ if (media_type) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ media_type = VFD_MEDIA_F3_1P4;
+ }
+ else if (strcmp(*args, "/168") == 0 ||
+ strcmp(*args, "/1.68") == 0) {
+ if (media_type) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ media_type = VFD_MEDIA_F3_1P6;
+ }
+ else if (strcmp(*args, "/172") == 0 ||
+ strcmp(*args, "/1.72") == 0) {
+ if (media_type) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ media_type = VFD_MEDIA_F3_1P7;
+ }
+ else if (strcmp(*args, "/288") == 0 ||
+ strcmp(*args, "/2.88") == 0) {
+ if (media_type) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ media_type = VFD_MEDIA_F3_2P8;
+ }
+
+ // 5.25 inch media
+
+ else if (strcmp(*args, "/5") == 0 ||
+ strcmp(*args, "/525") == 0 ||
+ strcmp(*args, "/5.25") == 0) {
+
+ if (five_inch) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ five_inch = TRUE;
+ }
+
+ // target option
+
+ else if (isalnum(**args) &&
+ *(*args + 1) == ':' &&
+ *(*args + 2) == '\0') {
+
+ if (target != TARGET_NONE) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ target = toupper(**args);
+ }
+
+ // filename
+
+ else if (**args != '/') {
+ if (file_name) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ file_name = *args;
+ }
+ else {
+ PrintMessage(MSG_UNKNOWN_OPTION, *args);
+ PrintMessage(MSG_HINT_OPEN, help_progname);
+ return VFD_NG;
+ }
+
+ args++;
+ }
+
+ if (target == TARGET_NONE) {
+ // default target
+ target = '0';
+ PrintMessage(MSG_TARGET_NOTICE, target);
+ }
+
+ // check target file
+
+ if (file_name) {
+ DWORD file_attr;
+ VFD_FILETYPE file_type;
+ ULONG image_size;
+ BOOL overwrite = FALSE;
+
+ ret = VfdCheckImageFile(
+ file_name, &file_attr, &file_type, &image_size);
+
+ if (ret == ERROR_FILE_NOT_FOUND) {
+
+ // the target file does not exist
+
+ if (!create) { // create option not specified
+
+ if (mode == OPERATION_FORCE) {
+ PrintMessage(MSG_CREATE_NOTICE);
+ }
+ else {
+ printf("%s", SystemError(ret));
+
+ if (mode == OPERATION_QUIT ||
+ InputChar(MSG_CREATE_CONFIRM, "yn") == 'n') {
+ return VFD_NG;
+ }
+ }
+
+ create = TRUE;
+ }
+ }
+ else if (ret == ERROR_SUCCESS) {
+
+ // the target file exists
+
+ if (create) { // create option is specified
+
+ if (mode == OPERATION_FORCE) {
+ PrintMessage(MSG_OVERWRITE_NOTICE);
+ }
+ else {
+ printf("%s", SystemError(ERROR_FILE_EXISTS));
+
+ if (mode == OPERATION_QUIT ||
+ InputChar(MSG_OVERWRITE_CONFIRM, "yn") == 'n') {
+ return VFD_NG;
+ }
+ }
+
+ overwrite = TRUE;
+ }
+ }
+ else {
+ PrintMessage(MSG_OPEN_NG, file_name);
+ printf("%s", SystemError(ret));
+ return VFD_NG;
+ }
+
+ //
+ // create or overwrite the target file
+ //
+
+ if (create) {
+
+ if (media_type == VFD_MEDIA_NONE) {
+
+ if (mode == OPERATION_FORCE) {
+ PrintMessage(MSG_CREATE144_NOTICE);
+ }
+ else {
+ PrintMessage(MSG_FILE_MEDIA_UNKNOWN);
+
+ if (mode == OPERATION_QUIT ||
+ InputChar(MSG_CREATE144_CONFIRM, "yn") == 'n') {
+ return VFD_NG;
+ }
+ }
+
+ media_type = VFD_MEDIA_F3_1P4;
+ }
+
+ ret = VfdCreateImageFile(
+ file_name, media_type, VFD_FILETYPE_RAW, overwrite);
+
+ if (ret != ERROR_SUCCESS) {
+ PrintMessage(MSG_CREATE_NG, file_name);
+ printf("%s", SystemError(ret));
+ return VFD_NG;
+ }
+
+ PrintMessage(MSG_FILE_CREATED);
+
+ ret = VfdCheckImageFile(
+ file_name, &file_attr, &file_type, &image_size);
+
+ if (ret != ERROR_SUCCESS) {
+ PrintMessage(MSG_OPEN_NG, file_name);
+ printf("%s", SystemError(ret));
+ return VFD_NG;
+ }
+ }
+ else {
+ //
+ // use the existing target file
+ // check image size and the media type
+ //
+
+ VFD_MEDIA def_media; // default media for image size
+ ULONG media_size; // specified media size
+
+ media_size = VfdGetMediaSize(media_type);
+
+ if (media_size > image_size) {
+
+ // specified media is too large for the image
+
+ PrintMessage(MSG_IMAGE_TOO_SMALL);
+ return VFD_NG;
+ }
+
+ def_media = VfdLookupMedia(image_size);
+
+ if (def_media == VFD_MEDIA_NONE) {
+
+ // image is too small for the smallest media
+
+ PrintMessage(MSG_IMAGE_TOO_SMALL);
+ return VFD_NG;
+ }
+
+ if (media_type == VFD_MEDIA_NONE) {
+
+ // media type is not specified
+
+ ULONG def_size = VfdGetMediaSize(def_media);
+
+ if (def_size != image_size) {
+
+ // image size does not match the largest media size
+
+ PrintMessage(MSG_NO_MATCHING_MEDIA, image_size);
+
+ if (mode == OPERATION_FORCE) {
+ PrintMessage(MSG_MEDIATYPE_NOTICE,
+ VfdMediaTypeName(def_media), def_size);
+ }
+ else if (mode == OPERATION_QUIT) {
+ return VFD_NG;
+ }
+ else {
+ PrintMessage(MSG_MEDIATYPE_SUGGEST,
+ VfdMediaTypeName(def_media), def_size);
+
+ if (InputChar(MSG_MEDIATYPE_CONFIRM, "yn") == 'n') {
+ return VFD_NG;
+ }
+ }
+ }
+
+ media_type = def_media;
+ }
+ }
+
+ // check file attributes against the disk type
+
+ if (file_type == VFD_FILETYPE_ZIP ||
+ (file_attr & (FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_COMPRESSED |
FILE_ATTRIBUTE_ENCRYPTED))) {
+
+ if (disk_type != VFD_DISKTYPE_RAM) {
+
+ if (mode == OPERATION_FORCE) {
+ PrintMessage(MSG_RAM_MODE_NOTICE);
+ }
+ else {
+ PrintMessage(MSG_RAM_MODE_ONLY);
+
+ if (mode == OPERATION_QUIT ||
+ InputChar(MSG_RAM_MODE_CONFIRM, "yn") == 'n') {
+ return VFD_NG;
+ }
+ }
+
+ disk_type = VFD_DISKTYPE_RAM;
+ }
+ }
+
+ if (disk_type != VFD_DISKTYPE_FILE) {
+ if (!protect) {
+ PrintMessage(MSG_DEFAULT_PROTECT);
+ protect = 'P';
+ }
+ }
+ }
+ else {
+ //
+ // pure RAM disk
+ //
+ disk_type = VFD_DISKTYPE_RAM;
+
+ if (media_type == VFD_MEDIA_NONE) {
+
+ if (mode == OPERATION_FORCE) {
+ PrintMessage(MSG_CREATE144_NOTICE);
+ }
+ else {
+ PrintMessage(MSG_RAM_MEDIA_UNKNOWN);
+
+ if (mode == OPERATION_QUIT ||
+ InputChar(MSG_CREATE144_CONFIRM, "yn") == 'n') {
+ return VFD_NG;
+ }
+ }
+
+ media_type = VFD_MEDIA_F3_1P4;
+ }
+ }
+
+ if (protect == 'P') {
+ media_flags |= VFD_FLAG_WRITE_PROTECTED;
+ }
+
+ if (five_inch &&
+ VfdGetMediaSize(media_type) ==
+ VfdGetMediaSize((VFD_MEDIA)(media_type + 1))) {
+ media_type = (VFD_MEDIA)(media_type + 1);
+ }
+
+ // ensure that the driver is installed
+
+ if (driver_state == VFD_NOT_INSTALLED &&
+ Install(NULL) != VFD_OK) {
+ return VFD_NG;
+ }
+
+ // ensure that the driver is up to date
+
+ if (CheckDriver() != VFD_OK) {
+ return VFD_NG;
+ }
+
+ // ensure that the driver is running
+
+ if (driver_state != SERVICE_RUNNING &&
+ Start(NULL) != VFD_OK) {
+ return VFD_NG;
+ }
+
+ // Open the target device
+
+ hDevice = VfdOpenDevice(target);
+
+ if (hDevice == INVALID_HANDLE_VALUE) {
+ ret = GetLastError();
+ PrintMessage(MSG_ACCESS_NG, target);
+ printf("%s", SystemError(ret));
+ return VFD_NG;
+ }
+
+ // Ensure that the drive is empty
+
+ ret = VfdGetMediaState(hDevice);
+
+ if (ret != ERROR_NOT_READY) {
+ if (ret == ERROR_SUCCESS ||
+ ret == ERROR_WRITE_PROTECT) {
+ PrintMessage(MSG_DRIVE_BUSY);
+ }
+ else {
+ PrintMessage(MSG_GET_MEDIA_NG);
+ printf("%s", SystemError(ret));
+ }
+
+ CloseHandle(hDevice);
+ return VFD_NG;
+ }
+
+ // Open the image file
+
+ ret = VfdOpenImage(hDevice, file_name,
+ disk_type, media_type, media_flags);
+
+ if (ret != ERROR_SUCCESS) {
+ PrintMessage(MSG_OPEN_NG, file_name ? file_name : "<RAM>");
+ printf("%s", SystemError(ret));
+
+ CloseHandle(hDevice);
+ return VFD_NG;
+ }
+
+ // assign a drive letter if the drive has none
+
+ VfdGetGlobalLink(hDevice, &letter);
+
+ if (!isalpha(letter)) {
+ VfdGetLocalLink(hDevice, &letter);
+ }
+
+ if (!isalpha(letter)) {
+ VfdSetLocalLink(hDevice, VfdChooseLetter());
+ }
+
+ // Get the actually opened image information.
+
+ PrintImageInfo(hDevice);
+
+ CloseHandle(hDevice);
+
+ return VFD_OK;
+}
+
+//
+// Close the current virtual floppy image
+// Command Line Parameters:
+// drive number or drive letter
+// /F | /FORCE | /Q | /QUIT
+//
+int Close(const char **args)
+{
+ ULONG mode = OPERATION_ASK;
+
+ ULONG target_min = TARGET_NONE;
+ ULONG target_max = TARGET_NONE;
+ HANDLE hDevice;
+
+ VFD_MEDIA media_type;
+ VFD_FLAGS media_flags;
+
+ DWORD ret;
+
+ // check parameterS
+
+ while (args && *args) {
+
+ if (!_stricmp(*args, "/f") ||
+ !_stricmp(*args, "/force")) {
+
+ if (mode != OPERATION_ASK) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ mode = OPERATION_FORCE;
+ }
+ else if (!_stricmp(*args, "/q") ||
+ !_stricmp(*args, "/quit")) {
+
+ if (mode != OPERATION_ASK) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ mode = OPERATION_QUIT;
+ }
+ else if ((isalnum(**args) || **args == '*') &&
+ (*(*args + 1) == ':' || *(*args + 1) == '\0')) {
+
+ if (target_min != TARGET_NONE) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ if (**args == '*') {
+ target_min = '0';
+ target_max = '0' + VFD_MAXIMUM_DEVICES;
+ }
+ else {
+ target_min = toupper(**args);
+ target_max = target_min + 1;
+ }
+ }
+ else {
+ PrintMessage(MSG_UNKNOWN_OPTION, *args);
+ PrintMessage(MSG_HINT_CLOSE, help_progname);
+ return VFD_NG;
+ }
+
+ args++;
+ }
+
+ if (target_min == TARGET_NONE) {
+ // default target = drive 0
+ target_min = '0';
+ target_max = '1';
+ PrintMessage(MSG_TARGET_NOTICE, target_min);
+ }
+
+ // ensure that the driver is installed
+
+ if (driver_state == VFD_NOT_INSTALLED) {
+ PrintMessage(MSG_NOT_INSTALLED);
+ return VFD_NG;
+ }
+
+ // ensure that the driver is running
+
+ if (driver_state != SERVICE_RUNNING) {
+ PrintMessage(MSG_NOT_STARTED);
+ return VFD_NG;
+ }
+
+ // Close the drive(s)
+
+ while (target_min < target_max) {
+
+ // open the target device
+
+ hDevice = VfdOpenDevice(target_min);
+
+ if (hDevice == INVALID_HANDLE_VALUE) {
+ ret = GetLastError();
+
+ PrintMessage(MSG_ACCESS_NG, target_min);
+ printf("%s", SystemError(ret));
+
+ if (mode != OPERATION_FORCE) {
+ return VFD_NG;
+ }
+
+ target_min++;
+ continue;
+ }
+
+ // get the current image information
+
+ ret = VfdGetImageInfo(hDevice, NULL, NULL,
+ &media_type, &media_flags, NULL, NULL);
+
+ if (ret != ERROR_SUCCESS) {
+ PrintMessage(MSG_ACCESS_NG, target_min);
+ printf("%s", SystemError(ret));
+
+ CloseHandle(hDevice);
+
+ if (mode != OPERATION_FORCE) {
+ return VFD_NG;
+ }
+
+ target_min++;
+ continue;
+ }
+
+ if (media_type == VFD_MEDIA_NONE) {
+
+ // drive is empty
+
+ CloseHandle(hDevice);
+ target_min++;
+ continue;
+ }
+
+ if (media_flags & VFD_FLAG_DATA_MODIFIED) {
+
+ // RAM disk data is modified
+
+ PrintMessage(MSG_MEDIA_MODIFIED, target_min);
+
+ if (mode == OPERATION_FORCE) {
+ PrintMessage(MSG_CLOSE_FORCE);
+ }
+ else if (mode == OPERATION_QUIT) {
+ PrintMessage(MSG_CLOSE_QUIT);
+ CloseHandle(hDevice);
+ return VFD_NG;
+ }
+ else {
+ if (InputChar(MSG_CLOSE_CONFIRM, "yn") == 'n') {
+ CloseHandle(hDevice);
+ return VFD_NG;
+ }
+ }
+ }
+
+retry:
+ ret = VfdCloseImage(
+ hDevice, (mode == OPERATION_FORCE));
+
+ if (ret == ERROR_ACCESS_DENIED) {
+
+ PrintMessage(MSG_LOCK_NG, target_min);
+
+ if (mode == OPERATION_QUIT) {
+ CloseHandle(hDevice);
+ return VFD_NG;
+ }
+ else if (mode == OPERATION_ASK) {
+
+ int c;
+
+ if (IS_WINDOWS_NT()) {
+ c = InputChar(MSG_RETRY_CANCEL, "rc");
+ }
+ else {
+ c = InputChar(MSG_RETRY_FORCE_CANCEL, "rfc");
+ }
+
+ if (c == 'f') { // force
+ ret = VfdCloseImage(hDevice, TRUE);
+ }
+ else if (c == 'c') { // cancel
+ CloseHandle(hDevice);
+ return VFD_NG;
+ }
+ else {
+ goto retry;
+ }
+ }
+ }
+
+ CloseHandle(hDevice);
+
+ if (ret == ERROR_SUCCESS) {
+ PrintMessage(MSG_CLOSE_OK, target_min);
+ }
+ else if (ret != ERROR_NOT_READY) {
+ PrintMessage(MSG_CLOSE_NG, target_min);
+ printf("%s", SystemError(ret));
+
+ if (mode != OPERATION_FORCE) {
+ return VFD_NG;
+ }
+ }
+
+ target_min++;
+ }
+
+ return VFD_OK;
+}
+
+//
+// Save the current image into a file
+//
+int Save(const char **args)
+{
+ int mode = OPERATION_ASK;
+ ULONG target = TARGET_NONE;
+ CHAR file_name[MAX_PATH] = {0};
+ BOOL overwrite = FALSE;
+ BOOL truncate = FALSE;
+
+ HANDLE hDevice;
+ CHAR current[MAX_PATH] = {0};
+ VFD_MEDIA media_type;
+ VFD_FLAGS media_flags;
+ VFD_FILETYPE file_type;
+ DWORD file_attr;
+ ULONG image_size;
+ DWORD ret;
+
+ // check parameters
+
+ while (args && *args) {
+
+ if (!_stricmp(*args, "/f") ||
+ !_stricmp(*args, "/force")) {
+
+ if (mode != OPERATION_ASK) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ mode = OPERATION_FORCE;
+ }
+ else if (!_stricmp(*args, "/q") ||
+ !_stricmp(*args, "/quit")) {
+
+ if (mode != OPERATION_ASK) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ mode = OPERATION_QUIT;
+ }
+ else if (!_stricmp(*args, "/o") ||
+ !_stricmp(*args, "/over")) {
+
+ if (truncate || overwrite) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ overwrite = TRUE;
+ }
+ else if (!_stricmp(*args, "/t") ||
+ !_stricmp(*args, "/trunc")) {
+
+ if (truncate || overwrite) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ truncate = TRUE;
+ }
+ else if (isalnum(**args) &&
+ *(*args + 1) == ':' &&
+ *(*args + 2) == '\0') {
+
+ if (target != TARGET_NONE) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ target = toupper(**args);
+ }
+ else if (**args == '/') {
+ PrintMessage(MSG_UNKNOWN_OPTION, *args);
+ PrintMessage(MSG_HINT_SAVE, help_progname);
+ return VFD_NG;
+ }
+ else {
+ strcpy(file_name, *args);
+ }
+
+ args++;
+ }
+
+ if (target == TARGET_NONE) {
+ target = '0';
+ PrintMessage(MSG_TARGET_NOTICE, target);
+ }
+
+ // ensure that the driver is installed
+
+ if (driver_state == VFD_NOT_INSTALLED) {
+ PrintMessage(MSG_NOT_INSTALLED);
+ return VFD_NG;
+ }
+
+ // ensure that the driver is up to date
+
+ if (CheckDriver() != VFD_OK) {
+ return VFD_NG;
+ }
+
+ // ensure that the driver is running
+
+ if (driver_state != SERVICE_RUNNING) {
+ PrintMessage(MSG_NOT_STARTED);
+ return VFD_NG;
+ }
+
+ // Open the target device
+
+ hDevice = VfdOpenDevice(target);
+
+ if (hDevice == INVALID_HANDLE_VALUE) {
+ ret = GetLastError();
+ PrintMessage(MSG_ACCESS_NG, target);
+ printf("%s", SystemError(ret));
+ return VFD_NG;
+ }
+
+ // Get the current image info
+
+ ret = VfdGetImageInfo(hDevice, current, NULL,
+ &media_type, &media_flags, NULL, NULL);
+
+ if (ret != ERROR_SUCCESS) {
+ printf("%s", SystemError(ret));
+ CloseHandle(hDevice);
+ return VFD_NG;
+ }
+
+ if (media_type == VFD_MEDIA_NONE) {
+ printf("%s", SystemError(ERROR_NOT_READY));
+ CloseHandle(hDevice);
+ return VFD_NG;
+ }
+
+ if (file_name[0] == '\0') {
+
+ if (current[0] == '\0') {
+
+ PrintMessage(MSG_TARGET_REQUIRED);
+ CloseHandle(hDevice);
+
+ return VFD_NG;
+ }
+
+ strcpy(file_name, current);
+ }
+
+ if (!_stricmp(file_name, current)) {
+
+ // target is the current image file
+
+ if (!(media_flags & VFD_FLAG_DATA_MODIFIED)) {
+
+ // FILE disk (always up to date) or RAM disk is not modified
+
+ PrintMessage(MSG_TARGET_UP_TO_DATE);
+ CloseHandle(hDevice);
+
+ return VFD_OK;
+ }
+
+ overwrite = TRUE;
+ }
+
+ // check target file
+
+ ret = VfdCheckImageFile(file_name,
+ &file_attr, &file_type, &image_size);
+
+ if (ret == ERROR_SUCCESS) {
+
+ if (!overwrite && !truncate) {
+
+ if (mode == OPERATION_FORCE) {
+ PrintMessage(MSG_OVERWRITE_NOTICE);
+ overwrite = TRUE;
+ }
+ else if (mode == OPERATION_QUIT) {
+ printf("%s", SystemError(ERROR_FILE_EXISTS));
+ CloseHandle(hDevice);
+
+ return VFD_NG;
+ }
+ else {
+ int c;
+
+ printf("%s", SystemError(ERROR_FILE_EXISTS));
+
+ c = InputChar(MSG_OVERWRITE_PROMPT, "otc");
+
+ if (c == 'o') {
+ overwrite = TRUE;
+ }
+ else if (c == 't') {
+ truncate = TRUE;
+ }
+ else {
+ CloseHandle(hDevice);
+ return VFD_NG;
+ }
+ }
+ }
+ }
+ else if (ret != ERROR_FILE_NOT_FOUND) {
+
+ printf("%s", SystemError(ret));
+ CloseHandle(hDevice);
+
+ return VFD_NG;
+ }
+
+ if (file_type == VFD_FILETYPE_ZIP) {
+
+ // Cannot update a zip file
+
+ PrintMessage(MSG_TARGET_IS_ZIP);
+ CloseHandle(hDevice);
+
+ return VFD_NG;
+ }
+
+retry:
+ ret = VfdDismountVolume(
+ hDevice, (mode == OPERATION_FORCE));
+
+ if (ret == ERROR_ACCESS_DENIED) {
+
+ PrintMessage(MSG_LOCK_NG, target);
+
+ if (mode == OPERATION_FORCE) {
+ PrintMessage(MSG_SAVE_FORCE);
+ }
+ else if (mode == OPERATION_QUIT) {
+ PrintMessage(MSG_SAVE_QUIT);
+ CloseHandle(hDevice);
+ return VFD_NG;
+ }
+ else {
+ int c = InputChar(MSG_RETRY_FORCE_CANCEL, "rfc");
+
+ if (c == 'r') { // retry
+ goto retry;
+ }
+ else if (c == 'f') { // force
+ VfdDismountVolume(hDevice, TRUE);
+ }
+ else { // cancel
+ CloseHandle(hDevice);
+ return VFD_NG;
+ }
+ }
+ }
+ else if (ret != ERROR_SUCCESS) {
+ printf("%s", SystemError(ret));
+ CloseHandle(hDevice);
+ return VFD_NG;
+ }
+
+ ret = VfdSaveImage(hDevice, file_name,
+ (overwrite || truncate), truncate);
+
+ CloseHandle(hDevice);
+
+ if (ret != ERROR_SUCCESS) {
+ PrintMessage(MSG_SAVE_NG, target, file_name);
+ printf("%s", SystemError(ret));
+
+ return VFD_NG;
+ }
+
+ PrintMessage(MSG_SAVE_OK, target, file_name);
+
+ return VFD_OK;
+}
+
+//
+// Enable/disable virtual media write protection
+//
+int Protect(const char **args)
+{
+#define PROTECT_NONE 0
+#define PROTECT_ON 1
+#define PROTECT_OFF 2
+ ULONG protect = PROTECT_NONE;
+ ULONG target = TARGET_NONE;
+ HANDLE hDevice;
+ DWORD ret;
+
+ // check parameters
+
+ while (args && *args) {
+
+ // Disk type options
+
+ if (_stricmp(*args, "/on") == 0) {
+
+ if (protect) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ protect = PROTECT_ON;
+ }
+ else if (_stricmp(*args, "/off") == 0) {
+
+ if (protect) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ protect = PROTECT_OFF;
+ }
+ else if (isalnum(**args)) {
+
+ if (target != TARGET_NONE) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ target = toupper(**args);
+ }
+ else {
+ PrintMessage(MSG_UNKNOWN_OPTION, *args);
+ PrintMessage(MSG_HINT_PROTECT, help_progname);
+ return VFD_NG;
+ }
+
+ args++;
+ }
+
+ if (target == TARGET_NONE) {
+ target = '0';
+ PrintMessage(MSG_TARGET_NOTICE, target);
+ }
+
+ // ensure that the driver is installed
+
+ if (driver_state == VFD_NOT_INSTALLED) {
+ PrintMessage(MSG_NOT_INSTALLED);
+ return VFD_NG;
+ }
+
+ // ensure that the driver is up to date
+
+ if (CheckDriver() != VFD_OK) {
+ return VFD_NG;
+ }
+
+ // ensure that the driver is running
+
+ if (driver_state != SERVICE_RUNNING) {
+ PrintMessage(MSG_NOT_STARTED);
+ return VFD_NG;
+ }
+
+ // open the target drive
+
+ hDevice = VfdOpenDevice(target);
+
+ if (hDevice == INVALID_HANDLE_VALUE) {
+ ret = GetLastError();
+ PrintMessage(MSG_ACCESS_NG, target);
+ printf("%s", SystemError(ret));
+ return VFD_NG;
+ }
+
+ if (protect) {
+ // change protect state
+
+ ret = VfdWriteProtect(
+ hDevice, (protect == PROTECT_ON));
+
+ if (ret != ERROR_SUCCESS) {
+ PrintMessage(MSG_PROTECT_NG, target);
+ printf("%s", SystemError(ret));
+
+ CloseHandle(hDevice);
+ return VFD_NG;
+ }
+ }
+
+ // get the current protect state
+
+ ret = VfdGetMediaState(hDevice);
+
+ CloseHandle(hDevice);
+
+ if (ret == ERROR_SUCCESS) {
+ PrintMessage(MSG_MEDIA_WRITABLE);
+ }
+ else if (ret == ERROR_WRITE_PROTECT) {
+ PrintMessage(MSG_MEDIA_PROTECTED);
+ }
+ else {
+ PrintMessage(MSG_GET_MEDIA_NG);
+ printf("%s", SystemError(ret));
+ return VFD_NG;
+ }
+
+ return VFD_OK;
+}
+
+//
+// Format the virtual media with FAT12
+//
+int Format(const char **args)
+{
+ int mode = OPERATION_ASK;
+ ULONG target = TARGET_NONE;
+ HANDLE hDevice;
+ DWORD ret;
+
+ // check parameters
+
+ while (args && *args) {
+
+ if (!_stricmp(*args, "/f") ||
+ !_stricmp(*args, "/force")) {
+
+ if (mode != OPERATION_ASK) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ mode = OPERATION_FORCE;
+ }
+ else if (!_stricmp(*args, "/q") ||
+ !_stricmp(*args, "/quit")) {
+
+ if (mode != OPERATION_ASK) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ mode = OPERATION_QUIT;
+ }
+ else if (isalnum(**args)) {
+ if (target != TARGET_NONE) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ target = toupper(**args);
+ }
+ else {
+ PrintMessage(MSG_UNKNOWN_OPTION, *args);
+ PrintMessage(MSG_HINT_FORMAT, help_progname);
+ return VFD_NG;
+ }
+
+ args++;
+ }
+
+ if (target == TARGET_NONE) {
+ target = '0';
+ PrintMessage(MSG_TARGET_NOTICE, target);
+ }
+
+ // ensure that the driver is installed
+
+ if (driver_state == VFD_NOT_INSTALLED) {
+ PrintMessage(MSG_NOT_INSTALLED);
+ return VFD_NG;
+ }
+
+ // ensure that the driver is up to date
+
+ if (CheckDriver() != VFD_OK) {
+ return VFD_NG;
+ }
+
+ // ensure that the driver is running
+
+ if (driver_state != SERVICE_RUNNING) {
+ PrintMessage(MSG_NOT_STARTED);
+ return VFD_NG;
+ }
+
+ // Open the device
+
+ hDevice = VfdOpenDevice(target);
+
+ if (hDevice == INVALID_HANDLE_VALUE) {
+ ret = GetLastError();
+ PrintMessage(MSG_ACCESS_NG, target);
+ printf("%s", SystemError(ret));
+ return VFD_NG;
+ }
+
+ // check if the media is writable
+
+ ret = VfdGetMediaState(hDevice);
+
+ if (ret != ERROR_SUCCESS) {
+ PrintMessage(MSG_FORMAT_NG, target);
+ printf("%s", SystemError(ret));
+
+ CloseHandle(hDevice);
+ return VFD_NG;
+ }
+
+ // format the media
+
+retry:
+ ret = VfdDismountVolume(
+ hDevice, (mode == OPERATION_FORCE));
+
+ if (ret == ERROR_ACCESS_DENIED) {
+
+ PrintMessage(MSG_LOCK_NG, target);
+
+ if (mode == OPERATION_FORCE) {
+ PrintMessage(MSG_FORMAT_FORCE);
+ }
+ else if (mode == OPERATION_QUIT) {
+ PrintMessage(MSG_FORMAT_QUIT);
+ CloseHandle(hDevice);
+ return VFD_NG;
+ }
+ else {
+ int c = InputChar(MSG_RETRY_FORCE_CANCEL, "rfc");
+
+ if (c == 'r') { // retry
+ goto retry;
+ }
+ else if (c == 'f') { // force
+ VfdDismountVolume(hDevice, TRUE);
+ }
+ else { // cancel
+ CloseHandle(hDevice);
+ return VFD_NG;
+ }
+ }
+ }
+ else if (ret != ERROR_SUCCESS) {
+ PrintMessage(MSG_LOCK_NG, target);
+ CloseHandle(hDevice);
+ return VFD_NG;
+ }
+
+ ret = VfdFormatMedia(hDevice);
+
+ CloseHandle(hDevice);
+
+ if (ret != ERROR_SUCCESS) {
+ PrintMessage(MSG_FORMAT_NG, target);
+ printf("%s", SystemError(ret));
+ return VFD_NG;
+ }
+
+ // successful operation
+
+ PrintMessage(MSG_FORMAT_OK);
+
+ return VFD_OK;
+}
+
+//
+// Assign a drive letter to a Virtual Floppy Drive
+//
+int Link(const char **args)
+{
+ ULONG target_min = TARGET_NONE;
+ ULONG target_max = TARGET_NONE;
+ PCSTR letters = NULL;
+ BOOL global = TRUE;
+ HANDLE hDevice;
+ DWORD ret;
+
+ while (args && *args) {
+ if (!_stricmp(*args, "/g")) {
+ global = TRUE;
+ }
+ else if (!_stricmp(*args, "/l")) {
+ global = FALSE;
+ }
+ else if (isdigit(**args) || **args == '*') {
+ if (target_min != TARGET_NONE) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ if (**args == '*') {
+ target_min = '0';
+ target_max = '0' + VFD_MAXIMUM_DEVICES;
+ }
+ else {
+ target_min = **args;
+ target_max = target_min + 1;
+ }
+ }
+ else if (isalpha(**args)) {
+ if (letters) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+ letters = *args;
+ }
+ else {
+ PrintMessage(MSG_UNKNOWN_OPTION, *args);
+ PrintMessage(MSG_HINT_LINK, help_progname);
+ return VFD_NG;
+ }
+
+ args++;
+ }
+
+ if (target_min == TARGET_NONE) {
+ // default: drive 0
+ target_min = '0';
+ target_max = '1';
+ PrintMessage(MSG_TARGET_NOTICE, target_min);
+ }
+
+ // ensure that the driver is installed
+
+ if (driver_state == VFD_NOT_INSTALLED) {
+ PrintMessage(MSG_NOT_INSTALLED);
+ return VFD_NG;
+ }
+
+ // ensure that the driver is up to date
+
+ if (CheckDriver() != VFD_OK) {
+ return VFD_NG;
+ }
+
+ // ensure that the driver is running
+
+ if (driver_state != SERVICE_RUNNING) {
+ PrintMessage(MSG_NOT_STARTED);
+ return VFD_NG;
+ }
+
+ while (target_min < target_max) {
+ ULONG number;
+ CHAR letter;
+
+ hDevice = VfdOpenDevice(target_min);
+
+ if (hDevice == INVALID_HANDLE_VALUE) {
+ ret = GetLastError();
+ PrintMessage(MSG_ACCESS_NG, target_min);
+ printf("%s", SystemError(ret));
+ target_min++;
+ continue;
+ }
+
+ ret = VfdGetDeviceNumber(hDevice, &number);
+
+ if (ret != ERROR_SUCCESS) {
+ PrintMessage(MSG_ACCESS_NG, target_min);
+ printf("%s", SystemError(ret));
+ CloseHandle(hDevice);
+ target_min++;
+ continue;
+ }
+
+ if (letters && isalpha(*letters)) {
+ letter = (CHAR)toupper(*(letters++));
+ }
+ else {
+ letter = VfdChooseLetter();
+ }
+
+ if (letter) {
+ if (global) {
+ ret = VfdSetGlobalLink(hDevice, letter);
+ }
+ else {
+ ret = VfdSetLocalLink(hDevice, letter);
+ }
+
+ if (ret != ERROR_SUCCESS) {
+ PrintMessage(MSG_LINK_NG, number, letter);
+ printf("%s", SystemError(ret));
+ }
+ }
+ else {
+ PrintMessage(MSG_LINK_FULL);
+ }
+
+ PrintDriveLetter(hDevice, number);
+
+ CloseHandle(hDevice);
+
+ target_min++;
+ }
+
+ return VFD_OK;
+}
+
+//
+// Remove a drive letter from a Virtual Floppy Drive
+//
+int Unlink(const char **args)
+{
+ ULONG target_min = TARGET_NONE;
+ ULONG target_max = TARGET_NONE;
+ HANDLE hDevice;
+ DWORD ret;
+
+ while (args && *args) {
+ if ((isalnum(**args) || **args == '*') &&
+ (*(*args + 1) == ':' || *(*args + 1) == '\0')) {
+
+ if (target_min != TARGET_NONE) {
+ PrintMessage(MSG_DUPLICATE_ARGS, *args);
+ return VFD_NG;
+ }
+
+ if (**args == '*') {
+ target_min = '0';
+ target_max = '0' + VFD_MAXIMUM_DEVICES;
+ }
+ else {
+ target_min = **args;
+ target_max = target_min + 1;
+ }
+ }
+ else {
+ PrintMessage(MSG_UNKNOWN_OPTION, *args);
+ PrintMessage(MSG_HINT_ULINK, help_progname);
+ return VFD_NG;
+ }
+
+ args++;
+ }
+
+ if (target_min == TARGET_NONE) {
+ // default: drive 0
+ target_min = '0';
+ target_max = '1';
+ PrintMessage(MSG_TARGET_NOTICE, target_min);
+ }
+
+ // ensure that the driver is installed
+
+ if (driver_state == VFD_NOT_INSTALLED) {
+ PrintMessage(MSG_NOT_INSTALLED);
+ return VFD_NG;
+ }
+
+ // ensure that the driver is up to date
+
+ if (CheckDriver() != VFD_OK) {
+ return VFD_NG;
+ }
+
+ // ensure that the driver is running
+
+ if (driver_state != SERVICE_RUNNING) {
+ PrintMessage(MSG_NOT_STARTED);
+ return VFD_NG;
+ }
+
+ while (target_min < target_max) {
+ ULONG number;
+
+ hDevice = VfdOpenDevice(target_min);
+
+ if (hDevice == INVALID_HANDLE_VALUE) {
+ ret = GetLastError();
+ PrintMessage(MSG_ACCESS_NG, target_min);
+ printf("%s", SystemError(ret));
+ target_min++;
+ continue;
+ }
+
+ ret = VfdGetDeviceNumber(hDevice, &number);
+
+ if (ret != ERROR_SUCCESS) {
+ PrintMessage(MSG_ACCESS_NG, target_min);
+ printf("%s", SystemError(ret));
+ CloseHandle(hDevice);
+ target_min++;
+ continue;
+ }
+
+ VfdSetGlobalLink(hDevice, 0);
+ VfdSetLocalLink(hDevice, 0);
+
+ PrintDriveLetter(hDevice, number);
+
+ CloseHandle(hDevice);
+
+ target_min++;
+ }
+
+ return VFD_OK;
+}
+
+//
+// Print current driver state
+// Command Line Parameters: None
+//
+int Status(const char **args)
+{
+ HANDLE hDevice;
+ TCHAR path[MAX_PATH];
+ DWORD start_type;
+ DWORD version;
+ ULONG target;
+ DWORD ret;
+
+ UNREFERENCED_PARAMETER(args);
+
+ if (driver_state == VFD_NOT_INSTALLED) {
+ PrintMessage(MSG_NOT_INSTALLED);
+ }
+ else {
+
+ // get current driver config
+
+ ret = VfdGetDriverConfig(path, &start_type);
+
+ if (ret != ERROR_SUCCESS) {
+ PrintMessage(MSG_GET_CONFIG_NG);
+ printf("%s", SystemError(ret));
+ return VFD_NG;
+ }
+
+ // print driver file path
+
+ PrintMessage(MSG_DRIVER_FILE, path);
+
+ // print driver version
+ version = 0;
+
+ if (driver_state == SERVICE_RUNNING) {
+
+ hDevice = VfdOpenDevice(0);
+
+ if (hDevice != INVALID_HANDLE_VALUE) {
+ ret = VfdGetDriverVersion(hDevice, &version);
+
+ CloseHandle(hDevice);
+ }
+
+ }
+
+ if (version == 0) {
+ ret = VfdCheckDriverFile(path, &version);
+ }
+
+ if (ret == ERROR_SUCCESS) {
+ PrintMessage(MSG_DRIVER_VERSION,
+ HIWORD(version) & 0x7fff,
+ LOWORD(version),
+ (version & 0x80000000) ? "(debug)" : "");
+ }
+ else {
+ PrintMessage(MSG_GET_VERSION_NG);
+ printf("%s", SystemError(ret));
+ }
+
+
+ // print driver start type
+
+ PrintMessage(MSG_START_TYPE);
+
+ switch (start_type) {
+ case SERVICE_AUTO_START:
+ PrintMessage(MSG_START_AUTO);
+ break;
+
+ case SERVICE_BOOT_START:
+ PrintMessage(MSG_START_BOOT);
+ break;
+
+ case SERVICE_DEMAND_START:
+ PrintMessage(MSG_START_DEMAND);
+ break;
+
+ case SERVICE_DISABLED:
+ PrintMessage(MSG_START_DISABLED);
+ break;
+
+ case SERVICE_SYSTEM_START :
+ PrintMessage(MSG_START_SYSTEM);
+ break;
+
+ default:
+ PrintMessage(MSG_UNKNOWN_LONG, start_type);
+ break;
+ }
+
+ // print current driver state
+
+ PrintMessage(MSG_DRIVER_STATUS);
+
+ switch (driver_state) {
+ case SERVICE_STOPPED:
+ PrintMessage(MSG_STATUS_STOPPED);
+ break;
+
+ case SERVICE_START_PENDING:
+ PrintMessage(MSG_STATUS_START_P);
+ break;
+
+ case SERVICE_STOP_PENDING:
+ PrintMessage(MSG_STATUS_STOP_P);
+ break;
+
+ case SERVICE_RUNNING:
+ PrintMessage(MSG_STATUS_RUNNING);
+ break;
+
+ case SERVICE_CONTINUE_PENDING:
+ PrintMessage(MSG_STATUS_CONT_P);
+ break;
+
+ case SERVICE_PAUSE_PENDING:
+ PrintMessage(MSG_STATUS_PAUSE_P);
+ break;
+
+ case SERVICE_PAUSED:
+ PrintMessage(MSG_STATUS_PAUSED);
+ break;
+
+ default:
+ PrintMessage(MSG_UNKNOWN_LONG, driver_state);
+ break;
+ }
+ }
+
+ // print shell extension status
+
+ printf("\n");
+
+ if (VfdCheckHandlers() == ERROR_SUCCESS) {
+ PrintMessage(MSG_SHELLEXT_ENABLED);
+ }
+ else {
+ PrintMessage(MSG_SHELLEXT_DISABLED);
+ }
+
+ // if driver is not running, no more info
+
+ if (driver_state != SERVICE_RUNNING) {
+ return VFD_OK;
+ }
+
+ // print image information
+
+ for (target = 0; target < VFD_MAXIMUM_DEVICES; target++) {
+ HANDLE hDevice = VfdOpenDevice(target);
+
+ if (hDevice == INVALID_HANDLE_VALUE) {
+ ret = GetLastError();
+ PrintMessage(MSG_ACCESS_NG, target + '0');
+ printf("%s", SystemError(ret));
+ return VFD_NG;
+ }
+
+ PrintImageInfo(hDevice);
+
+ CloseHandle(hDevice);
+ }
+
+ return VFD_OK;
+}
+
+//
+// Print usage help
+//
+int Help(const char **args)
+{
+ DWORD msg = MSG_HELP_GENERAL;
+ char *buf = NULL;
+
+ if (args && *args) {
+ int cmd = ParseHelpTopic(*args);
+
+ if (cmd < 0) {
+ msg = MSG_HELP_HELP;
+ }
+ else {
+ msg = HelpMsg[cmd].help;
+ }
+ }
+
+ FormatMessage(
+ FORMAT_MESSAGE_FROM_HMODULE |
+ FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_ARGUMENT_ARRAY,
+ NULL, msg, 0, (LPTSTR)&buf, 0,
+ (va_list *)&help_progname);
+
+ if (buf == NULL) {
+ printf("%s", SystemError(GetLastError()));
+ return VFD_NG;
+ }
+
+ ConsolePager(buf, TRUE);
+ LocalFree(buf);
+
+ return VFD_OK;
+}
+
+//
+// Print version information
+//
+int Version(const char **args)
+{
+ UNREFERENCED_PARAMETER(args);
+
+ printf(VFD_PRODUCT_DESC "\n" VFD_COPYRIGHT_STR "\n"
+ "http://chitchat.at.infoseek.co.jp/vmware/vfd.html\n");
+
+ return VFD_OK;
+}
+
+//
+// Parse command parameter
+//
+int ParseCommand(const char *cmd)
+{
+#define CMD_MATCH_NONE -1
+#define CMD_MATCH_MULTI -2
+
+ size_t len;
+ int idx;
+ int match;
+
+ // skip a leading '/'
+
+ if (*cmd == '/') {
+ cmd++;
+ }
+
+ if (*cmd == '\0') {
+
+ // empty command
+
+ return CMD_MATCH_NONE;
+ }
+
+ // find a match
+ len = strlen(cmd);
+ idx = 0;
+ match = CMD_MATCH_NONE;
+
+ while (Commands[idx].cmd) {
+
+ if (strlen(Commands[idx].cmd) >= len &&
+ !_strnicmp(cmd, Commands[idx].cmd, len)) {
+
+ if (match == CMD_MATCH_NONE) { // first match
+ match = idx;
+ }
+ else { // multiple matches
+ if (match != CMD_MATCH_MULTI) { // first time
+ PrintMessage(MSG_AMBIGUOUS_COMMAND, cmd);
+ printf("> %s ", Commands[match].cmd);
+ match = CMD_MATCH_MULTI;
+ }
+
+ printf("%s ", Commands[idx].cmd);
+ }
+ }
+
+ idx++;
+ }
+
+ if (match == CMD_MATCH_NONE) { // match not found
+ PrintMessage(MSG_UNKNOWN_COMMAND, cmd);
+ }
+ else if (match == CMD_MATCH_MULTI) { // multiple matches
+ printf("\n");
+ }
+
+ return match;
+}
+
+int ParseHelpTopic(const char *topic)
+{
+ size_t len;
+ int idx;
+ int match;
+
+ if (*topic == '\0') {
+
+ // empty command
+
+ return CMD_MATCH_NONE;
+ }
+
+ // find a match
+ len = strlen(topic);
+ idx = 0;
+ match = CMD_MATCH_NONE;
+
+ while (HelpMsg[idx].keyword) {
+
+ if (strlen(HelpMsg[idx].keyword) >= len &&
+ !_strnicmp(topic, HelpMsg[idx].keyword, len)) {
+
+ if (match == CMD_MATCH_NONE) { // first match
+ match = idx;
+ }
+ else { // multiple matches
+ if (match != CMD_MATCH_MULTI) { // first time
+ PrintMessage(MSG_AMBIGUOUS_COMMAND, topic);
+ printf("> %s ", HelpMsg[match].keyword);
+ match = CMD_MATCH_MULTI;
+ }
+
+ printf("%s ", HelpMsg[idx].keyword);
+ }
+ }
+
+ idx++;
+ }
+
+ if (match == CMD_MATCH_NONE) { // match not found
+ PrintMessage(MSG_UNKNOWN_COMMAND, topic);
+ }
+ else if (match == CMD_MATCH_MULTI) { // multiple matches
+ printf("\n");
+ }
+
+ return match;
+}
+
+//
+// Check driver version and update if necessary
+//
+int CheckDriver()
+{
+ char path[MAX_PATH];
+ DWORD start;
+
+ // check installed driver file version
+
+ if (VfdGetDriverConfig(path, &start) == ERROR_SUCCESS &&
+ VfdCheckDriverFile(path, NULL) == ERROR_SUCCESS) {
+
+ HANDLE hDevice;
+
+ if (driver_state != SERVICE_RUNNING) {
+ return VFD_OK;
+ }
+
+ // check running driver version
+
+ hDevice = VfdOpenDevice(0);
+
+ if (hDevice != INVALID_HANDLE_VALUE) {
+ CloseHandle(hDevice);
+ return VFD_OK;
+ }
+ }
+
+ PrintMessage(MSG_WRONG_DRIVER);
+ return VFD_NG;
+}
+
+//
+// Print a prompt message and accept the reply input
+//
+int InputChar(ULONG msg, PCSTR ans)
+{
+ HANDLE hStdIn;
+ INPUT_RECORD input;
+ DWORD result;
+ int reply;
+
+ PrintMessage(msg);
+ fflush(NULL);
+
+ hStdIn = GetStdHandle(STD_INPUT_HANDLE);
+
+ FlushConsoleInputBuffer(hStdIn);
+
+ for (;;) {
+ ReadConsoleInput(hStdIn, &input, sizeof(input), &result);
+
+ if (input.EventType == KEY_EVENT &&
+ input.Event.KeyEvent.bKeyDown) {
+
+ reply = tolower(input.Event.KeyEvent.uChar.AsciiChar);
+
+ if (strchr(ans, reply)) {
+ break;
+ }
+ }
+ }
+
+ printf("%c\n", reply);
+
+ return reply;
+}
+
+//
+// Print image information on a Virtual Floppy Drive
+//
+void PrintImageInfo(
+ HANDLE hDevice)
+{
+ ULONG device_number;
+ CHAR file_name[MAX_PATH];
+ CHAR file_desc[MAX_PATH];
+ VFD_DISKTYPE disk_type;
+ VFD_MEDIA media_type;
+ VFD_FLAGS media_flags;
+ VFD_FILETYPE file_type;
+ ULONG image_size;
+ DWORD ret;
+
+ printf("\n");
+
+ // get current device number
+
+ ret = VfdGetDeviceNumber(hDevice, &device_number);
+
+ if (ret != ERROR_SUCCESS) {
+ PrintMessage(MSG_GET_LINK_NG);
+ printf("%s", SystemError(ret));
+ device_number = (ULONG)-1;
+ }
+
+ // get current drive letters
+
+ PrintDriveLetter(hDevice, device_number);
+
+ // image file information
+
+ ret = VfdGetImageInfo(hDevice, file_name, &disk_type,
+ &media_type, &media_flags, &file_type, &image_size);
+
+ if (ret != ERROR_SUCCESS) {
+ PrintMessage(MSG_GET_FILE_NG);
+ printf("%s", SystemError(ret));
+ return;
+ }
+
+ // print image file information
+ if (media_type == VFD_MEDIA_NONE) {
+ PrintMessage(MSG_IMAGE_NONE);
+ return;
+ }
+
+ if (file_name[0]) {
+ PrintMessage(MSG_IMAGE_NAME, file_name);
+
+ VfdMakeFileDesc(file_desc, sizeof(file_desc),
+ file_type, image_size, GetFileAttributes(file_name));
+ }
+ else {
+ PrintMessage(MSG_IMAGE_NAME, "<RAM>");
+
+ VfdMakeFileDesc(file_desc, sizeof(file_desc),
+ VFD_FILETYPE_NONE, image_size, 0);
+ }
+
+ PrintMessage(MSG_FILE_DESC, file_desc);
+
+ if (disk_type == VFD_DISKTYPE_FILE) {
+ PrintMessage(MSG_DISKTYPE_FILE);
+ }
+ else {
+ if (media_flags & VFD_FLAG_DATA_MODIFIED) {
+ PrintMessage(MSG_DISKTYPE_RAM_DIRTY);
+ }
+ else {
+ PrintMessage(MSG_DISKTYPE_RAM_CLEAN);
+ }
+ }
+
+ // print other file info
+
+ PrintMessage(MSG_MEDIA_TYPE, VfdMediaTypeName(media_type));
+
+ if (media_flags & VFD_FLAG_WRITE_PROTECTED) {
+ PrintMessage(MSG_MEDIA_PROTECTED);
+ }
+ else {
+ PrintMessage(MSG_MEDIA_WRITABLE);
+ }
+}
+
+//
+// Print drive letters on a virtual floppy drive
+//
+void PrintDriveLetter(
+ HANDLE hDevice,
+ ULONG nDrive)
+{
+ CHAR letter;
+
+ PrintMessage(MSG_DRIVE_LETTER, nDrive);
+
+ VfdGetGlobalLink(hDevice, &letter);
+
+ if (isalpha(letter)) {
+ PrintMessage(MSG_PERSISTENT, toupper(letter));
+ }
+
+ while (VfdGetLocalLink(hDevice, &letter) == ERROR_SUCCESS &&
+ isalpha(letter)) {
+ PrintMessage(MSG_EPHEMERAL, toupper(letter));
+ }
+
+ printf("\n");
+}
+
+//
+// Prints a text on screen a page a time
+//
+BOOL ConsolePager(char *pBuffer, BOOL bReset)
+{
+ static int rows = 0;
+ char prompt[80];
+ int prompt_len = 0;
+ HANDLE hStdOut;
+ HANDLE hStdIn;
+
+ //
+ // prepare the console input and output handles
+ //
+ hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
+ hStdIn = GetStdHandle(STD_INPUT_HANDLE);
+
+ for (;;) {
+ CONSOLE_SCREEN_BUFFER_INFO info;
+ INPUT_RECORD input;
+ DWORD result;
+ DWORD mode;
+ int cols;
+ char *cur;
+ char save;
+
+ //
+ // Get the current console screen information
+ //
+ GetConsoleScreenBufferInfo(hStdOut, &info);
+
+ if (bReset || rows <= 0) {
+ rows = info.srWindow.Bottom - info.srWindow.Top - 1;
+ }
+
+ cols = info.dwSize.X;
+
+ // console window is too small for paging
+
+ if (rows <= 0) {
+ // print all text and exit
+ printf("%s", pBuffer);
+ break;
+ }
+
+ //
+ // find the tail of the text to be printed this time
+ //
+ cur = pBuffer;
+ save = '\0';
+
+ while (*cur) {
+ if (*(cur++) == '\n' || (cols--) == 0) {
+ // reached the end of a line
+ if (--rows == 0) {
+ // reached the end of a page
+ // insert a terminating NULL char
+ save = *cur;
+ *cur = '\0';
+ break;
+ }
+
+ cols = info.dwSize.X;
+ }
+ }
+
+ // print the current page
+ printf("%s", pBuffer);
+
+ // end of the whole text?
+ if (save == '\0') {
+ break;
+ }
+
+ //
+ // prompt for the next page
+ //
+
+ // prepare the prompt text
+
+ if (prompt_len == 0) {
+
+ prompt_len = FormatMessage(
+ FORMAT_MESSAGE_FROM_HMODULE |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, MSG_PAGER_PROMPT, 0,
+ prompt, sizeof(prompt), NULL);
+
+ if (prompt_len == 0) {
+ strcpy(prompt, "Press any key to continue...");
+ prompt_len = strlen(prompt);
+ }
+ }
+
+ // get the current console input mode
+
+ GetConsoleMode(hStdIn, &mode);
+
+ // change the mode to receive Ctrl+C as a regular input
+
+ SetConsoleMode(hStdIn, (mode & ~ENABLE_PROCESSED_INPUT));
+
+ // get the current cursor position
+
+ GetConsoleScreenBufferInfo(hStdOut, &info);
+
+ // print the prompt text
+
+ WriteConsoleOutputCharacter(hStdOut, prompt,
+ prompt_len, info.dwCursorPosition, &result);
+
+ // reverse the text color
+
+ FillConsoleOutputAttribute(hStdOut,
+ (WORD)(info.wAttributes | COMMON_LVB_REVERSE_VIDEO),
+ prompt_len, info.dwCursorPosition, &result);
+
+ // move cursor to the end of the prompt text
+
+ info.dwCursorPosition.X =
+ (short)(info.dwCursorPosition.X + prompt_len);
+
+ SetConsoleCursorPosition(hStdOut, info.dwCursorPosition);
+
+ // wait for a key press event
+
+ FlushConsoleInputBuffer(hStdIn);
+
+ do {
+ ReadConsoleInput(hStdIn, &input, sizeof(input), &result);
+ }
+ while (input.EventType != KEY_EVENT ||
+ !input.Event.KeyEvent.bKeyDown ||
+ !input.Event.KeyEvent.uChar.AsciiChar);
+
+ // restore the original cursor position
+
+ info.dwCursorPosition.X =
+ (short)(info.dwCursorPosition.X - prompt_len);
+
+ SetConsoleCursorPosition(hStdOut, info.dwCursorPosition);
+
+ // delete the prompt text
+
+ FillConsoleOutputCharacter(hStdOut, ' ',
+ prompt_len, info.dwCursorPosition, &result);
+
+ // restore the text attribute to norml
+
+ FillConsoleOutputAttribute(hStdOut, info.wAttributes,
+ prompt_len, info.dwCursorPosition, &result);
+
+ // restore the original console mode
+
+ SetConsoleMode(hStdIn, mode);
+
+ // check if the input was 'q', <esc> or <Ctrl+C> ?
+
+ if (input.Event.KeyEvent.uChar.AsciiChar == VK_CANCEL ||
+ input.Event.KeyEvent.uChar.AsciiChar == VK_ESCAPE ||
+ tolower(input.Event.KeyEvent.uChar.AsciiChar) == 'q') {
+
+ // cancelled by the user
+ return FALSE;
+ }
+
+ //
+ // process the next page
+ //
+ *cur = save;
+ pBuffer = cur;
+ }
+
+ return TRUE;
+}
+
+//
+// Format and print a message text
+//
+void PrintMessage(UINT msg, ...)
+{
+ char *buf = NULL;
+ va_list list;
+
+ va_start(list, msg);
+
+ if (FormatMessage(
+ FORMAT_MESSAGE_FROM_HMODULE |
+ FORMAT_MESSAGE_ALLOCATE_BUFFER,
+ NULL, msg, 0, (LPTSTR)&buf, 0, &list)) {
+
+ printf("%s", buf);
+ }
+ else {
+ printf("Unknown Message ID %u\n", msg);
+ }
+
+ va_end(list);
+
+ if (buf) {
+ LocalFree(buf);
+ }
+}
+
+//
+// Return a system error message text
+//
+const char *SystemError(DWORD err)
+{
+ static char msg[256];
+
+ if (!FormatMessage(
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, err, 0, msg, sizeof(msg), NULL)) {
+#ifndef __REACTOS__
+ sprintf(msg, "Unknown system error %lu (0x%08x)\n", err, err);
+#else
+ sprintf(msg, "Unknown system error %lu (0x%08lx)\n", err, err);
+#endif
+ }
+
+ return msg;
+}
+
+//
+// Convert a path to match the case of names on the disk
+//
+void ConvertPathCase(char *src, char *dst)
+{
+ HANDLE hFind;
+ WIN32_FIND_DATA find;
+ char *p;
+
+ p = dst;
+
+ if (*src == '\"') {
+ src++;
+ }
+
+ if (*(src + strlen(src) - 1) == '\"') {
+ *(src + strlen(src) - 1) = '\0';
+ }
+
+ //
+ // handle drive / remote server name
+ //
+ if (isalpha(*src) && *(src + 1) == ':') {
+
+ // drive name
+
+ *(p++) = (char)toupper(*src);
+ strcpy(p++, ":\\");
+
+ src += 2;
+ }
+ else if (*src == '\\' || *src == '/') {
+
+ // absolute path or remote name
+
+ if ((*(src + 1) == '\\' || *(src + 1) == '/') &&
+ *(src + 2) && *(src + 2) != '\\' && *(src + 2) != '/')
{
+
+ // remote path
+
+ *(p++) = '\\';
+ *(p++) = '\\';
+ src += 2;
+
+ while (*src && *src != '\\' && *src != '/') {
+ *(p++) = *(src++);
+ }
+ }
+
+ strcpy(p, "\\");
+ }
+ else {
+ *p = '\0';
+ }
+
+ // skip redundant '\'
+
+ while (*src == '\\' || *src == '/') {
+ src++;
+ }
+
+ // process the path
+
+ while (*src) {
+
+ char *q = src;
+
+ // separate the next part
+
+ while (*q && *q != '\\' && *q != '/') {
+ q++;
+ }
+
+ if ((q - src) == 2 && !strncmp(src, "..", 2)) {
+ // parent dir - copy as it is
+ if (p != dst) {
+ *p++ = '\\';
+ }
+
+ strcpy(p, "..");
+ p += 2;
+ }
+ else if ((q - src) > 1 || *src != '.') {
+ // path name other than "."
+ if (p != dst) {
+ *(p++) = '\\';
+ }
+
+ strncpy(p, src, (q - src));
+ *(p + (q - src)) = '\0';
+
+ hFind = FindFirstFile(dst, &find);
+
+ if (hFind == INVALID_HANDLE_VALUE) {
+ strcpy(p, src);
+ break;
+ }
+
+ FindClose(hFind);
+
+ strcpy(p, find.cFileName);
+ p += strlen(p);
+ }
+
+ // skip trailing '\'s
+
+ while (*q == '\\' || *q == '/') {
+ q++;
+ }
+
+ src = q;
+ }
+}
diff --git a/modules/rosapps/applications/cmdutils/vfdcmd/vfdcmd.rc
b/modules/rosapps/applications/cmdutils/vfdcmd/vfdcmd.rc
new file mode 100644
index 0000000000..6f4b582bdd
--- /dev/null
+++ b/modules/rosapps/applications/cmdutils/vfdcmd/vfdcmd.rc
@@ -0,0 +1,6 @@
+#define REACTOS_STR_FILE_DESCRIPTION "Virtual Floppy Controler"
+#define REACTOS_STR_INTERNAL_NAME "vfdcmd"
+#define REACTOS_STR_ORIGINAL_FILENAME "vfdcmd.exe"
+#include <reactos/version.rc>
+
+#include <vfdmsg.rc>
diff --git a/modules/rosapps/applications/cmdutils/vfdcmd/vfdcmd.rs
b/modules/rosapps/applications/cmdutils/vfdcmd/vfdcmd.rs
new file mode 100644
index 0000000000..3956ecc835
--- /dev/null
+++ b/modules/rosapps/applications/cmdutils/vfdcmd/vfdcmd.rs
@@ -0,0 +1,49 @@
+/*
+ vfdcmd.rs
+
+ Virtual Floppy Drive for Windows
+ Driver control program (console version)
+ Resource script
+
+ The non-standard extension ".rs" is intentional, so that
+ Microsoft Visual Studio won't try to open this file with
+ the resource editor
+
+ Copyright (c) 2003-2005 Ken Kato
+*/
+
+#ifndef APSTUDIO_INVOKED
+
+//
+// version resource
+//
+#include <winver.h>
+#include "vfdver.h"
+
+#define VFD_FILEOS VOS_NT_WINDOWS32
+#define VFD_FILETYPE VFT_APP
+#define VFD_FILESUBTYPE VFT2_UNKNOWN
+
+#define VFD_DESCRIPTION "Virtual Floppy Drive Console"
+#define VFD_INTERNALNAME "vfd.exe"
+#define VFD_FILE_MAJOR 2
+#define VFD_FILE_MINOR 1
+
+//
+// for Japanese version resources
+//
+#define VFD_VERSIONINFO_ALT "041104B0"
+#undef VFD_VERSIONINFO_TRANS
+#define VFD_VERSIONINFO_TRANS 0x0409, 0x04B0, 0x0411, 0x04B0
+
+#define VFD_DESCRIPTION_ALT "Virtual Floppy Drive �R���\�[��"
+#define VFD_PRODUCT_NAME_ALT VFD_PRODUCT_NAME
+
+#include "vfdver.rc"
+
+//
+// Message resource
+//
+#include "vfdmsg.rc"
+
+#endif // not APSTUDIO_INVOKED
diff --git a/modules/rosapps/applications/cmdutils/vfdcmd/vfdmsg.mc
b/modules/rosapps/applications/cmdutils/vfdcmd/vfdmsg.mc
new file mode 100644
index 0000000000..222c04d761
--- /dev/null
+++ b/modules/rosapps/applications/cmdutils/vfdcmd/vfdmsg.mc
@@ -0,0 +1,1596 @@
+;/*
+; vfdmsg.h
+;
+; Virtual Floppy Drive for Windows
+; Driver control program (console version)
+; Message definition
+;
+; Copyright (C) 2003-2005 Ken Kato
+;*/
+;
+;#ifndef _VFDMSG_H_
+;#define _VFDMSG_H_
+;
+
+MessageIdTypedef=DWORD
+LanguageNames=(English=0x409:MSG0409)
+
+;//==============================================
+;// Generic error messages
+;//==============================================
+;
+
+MessageId=
+SymbolicName=MSG_WRONG_PLATFORM
+Language=English
+Virtual Floppy Drive does not run on Windows 95/98/Me.
+.
+
+
+MessageId=
+SymbolicName=MSG_TOO_MANY_ARGS
+Language=English
+Too many command line parameters.
+.
+
+
+MessageId=
+SymbolicName=MSG_UNKNOWN_COMMAND
+Language=English
+Command '%1!s!' is unknown.
+.
+
+
+MessageId=
+SymbolicName=MSG_AMBIGUOUS_COMMAND
+Language=English
+Command '%1!s!' is ambiguous.
+.
+
+
+MessageId=
+SymbolicName=MSG_UNKNOWN_OPTION
+Language=English
+Option '%1!s!' is unknown.
+.
+
+
+MessageId=
+SymbolicName=MSG_DUPLICATE_ARGS
+Language=English
+Parameter %1!s! is used more than once.
+.
+
+
+;//==============================================
+;// Command result message
+;//==============================================
+;
+
+MessageId=
+SymbolicName=MSG_INSTALL_OK
+Language=English
+Installed the Virtual Floppy driver.
+.
+
+
+MessageId=
+SymbolicName=MSG_INSTALL_NG
+Language=English
+Failed to install the Virtual Floppy driver.
+.
+
+
+MessageId=
+SymbolicName=MSG_CONFIG_OK
+Language=English
+Configured the Virtual Floppy driver start method.
+.
+
+
+MessageId=
+SymbolicName=MSG_CONFIG_NG
+Language=English
+Failed to configure the Virtual Floppy driver start method.
+.
+
+
+MessageId=
+SymbolicName=MSG_REMOVE_OK
+Language=English
+Uninstalled the Virtual Floppy driver.
+.
+
+
+MessageId=
+SymbolicName=MSG_REMOVE_NG
+Language=English
+Failed to uninstall the Virtual Floppy driver.
+.
+
+
+MessageId=
+SymbolicName=MSG_REMOVE_PENDING
+Language=English
+The Virtual Floppy driver is going to be removed on the next system start up.
+You may need to restart the system before installing the driver again.
+.
+
+
+MessageId=
+SymbolicName=MSG_START_OK
+Language=English
+Started the Virtual Floppy driver.
+.
+
+
+MessageId=
+SymbolicName=MSG_START_NG
+Language=English
+Failed to start the Virtual Floppy driver.
+.
+
+
+MessageId=
+SymbolicName=MSG_STOP_OK
+Language=English
+Stopped the Virtual Floppy driver.
+.
+
+
+MessageId=
+SymbolicName=MSG_STOP_NG
+Language=English
+Failed to stop the Virtual Floppy driver.
+.
+
+
+MessageId=
+SymbolicName=MSG_STOP_PENDING
+Language=English
+Stop operation has succeeded, but something
+is preventing the driver from actually stopping.
+You may need to reboot the system before restarting the driver.
+.
+
+
+MessageId=
+SymbolicName=MSG_GET_SHELLEXT_NG
+Language=English
+Failed to get the shell extension status.
+.
+
+
+MessageId=
+SymbolicName=MSG_SET_SHELLEXT_NG
+Language=English
+Failed to set the shell extension status.
+.
+
+
+MessageId=
+SymbolicName=MSG_SHELLEXT_ENABLED
+Language=English
+Shell extension is enabled.
+.
+
+
+MessageId=
+SymbolicName=MSG_SHELLEXT_DISABLED
+Language=English
+Shell extension is disabled.
+.
+
+
+MessageId=
+SymbolicName=MSG_OPEN_NG
+Language=English
+Failed to open the image '%1!s!'.
+.
+
+
+MessageId=
+SymbolicName=MSG_CLOSE_OK
+Language=English
+Closed the image on the drive %1!c!.
+.
+
+
+MessageId=
+SymbolicName=MSG_CLOSE_NG
+Language=English
+Failed to close the image on the drive %1!c!.
+.
+
+
+MessageId=
+SymbolicName=MSG_SAVE_OK
+Language=English
+Saved the image on the drive %1!c! into '%2!s!'.
+.
+
+
+MessageId=
+SymbolicName=MSG_SAVE_NG
+Language=English
+Failed to save the image on the drive %1!c! into '%2!s!'.
+.
+
+
+MessageId=
+SymbolicName=MSG_PROTECT_NG
+Language=English
+Failed to set write protect state on the drive %1!c!.
+.
+
+
+MessageId=
+SymbolicName=MSG_FORMAT_OK
+Language=English
+Format complete.
+.
+
+
+MessageId=
+SymbolicName=MSG_FORMAT_NG
+Language=English
+Failed to format the drive %1!c!.
+.
+
+
+MessageId=
+SymbolicName=MSG_LINK_NG
+Language=English
+Failed to assign '%2!c!' to the drive %1!lu!.
+.
+
+
+MessageId=
+SymbolicName=MSG_UNLINK_NG
+Language=English
+Failed to unlink the letter from the drive %1!lu!.
+.
+
+
+;//==============================================
+;// Supplemental result message
+;//==============================================
+;
+
+MessageId=
+SymbolicName=MSG_GET_STAT_NG
+Language=English
+Failed to get the driver status.
+.
+
+
+MessageId=
+SymbolicName=MSG_GET_CONFIG_NG
+Language=English
+Failed to get the driver configuration.
+.
+
+
+MessageId=
+SymbolicName=MSG_GET_VERSION_NG
+Language=English
+Failed to get the driver version.
+.
+
+
+MessageId=
+SymbolicName=MSG_WRONG_DRIVER
+Language=English
+A wrong driver is installed.
+.
+
+
+MessageId=
+SymbolicName=MSG_QUERY_UPDATE
+Language=English
+Update now (y / n) ? %0
+.
+
+
+MessageId=
+SymbolicName=MSG_GET_MEDIA_NG
+Language=English
+Failed to get the current media status.
+.
+
+
+MessageId=
+SymbolicName=MSG_GET_FILE_NG
+Language=English
+Failed to get the image information.
+.
+
+
+MessageId=
+SymbolicName=MSG_GET_LINK_NG
+Language=English
+Failed to get the current drive letter.
+.
+
+
+MessageId=
+SymbolicName=MSG_LINK_FULL
+Language=English
+No drive letter is available.
+.
+
+
+MessageId=
+SymbolicName=MSG_ACCESS_NG
+Language=English
+Failed to access the drive %1!c!.
+.
+
+
+MessageId=
+SymbolicName=MSG_DRIVER_EXISTS
+Language=English
+The Virtual Floppy driver is already installed.
+.
+
+
+MessageId=
+SymbolicName=MSG_NOT_INSTALLED
+Language=English
+The Virtual Floppy driver is not installed.
+.
+
+
+MessageId=
+SymbolicName=MSG_ALREADY_RUNNING
+Language=English
+The Virtual Floppy driver is already running.
+.
+
+
+MessageId=
+SymbolicName=MSG_NOT_STARTED
+Language=English
+The Virtual Floppy driver is not running.
+.
+
+
+MessageId=
+SymbolicName=MSG_TARGET_NOTICE
+Language=English
+Using the default drive (%1!c!).
+.
+
+
+MessageId=
+SymbolicName=MSG_CREATE_NOTICE
+Language=English
+Creating a new image file.
+.
+
+
+MessageId=
+SymbolicName=MSG_CREATE_CONFIRM
+Language=English
+Create a new image file (Y:yes / N:no) ? %0
+.
+
+
+MessageId=
+SymbolicName=MSG_OVERWRITE_NOTICE
+Language=English
+Overwriting the existing file.
+.
+
+
+MessageId=
+SymbolicName=MSG_OVERWRITE_CONFIRM
+Language=English
+Overwrite the existing file (Y:yes / N:no) ? %0
+.
+
+
+MessageId=
+SymbolicName=MSG_CREATE_NG
+Language=English
+Failed to create the new image file '%1!s!'.
+.
+
+
+MessageId=
+SymbolicName=MSG_FILE_CREATED
+Language=English
+Created a new image file.
+.
+
+
+MessageId=
+SymbolicName=MSG_RAM_MEDIA_UNKNOWN
+Language=English
+A size is not specified for a new RAM image.
+.
+
+
+MessageId=
+SymbolicName=MSG_FILE_MEDIA_UNKNOWN
+Language=English
+A size is not specified for a new image file.
+.
+
+
+MessageId=
+SymbolicName=MSG_CREATE144_NOTICE
+Language=English
+Creating a 1.44MB image.
+.
+
+
+MessageId=
+SymbolicName=MSG_CREATE144_CONFIRM
+Language=English
+Create a 1.44MB image (Y:yes / N:no) ? %0
+.
+
+
+MessageId=
+SymbolicName=MSG_IMAGE_TOO_SMALL
+Language=English
+The image is too small.
+.
+
+
+MessageId=
+SymbolicName=MSG_NO_MATCHING_MEDIA
+Language=English
+The image size (%1!lu! bytes) does not match any supported media.
+.
+
+
+MessageId=
+SymbolicName=MSG_MEDIATYPE_NOTICE
+Language=English
+Opening as a %1!s! media (%2!lu! bytes).
+.
+
+
+MessageId=
+SymbolicName=MSG_MEDIATYPE_SUGGEST
+Language=English
+The largest possible media is %1!s! (%2!lu! bytes).
+.
+
+
+MessageId=
+SymbolicName=MSG_MEDIATYPE_CONFIRM
+Language=English
+Open as this media type (Y:yes / N:no) ? %0
+.
+
+
+MessageId=
+SymbolicName=MSG_RAM_MODE_NOTICE
+Language=English
+Opening the image in RAM mode.
+.
+
+
+MessageId=
+SymbolicName=MSG_RAM_MODE_ONLY
+Language=English
+This file must be opened in RAM mode.
+.
+
+
+MessageId=
+SymbolicName=MSG_RAM_MODE_CONFIRM
+Language=English
+Open in RAM mode (Y:yes / N:no) ? %0
+.
+
+
+MessageId=
+SymbolicName=MSG_DEFAULT_PROTECT
+Language=English
+The media will be write protected by default.
+.
+
+
+MessageId=
+SymbolicName=MSG_DRIVE_BUSY
+Language=English
+An image is already opened.
+.
+
+
+MessageId=
+SymbolicName=MSG_TARGET_REQUIRED
+Language=English
+Specify a target file to save.
+.
+
+
+MessageId=
+SymbolicName=MSG_TARGET_UP_TO_DATE
+Language=English
+The image file is up to date.
+.
+
+
+MessageId=
+SymbolicName=MSG_OVERWRITE_PROMPT
+Language=English
+Overwrite the existing file
+(O: just overwrite / T: overwrite & truncate / C: cancel) ? %0
+.
+
+
+MessageId=
+SymbolicName=MSG_TARGET_IS_ZIP
+Language=English
+Cannot overwrite a ZIP compressed file.
+.
+
+
+MessageId=
+SymbolicName=MSG_SAVE_FORCE
+Language=English
+The save operation is forced to continue.
+.
+
+
+MessageId=
+SymbolicName=MSG_SAVE_QUIT
+Language=English
+The save operation is aborted.
+.
+
+
+MessageId=
+SymbolicName=MSG_FORMAT_FORCE
+Language=English
+The format operation is forced to continue.
+.
+
+
+MessageId=
+SymbolicName=MSG_FORMAT_QUIT
+Language=English
+The format operation is aborted.
+.
+
+
+MessageId=
+SymbolicName=MSG_MEDIA_MODIFIED
+Language=English
+RAM disk data on the drive %1!c!: is modified.
+.
+
+
+MessageId=
+SymbolicName=MSG_CLOSE_FORCE
+Language=English
+The close operation is forced to continue.
+.
+
+
+MessageId=
+SymbolicName=MSG_CLOSE_QUIT
+Language=English
+The close operation is aborted.
+.
+
+
+MessageId=
+SymbolicName=MSG_CLOSE_CONFIRM
+Language=English
+Close the image anyway (Y:yes / N:no) ? %0
+.
+
+
+MessageId=
+SymbolicName=MSG_RETRY_FORCE_CANCEL
+Language=English
+R:retry / F:force / C:cancel ? %0
+.
+
+
+MessageId=
+SymbolicName=MSG_RETRY_CANCEL
+Language=English
+R:retry / C:cancel ? %0
+.
+
+
+MessageId=
+SymbolicName=MSG_LOCK_NG
+Language=English
+Failed to lock the drive %1!c!. Some programs may be using the drive.
+.
+
+
+MessageId=
+SymbolicName=MSG_STOP_FORCE
+Language=English
+Failed to close the all drives. The operation is forced to continue.
+.
+
+
+MessageId=
+SymbolicName=MSG_STOP_QUIT
+Language=English
+Failed to close the all drives. The operation is aborted.
+.
+
+
+MessageId=
+SymbolicName=MSG_STOP_WARN
+Language=English
+Failed to close the all drives. The driver may not be able to unload
+properly. Continue the stop operation?
+.
+
+
+MessageId=
+SymbolicName=MSG_REMOVE_FORCE
+Language=English
+Failed to stop the driver. The operation is forced to continue;
+.
+
+
+MessageId=
+SymbolicName=MSG_REMOVE_QUIT
+Language=English
+Failed to stop the driver. The operation is aborted.
+.
+
+
+MessageId=
+SymbolicName=MSG_REMOVE_WARN
+Language=English
+Failed to stop the driver. The driver may not be removed completely
+until the system is restarted. Continue the operation?
+.
+
+
+MessageId=
+SymbolicName=MSG_UNKNOWN_LONG
+Language=English
+Unknown (0x%1!08x!)
+.
+
+
+MessageId=
+SymbolicName=MSG_DRIVER_FILE
+Language=English
+Driver : %1!s!
+.
+
+
+MessageId=
+SymbolicName=MSG_DRIVER_VERSION
+Language=English
+Version : %1!d!.%2!d! %3!s!
+.
+
+
+MessageId=
+SymbolicName=MSG_START_TYPE
+Language=English
+Start Type : %0
+.
+
+
+MessageId=
+SymbolicName=MSG_START_AUTO
+Language=English
+AUTO
+.
+
+
+MessageId=
+SymbolicName=MSG_START_BOOT
+Language=English
+BOOT
+.
+
+
+MessageId=
+SymbolicName=MSG_START_DEMAND
+Language=English
+DEMAND
+.
+
+
+MessageId=
+SymbolicName=MSG_START_DISABLED
+Language=English
+DISABLED
+.
+
+
+MessageId=
+SymbolicName=MSG_START_SYSTEM
+Language=English
+SYSTEM
+.
+
+
+MessageId=
+SymbolicName=MSG_DRIVER_STATUS
+Language=English
+Status : %0
+.
+
+
+MessageId=
+SymbolicName=MSG_STATUS_STOPPED
+Language=English
+STOPPED
+.
+
+
+MessageId=
+SymbolicName=MSG_STATUS_START_P
+Language=English
+START_PENDING
+.
+
+
+MessageId=
+SymbolicName=MSG_STATUS_STOP_P
+Language=English
+STOP_PENDING
+.
+
+
+MessageId=
+SymbolicName=MSG_STATUS_RUNNING
+Language=English
+RUNNING
+.
+
+
+MessageId=
+SymbolicName=MSG_STATUS_CONT_P
+Language=English
+CONTINUE_PENDING
+.
+
+
+MessageId=
+SymbolicName=MSG_STATUS_PAUSE_P
+Language=English
+PAUSE_PENDING
+.
+
+
+MessageId=
+SymbolicName=MSG_STATUS_PAUSED
+Language=English
+PAUSED
+.
+
+
+MessageId=
+SymbolicName=MSG_DRIVE_LETTER
+Language=English
+Drive %1!lu! : %0
+.
+
+
+MessageId=
+SymbolicName=MSG_PERSISTENT
+Language=English
+%1!c! (Persistent) %0
+.
+
+
+MessageId=
+SymbolicName=MSG_EPHEMERAL
+Language=English
+%1!c! (Ephemeral) %0
+.
+
+
+MessageId=
+SymbolicName=MSG_IMAGE_NONE
+Language=English
+Image : <none>
+.
+
+
+MessageId=
+SymbolicName=MSG_IMAGE_NAME
+Language=English
+Image : %1!s!
+.
+
+
+MessageId=
+SymbolicName=MSG_FILE_DESC
+Language=English
+Description: %1!s!
+.
+
+
+MessageId=
+SymbolicName=MSG_DISKTYPE_FILE
+Language=English
+Type : FILE
+.
+
+
+MessageId=
+SymbolicName=MSG_DISKTYPE_RAM_CLEAN
+Language=English
+Type : RAM (not modified)
+.
+
+
+MessageId=
+SymbolicName=MSG_DISKTYPE_RAM_DIRTY
+Language=English
+Type : RAM (modified)
+.
+
+
+MessageId=
+SymbolicName=MSG_MEDIA_TYPE
+Language=English
+Media : %1!s!
+.
+
+
+MessageId=
+SymbolicName=MSG_MEDIA_WRITABLE
+Language=English
+Access : Writable
+.
+
+
+MessageId=
+SymbolicName=MSG_MEDIA_PROTECTED
+Language=English
+Access : Write Protected
+.
+
+
+;//
+;// Help message text
+;//
+MessageId=
+SymbolicName=MSG_HINT_INSTALL
+Language=English
+SYNTAX: %1!s!INSTALL [driver] [/AUTO | /A]
+Try '%1!s!HELP INSTALL' for more information.
+.
+
+
+MessageId=
+SymbolicName=MSG_HINT_REMOVE
+Language=English
+SYNTAX: %1!s!REMOVE [/FORCE | /F | /QUIT | /Q]
+Try '%1!s!HELP REMOVE' for more information.
+.
+
+
+MessageId=
+SymbolicName=MSG_HINT_CONFIG
+Language=English
+SYNTAX: %1!s!CONFIG {/AUTO | /A | /MANUAL | /M}
+Try '%1!s!HELP CONFIG' for more information.
+.
+
+
+MessageId=
+SymbolicName=MSG_HINT_START
+Language=English
+SYNTAX: %1!s!START
+Try '%1!s!HELP START' for more information.
+.
+
+
+MessageId=
+SymbolicName=MSG_HINT_STOP
+Language=English
+SYNTAX: %1!s!STOP [/FORCE | /F | /QUIT | /Q]
+Try '%1!s!HELP STOP' for more information.
+.
+
+
+MessageId=
+SymbolicName=MSG_HINT_SHELL
+Language=English
+SYNTAX: %1!s!SHELL [/ON | /OFF]
+Try '%1!s!HELP SHELL' for more information.
+.
+
+
+MessageId=
+SymbolicName=MSG_HINT_OPEN
+Language=English
+SYNTAX: %1!s!OPEN [drive:] [file] [/NEW] [/RAM] [/P | /W]
+ [ /160 | /180 | /320 | /360 | /640 | /720 | /820 | /120 | /1.20
+ | /144 | /1.44 | /168 | /1.68 | /172 | /1.72 | /288 | /2.88 ]
+ [ /5 | /525 | /5.25 ] [/F | /FORCE | /Q | QUIT]
+Try '%1!s!HELP OPEN' for more information.
+.
+
+
+MessageId=
+SymbolicName=MSG_HINT_CLOSE
+Language=English
+SYNTAX: %1!s!CLOSE [drive:] [/FORCE | /F | /QUIT | /Q]
+Try '%1!s!HELP CLOSE' for more information.
+.
+
+
+MessageId=
+SymbolicName=MSG_HINT_SAVE
+Language=English
+SYNTAX: %1!s!SAVE [drive:] [file] [/OVER | /O | /TRUNC | /T]
+ [/FORCE | /F | /QUIT | /Q]
+Try '%1!s!HELP SAVE' for more information.
+.
+
+
+MessageId=
+SymbolicName=MSG_HINT_PROTECT
+Language=English
+SYNTAX: %1!s!PROTECT [drive:] [/ON | /OFF]
+Try '%1!s!HELP PROTECT' for more information.
+.
+
+
+MessageId=
+SymbolicName=MSG_HINT_FORMAT
+Language=English
+SYNTAX: %1!s!FORMAT [drive:] [/FORCE | /F | /QUIT | /Q]
+Try '%1!s!HELP FORMAT' for more information.
+.
+
+
+MessageId=
+SymbolicName=MSG_HINT_LINK
+Language=English
+SYNTAX: %1!s!LINK [number] [letter] [/L]
+Try '%1!s!HELP LINK' for more information.
+.
+
+
+MessageId=
+SymbolicName=MSG_HINT_ULINK
+Language=English
+SYNTAX: %1!s!ULINK [drive]
+Try '%1!s!HELP ULINK' for more information.
+.
+
+
+MessageId=
+SymbolicName=MSG_HINT_STATUS
+Language=English
+SYNTAX: %1!s!STATUS
+Try '%1!s!HELP STATUS' for more information.
+.
+
+
+MessageId=
+SymbolicName=MSG_HINT_VERSION
+Language=English
+SYNTAX: %1!s!VERSION
+Print version information.
+.
+
+
+MessageId=
+SymbolicName=MSG_HELP_GENERAL
+Language=English
+Usage:
+ %1!s![command [options...]]
+
+Commands:
+ INSTALL Install the Virtual Floppy driver.
+ REMOVE Uninstall the Virtual Floppy driver.
+ CONFIG Configure the Virtual Floppy driver.
+ START Start the Virtual Floppy driver.
+ STOP Stop the Virtual Floppy driver.
+ SHELL Enable/disable the shell extension.
+ OPEN Open a Virtual Floppy image.
+ CLOSE Close a Virtual Floppy image.
+ SAVE Save the current image into a file.
+ PROTECT Enable/disable drive write protect.
+ FORMAT Format the current Virtual Floppy media.
+ LINK Assign a drive letter to a Virtual Floppy drive.
+ ULINK Remove a drive letter from a Virtual Floppy drive.
+ STATUS Print the current status.
+ HELP | ? Print usage help.
+ VERSION Print version information
+
+If a command is not specified, the interactive console is started.
+Type '%1!s!HELP CONSOLE' for more information about the interactive
+console.
+
+All commands and options are case insensitive.
+
+Shorter command name can be used as long as the command can be
+distinguished uniquely: I for INSTALL, REM for REMOVE, etc. are
+accepted, but ST is invalid because it is ambiguous. You have
+to type as much as STAR, STO or STAT in order to distinguish them.
+
+'%1!s!command {/? | /h}' shows a brief hint about each command.
+.
+
+
+MessageId=
+SymbolicName=MSG_HELP_INSTALL
+Language=English
+Install the Virtual Floppy driver.
+
+SYNTAX:
+ %1!s!INSTALL [driver] [/AUTO | /A]
+
+OPTIONS:
+ driver Specifies the path to the Virtual Floppy driver file.
+ Default is VFD.SYS in the same directory as the VFD
+ console program (Note: *NOT* current directory).
+
+ /AUTO Configures the driver to start at the system startup.
+ /A (Note: *NOT* to start the driver after installation.)
+ By default the driver has to be started manually.
+
+Administrator rights are required to install a devide driver.
+
+Device drivers cannot be installed from network drives.
+Make sure to place VFD.SYS on a local drive.
+
+It is advised to install the driver with the /AUTO option if the
+Virtual Floppy drive is going to be used by users other than
+Administrators and Power Users, who don't have enough rights to
+start device drivers.
+.
+
+
+MessageId=
+SymbolicName=MSG_HELP_CONFIG
+Language=English
+Configure the Virtual Floppy driver start method.
+
+SYNTAX:
+ %1!s!CONFIG {/AUTO | /A | /MANUAL | /M}
+
+OPTIONS:
+ /AUTO Configures the driver to start at the system startup.
+ /A
+
+ /MANUAL Configures the driver to start on demand.
+ /M
+
+The change takes effect the next system start up.
+Administrator rights are required to configure a devide driver.
+.
+
+
+MessageId=
+SymbolicName=MSG_HELP_REMOVE
+Language=English
+Uninstall the Virtual Floppy driver.
+
+SYNTAX:
+ %1!s!REMOVE [/FORCE | /F | /QUIT | /Q]
+
+OPTIONS:
+ /FORCE Suppress prompting and forces the remove operation when
+ /F the driver cannot be stopped.
+
+ /QUIT Suppress prompting and quits the remove operation when
+ /Q the driver cannot be stopped.
+
+Closes all images and stops the driver if necessary, then removes the
+Virtual Floppy driver entries from the system registry.
+This command does not delete the driver file from the local disk.
+
+There are cases, due to the condition of the system, when
+uninstallation does not complete immediately and restarting of the
+system is required. In such cases you may not be able to install the
+Virtual Floppy driver again until the system is restarted and
+uninstallation process is complete.
+
+Administrator rights are required to uninstall a device driver.
+.
+
+
+MessageId=
+SymbolicName=MSG_HELP_START
+Language=English
+Start the Virtual Floppy driver.
+
+SYNTAX:
+ %1!s!START
+
+OPTIONS:
+ NONE
+
+If the driver is not installed, this command attempts to install it
+with thedefault options.
+
+At least Power User rights are required to start a device driver.
+.
+
+
+MessageId=
+SymbolicName=MSG_HELP_STOP
+Language=English
+Stop the Virtual Floppy driver
+
+SYNTAX:
+ %1!s!STOP [/FORCE | /F | /QUIT | /Q]
+
+OPTIONS:
+ /FORCE Suppress prompting and forces the stop operation when any
+ /F of the drives are in use and cannot be closed.
+
+ /QUIT Suppress prompting and quits the stop operation when any
+ /Q of the drives are in use and cannot be closed.
+
+This command closes all images before stopping the driver.
+An image cannot be closed if the virtual drive is used by any other
+programs. Forcing the stop operation with a drive in use may leave
+the driver in stop pending state. In such cases the driver cannot be
+restarted until all programs stop using the drive and the driver is
+properly unloaded.
+
+At least Power User rights are required to stop a device driver.
+.
+
+
+MessageId=
+SymbolicName=MSG_HELP_SHELL
+Language=English
+Enable / disable the Virtual Floppy drive shell extension.
+
+SYNTAX:
+ %1!s!SHELL [/ON | /OFF]
+
+OPTIONS:
+ /ON Enables the shell extension.
+
+ /OFF Disables the shell extension.
+
+If an option is not specified, this command prints the current state
+of the shell extension.
+.
+
+
+MessageId=
+SymbolicName=MSG_HELP_OPEN
+Language=English
+Open a Virtual Floppy image.
+
+SYNTAX:
+ %1!s!OPEN [drive:] [file] [/NEW] [/RAM] [/P | /W]
+ [/size] [/media] [/F | /FORCE | /Q | /QUIT]
+
+OPTIONS:
+ drive: Specifies a target Virtual Floppy drive, either by a drive
+ number or a drive letter, such as "0:", "1:",
"B:", "X:".
+ The trailing ':' is required.
+ The drive 0 is assumed if not specified.
+
+ file Specifies a Virtual Floppy image file to open.
+ An empty RAM disk is created if not specified.
+
+ /NEW Creates a new image file.
+ Ignored if a file is not specified.
+
+ /RAM RAM mode - mounts an on-memory copy of the image, instead
+ of directly mounting the image file.
+ Changes made to the virtual media are lost when the image
+ is closed, unless the image is explicitly saved to a file
+ with the 'SAVE' command.
+ Ignored if a file is not specified.
+
+ /P Opens the image as a write protected media.
+ Write protection state can be chenged later with the
+ 'PROTECT' command.
+
+ /W Opens the image as a writable media.
+ Write protection state can be chenged later with the
+ 'PROTECT' command.
+
+ /size Specifies a media size. Acceptable options are:
+
+ /160 (160KB) /820 (820KB)
+ /180 (180KB) /120 or /1.20 (1.20MB)
+ /320 (320KB) /144 or /1.44 (1.44MB)
+ /360 (360KB) /168 or /1.68 (1.68MB DMF)
+ /640 (640KB) /172 or /1.72 (1.72MB DMF)
+ /720 (720KB) /288 or /2.88 (2.88MB)
+
+ /5 Specifies a 5.25 inch media. Takes effect only with
+ /525 640KB, 720KB and 1.2MB media and otherwise ignored.
+ /5.25 160KB, 180KB, 320KB and 360KB media are always 5.25".
+ 820KB, 1.44MB, 1.68MB, 1.72MB and 2.88MB media are always
+ 3.5".
+
+ /FORCE Suppress prompring on minor conflicts and/or omission of
+ /F necessary parameters and continues the operation as best
+ as possible, employing default values if necessary.
+ See below for details.
+
+ /QUIT Suppress prompring on minor conflicts and/or omission of
+ /Q necessary parameters and quits the operation on the first
+ such occasion.
+ See below for details.
+
+If the target drive does not have a drive letter, this command also
+assigns a local drive letter (see '%1!s!HELP LINK') using the first
+available letter.
+
+Read only files, NTFS encrypted/compressed files and ZIP compressed
+image files (such as WinImage IMZ file) cannot be mounted directly
+and must be opened in RAM mode.
+
+Without a size option, size of a virtual media is decided from the
+actual image size. With an explicit size option you can mount a
+file as a smaller media, in such cases surplus data at the end of
+the image is ignored.
+A virtual media size cannot exceed the actual image size.
+
+The /F and /Q options affect the behavior of the OPEN command in
+many ways:
+
+ When the target file does not exist and the /NEW option
+ is not present
+
+ (none) ask user whether to create the target
+ /F create the target without asking
+ /Q abort the operation without asking
+
+ The target file exists and the /NEW option is present
+
+ (none) ask user whether to overwrite the existing file
+ /F overwrite the file without asking
+ /Q abort the operation without asking
+
+ The target file cannot be mounted directly and the /RAM
+ option is not present
+
+ (none) ask user whether to open in RAM mode
+ /F open in RAM mode without asking
+ /Q abort the operation without asking
+
+ A size option is not present for creating a new image
+
+ (none) ask user whether to create a 1.44MB (default) image
+ /F create a 1.44MB image without asking
+ /Q abort the operation without asking
+
+ A size option is not present and the target file size is
+ not an exact match for any of supported media
+
+ (none) ask user whether to mount as a largest media to fit
+ in the actual image
+ /F mount as a largest media to fit in the actual image
+ without asking
+ /Q abort the operation without asking
+.
+
+
+MessageId=
+SymbolicName=MSG_HELP_CLOSE
+Language=English
+Close a Virtual Floppy image.
+
+SYNTAX:
+ %1!s!CLOSE [drive:] [/FORCE | /F | /QUIT | /Q]
+
+OPTIONS:
+ drive: Specifies a target Virtual Floppy drive, either by a drive
+ number or a drive letter, such as "0:", "1:",
"B:", "X:".
+ The trailing ':' is optional.
+ "*" stands for both drives.
+ The drive 0 is used if not specified.
+
+ /FORCE Suppress prompting and forces the close operation when RAM
+ /F disk data is modified or the drive is in use.
+ Forcing with the drive in use will work only on Windows
+ 2000 and later (not on NT).
+
+ /QUIT Suppress prompting and quits the close operation when RAM
+ /Q disk data is modified or the drive is in use.
+
+If neither /Q nor /F is specified, the user has to choose whether to
+retry, force, or quit.
+
+Unlike the previous versions of the VFD, this command does *NOT*
+remove the drive letter of the target drive.
+.
+
+
+MessageId=
+SymbolicName=MSG_HELP_SAVE
+Language=English
... 17405 lines suppressed ...