diff --git a/dlls/kernel32/oldconfig.c b/dlls/kernel32/oldconfig.c index ee41d81..361428e 100644 --- a/dlls/kernel32/oldconfig.c +++ b/dlls/kernel32/oldconfig.c @@ -331,8 +331,8 @@ static int SCSI_getprocentry( FILE * procfile, struct LinuxProcScsiDevice * dev } -/* create the hardware registry branch */ -static void create_hardware_branch(void) +/* create the scsi registry branch */ +static void create_scsi_branch(void) { /* The following mostly will work on Linux, but should not cause * problems on other systems. */ @@ -453,6 +453,76 @@ static void create_hardware_branch(void) fclose( procfile ); } +/* create SERIALCOMM branch containing keys for com1 - com4 */ +void create_serialcomm_branch(void) +{ + OBJECT_ATTRIBUTES attr; + UNICODE_STRING nameW; + WCHAR dataW[50]; + DWORD lenW; + DWORD disp; + HANDLE targetKey; + struct stat devstat; + const char * wineprefixdir; + char * dosdevpath = 0; + static const char dosdevdirsuffix[] = "/dosdevices/com1"; + int suffixlength = 16; + int wpdlength = 0; + int fullpathlength = 0; + char keyname[] = "\\Device\\Serial0"; + char keydata[] = "COM1"; + int index = 0; + + + attr.Length = sizeof(attr); + attr.RootDirectory = 0; + attr.ObjectName = &nameW; + attr.Attributes = 0; + attr.SecurityDescriptor = NULL; + attr.SecurityQualityOfService = NULL; + + /* Ensure there is HARDWARE\\DEVICEMAP\\SERIALCOMM key */ + if (!RtlCreateUnicodeStringFromAsciiz( &nameW, "Machine\\HARDWARE\\DEVICEMAP\\SERIALCOMM" ) || + NtCreateKey( &targetKey, KEY_ALL_ACCESS, &attr, 0, + NULL, REG_OPTION_VOLATILE, &disp )) + { + ERR("Cannot create DEVICEMAP\\SERIALCOMM registry key\n" ); + return; + } + RtlFreeUnicodeString( &nameW ); + + /* we're repeating mountmgr.sys's get_dosdevice_path() */ + wineprefixdir = wine_get_config_dir(); + wpdlength = strlen(wineprefixdir); + fullpathlength = wpdlength + suffixlength + 1; + dosdevpath = malloc(fullpathlength); + strcpy(dosdevpath, wineprefixdir); + strcpy(dosdevpath + wpdlength, dosdevdirsuffix); + + for (index = 1; index < 5; index++) + { + dosdevpath[fullpathlength - 2] = (char)(48 + index); + keyname[14] = (char)(47 + index); + keydata[3] = (char)(48 + index); + + if(!stat((const char *) dosdevpath, &devstat)) + { + RtlCreateUnicodeStringFromAsciiz( &nameW, &keyname ); + RtlMultiByteToUnicodeN( dataW, sizeof(dataW), &lenW, keydata, 4); + NtSetValueKey( targetKey, &nameW, 0, REG_SZ, (BYTE*)dataW, lenW ); + RtlFreeUnicodeString( &nameW ); + } + } + free(dosdevpath); +} + +/* create the hardware registry branch */ +void create_hardware_branch(void) +{ + create_scsi_branch(); + create_serialcomm_branch(); +} + /*********************************************************************** * convert_old_config