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
51 #include "wine/library.h"
52 #include "wine/server.h"
53 #include "wine/unicode.h"
54 #include "wine/debug.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 if (NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ) != STATUS_SUCCESS) continue;
93 RtlInitUnicodeString( &nameW, PathW );
94 if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
97 WCHAR *data = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
98 ExpandEnvironmentStringsW( data, path, sizeof(path)/sizeof(WCHAR) );
100 p = path + strlenW(path) - 1;
101 while ((p > path) && (*p == '/')) *p-- = '\0';
109 /* relative paths are relative to config dir */
110 memmove( path + 3, path, (strlenW(path) + 1) * sizeof(WCHAR) );
115 if (DefineDosDeviceW( DDD_RAW_TARGET_PATH, name, path ))
117 WideCharToMultiByte(CP_UNIXCP, 0, path, -1, dest, sizeof(dest), NULL, NULL);
118 MESSAGE( "Created symlink %s/dosdevices/%c: -> %s\n",
119 wine_get_config_dir(), 'a' + i, dest );
126 /* create symlinks for the drive devices */
128 buffer = HeapAlloc( GetProcessHeap(), 0,
129 strlen(config_dir) + sizeof("/dosdevices/a::") );
130 strcpy( buffer, config_dir );
131 strcat( buffer, "/dosdevices/a::" );
133 for (i = 0; i < 26; i++)
135 RtlInitUnicodeString( &nameW, driveW );
136 nameW.Buffer[(nameW.Length / sizeof(WCHAR)) - 1] = 'A' + i;
137 if (NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ) != STATUS_SUCCESS) continue;
139 RtlInitUnicodeString( &nameW, DeviceW );
140 if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
142 WCHAR *data = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
143 WideCharToMultiByte(CP_UNIXCP, 0, data, -1, dest, sizeof(dest), NULL, NULL);
145 buffer[strlen(buffer) - 3] = 'a' + i;
146 if (!symlink( dest, buffer ))
148 MESSAGE( "Created symlink %s/dosdevices/%c:: -> %s\n",
149 wine_get_config_dir(), 'a' + i, dest );
155 HeapFree( GetProcessHeap(), 0, buffer );
161 /* create the device files for the new device naming scheme */
162 static void create_dos_devices(void)
164 const char *config_dir = wine_get_config_dir();
168 if (!(buffer = HeapAlloc( GetProcessHeap(), 0,
169 strlen(config_dir) + sizeof("/dosdevices/a::") )))
172 strcpy( buffer, config_dir );
173 strcat( buffer, "/dosdevices" );
175 if (!mkdir( buffer, 0777 )) /* we created it, so now create the devices */
179 OBJECT_ATTRIBUTES attr;
180 UNICODE_STRING nameW;
183 WCHAR com[5] = {'C','O','M','1',0};
184 WCHAR lpt[5] = {'L','P','T','1',0};
186 static const WCHAR serialportsW[] = {'M','a','c','h','i','n','e','\\',
187 'S','o','f','t','w','a','r','e','\\',
188 'W','i','n','e','\\','W','i','n','e','\\',
189 'C','o','n','f','i','g','\\',
190 'S','e','r','i','a','l','P','o','r','t','s',0};
191 static const WCHAR parallelportsW[] = {'M','a','c','h','i','n','e','\\',
192 'S','o','f','t','w','a','r','e','\\',
193 'W','i','n','e','\\','W','i','n','e','\\',
194 'C','o','n','f','i','g','\\',
195 'P','a','r','a','l','l','e','l','P','o','r','t','s',0};
197 attr.Length = sizeof(attr);
198 attr.RootDirectory = 0;
199 attr.ObjectName = &nameW;
201 attr.SecurityDescriptor = NULL;
202 attr.SecurityQualityOfService = NULL;
203 RtlInitUnicodeString( &nameW, serialportsW );
205 if (!NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ))
207 RtlInitUnicodeString( &nameW, com );
208 for (i = 1; i <= 9; i++)
211 if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation,
212 tmp, sizeof(tmp), &dummy ))
214 devnameW = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
215 if ((p = strchrW( devnameW, ',' ))) *p = 0;
216 if (DefineDosDeviceW( DDD_RAW_TARGET_PATH, com, devnameW ))
219 WideCharToMultiByte(CP_UNIXCP, 0, devnameW, -1,
220 devname, sizeof(devname), NULL, NULL);
221 MESSAGE( "Created symlink %s/dosdevices/com%d -> %s\n", config_dir, i, devname );
229 RtlInitUnicodeString( &nameW, parallelportsW );
230 if (!NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ))
232 RtlInitUnicodeString( &nameW, lpt );
233 for (i = 1; i <= 9; i++)
236 if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation,
237 tmp, sizeof(tmp), &dummy ))
239 devnameW = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
240 if ((p = strchrW( devnameW, ',' ))) *p = 0;
241 if (DefineDosDeviceW( DDD_RAW_TARGET_PATH, lpt, devnameW ))
244 WideCharToMultiByte(CP_UNIXCP, 0, devnameW, -1,
245 devname, sizeof(devname), NULL, NULL);
246 MESSAGE( "Created symlink %s/dosdevices/lpt%d -> %s\n", config_dir, i, devname );
253 count += create_drives( FALSE );
260 /* it is possible that the serial/parallel devices have been created but */
261 /* not the drives; check for at least one drive symlink to catch that case */
262 strcat( buffer, "/a:" );
263 for (i = 0; i < 26; i++)
265 buffer[strlen(buffer)-2] = 'a' + i;
266 if (!lstat( buffer, &st )) break;
268 if (i == 26) count += create_drives( FALSE );
271 strcat( buffer, ":" );
272 for (i = 0; i < 26; i++)
274 buffer[strlen(buffer)-3] = 'a' + i;
275 if (!lstat( buffer, &st )) break;
277 if (i == 26) count += create_drives( TRUE );
282 MESSAGE( "\nYou can now remove the [SerialPorts], [ParallelPorts], and [Drive] sections\n"
283 "in your configuration file, they are replaced by the above symlinks.\n\n" );
285 HeapFree( GetProcessHeap(), 0, buffer );
289 /* convert the drive type entries from the old format to the new one */
290 static void convert_drive_types(void)
292 static const WCHAR TypeW[] = {'T','y','p','e',0};
293 static const WCHAR drive_types_keyW[] = {'M','a','c','h','i','n','e','\\',
294 'S','o','f','t','w','a','r','e','\\',
295 'W','i','n','e','\\',
296 'D','r','i','v','e','s',0 };
297 WCHAR driveW[] = {'M','a','c','h','i','n','e','\\','S','o','f','t','w','a','r','e','\\',
298 'W','i','n','e','\\','W','i','n','e','\\',
299 'C','o','n','f','i','g','\\','D','r','i','v','e',' ','A',0};
300 char tmp[32*sizeof(WCHAR) + sizeof(KEY_VALUE_PARTIAL_INFORMATION)];
301 OBJECT_ATTRIBUTES attr;
302 UNICODE_STRING nameW;
305 HKEY hkey_old, hkey_new;
308 attr.Length = sizeof(attr);
309 attr.RootDirectory = 0;
310 attr.ObjectName = &nameW;
312 attr.SecurityDescriptor = NULL;
313 attr.SecurityQualityOfService = NULL;
314 RtlInitUnicodeString( &nameW, drive_types_keyW );
316 if (NtCreateKey( &hkey_new, KEY_ALL_ACCESS, &attr, 0, NULL, 0, &disp )) return;
317 if (disp != REG_CREATED_NEW_KEY)
323 for (i = 0; i < 26; i++)
325 RtlInitUnicodeString( &nameW, driveW );
326 nameW.Buffer[(nameW.Length / sizeof(WCHAR)) - 1] = 'A' + i;
327 if (NtOpenKey( &hkey_old, KEY_ALL_ACCESS, &attr ) != STATUS_SUCCESS) continue;
328 RtlInitUnicodeString( &nameW, TypeW );
329 if (!NtQueryValueKey( hkey_old, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
331 WCHAR valueW[] = {'A',':',0};
332 WCHAR *type = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
335 RtlInitUnicodeString( &nameW, valueW );
336 NtSetValueKey( hkey_new, &nameW, 0, REG_SZ, type, (strlenW(type) + 1) * sizeof(WCHAR) );
337 MESSAGE( "Converted drive type to new entry HKLM\\Software\\Wine\\Drives \"%c:\" = %s\n",
338 'A' + i, debugstr_w(type) );
346 /* convert the environment variable entries from the old format to the new one */
347 static void convert_environment( HKEY hkey_current_user )
349 static const WCHAR wineW[] = {'M','a','c','h','i','n','e','\\',
350 'S','o','f','t','w','a','r','e','\\',
351 'W','i','n','e','\\','W','i','n','e','\\',
352 'C','o','n','f','i','g','\\','W','i','n','e',0};
353 static const WCHAR windowsW[] = {'w','i','n','d','o','w','s',0};
354 static const WCHAR systemW[] = {'s','y','s','t','e','m',0};
355 static const WCHAR windirW[] = {'w','i','n','d','i','r',0};
356 static const WCHAR systemrootW[] = {'S','y','s','t','e','m','r','o','o','t',0};
357 static const WCHAR winsysdirW[] = {'w','i','n','s','y','s','d','i','r',0};
358 static const WCHAR envW[] = {'E','n','v','i','r','o','n','m','e','n','t',0};
359 static const WCHAR tempW[] = {'T','E','M','P',0};
360 static const WCHAR tmpW[] = {'T','M','P',0};
361 static const WCHAR pathW[] = {'P','A','T','H',0};
362 static const WCHAR profileW[] = {'p','r','o','f','i','l','e',0};
363 static const WCHAR userprofileW[] = {'U','S','E','R','P','R','O','F','I','L','E',0};
365 char buffer[1024*sizeof(WCHAR) + sizeof(KEY_VALUE_PARTIAL_INFORMATION)];
366 KEY_VALUE_PARTIAL_INFORMATION *info = (KEY_VALUE_PARTIAL_INFORMATION *)buffer;
367 OBJECT_ATTRIBUTES attr;
368 UNICODE_STRING nameW;
371 HKEY hkey_old, hkey_env;
373 attr.Length = sizeof(attr);
374 attr.RootDirectory = 0;
375 attr.ObjectName = &nameW;
377 attr.SecurityDescriptor = NULL;
378 attr.SecurityQualityOfService = NULL;
379 RtlInitUnicodeString( &nameW, wineW );
381 if (NtOpenKey( &hkey_old, KEY_ALL_ACCESS, &attr ) != STATUS_SUCCESS) return;
383 attr.RootDirectory = hkey_current_user;
384 RtlInitUnicodeString( &nameW, envW );
385 if (NtCreateKey( &hkey_env, KEY_ALL_ACCESS, &attr, 0, NULL, 0, &disp ))
391 /* Test for existence of TEMP */
392 RtlInitUnicodeString( &nameW, tempW );
393 if (NtQueryValueKey(hkey_env, &nameW, KeyValuePartialInformation, buffer, sizeof(buffer), &dummy ))
396 RtlInitUnicodeString( &nameW, tempW );
397 if (!NtQueryValueKey( hkey_old, &nameW, KeyValuePartialInformation, buffer, sizeof(buffer), &dummy ))
399 NtSetValueKey( hkey_env, &nameW, 0, info->Type, info->Data, info->DataLength );
400 RtlInitUnicodeString( &nameW, tmpW );
401 NtSetValueKey( hkey_env, &nameW, 0, info->Type, info->Data, info->DataLength );
402 MESSAGE( "Converted temp dir to new entry HKCU\\Environment \"TEMP\" = %s\n",
403 debugstr_w( (WCHAR*)info->Data ) );
407 /* Test for existence of PATH */
408 RtlInitUnicodeString( &nameW, pathW );
409 if (NtQueryValueKey(hkey_env, &nameW, KeyValuePartialInformation, buffer, sizeof(buffer), &dummy ))
412 RtlInitUnicodeString( &nameW, pathW );
413 if (!NtQueryValueKey( hkey_old, &nameW, KeyValuePartialInformation, buffer, sizeof(buffer), &dummy ))
415 NtSetValueKey( hkey_env, &nameW, 0, info->Type, info->Data, info->DataLength );
416 MESSAGE( "Converted path dir to new entry HKCU\\Environment \"PATH\" = %s\n",
417 debugstr_w( (WCHAR*)info->Data ) );
421 /* Test for existence of USERPROFILE */
422 RtlInitUnicodeString( &nameW, userprofileW );
423 if (NtQueryValueKey(hkey_env, &nameW, KeyValuePartialInformation, buffer, sizeof(buffer), &dummy ))
425 /* convert USERPROFILE */
426 RtlInitUnicodeString( &nameW, profileW );
427 if (!NtQueryValueKey( hkey_old, &nameW, KeyValuePartialInformation, buffer, sizeof(buffer), &dummy ))
429 RtlInitUnicodeString( &nameW, userprofileW );
430 NtSetValueKey( hkey_env, &nameW, 0, info->Type, info->Data, info->DataLength );
431 MESSAGE( "Converted profile dir to new entry HKCU\\Environment \"USERPROFILE\" = %s\n",
432 debugstr_w( (WCHAR*)info->Data ) );
436 /* Test for existence of windir */
437 RtlInitUnicodeString( &nameW, windirW );
438 if (NtQueryValueKey(hkey_env, &nameW, KeyValuePartialInformation, buffer, sizeof(buffer), &dummy ))
441 RtlInitUnicodeString( &nameW, windowsW );
442 if (!NtQueryValueKey( hkey_old, &nameW, KeyValuePartialInformation, buffer, sizeof(buffer), &dummy ))
444 RtlInitUnicodeString( &nameW, windirW );
445 NtSetValueKey( hkey_env, &nameW, 0, info->Type, info->Data, info->DataLength );
446 RtlInitUnicodeString( &nameW, systemrootW );
447 NtSetValueKey( hkey_env, &nameW, 0, info->Type, info->Data, info->DataLength );
448 MESSAGE( "Converted windows dir to new entry HKCU\\Environment \"windir\" = %s\n",
449 debugstr_w( (WCHAR*)info->Data ) );
453 /* Test for existence of winsysdir */
454 RtlInitUnicodeString( &nameW, winsysdirW );
455 if (NtQueryValueKey(hkey_env, &nameW, KeyValuePartialInformation, buffer, sizeof(buffer), &dummy ))
457 /* convert winsysdir */
458 RtlInitUnicodeString( &nameW, systemW );
459 if (!NtQueryValueKey( hkey_old, &nameW, KeyValuePartialInformation, buffer, sizeof(buffer), &dummy ))
461 RtlInitUnicodeString( &nameW, winsysdirW );
462 NtSetValueKey( hkey_env, &nameW, 0, info->Type, info->Data, info->DataLength );
463 MESSAGE( "Converted system dir to new entry HKCU\\Environment \"winsysdir\" = %s\n",
464 debugstr_w( (WCHAR*)info->Data ) );
472 /* registry initialisation, allocates some default keys. */
473 static ULONG allocate_default_keys(void)
475 static const WCHAR StatDataW[] = {'D','y','n','D','a','t','a','\\',
476 'P','e','r','f','S','t','a','t','s','\\',
477 'S','t','a','t','D','a','t','a',0};
478 static const WCHAR ConfigManagerW[] = {'D','y','n','D','a','t','a','\\',
479 'C','o','n','f','i','g',' ','M','a','n','a','g','e','r','\\',
483 OBJECT_ATTRIBUTES attr;
484 UNICODE_STRING nameW;
486 attr.Length = sizeof(attr);
487 attr.RootDirectory = 0;
488 attr.ObjectName = &nameW;
490 attr.SecurityDescriptor = NULL;
491 attr.SecurityQualityOfService = NULL;
493 RtlInitUnicodeString( &nameW, StatDataW );
494 if (!NtCreateKey( &hkey, KEY_ALL_ACCESS, &attr, 0, NULL, 0, &dispos )) NtClose( hkey );
495 if (dispos == REG_OPENED_EXISTING_KEY)
496 return dispos; /* someone else already loaded the registry */
498 RtlInitUnicodeString( &nameW, ConfigManagerW );
499 if (!NtCreateKey( &hkey, KEY_ALL_ACCESS, &attr, 0, NULL, 0, NULL )) NtClose( hkey );
505 /******************************************************************
506 * init_cdrom_registry
508 * Initializes registry to contain scsi info about the cdrom in NT.
509 * All devices (even not real scsi ones) have this info in NT.
510 * TODO: for now it only works for non scsi devices
511 * NOTE: programs usually read these registry entries after sending the
512 * IOCTL_SCSI_GET_ADDRESS ioctl to the cdrom
514 static void init_cdrom_registry( HANDLE handle )
516 OBJECT_ATTRIBUTES attr;
517 UNICODE_STRING nameW;
529 SCSI_ADDRESS scsi_addr;
531 if (NtDeviceIoControlFile( handle, 0, NULL, NULL, &io, IOCTL_SCSI_GET_ADDRESS,
532 NULL, 0, &scsi_addr, sizeof(scsi_addr) ))
535 attr.Length = sizeof(attr);
536 attr.RootDirectory = 0;
537 attr.ObjectName = &nameW;
539 attr.SecurityDescriptor = NULL;
540 attr.SecurityQualityOfService = NULL;
542 /* Ensure there is Scsi key */
543 if (!RtlCreateUnicodeStringFromAsciiz( &nameW, "Machine\\HARDWARE\\DEVICEMAP\\Scsi" ) ||
544 NtCreateKey( &scsiKey, KEY_ALL_ACCESS, &attr, 0,
545 NULL, REG_OPTION_VOLATILE, &disp ))
547 ERR("Cannot create DEVICEMAP\\Scsi registry key\n" );
550 RtlFreeUnicodeString( &nameW );
552 snprintf(buffer,sizeof(buffer),"Scsi Port %d",scsi_addr.PortNumber);
553 attr.RootDirectory = scsiKey;
554 if (!RtlCreateUnicodeStringFromAsciiz( &nameW, buffer ) ||
555 NtCreateKey( &portKey, KEY_ALL_ACCESS, &attr, 0,
556 NULL, REG_OPTION_VOLATILE, &disp ))
558 ERR("Cannot create DEVICEMAP\\Scsi Port registry key\n" );
561 RtlFreeUnicodeString( &nameW );
563 RtlCreateUnicodeStringFromAsciiz( &nameW, "Driver" );
565 RtlMultiByteToUnicodeN( dataW, 50, &lenW, data, strlen(data));
566 NtSetValueKey( portKey, &nameW, 0, REG_SZ, (BYTE*)dataW, lenW );
567 RtlFreeUnicodeString( &nameW );
569 RtlCreateUnicodeStringFromAsciiz( &nameW, "FirstBusTimeScanInMs" );
570 NtSetValueKey( portKey,&nameW, 0, REG_DWORD, (BYTE *)&value, sizeof(DWORD));
571 RtlFreeUnicodeString( &nameW );
576 if (!wine_server_handle_to_fd( handle, 0, &fd, NULL ))
578 if (ioctl(fd,HDIO_GET_DMA, &dma) != -1) value = dma;
579 wine_server_release_fd( handle, fd );
583 RtlCreateUnicodeStringFromAsciiz( &nameW, "DMAEnabled" );
584 NtSetValueKey( portKey,&nameW, 0, REG_DWORD, (BYTE *)&value, sizeof(DWORD));
585 RtlFreeUnicodeString( &nameW );
587 snprintf(buffer,40,"Scsi Bus %d", scsi_addr.PathId);
588 attr.RootDirectory = portKey;
589 if (!RtlCreateUnicodeStringFromAsciiz( &nameW, buffer ) ||
590 NtCreateKey( &busKey, KEY_ALL_ACCESS, &attr, 0,
591 NULL, REG_OPTION_VOLATILE, &disp ))
593 ERR("Cannot create DEVICEMAP\\Scsi Port\\Scsi Bus registry key\n" );
596 RtlFreeUnicodeString( &nameW );
598 attr.RootDirectory = busKey;
599 if (!RtlCreateUnicodeStringFromAsciiz( &nameW, "Initiator Id 255" ) ||
600 NtCreateKey( &targetKey, KEY_ALL_ACCESS, &attr, 0,
601 NULL, REG_OPTION_VOLATILE, &disp ))
603 ERR("Cannot create DEVICEMAP\\Scsi Port\\Scsi Bus\\Initiator Id 255 registry key\n" );
606 RtlFreeUnicodeString( &nameW );
607 NtClose( targetKey );
609 snprintf(buffer,40,"Target Id %d", scsi_addr.TargetId);
610 attr.RootDirectory = busKey;
611 if (!RtlCreateUnicodeStringFromAsciiz( &nameW, buffer ) ||
612 NtCreateKey( &targetKey, KEY_ALL_ACCESS, &attr, 0,
613 NULL, REG_OPTION_VOLATILE, &disp ))
615 ERR("Cannot create DEVICEMAP\\Scsi Port\\Scsi Bus 0\\Target Id registry key\n" );
618 RtlFreeUnicodeString( &nameW );
620 RtlCreateUnicodeStringFromAsciiz( &nameW, "Type" );
621 data = "CdRomPeripheral";
622 RtlMultiByteToUnicodeN( dataW, 50, &lenW, data, strlen(data));
623 NtSetValueKey( targetKey, &nameW, 0, REG_SZ, (BYTE*)dataW, lenW );
624 RtlFreeUnicodeString( &nameW );
625 /* FIXME - maybe read the real identifier?? */
626 RtlCreateUnicodeStringFromAsciiz( &nameW, "Identifier" );
628 RtlMultiByteToUnicodeN( dataW, 50, &lenW, data, strlen(data));
629 NtSetValueKey( targetKey, &nameW, 0, REG_SZ, (BYTE*)dataW, lenW );
630 RtlFreeUnicodeString( &nameW );
631 /* FIXME - we always use Cdrom0 - do not know about the nt behaviour */
632 RtlCreateUnicodeStringFromAsciiz( &nameW, "DeviceName" );
634 RtlMultiByteToUnicodeN( dataW, 50, &lenW, data, strlen(data));
635 NtSetValueKey( targetKey, &nameW, 0, REG_SZ, (BYTE*)dataW, lenW );
636 RtlFreeUnicodeString( &nameW );
638 NtClose( targetKey );
645 /* create the hardware registry branch */
646 static void create_hardware_branch(void)
650 char drive[] = "\\\\.\\A:";
652 /* create entries for cdroms (skipping A: and B:) */
653 for (i = 2; i < 26; i++)
656 handle = CreateFileA( drive, 0, 0, NULL, OPEN_EXISTING, 0, 0 );
657 if (handle == INVALID_HANDLE_VALUE) continue;
658 init_cdrom_registry( handle );
659 CloseHandle( handle );
664 /***********************************************************************
667 void convert_old_config(void)
669 HKEY hkey_current_user;
671 if (allocate_default_keys() == REG_OPENED_EXISTING_KEY)
672 return; /* someone else already loaded the registry */
674 RtlOpenCurrentUser( KEY_ALL_ACCESS, &hkey_current_user );
676 /* load the user registry (FIXME: should be done at server init time) */
677 SERVER_START_REQ( load_user_registries )
679 req->hkey = hkey_current_user;
680 wine_server_call( req );
684 /* convert old configuration */
685 create_dos_devices();
686 convert_drive_types();
687 convert_environment( hkey_current_user );
689 /* create some hardware keys (FIXME: should not be done here) */
690 create_hardware_branch();
692 NtClose( hkey_current_user );