2 * Support for converting from old configuration format
4 * Copyright 2005 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 * This file should be removed after a suitable transition period.
25 #include "wine/port.h"
30 #ifdef HAVE_SYS_STAT_H
31 # include <sys/stat.h>
34 #ifdef HAVE_SYS_IOCTL_H
35 #include <sys/ioctl.h>
37 #ifdef HAVE_LINUX_HDREG_H
38 # include <linux/hdreg.h>
41 #define NONAMELESSUNION
42 #define NONAMELESSSTRUCT
50 #include "wine/library.h"
51 #include "wine/server.h"
52 #include "wine/unicode.h"
53 #include "wine/debug.h"
54 #include "kernel_private.h"
56 WINE_DEFAULT_DEBUG_CHANNEL(reg);
59 /* create symlinks for the DOS drives; helper for create_dos_devices */
60 static int create_drives( int devices_only )
62 static const WCHAR PathW[] = {'P','a','t','h',0};
63 static const WCHAR DeviceW[] = {'D','e','v','i','c','e',0};
64 WCHAR driveW[] = {'M','a','c','h','i','n','e','\\','S','o','f','t','w','a','r','e','\\',
65 'W','i','n','e','\\','W','i','n','e','\\',
66 'C','o','n','f','i','g','\\','D','r','i','v','e',' ','A',0};
67 const char *config_dir = wine_get_config_dir();
68 OBJECT_ATTRIBUTES attr;
70 char tmp[1024*sizeof(WCHAR) + sizeof(KEY_VALUE_PARTIAL_INFORMATION)];
78 attr.Length = sizeof(attr);
79 attr.RootDirectory = 0;
80 attr.ObjectName = &nameW;
82 attr.SecurityDescriptor = NULL;
83 attr.SecurityQualityOfService = NULL;
85 /* create symlinks for the drive roots */
87 if (!devices_only) for (i = 0; i < 26; i++)
89 RtlInitUnicodeString( &nameW, driveW );
90 nameW.Buffer[(nameW.Length / sizeof(WCHAR)) - 1] = 'A' + i;
91 /* @@ Wine registry key: HKLM\Software\Wine\Wine\Config\Drive A */
92 if (NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ) != STATUS_SUCCESS) continue;
94 RtlInitUnicodeString( &nameW, PathW );
95 if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
98 WCHAR *data = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
99 ExpandEnvironmentStringsW( data, path, sizeof(path)/sizeof(WCHAR) );
101 p = path + strlenW(path) - 1;
102 while ((p > path) && (*p == '/')) *p-- = '\0';
110 /* relative paths are relative to config dir */
111 memmove( path + 3, path, (strlenW(path) + 1) * sizeof(WCHAR) );
116 if (DefineDosDeviceW( DDD_RAW_TARGET_PATH, name, path ))
118 WideCharToMultiByte(CP_UNIXCP, 0, path, -1, dest, sizeof(dest), NULL, NULL);
119 MESSAGE( "Created symlink %s/dosdevices/%c: -> %s\n",
120 wine_get_config_dir(), 'a' + i, dest );
127 /* create symlinks for the drive devices */
129 buffer = HeapAlloc( GetProcessHeap(), 0,
130 strlen(config_dir) + sizeof("/dosdevices/a::") );
131 strcpy( buffer, config_dir );
132 strcat( buffer, "/dosdevices/a::" );
134 for (i = 0; i < 26; i++)
136 RtlInitUnicodeString( &nameW, driveW );
137 nameW.Buffer[(nameW.Length / sizeof(WCHAR)) - 1] = 'A' + i;
138 /* @@ Wine registry key: HKLM\Software\Wine\Wine\Config\Drive A */
139 if (NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ) != STATUS_SUCCESS) continue;
141 RtlInitUnicodeString( &nameW, DeviceW );
142 if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
144 WCHAR *data = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
145 WideCharToMultiByte(CP_UNIXCP, 0, data, -1, dest, sizeof(dest), NULL, NULL);
147 buffer[strlen(buffer) - 3] = 'a' + i;
148 if (!symlink( dest, buffer ))
150 MESSAGE( "Created symlink %s/dosdevices/%c:: -> %s\n",
151 wine_get_config_dir(), 'a' + i, dest );
157 HeapFree( GetProcessHeap(), 0, buffer );
163 /* create the device files for the new device naming scheme */
164 static void create_dos_devices(void)
166 const char *config_dir = wine_get_config_dir();
170 if (!(buffer = HeapAlloc( GetProcessHeap(), 0,
171 strlen(config_dir) + sizeof("/dosdevices/a::") )))
174 strcpy( buffer, config_dir );
175 strcat( buffer, "/dosdevices" );
177 if (!mkdir( buffer, 0777 )) /* we created it, so now create the devices */
181 OBJECT_ATTRIBUTES attr;
182 UNICODE_STRING nameW;
185 WCHAR com[5] = {'C','O','M','1',0};
186 WCHAR lpt[5] = {'L','P','T','1',0};
188 static const WCHAR serialportsW[] = {'M','a','c','h','i','n','e','\\',
189 'S','o','f','t','w','a','r','e','\\',
190 'W','i','n','e','\\','W','i','n','e','\\',
191 'C','o','n','f','i','g','\\',
192 'S','e','r','i','a','l','P','o','r','t','s',0};
193 static const WCHAR parallelportsW[] = {'M','a','c','h','i','n','e','\\',
194 'S','o','f','t','w','a','r','e','\\',
195 'W','i','n','e','\\','W','i','n','e','\\',
196 'C','o','n','f','i','g','\\',
197 'P','a','r','a','l','l','e','l','P','o','r','t','s',0};
199 attr.Length = sizeof(attr);
200 attr.RootDirectory = 0;
201 attr.ObjectName = &nameW;
203 attr.SecurityDescriptor = NULL;
204 attr.SecurityQualityOfService = NULL;
205 RtlInitUnicodeString( &nameW, serialportsW );
207 /* @@ Wine registry key: HKLM\Software\Wine\Wine\Config\SerialPorts */
208 if (!NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ))
210 RtlInitUnicodeString( &nameW, com );
211 for (i = 1; i <= 9; i++)
214 if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation,
215 tmp, sizeof(tmp), &dummy ))
217 devnameW = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
218 if ((p = strchrW( devnameW, ',' ))) *p = 0;
219 if (DefineDosDeviceW( DDD_RAW_TARGET_PATH, com, devnameW ))
222 WideCharToMultiByte(CP_UNIXCP, 0, devnameW, -1,
223 devname, sizeof(devname), NULL, NULL);
224 MESSAGE( "Created symlink %s/dosdevices/com%d -> %s\n", config_dir, i, devname );
232 /* @@ Wine registry key: HKLM\Software\Wine\Wine\Config\ParallelPorts */
233 RtlInitUnicodeString( &nameW, parallelportsW );
234 if (!NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ))
236 RtlInitUnicodeString( &nameW, lpt );
237 for (i = 1; i <= 9; i++)
240 if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation,
241 tmp, sizeof(tmp), &dummy ))
243 devnameW = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
244 if ((p = strchrW( devnameW, ',' ))) *p = 0;
245 if (DefineDosDeviceW( DDD_RAW_TARGET_PATH, lpt, devnameW ))
248 WideCharToMultiByte(CP_UNIXCP, 0, devnameW, -1,
249 devname, sizeof(devname), NULL, NULL);
250 MESSAGE( "Created symlink %s/dosdevices/lpt%d -> %s\n", config_dir, i, devname );
257 count += create_drives( FALSE );
264 /* it is possible that the serial/parallel devices have been created but */
265 /* not the drives; check for at least one drive symlink to catch that case */
266 strcat( buffer, "/a:" );
267 for (i = 0; i < 26; i++)
269 buffer[strlen(buffer)-2] = 'a' + i;
270 if (!lstat( buffer, &st )) break;
272 if (i == 26) count += create_drives( FALSE );
275 strcat( buffer, ":" );
276 for (i = 0; i < 26; i++)
278 buffer[strlen(buffer)-3] = 'a' + i;
279 if (!lstat( buffer, &st )) break;
281 if (i == 26) count += create_drives( TRUE );
286 MESSAGE( "\nYou can now remove the [SerialPorts], [ParallelPorts], and [Drive] sections\n"
287 "in your configuration file, they are replaced by the above symlinks.\n\n" );
289 HeapFree( GetProcessHeap(), 0, buffer );
293 /* convert the drive type entries from the old format to the new one */
294 static void convert_drive_types(void)
296 static const WCHAR TypeW[] = {'T','y','p','e',0};
297 static const WCHAR drive_types_keyW[] = {'M','a','c','h','i','n','e','\\',
298 'S','o','f','t','w','a','r','e','\\',
299 'W','i','n','e','\\',
300 'D','r','i','v','e','s',0 };
301 WCHAR driveW[] = {'M','a','c','h','i','n','e','\\','S','o','f','t','w','a','r','e','\\',
302 'W','i','n','e','\\','W','i','n','e','\\',
303 'C','o','n','f','i','g','\\','D','r','i','v','e',' ','A',0};
304 char tmp[32*sizeof(WCHAR) + sizeof(KEY_VALUE_PARTIAL_INFORMATION)];
305 OBJECT_ATTRIBUTES attr;
306 UNICODE_STRING nameW;
309 HANDLE hkey_old, hkey_new;
312 attr.Length = sizeof(attr);
313 attr.RootDirectory = 0;
314 attr.ObjectName = &nameW;
316 attr.SecurityDescriptor = NULL;
317 attr.SecurityQualityOfService = NULL;
318 RtlInitUnicodeString( &nameW, drive_types_keyW );
320 /* @@ Wine registry key: HKLM\Software\Wine\Drives */
321 if (NtCreateKey( &hkey_new, KEY_ALL_ACCESS, &attr, 0, NULL, 0, &disp )) return;
322 if (disp != REG_CREATED_NEW_KEY)
328 for (i = 0; i < 26; i++)
330 RtlInitUnicodeString( &nameW, driveW );
331 nameW.Buffer[(nameW.Length / sizeof(WCHAR)) - 1] = 'A' + i;
332 /* @@ Wine registry key: HKLM\Software\Wine\Wine\Config\Drive A */
333 if (NtOpenKey( &hkey_old, KEY_ALL_ACCESS, &attr ) != STATUS_SUCCESS) continue;
334 RtlInitUnicodeString( &nameW, TypeW );
335 if (!NtQueryValueKey( hkey_old, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
337 WCHAR valueW[] = {'A',':',0};
338 WCHAR *type = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
341 RtlInitUnicodeString( &nameW, valueW );
342 NtSetValueKey( hkey_new, &nameW, 0, REG_SZ, type, (strlenW(type) + 1) * sizeof(WCHAR) );
343 MESSAGE( "Converted drive type to new entry HKLM\\Software\\Wine\\Drives \"%c:\" = %s\n",
344 'A' + i, debugstr_w(type) );
352 /* convert the environment variable entries from the old format to the new one */
353 static void convert_environment( HANDLE hkey_current_user )
355 static const WCHAR wineW[] = {'M','a','c','h','i','n','e','\\',
356 'S','o','f','t','w','a','r','e','\\',
357 'W','i','n','e','\\','W','i','n','e','\\',
358 'C','o','n','f','i','g','\\','W','i','n','e',0};
359 static const WCHAR windowsW[] = {'w','i','n','d','o','w','s',0};
360 static const WCHAR systemW[] = {'s','y','s','t','e','m',0};
361 static const WCHAR windirW[] = {'w','i','n','d','i','r',0};
362 static const WCHAR systemrootW[] = {'S','y','s','t','e','m','r','o','o','t',0};
363 static const WCHAR winsysdirW[] = {'w','i','n','s','y','s','d','i','r',0};
364 static const WCHAR envW[] = {'E','n','v','i','r','o','n','m','e','n','t',0};
365 static const WCHAR tempW[] = {'T','E','M','P',0};
366 static const WCHAR tmpW[] = {'T','M','P',0};
367 static const WCHAR pathW[] = {'P','A','T','H',0};
368 static const WCHAR profileW[] = {'p','r','o','f','i','l','e',0};
369 static const WCHAR userprofileW[] = {'U','S','E','R','P','R','O','F','I','L','E',0};
371 char buffer[1024*sizeof(WCHAR) + sizeof(KEY_VALUE_PARTIAL_INFORMATION)];
372 KEY_VALUE_PARTIAL_INFORMATION *info = (KEY_VALUE_PARTIAL_INFORMATION *)buffer;
373 OBJECT_ATTRIBUTES attr;
374 UNICODE_STRING nameW;
377 HANDLE hkey_old, hkey_env;
379 attr.Length = sizeof(attr);
380 attr.RootDirectory = 0;
381 attr.ObjectName = &nameW;
383 attr.SecurityDescriptor = NULL;
384 attr.SecurityQualityOfService = NULL;
385 RtlInitUnicodeString( &nameW, wineW );
387 /* @@ Wine registry key: HKLM\Software\Wine\Wine\Config\Wine */
388 if (NtOpenKey( &hkey_old, KEY_ALL_ACCESS, &attr ) != STATUS_SUCCESS) return;
390 attr.RootDirectory = hkey_current_user;
391 RtlInitUnicodeString( &nameW, envW );
392 if (NtCreateKey( &hkey_env, KEY_ALL_ACCESS, &attr, 0, NULL, 0, &disp ))
398 /* Test for existence of TEMP */
399 RtlInitUnicodeString( &nameW, tempW );
400 if (NtQueryValueKey(hkey_env, &nameW, KeyValuePartialInformation, buffer, sizeof(buffer), &dummy ))
403 RtlInitUnicodeString( &nameW, tempW );
404 if (!NtQueryValueKey( hkey_old, &nameW, KeyValuePartialInformation, buffer, sizeof(buffer), &dummy ))
406 NtSetValueKey( hkey_env, &nameW, 0, info->Type, info->Data, info->DataLength );
407 RtlInitUnicodeString( &nameW, tmpW );
408 NtSetValueKey( hkey_env, &nameW, 0, info->Type, info->Data, info->DataLength );
409 MESSAGE( "Converted temp dir to new entry HKCU\\Environment \"TEMP\" = %s\n",
410 debugstr_w( (WCHAR*)info->Data ) );
414 /* Test for existence of PATH */
415 RtlInitUnicodeString( &nameW, pathW );
416 if (NtQueryValueKey(hkey_env, &nameW, KeyValuePartialInformation, buffer, sizeof(buffer), &dummy ))
419 RtlInitUnicodeString( &nameW, pathW );
420 if (!NtQueryValueKey( hkey_old, &nameW, KeyValuePartialInformation, buffer, sizeof(buffer), &dummy ))
422 NtSetValueKey( hkey_env, &nameW, 0, info->Type, info->Data, info->DataLength );
423 MESSAGE( "Converted path dir to new entry HKCU\\Environment \"PATH\" = %s\n",
424 debugstr_w( (WCHAR*)info->Data ) );
428 /* Test for existence of USERPROFILE */
429 RtlInitUnicodeString( &nameW, userprofileW );
430 if (NtQueryValueKey(hkey_env, &nameW, KeyValuePartialInformation, buffer, sizeof(buffer), &dummy ))
432 /* convert USERPROFILE */
433 RtlInitUnicodeString( &nameW, profileW );
434 if (!NtQueryValueKey( hkey_old, &nameW, KeyValuePartialInformation, buffer, sizeof(buffer), &dummy ))
436 RtlInitUnicodeString( &nameW, userprofileW );
437 NtSetValueKey( hkey_env, &nameW, 0, info->Type, info->Data, info->DataLength );
438 MESSAGE( "Converted profile dir to new entry HKCU\\Environment \"USERPROFILE\" = %s\n",
439 debugstr_w( (WCHAR*)info->Data ) );
443 /* Test for existence of windir */
444 RtlInitUnicodeString( &nameW, windirW );
445 if (NtQueryValueKey(hkey_env, &nameW, KeyValuePartialInformation, buffer, sizeof(buffer), &dummy ))
448 RtlInitUnicodeString( &nameW, windowsW );
449 if (!NtQueryValueKey( hkey_old, &nameW, KeyValuePartialInformation, buffer, sizeof(buffer), &dummy ))
451 RtlInitUnicodeString( &nameW, windirW );
452 NtSetValueKey( hkey_env, &nameW, 0, info->Type, info->Data, info->DataLength );
453 RtlInitUnicodeString( &nameW, systemrootW );
454 NtSetValueKey( hkey_env, &nameW, 0, info->Type, info->Data, info->DataLength );
455 MESSAGE( "Converted windows dir to new entry HKCU\\Environment \"windir\" = %s\n",
456 debugstr_w( (WCHAR*)info->Data ) );
460 /* Test for existence of winsysdir */
461 RtlInitUnicodeString( &nameW, winsysdirW );
462 if (NtQueryValueKey(hkey_env, &nameW, KeyValuePartialInformation, buffer, sizeof(buffer), &dummy ))
464 /* convert winsysdir */
465 RtlInitUnicodeString( &nameW, systemW );
466 if (!NtQueryValueKey( hkey_old, &nameW, KeyValuePartialInformation, buffer, sizeof(buffer), &dummy ))
468 RtlInitUnicodeString( &nameW, winsysdirW );
469 NtSetValueKey( hkey_env, &nameW, 0, info->Type, info->Data, info->DataLength );
470 MESSAGE( "Converted system dir to new entry HKCU\\Environment \"winsysdir\" = %s\n",
471 debugstr_w( (WCHAR*)info->Data ) );
479 /* registry initialisation, allocates some default keys. */
480 static ULONG allocate_default_keys(void)
482 static const WCHAR StatDataW[] = {'D','y','n','D','a','t','a','\\',
483 'P','e','r','f','S','t','a','t','s','\\',
484 'S','t','a','t','D','a','t','a',0};
485 static const WCHAR ConfigManagerW[] = {'D','y','n','D','a','t','a','\\',
486 'C','o','n','f','i','g',' ','M','a','n','a','g','e','r','\\',
490 OBJECT_ATTRIBUTES attr;
491 UNICODE_STRING nameW;
493 attr.Length = sizeof(attr);
494 attr.RootDirectory = 0;
495 attr.ObjectName = &nameW;
497 attr.SecurityDescriptor = NULL;
498 attr.SecurityQualityOfService = NULL;
500 RtlInitUnicodeString( &nameW, StatDataW );
501 if (!NtCreateKey( &hkey, KEY_ALL_ACCESS, &attr, 0, NULL, 0, &dispos )) NtClose( hkey );
502 if (dispos == REG_OPENED_EXISTING_KEY)
503 return dispos; /* someone else already loaded the registry */
505 RtlInitUnicodeString( &nameW, ConfigManagerW );
506 if (!NtCreateKey( &hkey, KEY_ALL_ACCESS, &attr, 0, NULL, 0, NULL )) NtClose( hkey );
512 /******************************************************************
513 * init_cdrom_registry
515 * Initializes registry to contain scsi info about the cdrom in NT.
516 * All devices (even not real scsi ones) have this info in NT.
517 * TODO: for now it only works for non scsi devices
518 * NOTE: programs usually read these registry entries after sending the
519 * IOCTL_SCSI_GET_ADDRESS ioctl to the cdrom
521 static void init_cdrom_registry( HANDLE handle )
523 OBJECT_ATTRIBUTES attr;
524 UNICODE_STRING nameW;
536 SCSI_ADDRESS scsi_addr;
538 if (NtDeviceIoControlFile( handle, 0, NULL, NULL, &io, IOCTL_SCSI_GET_ADDRESS,
539 NULL, 0, &scsi_addr, sizeof(scsi_addr) ))
542 attr.Length = sizeof(attr);
543 attr.RootDirectory = 0;
544 attr.ObjectName = &nameW;
546 attr.SecurityDescriptor = NULL;
547 attr.SecurityQualityOfService = NULL;
549 /* Ensure there is Scsi key */
550 if (!RtlCreateUnicodeStringFromAsciiz( &nameW, "Machine\\HARDWARE\\DEVICEMAP\\Scsi" ) ||
551 NtCreateKey( &scsiKey, KEY_ALL_ACCESS, &attr, 0,
552 NULL, REG_OPTION_VOLATILE, &disp ))
554 ERR("Cannot create DEVICEMAP\\Scsi registry key\n" );
557 RtlFreeUnicodeString( &nameW );
559 snprintf(buffer,sizeof(buffer),"Scsi Port %d",scsi_addr.PortNumber);
560 attr.RootDirectory = scsiKey;
561 if (!RtlCreateUnicodeStringFromAsciiz( &nameW, buffer ) ||
562 NtCreateKey( &portKey, KEY_ALL_ACCESS, &attr, 0,
563 NULL, REG_OPTION_VOLATILE, &disp ))
565 ERR("Cannot create DEVICEMAP\\Scsi Port registry key\n" );
568 RtlFreeUnicodeString( &nameW );
570 RtlCreateUnicodeStringFromAsciiz( &nameW, "Driver" );
572 RtlMultiByteToUnicodeN( dataW, 50, &lenW, data, strlen(data));
573 NtSetValueKey( portKey, &nameW, 0, REG_SZ, (BYTE*)dataW, lenW );
574 RtlFreeUnicodeString( &nameW );
576 RtlCreateUnicodeStringFromAsciiz( &nameW, "FirstBusTimeScanInMs" );
577 NtSetValueKey( portKey,&nameW, 0, REG_DWORD, (BYTE *)&value, sizeof(DWORD));
578 RtlFreeUnicodeString( &nameW );
583 if (!wine_server_handle_to_fd( handle, 0, &fd, NULL ))
585 if (ioctl(fd,HDIO_GET_DMA, &dma) != -1) value = dma;
586 wine_server_release_fd( handle, fd );
590 RtlCreateUnicodeStringFromAsciiz( &nameW, "DMAEnabled" );
591 NtSetValueKey( portKey,&nameW, 0, REG_DWORD, (BYTE *)&value, sizeof(DWORD));
592 RtlFreeUnicodeString( &nameW );
594 snprintf(buffer,40,"Scsi Bus %d", scsi_addr.PathId);
595 attr.RootDirectory = portKey;
596 if (!RtlCreateUnicodeStringFromAsciiz( &nameW, buffer ) ||
597 NtCreateKey( &busKey, KEY_ALL_ACCESS, &attr, 0,
598 NULL, REG_OPTION_VOLATILE, &disp ))
600 ERR("Cannot create DEVICEMAP\\Scsi Port\\Scsi Bus registry key\n" );
603 RtlFreeUnicodeString( &nameW );
605 attr.RootDirectory = busKey;
606 if (!RtlCreateUnicodeStringFromAsciiz( &nameW, "Initiator Id 255" ) ||
607 NtCreateKey( &targetKey, KEY_ALL_ACCESS, &attr, 0,
608 NULL, REG_OPTION_VOLATILE, &disp ))
610 ERR("Cannot create DEVICEMAP\\Scsi Port\\Scsi Bus\\Initiator Id 255 registry key\n" );
613 RtlFreeUnicodeString( &nameW );
614 NtClose( targetKey );
616 snprintf(buffer,40,"Target Id %d", scsi_addr.TargetId);
617 attr.RootDirectory = busKey;
618 if (!RtlCreateUnicodeStringFromAsciiz( &nameW, buffer ) ||
619 NtCreateKey( &targetKey, KEY_ALL_ACCESS, &attr, 0,
620 NULL, REG_OPTION_VOLATILE, &disp ))
622 ERR("Cannot create DEVICEMAP\\Scsi Port\\Scsi Bus 0\\Target Id registry key\n" );
625 RtlFreeUnicodeString( &nameW );
627 RtlCreateUnicodeStringFromAsciiz( &nameW, "Type" );
628 data = "CdRomPeripheral";
629 RtlMultiByteToUnicodeN( dataW, 50, &lenW, data, strlen(data));
630 NtSetValueKey( targetKey, &nameW, 0, REG_SZ, (BYTE*)dataW, lenW );
631 RtlFreeUnicodeString( &nameW );
632 /* FIXME - maybe read the real identifier?? */
633 RtlCreateUnicodeStringFromAsciiz( &nameW, "Identifier" );
635 RtlMultiByteToUnicodeN( dataW, 50, &lenW, data, strlen(data));
636 NtSetValueKey( targetKey, &nameW, 0, REG_SZ, (BYTE*)dataW, lenW );
637 RtlFreeUnicodeString( &nameW );
638 /* FIXME - we always use Cdrom0 - do not know about the nt behaviour */
639 RtlCreateUnicodeStringFromAsciiz( &nameW, "DeviceName" );
641 RtlMultiByteToUnicodeN( dataW, 50, &lenW, data, strlen(data));
642 NtSetValueKey( targetKey, &nameW, 0, REG_SZ, (BYTE*)dataW, lenW );
643 RtlFreeUnicodeString( &nameW );
645 NtClose( targetKey );
652 /* create the hardware registry branch */
653 static void create_hardware_branch(void)
657 char drive[] = "\\\\.\\A:";
659 /* create entries for cdroms (skipping A: and B:) */
660 for (i = 2; i < 26; i++)
663 handle = CreateFileA( drive, 0, 0, NULL, OPEN_EXISTING, 0, 0 );
664 if (handle == INVALID_HANDLE_VALUE) continue;
665 init_cdrom_registry( handle );
666 CloseHandle( handle );
671 /***********************************************************************
674 void convert_old_config(void)
676 HANDLE hkey_current_user;
678 if (allocate_default_keys() == REG_OPENED_EXISTING_KEY)
679 return; /* someone else already loaded the registry */
681 RtlOpenCurrentUser( KEY_ALL_ACCESS, &hkey_current_user );
683 /* load the user registry (FIXME: should be done at server init time) */
684 SERVER_START_REQ( load_user_registries )
686 req->hkey = hkey_current_user;
687 wine_server_call( req );
691 /* convert old configuration */
692 create_dos_devices();
693 convert_drive_types();
694 convert_environment( hkey_current_user );
696 /* create some hardware keys (FIXME: should not be done here) */
697 create_hardware_branch();
699 NtClose( hkey_current_user );