4 * Copyright 1996 Marcus Meissner
5 * Copyright 1998 Matthew Becker
6 * Copyright 1999 Sylvain St-Germain
8 * December 21, 1997 - Kevin Cozens
9 * Fixed bugs in the _w95_loadreg() function. Added extra information
10 * regarding the format of the Windows '95 registry files.
12 * This library is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public
14 * License as published by the Free Software Foundation; either
15 * version 2.1 of the License, or (at your option) any later version.
17 * This library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 * Time for RegEnumKey*, RegQueryInfoKey*
33 #include "wine/port.h"
43 #include <sys/types.h>
46 #ifdef HAVE_SYS_IOCTL_H
47 #include <sys/ioctl.h>
49 #ifdef HAVE_LINUX_HDREG_H
50 # include <linux/hdreg.h>
53 #define NONAMELESSUNION
54 #define NONAMELESSSTRUCT
62 #include "wine/library.h"
63 #include "wine/server.h"
64 #include "wine/unicode.h"
66 #include "wine/debug.h"
68 WINE_DEFAULT_DEBUG_CHANNEL(reg
);
70 #define SAVE_GLOBAL_REGBRANCH_USER_DEFAULT "/wine.userreg"
71 #define SAVE_GLOBAL_REGBRANCH_LOCAL_MACHINE "/wine.systemreg"
73 #define MAX_PATHNAME_LEN 1024
75 #define IS_OPTION_FALSE(ch) \
76 ((ch) == 'n' || (ch) == 'N' || (ch) == 'f' || (ch) == 'F' || (ch) == '0')
80 /******************************************************************************
81 * _allocate_default_keys [Internal]
82 * Registry initialisation, allocates some default keys.
84 static void _allocate_default_keys(void)
86 static const WCHAR StatDataW
[] = {'D','y','n','D','a','t','a','\\',
87 'P','e','r','f','S','t','a','t','s','\\',
88 'S','t','a','t','D','a','t','a',0};
89 static const WCHAR ConfigManagerW
[] = {'D','y','n','D','a','t','a','\\',
90 'C','o','n','f','i','g',' ','M','a','n','a','g','e','r','\\',
92 static const WCHAR Clone
[] = {'M','a','c','h','i','n','e','\\',
93 'S','y','s','t','e','m','\\',
94 'C','l','o','n','e',0};
96 OBJECT_ATTRIBUTES attr
;
101 attr
.Length
= sizeof(attr
);
102 attr
.RootDirectory
= 0;
103 attr
.ObjectName
= &nameW
;
105 attr
.SecurityDescriptor
= NULL
;
106 attr
.SecurityQualityOfService
= NULL
;
108 RtlInitUnicodeString( &nameW
, StatDataW
);
109 if (!NtCreateKey( &hkey
, KEY_ALL_ACCESS
, &attr
, 0, NULL
, 0, NULL
)) NtClose( hkey
);
111 RtlInitUnicodeString( &nameW
, ConfigManagerW
);
112 if (!NtCreateKey( &hkey
, KEY_ALL_ACCESS
, &attr
, 0, NULL
, 0, NULL
)) NtClose( hkey
);
114 /* this key is generated when the nt-core booted successfully */
115 RtlInitUnicodeString( &nameW
, Clone
);
116 if (!NtCreateKey( &hkey
, KEY_ALL_ACCESS
, &attr
, 0, NULL
, 0, NULL
)) NtClose( hkey
);
121 /* load the registry file in wine format [Internal] */
122 static void load_wine_registry(HKEY hkey
,LPCSTR fn
)
128 OBJECT_ATTRIBUTES attr
;
131 len
= MultiByteToWideChar( CP_UNIXCP
, 0, fn
, -1, NULL
, 0 );
132 if (!(buffer
= HeapAlloc( GetProcessHeap(), 0, len
* sizeof(WCHAR
) ))) return;
133 MultiByteToWideChar( CP_UNIXCP
, 0, fn
, -1, buffer
, len
);
134 RtlInitUnicodeString( &name
, buffer
);
136 attr
.Length
= sizeof(attr
);
137 attr
.RootDirectory
= 0;
139 attr
.ObjectName
= &name
;
140 attr
.SecurityDescriptor
= NULL
;
141 attr
.SecurityQualityOfService
= NULL
;
143 if (!NtOpenFile( &file
, GENERIC_READ
, &attr
, &io
, FILE_SHARE_READ
| FILE_SHARE_WRITE
,
144 FILE_NON_DIRECTORY_FILE
| FILE_SYNCHRONOUS_IO_NONALERT
))
146 SERVER_START_REQ( load_registry
)
150 wine_server_call( req
);
155 HeapFree( GetProcessHeap(), 0, buffer
);
159 /******************************************************************
160 * init_cdrom_registry
162 * Initializes registry to contain scsi info about the cdrom in NT.
163 * All devices (even not real scsi ones) have this info in NT.
164 * TODO: for now it only works for non scsi devices
165 * NOTE: programs usually read these registry entries after sending the
166 * IOCTL_SCSI_GET_ADDRESS ioctl to the cdrom
168 static void init_cdrom_registry( HANDLE handle
)
170 OBJECT_ATTRIBUTES attr
;
171 UNICODE_STRING nameW
;
183 SCSI_ADDRESS scsi_addr
;
185 if (NtDeviceIoControlFile( handle
, 0, NULL
, NULL
, &io
, IOCTL_SCSI_GET_ADDRESS
,
186 NULL
, 0, &scsi_addr
, sizeof(scsi_addr
) ))
189 attr
.Length
= sizeof(attr
);
190 attr
.RootDirectory
= 0;
191 attr
.ObjectName
= &nameW
;
193 attr
.SecurityDescriptor
= NULL
;
194 attr
.SecurityQualityOfService
= NULL
;
196 /* Ensure there is Scsi key */
197 if (!RtlCreateUnicodeStringFromAsciiz( &nameW
, "Machine\\HARDWARE\\DEVICEMAP\\Scsi" ) ||
198 NtCreateKey( &scsiKey
, KEY_ALL_ACCESS
, &attr
, 0,
199 NULL
, REG_OPTION_VOLATILE
, &disp
))
201 ERR("Cannot create DEVICEMAP\\Scsi registry key\n" );
204 RtlFreeUnicodeString( &nameW
);
206 snprintf(buffer
,sizeof(buffer
),"Scsi Port %d",scsi_addr
.PortNumber
);
207 attr
.RootDirectory
= scsiKey
;
208 if (!RtlCreateUnicodeStringFromAsciiz( &nameW
, buffer
) ||
209 NtCreateKey( &portKey
, KEY_ALL_ACCESS
, &attr
, 0,
210 NULL
, REG_OPTION_VOLATILE
, &disp
))
212 ERR("Cannot create DEVICEMAP\\Scsi Port registry key\n" );
215 RtlFreeUnicodeString( &nameW
);
217 RtlCreateUnicodeStringFromAsciiz( &nameW
, "Driver" );
219 RtlMultiByteToUnicodeN( dataW
, 50, &lenW
, data
, strlen(data
));
220 NtSetValueKey( portKey
, &nameW
, 0, REG_SZ
, (BYTE
*)dataW
, lenW
);
221 RtlFreeUnicodeString( &nameW
);
223 RtlCreateUnicodeStringFromAsciiz( &nameW
, "FirstBusTimeScanInMs" );
224 NtSetValueKey( portKey
,&nameW
, 0, REG_DWORD
, (BYTE
*)&value
, sizeof(DWORD
));
225 RtlFreeUnicodeString( &nameW
);
230 if (!wine_server_handle_to_fd( handle
, 0, &fd
, NULL
))
232 if (ioctl(fd
,HDIO_GET_DMA
, &dma
) != -1) value
= dma
;
233 wine_server_release_fd( handle
, fd
);
237 RtlCreateUnicodeStringFromAsciiz( &nameW
, "DMAEnabled" );
238 NtSetValueKey( portKey
,&nameW
, 0, REG_DWORD
, (BYTE
*)&value
, sizeof(DWORD
));
239 RtlFreeUnicodeString( &nameW
);
241 snprintf(buffer
,40,"Scsi Bus %d", scsi_addr
.PathId
);
242 attr
.RootDirectory
= portKey
;
243 if (!RtlCreateUnicodeStringFromAsciiz( &nameW
, buffer
) ||
244 NtCreateKey( &busKey
, KEY_ALL_ACCESS
, &attr
, 0,
245 NULL
, REG_OPTION_VOLATILE
, &disp
))
247 ERR("Cannot create DEVICEMAP\\Scsi Port\\Scsi Bus registry key\n" );
250 RtlFreeUnicodeString( &nameW
);
252 attr
.RootDirectory
= busKey
;
253 if (!RtlCreateUnicodeStringFromAsciiz( &nameW
, "Initiator Id 255" ) ||
254 NtCreateKey( &targetKey
, KEY_ALL_ACCESS
, &attr
, 0,
255 NULL
, REG_OPTION_VOLATILE
, &disp
))
257 ERR("Cannot create DEVICEMAP\\Scsi Port\\Scsi Bus\\Initiator Id 255 registry key\n" );
260 RtlFreeUnicodeString( &nameW
);
261 NtClose( targetKey
);
263 snprintf(buffer
,40,"Target Id %d", scsi_addr
.TargetId
);
264 attr
.RootDirectory
= busKey
;
265 if (!RtlCreateUnicodeStringFromAsciiz( &nameW
, buffer
) ||
266 NtCreateKey( &targetKey
, KEY_ALL_ACCESS
, &attr
, 0,
267 NULL
, REG_OPTION_VOLATILE
, &disp
))
269 ERR("Cannot create DEVICEMAP\\Scsi Port\\Scsi Bus 0\\Target Id registry key\n" );
272 RtlFreeUnicodeString( &nameW
);
274 RtlCreateUnicodeStringFromAsciiz( &nameW
, "Type" );
275 data
= "CdRomPeripheral";
276 RtlMultiByteToUnicodeN( dataW
, 50, &lenW
, data
, strlen(data
));
277 NtSetValueKey( targetKey
, &nameW
, 0, REG_SZ
, (BYTE
*)dataW
, lenW
);
278 RtlFreeUnicodeString( &nameW
);
279 /* FIXME - maybe read the real identifier?? */
280 RtlCreateUnicodeStringFromAsciiz( &nameW
, "Identifier" );
282 RtlMultiByteToUnicodeN( dataW
, 50, &lenW
, data
, strlen(data
));
283 NtSetValueKey( targetKey
, &nameW
, 0, REG_SZ
, (BYTE
*)dataW
, lenW
);
284 RtlFreeUnicodeString( &nameW
);
285 /* FIXME - we always use Cdrom0 - do not know about the nt behaviour */
286 RtlCreateUnicodeStringFromAsciiz( &nameW
, "DeviceName" );
288 RtlMultiByteToUnicodeN( dataW
, 50, &lenW
, data
, strlen(data
));
289 NtSetValueKey( targetKey
, &nameW
, 0, REG_SZ
, (BYTE
*)dataW
, lenW
);
290 RtlFreeUnicodeString( &nameW
);
292 NtClose( targetKey
);
299 /* create the hardware registry branch */
300 static void create_hardware_branch(void)
304 char drive
[] = "\\\\.\\A:";
306 /* create entries for cdroms */
307 for (i
= 0; i
< 26; i
++)
310 handle
= CreateFileA( drive
, 0, 0, NULL
, OPEN_EXISTING
, 0, 0 );
311 if (handle
== INVALID_HANDLE_VALUE
) continue;
312 init_cdrom_registry( handle
);
313 CloseHandle( handle
);
318 /* convert the drive type entries from the old format to the new one */
319 static void convert_drive_types(void)
321 static const WCHAR TypeW
[] = {'T','y','p','e',0};
322 static const WCHAR drive_types_keyW
[] = {'M','a','c','h','i','n','e','\\',
323 'S','o','f','t','w','a','r','e','\\',
324 'W','i','n','e','\\',
325 'D','r','i','v','e','s',0 };
326 WCHAR driveW
[] = {'M','a','c','h','i','n','e','\\','S','o','f','t','w','a','r','e','\\',
327 'W','i','n','e','\\','W','i','n','e','\\',
328 'C','o','n','f','i','g','\\','D','r','i','v','e',' ','A',0};
329 char tmp
[32*sizeof(WCHAR
) + sizeof(KEY_VALUE_PARTIAL_INFORMATION
)];
330 OBJECT_ATTRIBUTES attr
;
331 UNICODE_STRING nameW
;
334 HKEY hkey_old
, hkey_new
;
337 attr
.Length
= sizeof(attr
);
338 attr
.RootDirectory
= 0;
339 attr
.ObjectName
= &nameW
;
341 attr
.SecurityDescriptor
= NULL
;
342 attr
.SecurityQualityOfService
= NULL
;
343 RtlInitUnicodeString( &nameW
, drive_types_keyW
);
345 if (NtCreateKey( &hkey_new
, KEY_ALL_ACCESS
, &attr
, 0, NULL
, 0, &disp
)) return;
346 if (disp
!= REG_CREATED_NEW_KEY
)
352 for (i
= 0; i
< 26; i
++)
354 RtlInitUnicodeString( &nameW
, driveW
);
355 nameW
.Buffer
[(nameW
.Length
/ sizeof(WCHAR
)) - 1] = 'A' + i
;
356 if (NtOpenKey( &hkey_old
, KEY_ALL_ACCESS
, &attr
) != STATUS_SUCCESS
) continue;
357 RtlInitUnicodeString( &nameW
, TypeW
);
358 if (!NtQueryValueKey( hkey_old
, &nameW
, KeyValuePartialInformation
, tmp
, sizeof(tmp
), &dummy
))
360 WCHAR valueW
[] = {'A',':',0};
361 WCHAR
*type
= (WCHAR
*)((KEY_VALUE_PARTIAL_INFORMATION
*)tmp
)->Data
;
364 RtlInitUnicodeString( &nameW
, valueW
);
365 NtSetValueKey( hkey_new
, &nameW
, 0, REG_SZ
, type
, (strlenW(type
) + 1) * sizeof(WCHAR
) );
366 MESSAGE( "Converted drive type to new entry HKLM\\Software\\Wine\\Drives \"%c:\" = %s\n",
367 'A' + i
, debugstr_w(type
) );
375 /* convert the environment variable entries from the old format to the new one */
376 static void convert_environment( HKEY hkey_current_user
)
378 static const WCHAR wineW
[] = {'M','a','c','h','i','n','e','\\',
379 'S','o','f','t','w','a','r','e','\\',
380 'W','i','n','e','\\','W','i','n','e','\\',
381 'C','o','n','f','i','g','\\','W','i','n','e',0};
382 static const WCHAR windowsW
[] = {'w','i','n','d','o','w','s',0};
383 static const WCHAR systemW
[] = {'s','y','s','t','e','m',0};
384 static const WCHAR windirW
[] = {'w','i','n','d','i','r',0};
385 static const WCHAR systemrootW
[] = {'S','y','s','t','e','m','r','o','o','t',0};
386 static const WCHAR winsysdirW
[] = {'w','i','n','s','y','s','d','i','r',0};
387 static const WCHAR envW
[] = {'E','n','v','i','r','o','n','m','e','n','t',0};
388 static const WCHAR tempW
[] = {'T','E','M','P',0};
389 static const WCHAR tmpW
[] = {'T','M','P',0};
390 static const WCHAR pathW
[] = {'P','A','T','H',0};
391 static const WCHAR profileW
[] = {'p','r','o','f','i','l','e',0};
392 static const WCHAR userprofileW
[] = {'U','S','E','R','P','R','O','F','I','L','E',0};
394 char buffer
[1024*sizeof(WCHAR
) + sizeof(KEY_VALUE_PARTIAL_INFORMATION
)];
395 KEY_VALUE_PARTIAL_INFORMATION
*info
= (KEY_VALUE_PARTIAL_INFORMATION
*)buffer
;
396 OBJECT_ATTRIBUTES attr
;
397 UNICODE_STRING nameW
;
400 HKEY hkey_old
, hkey_env
;
402 attr
.Length
= sizeof(attr
);
403 attr
.RootDirectory
= 0;
404 attr
.ObjectName
= &nameW
;
406 attr
.SecurityDescriptor
= NULL
;
407 attr
.SecurityQualityOfService
= NULL
;
408 RtlInitUnicodeString( &nameW
, wineW
);
410 if (NtOpenKey( &hkey_old
, KEY_ALL_ACCESS
, &attr
) != STATUS_SUCCESS
) return;
412 attr
.RootDirectory
= hkey_current_user
;
413 RtlInitUnicodeString( &nameW
, envW
);
414 if (NtCreateKey( &hkey_env
, KEY_ALL_ACCESS
, &attr
, 0, NULL
, 0, &disp
))
420 /* Test for existence of TEMP */
421 RtlInitUnicodeString( &nameW
, tempW
);
422 if (NtQueryValueKey(hkey_env
, &nameW
, KeyValuePartialInformation
, buffer
, sizeof(buffer
), &dummy
))
425 RtlInitUnicodeString( &nameW
, tempW
);
426 if (!NtQueryValueKey( hkey_old
, &nameW
, KeyValuePartialInformation
, buffer
, sizeof(buffer
), &dummy
))
428 NtSetValueKey( hkey_env
, &nameW
, 0, info
->Type
, info
->Data
, info
->DataLength
);
429 RtlInitUnicodeString( &nameW
, tmpW
);
430 NtSetValueKey( hkey_env
, &nameW
, 0, info
->Type
, info
->Data
, info
->DataLength
);
431 MESSAGE( "Converted temp dir to new entry HKCU\\Environment \"TEMP\" = %s\n",
432 debugstr_w( (WCHAR
*)info
->Data
) );
436 /* Test for existence of PATH */
437 RtlInitUnicodeString( &nameW
, pathW
);
438 if (NtQueryValueKey(hkey_env
, &nameW
, KeyValuePartialInformation
, buffer
, sizeof(buffer
), &dummy
))
441 RtlInitUnicodeString( &nameW
, pathW
);
442 if (!NtQueryValueKey( hkey_old
, &nameW
, KeyValuePartialInformation
, buffer
, sizeof(buffer
), &dummy
))
444 NtSetValueKey( hkey_env
, &nameW
, 0, info
->Type
, info
->Data
, info
->DataLength
);
445 MESSAGE( "Converted path dir to new entry HKCU\\Environment \"PATH\" = %s\n",
446 debugstr_w( (WCHAR
*)info
->Data
) );
450 /* Test for existence of USERPROFILE */
451 RtlInitUnicodeString( &nameW
, userprofileW
);
452 if (NtQueryValueKey(hkey_env
, &nameW
, KeyValuePartialInformation
, buffer
, sizeof(buffer
), &dummy
))
454 /* convert USERPROFILE */
455 RtlInitUnicodeString( &nameW
, profileW
);
456 if (!NtQueryValueKey( hkey_old
, &nameW
, KeyValuePartialInformation
, buffer
, sizeof(buffer
), &dummy
))
458 RtlInitUnicodeString( &nameW
, userprofileW
);
459 NtSetValueKey( hkey_env
, &nameW
, 0, info
->Type
, info
->Data
, info
->DataLength
);
460 MESSAGE( "Converted profile dir to new entry HKCU\\Environment \"USERPROFILE\" = %s\n",
461 debugstr_w( (WCHAR
*)info
->Data
) );
465 /* Test for existence of windir */
466 RtlInitUnicodeString( &nameW
, windirW
);
467 if (NtQueryValueKey(hkey_env
, &nameW
, KeyValuePartialInformation
, buffer
, sizeof(buffer
), &dummy
))
470 RtlInitUnicodeString( &nameW
, windowsW
);
471 if (!NtQueryValueKey( hkey_old
, &nameW
, KeyValuePartialInformation
, buffer
, sizeof(buffer
), &dummy
))
473 RtlInitUnicodeString( &nameW
, windirW
);
474 NtSetValueKey( hkey_env
, &nameW
, 0, info
->Type
, info
->Data
, info
->DataLength
);
475 RtlInitUnicodeString( &nameW
, systemrootW
);
476 NtSetValueKey( hkey_env
, &nameW
, 0, info
->Type
, info
->Data
, info
->DataLength
);
477 MESSAGE( "Converted windows dir to new entry HKCU\\Environment \"windir\" = %s\n",
478 debugstr_w( (WCHAR
*)info
->Data
) );
482 /* Test for existence of winsysdir */
483 RtlInitUnicodeString( &nameW
, winsysdirW
);
484 if (NtQueryValueKey(hkey_env
, &nameW
, KeyValuePartialInformation
, buffer
, sizeof(buffer
), &dummy
))
486 /* convert winsysdir */
487 RtlInitUnicodeString( &nameW
, systemW
);
488 if (!NtQueryValueKey( hkey_old
, &nameW
, KeyValuePartialInformation
, buffer
, sizeof(buffer
), &dummy
))
490 RtlInitUnicodeString( &nameW
, winsysdirW
);
491 NtSetValueKey( hkey_env
, &nameW
, 0, info
->Type
, info
->Data
, info
->DataLength
);
492 MESSAGE( "Converted system dir to new entry HKCU\\Environment \"winsysdir\" = %s\n",
493 debugstr_w( (WCHAR
*)info
->Data
) );
501 /* load all registry (native and global and home) */
502 void SHELL_LoadRegistry( void )
504 HKEY hkey_local_machine
, hkey_users
, hkey_users_default
, hkey_current_user
, hkey_config
;
505 OBJECT_ATTRIBUTES attr
;
506 UNICODE_STRING nameW
;
513 static const WCHAR MachineW
[] = {'M','a','c','h','i','n','e',0};
514 static const WCHAR UserW
[] = {'U','s','e','r',0};
515 static const WCHAR DefaultW
[] = {'.','D','e','f','a','u','l','t',0};
516 static const WCHAR RegistryW
[] = {'M','a','c','h','i','n','e','\\',
517 'S','o','f','t','w','a','r','e','\\',
518 'W','i','n','e','\\',
519 'W','i','n','e','\\',
520 'C','o','n','f','i','g','\\',
521 'R','e','g','i','s','t','r','y',0};
522 static const WCHAR load_global_reg_filesW
[] = {'L','o','a','d','G','l','o','b','a','l','R','e','g','i','s','t','r','y','F','i','l','e','s',0};
523 static const WCHAR SaveOnlyUpdatedKeysW
[] = {'S','a','v','e','O','n','l','y','U','p','d','a','t','e','d','K','e','y','s',0};
524 static const WCHAR PeriodicSaveW
[] = {'P','e','r','i','o','d','i','c','S','a','v','e',0};
525 static const WCHAR GlobalRegistryDirW
[] = {'G','l','o','b','a','l','R','e','g','i','s','t','r','y','D','i','r',0};
529 attr
.Length
= sizeof(attr
);
530 attr
.RootDirectory
= 0;
531 attr
.ObjectName
= &nameW
;
533 attr
.SecurityDescriptor
= NULL
;
534 attr
.SecurityQualityOfService
= NULL
;
536 RtlInitUnicodeString( &nameW
, UserW
);
537 NtCreateKey( &hkey_users
, KEY_ALL_ACCESS
, &attr
, 0, NULL
, 0, &dispos
);
538 if (dispos
== REG_OPENED_EXISTING_KEY
)
540 /* someone else already loaded the registry */
541 NtClose( hkey_users
);
545 RtlInitUnicodeString( &nameW
, MachineW
);
546 NtCreateKey( &hkey_local_machine
, KEY_ALL_ACCESS
, &attr
, 0, NULL
, 0, NULL
);
548 attr
.RootDirectory
= hkey_users
;
549 RtlInitUnicodeString( &nameW
, DefaultW
);
550 if (NtCreateKey( &hkey_users_default
, KEY_ALL_ACCESS
, &attr
, 0, NULL
, 0, NULL
))
552 ERR("Cannot create HKEY_USERS/.Default\n" );
555 RtlOpenCurrentUser( KEY_ALL_ACCESS
, &hkey_current_user
);
557 _allocate_default_keys();
559 attr
.RootDirectory
= 0;
560 RtlInitUnicodeString( &nameW
, RegistryW
);
561 if (NtOpenKey( &hkey_config
, KEY_ALL_ACCESS
, &attr
)) hkey_config
= 0;
563 /* load global registry if required */
566 RtlInitUnicodeString( &nameW
, load_global_reg_filesW
);
567 if (!NtQueryValueKey( hkey_config
, &nameW
, KeyValuePartialInformation
, tmp
, sizeof(tmp
), &count
))
569 WCHAR
*str
= (WCHAR
*)((KEY_VALUE_PARTIAL_INFORMATION
*)tmp
)->Data
;
570 res
= !IS_OPTION_FALSE(str
[0]);
574 /* load global registry files (stored in /etc/wine) */
575 char *p
, configfile
[MAX_PATHNAME_LEN
];
577 /* Override ETCDIR? */
579 RtlInitUnicodeString( &nameW
, GlobalRegistryDirW
);
580 if (!NtQueryValueKey( hkey_config
, &nameW
, KeyValuePartialInformation
, tmp
, sizeof(tmp
), &count
))
582 WCHAR
*str
= (WCHAR
*)((KEY_VALUE_PARTIAL_INFORMATION
*)tmp
)->Data
;
583 RtlUnicodeToMultiByteN( configfile
, sizeof(configfile
), NULL
,
584 str
, (strlenW(str
) + 1) * sizeof(WCHAR
));
586 if (configfile
[0] != '/') strcpy(configfile
, ETCDIR
);
588 TRACE("GlobalRegistryDir is '%s'.\n", configfile
);
590 /* Load the global HKU hive directly from sysconfdir */
591 p
= configfile
+ strlen(configfile
);
592 strcpy(p
, SAVE_GLOBAL_REGBRANCH_USER_DEFAULT
);
593 load_wine_registry( hkey_users
, configfile
);
595 /* Load the global machine defaults directly from sysconfdir */
596 strcpy(p
, SAVE_GLOBAL_REGBRANCH_LOCAL_MACHINE
);
597 load_wine_registry( hkey_local_machine
, configfile
);
600 /* setup registry saving */
603 RtlInitUnicodeString( &nameW
, SaveOnlyUpdatedKeysW
);
604 if (!NtQueryValueKey( hkey_config
, &nameW
, KeyValuePartialInformation
, tmp
, sizeof(tmp
), &count
))
606 WCHAR
*str
= (WCHAR
*)((KEY_VALUE_PARTIAL_INFORMATION
*)tmp
)->Data
;
607 all
= IS_OPTION_FALSE(str
[0]);
611 RtlInitUnicodeString( &nameW
, PeriodicSaveW
);
612 if (!NtQueryValueKey( hkey_config
, &nameW
, KeyValuePartialInformation
, tmp
, sizeof(tmp
), &count
))
614 WCHAR
*str
= (WCHAR
*)((KEY_VALUE_PARTIAL_INFORMATION
*)tmp
)->Data
;
615 period
= (int)strtolW(str
, NULL
, 10);
618 /* load home registry and set saving level (0 for saving everything,
619 * 1 for saving only modified keys) */
621 SERVER_START_REQ( load_user_registries
)
623 req
->hkey
= hkey_current_user
;
625 req
->period
= period
* 1000;
626 wine_server_call( req
);
630 /* create hardware registry branch */
632 create_hardware_branch();
634 /* convert keys from config file to new registry format */
636 convert_drive_types();
637 convert_environment( hkey_current_user
);
639 NtClose(hkey_users_default
);
640 NtClose(hkey_current_user
);
642 NtClose(hkey_local_machine
);
643 NtClose(hkey_config
);