winevdm: Try using the new DOSBox command to remap Z to a free drive

André Hentschel nerv at dawncrow.de
Sun Jul 24 08:27:07 CDT 2011


There is no way atm to detect if dosbox has that feature or not, so we could just try and fail if the user is not using dosbox-svn.
or we wait until dosbox 0.75 is out and established, but that can last a year or so.
Maybe a warning message that it may fail  -  if the user runs something from Z?
Anyway, here is my approach of using the new feature, it detects the highest unused drive and remaps dosbox's zdrive to it.
see also http://dosbox.svn.sourceforge.net/viewvc/dosbox/dosbox/trunk/src/dos/dos_programs.cpp?revision=3736&view=markup

---
 programs/winevdm/winevdm.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/programs/winevdm/winevdm.c b/programs/winevdm/winevdm.c
index 8abc282..ec67b73 100644
--- a/programs/winevdm/winevdm.c
+++ b/programs/winevdm/winevdm.c
@@ -158,15 +158,10 @@ static void start_dosbox( const char *appname, const char *args )
     int i;
     int ret = 1;
     DWORD written, drives = GetLogicalDrives();
+    CHAR virtdrive = 'Z';
     char *dosbox = find_dosbox();
 
     if (!dosbox) return;
-    if (tolower(appname[0]) == 'z')
-    {
-        WINE_MESSAGE( "winevdm: Cannot start DOS application %s\n", appname );
-        WINE_MESSAGE( "         because DOSBox doesn't support running from the Z: drive.\n" );
-        ExitProcess(1);
-    }
     if (!GetTempPathW( MAX_PATH, path )) return;
     if (!GetTempFileNameW( path, cfgW, 0, config )) return;
     if (!GetCurrentDirectoryW( MAX_PATH, path )) return;
@@ -179,7 +174,14 @@ static void start_dosbox( const char *appname, const char *args )
                         6 + strlen( appname ) + strlen( args ) + 20 );
     p = buffer;
     p += sprintf( p, "[autoexec]\n" );
-    for (i = 0; i < 25; i++)
+    for (i = 25; i >= 0; i--)
+        if (!(drives & (1 << i)))
+        {
+            virtdrive = 'A' + i ;
+            break;
+        }
+    p += sprintf( p, "mount -z %c\n", virtdrive );
+    for (i = 0; i <= 25; i++)
         if (drives & (1 << i))
             p += sprintf( p, "mount %c %s/dosdevices/%c:\n", 'a' + i, config_dir, 'a' + i );
     p += sprintf( p, "%c:\ncd ", path[0] );
-- 

Best Regards, André Hentschel



More information about the wine-patches mailing list