diff --git a/dlls/kernel32/oldconfig.c b/dlls/kernel32/oldconfig.c index 20b6eaa..63d2e7c 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,66 @@ static void create_hardware_branch(void) } +/* create SERIALCOMM branch containing keys for /dev/ttyS* */ +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"; + char devicename[] = "/dev/ttyS0"; + 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 ); + + for (index = 1; ; index++) + { + devicename[9] = (char)('0' + index - 1); + keyname[14] = (char)('0' + index - 1); + keydata[3] = (char)('0' + index); + + /* stat the device to check it's there */ + if( !stat((const char *) devicename, &devstat) ) + { + RtlCreateUnicodeStringFromAsciiz( &nameU, keyname ); + RtlMultiByteToUnicodeN( dataW, sizeof(dataW), &length, keydata, 5 ); + NtSetValueKey( targetKey, &nameU, 0, REG_SZ, (BYTE*)dataW, length ); + RtlFreeUnicodeString( &nameU ); + } + else + { + /* that was the last /dev/ttyS* - we're finished */ + break; + } + } + HeapFree(GetProcessHeap(), 0, dosdevpath); + NtClose(targetKey); +} + + /*********************************************************************** * convert_old_config */ @@ -463,5 +523,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(); }