diff --git a/dlls/kernel32/oldconfig.c b/dlls/kernel32/oldconfig.c index 20b6eaa..bb238fb 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. */ @@ -454,6 +454,74 @@ static void create_hardware_branch(void) } +/* create SERIALCOMM branch containing keys for com1 - com9 */ +void create_serialcomm_branch(void) +{ + OBJECT_ATTRIBUTES attr; + UNICODE_STRING nameU; + WCHAR dataW[50]; + DWORD length; + DWORD disp; + HANDLE targetKey; + struct stat devstat; + + const char * wineprefixdir; + char * dosdevpath = 0; + char keyname[] = "\\Device\\Serial0"; + char keydata[] = "COM1"; + static const char dosdevdirsuffix[] = "/dosdevices/com1"; + int suffixlength = 16; + int wpdlength = 0; + int fullpathlength = 0; + int index = 0; + + + attr.Length = sizeof(attr); + attr.RootDirectory = 0; + attr.ObjectName = &nameU; + attr.Attributes = 0; + attr.SecurityDescriptor = NULL; + attr.SecurityQualityOfService = NULL; + + /* Ensure there is HARDWARE\\DEVICEMAP\\SERIALCOMM key */ + if (!RtlCreateUnicodeStringFromAsciiz( &nameU, "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( &nameU ); + + /* we're doing a subset of mountmgr.sys/device.c's get_dosdevices_path() */ + wineprefixdir = wine_get_config_dir(); + wpdlength = strlen(wineprefixdir); + fullpathlength = wpdlength + suffixlength + 1; + dosdevpath = HeapAlloc(GetProcessHeap(), 0, fullpathlength); + strcpy(dosdevpath, wineprefixdir); + strcpy(dosdevpath + wpdlength, dosdevdirsuffix); + + + /* and a subset of ntdll/directory.c's get_dos_device() */ + for (index = 1; index < 10; index++) + { + dosdevpath[fullpathlength - 2] = (char)('0' + index); + keyname[14] = (char)('0' + index - 1); + keydata[3] = (char)('0' + index); + + if( !stat((const char *) dosdevpath, &devstat) ) + { + RtlCreateUnicodeStringFromAsciiz( &nameU, keyname ); + RtlMultiByteToUnicodeN( dataW, sizeof(dataW), &length, keydata, 5 ); + NtSetValueKey( targetKey, &nameU, 0, REG_SZ, (BYTE*)dataW, length ); + RtlFreeUnicodeString( &nameU ); + } + } + HeapFree(GetProcessHeap(), 0, dosdevpath); + NtClose(targetKey); +} + + /*********************************************************************** * convert_old_config */ @@ -463,5 +531,6 @@ void convert_old_config(void) return; /* someone else already loaded the registry */ /* create some hardware keys (FIXME: should not be done here) */ - create_hardware_branch(); + create_scsi_branch(); + create_serialcomm_branch(); }