winevdm: Avoid using wine_get_config_dir().

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2020-04-17 12:50:23 +02:00
parent 43e80d235e
commit a094f5173a

View file

@ -31,7 +31,6 @@
#include "winuser.h" #include "winuser.h"
#include "wincon.h" #include "wincon.h"
#include "wine/unicode.h" #include "wine/unicode.h"
#include "wine/library.h"
#include "wine/debug.h" #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(winevdm); WINE_DEFAULT_DEBUG_CHANNEL(winevdm);
@ -150,11 +149,12 @@ static char *find_dosbox(void)
static void start_dosbox( const char *appname, const char *args ) static void start_dosbox( const char *appname, const char *args )
{ {
static const WCHAR cfgW[] = {'c','f','g',0}; static const WCHAR cfgW[] = {'c','f','g',0};
const char *config_dir = wine_get_config_dir(); const char *home = getenv( "HOME" );
const char *prefix = getenv( "WINEPREFIX" );
WCHAR path[MAX_PATH], config[MAX_PATH]; WCHAR path[MAX_PATH], config[MAX_PATH];
HANDLE file; HANDLE file;
char *p, *buffer, app[MAX_PATH]; char *p, *buffer, app[MAX_PATH];
int i; int i, len;
int ret = 1; int ret = 1;
DWORD written, drives = GetLogicalDrives(); DWORD written, drives = GetLogicalDrives();
char *dosbox = find_dosbox(); char *dosbox = find_dosbox();
@ -168,9 +168,10 @@ static void start_dosbox( const char *appname, const char *args )
file = CreateFileW( config, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0 ); file = CreateFileW( config, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0 );
if (file == INVALID_HANDLE_VALUE) return; if (file == INVALID_HANDLE_VALUE) return;
len = prefix ? strlen(prefix) : strlen(home) + strlen("/.wine");
buffer = HeapAlloc( GetProcessHeap(), 0, sizeof("[autoexec]") + buffer = HeapAlloc( GetProcessHeap(), 0, sizeof("[autoexec]") +
sizeof("mount -z c") + sizeof("config -securemode") + sizeof("mount -z c") + sizeof("config -securemode") +
25 * (strlen(config_dir) + sizeof("mount c /dosdevices/c:")) + 25 * (len + sizeof("mount c /dosdevices/c:")) +
4 * strlenW( path ) + 4 * strlenW( path ) +
6 + strlen( app ) + strlen( args ) + 20 ); 6 + strlen( app ) + strlen( args ) + 20 );
p = buffer; p = buffer;
@ -182,8 +183,13 @@ static void start_dosbox( const char *appname, const char *args )
break; break;
} }
for (i = 0; i <= 25; i++) 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 ); if (!(drives & (1 << i))) continue;
if (prefix)
p += sprintf( p, "mount %c %s/dosdevices/%c:\n", 'a' + i, prefix, 'a' + i );
else
p += sprintf( p, "mount %c %s/.wine/dosdevices/%c:\n", 'a' + i, home, 'a' + i );
}
p += sprintf( p, "%c:\ncd ", path[0] ); p += sprintf( p, "%c:\ncd ", path[0] );
p += WideCharToMultiByte( CP_UNIXCP, 0, path + 2, -1, p, 4 * strlenW(path), NULL, NULL ) - 1; p += WideCharToMultiByte( CP_UNIXCP, 0, path + 2, -1, p, 4 * strlenW(path), NULL, NULL ) - 1;
p += sprintf( p, "\nconfig -securemode\n" ); p += sprintf( p, "\nconfig -securemode\n" );