From: André Hentschel Subject: wineboot: Create serial comm registry keys Message-Id: <561E88CF.5010703@dawncrow.de> Date: Wed, 14 Oct 2015 18:54:39 +0200 Signed-off-by: André Hentschel --- get_dos_device_path stolen from dlls/kernel32/volume.c supersedes 114615 This is for https://bugs.winehq.org/show_bug.cgi?id=11811 Next step would be https://bugs.winehq.org/show_bug.cgi?id=30409 programs/wineboot/wineboot.c | 56 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/programs/wineboot/wineboot.c b/programs/wineboot/wineboot.c index 1477287..6e079d6 100644 --- a/programs/wineboot/wineboot.c +++ b/programs/wineboot/wineboot.c @@ -91,6 +91,27 @@ extern void kill_processes( BOOL kill_desktop ); static WCHAR windowsdir[MAX_PATH]; +/* get the path of a dos device symlink in the $WINEPREFIX/dosdevices directory */ +static char *get_dos_device_path( LPCWSTR name ) +{ + const char *config_dir = wine_get_config_dir(); + char *buffer, *dev; + int i; + + if (!(buffer = HeapAlloc( GetProcessHeap(), 0, + strlen(config_dir) + sizeof("/dosdevices/") + 5 ))) + return NULL; + + strcpy( buffer, config_dir ); + strcat( buffer, "/dosdevices/" ); + dev = buffer + strlen(buffer); + /* no codepage conversion, DOS device names are ASCII anyway */ + for (i = 0; i < 5; i++) + if (!(dev[i] = (char)tolowerW(name[i]))) break; + dev[5] = 0; + return buffer; +} + /* retrieve the (unix) path to the wine.inf file */ static char *get_wine_inf_path(void) { @@ -274,6 +295,40 @@ static void create_hardware_registry_keys(void) HeapFree( GetProcessHeap(), 0, power_info ); } +static void create_serial_registry_keys(void) +{ + static const WCHAR SerialCommW[] = {'H','a','r','d','w','a','r','e','\\', + 'D','e','v','i','c','e','m','a','p','\\', + 'S','e','r','i','a','l','C','o','m','m',0}; + static const WCHAR ComDescW[] = {'C','O','M','%','d',0}; + HKEY key; + int i; + + if (RegCreateKeyExW( HKEY_LOCAL_MACHINE, SerialCommW, 0, NULL, REG_OPTION_VOLATILE, + KEY_ALL_ACCESS, NULL, &key, NULL )) + return; + + for (i = 1; i <= 9; i++) + { + WCHAR comW[5 /* com + single number + \0 */]; + char *link; + int ret; + + sprintfW( comW, ComDescW, i ); + link = get_dos_device_path( comW ); + ret = access( link, R_OK | W_OK ); + + if (ret) + RegDeleteValueW( key, comW ); + else + set_reg_value( key, comW, comW ); + + HeapFree( GetProcessHeap(), 0, link ); + } + + RegCloseKey( key ); +} + /* create the DynData registry keys */ static void create_dynamic_registry_keys(void) @@ -1234,6 +1289,7 @@ int main( int argc, char *argv[] ) create_hardware_registry_keys(); create_dynamic_registry_keys(); create_environment_registry_keys(); + create_serial_registry_keys(); wininit(); pendingRename(); -- 1.9.1