diff --git a/misc/registry.c b/misc/registry.c index 66754d21fa1..78dc0942751 100644 --- a/misc/registry.c +++ b/misc/registry.c @@ -54,8 +54,6 @@ DEFAULT_DEBUG_CHANNEL(reg); static void REGISTRY_Init(void); /* FIXME: following defines should be configured global ... */ -/* NOTE: do not append a /. linux' mkdir() WILL FAIL if you do that */ -#define WINE_PREFIX "/.wine" #define SAVE_USERS_DEFAULT ETCDIR"/wine.userreg" #define SAVE_LOCAL_MACHINE_DEFAULT ETCDIR"/wine.systemreg" @@ -64,10 +62,6 @@ static void REGISTRY_Init(void); #define SAVE_LOCAL_USERS_DEFAULT "wine.userreg" #define SAVE_LOCAL_MACHINE "system.reg" -#define KEY_REGISTRY "Software\\The WINE team\\WINE\\Registry" -#define VAL_SAVEUPDATED "SaveOnlyUpdatedKeys" - - /* what valuetypes do we need to convert? */ #define UNICONVMASK ((1<current = 1; req->saving = !all; req->version = version; server_call( REQ_SET_REGISTRY_LEVELS ); - SHELL_SaveRegistryBranch(HKEY_CURRENT_USER); - SHELL_SaveRegistryBranch(HKEY_LOCAL_MACHINE); - SHELL_SaveRegistryBranch(HKEY_USERS); + if (!(fn = HeapAlloc( GetProcessHeap(), 0, MAX_PATHNAME_LEN ))) + { + ERR( "Not enough memory to save registry\n" ); + return; + } + + if (PROFILE_GetWineIniBool("registry","WritetoAltRegistries",1)) + { + if (PROFILE_GetWineIniString( "registry", "AltCurrentUserFile", "", fn, MAX_PATHNAME_LEN )) + save_key( HKEY_CURRENT_USER, fn ); + if (PROFILE_GetWineIniString( "Registry", "AltLocalMachineFile", "", fn, MAX_PATHNAME_LEN )) + save_key( HKEY_LOCAL_MACHINE, fn ); + if (PROFILE_GetWineIniString( "Registry", "AltUserFile", "", fn, MAX_PATHNAME_LEN )) + save_key( HKEY_USERS, fn ); + + } + + if (PROFILE_GetWineIniBool("registry","WritetoHomeRegistries",1)) + { + char *str; + strcpy( fn, confdir ); + str = fn + strlen(fn); + *str++ = '/'; + + strcpy( str, SAVE_CURRENT_USER ); + save_key( HKEY_CURRENT_USER, fn ); + + strcpy( str, SAVE_LOCAL_MACHINE ); + save_key( HKEY_LOCAL_MACHINE, fn ); + + strcpy( str, SAVE_LOCAL_USERS_DEFAULT ); + save_key( HKEY_USERS, fn ); + } + + HeapFree( GetProcessHeap(), 0, fn ); } /* Periodic save callback */ @@ -1577,7 +1493,6 @@ static void SetLoadLevel(int level) void SHELL_LoadRegistry( void ) { - char *fn, *home; HKEY hkey; char windir[MAX_PATHNAME_LEN]; char path[MAX_PATHNAME_LEN]; @@ -1734,35 +1649,34 @@ void SHELL_LoadRegistry( void ) /* * Load the user saved registries */ - if (!(home = getenv( "HOME" ))) - WARN("Failed to get homedirectory of UID %ld.\n",(long) getuid()); - else if (PROFILE_GetWineIniBool("registry", "LoadHomeRegistryFiles", 1)) + if (PROFILE_GetWineIniBool("registry", "LoadHomeRegistryFiles", 1)) { + const char *confdir = get_config_dir(); + int len = strlen(confdir) + 20; + char *fn = path; + + if (len > sizeof(path)) fn = HeapAlloc( GetProcessHeap(), 0, len ); /* * Load user's personal versions of global HKU/.Default keys */ - fn=(char*)xmalloc( strlen(home)+ strlen(WINE_PREFIX) + - strlen(SAVE_LOCAL_USERS_DEFAULT)+2); - strcpy(fn, home); - strcat(fn, WINE_PREFIX"/"SAVE_LOCAL_USERS_DEFAULT); - _wine_loadreg( HKEY_USERS, fn ); - free(fn); + if (fn) + { + char *str; + strcpy( fn, confdir ); + str = fn + strlen(fn); + *str++ = '/'; - fn=(char*)xmalloc( strlen(home) + strlen(WINE_PREFIX) + strlen(SAVE_CURRENT_USER)+2); - strcpy(fn, home); - strcat(fn, WINE_PREFIX"/"SAVE_CURRENT_USER); - _wine_loadreg( HKEY_CURRENT_USER, fn ); - free(fn); + strcpy( str, SAVE_LOCAL_USERS_DEFAULT ); + _wine_loadreg( HKEY_USERS, fn ); - /* - * Load HKLM, attempt to get the registry location from the config - * file first, if exist, load and keep going. - */ - fn=(char*)xmalloc( strlen(home)+ strlen(WINE_PREFIX)+ strlen(SAVE_LOCAL_MACHINE)+2); - strcpy(fn,home); - strcat(fn,WINE_PREFIX"/"SAVE_LOCAL_MACHINE); - _wine_loadreg( HKEY_LOCAL_MACHINE, fn ); - free(fn); + strcpy( str, SAVE_CURRENT_USER ); + _wine_loadreg( HKEY_CURRENT_USER, fn ); + + strcpy( str, SAVE_LOCAL_MACHINE ); + _wine_loadreg( HKEY_LOCAL_MACHINE, fn ); + + if (fn != path) HeapFree( GetProcessHeap(), 0, fn ); + } } /* @@ -1771,37 +1685,23 @@ void SHELL_LoadRegistry( void ) */ if (PROFILE_GetWineIniBool ( "registry", "LoadAltRegistryFiles", 1)) { - fn = xmalloc( MAX_PATHNAME_LEN ); - if ( PROFILE_GetWineIniString( "registry", "AltCurrentUserFile", "", - fn, MAX_PATHNAME_LEN - 1)) - { - _wine_loadreg( HKEY_CURRENT_USER, fn ); - } - free (fn); + if (PROFILE_GetWineIniString( "registry", "AltCurrentUserFile", "", path, sizeof(path) )) + _wine_loadreg( HKEY_CURRENT_USER, path ); + /* * Load HKU, get the registry location from the config * file, if exist, load and keep going. */ - fn = xmalloc ( MAX_PATHNAME_LEN ); - if ( PROFILE_GetWineIniString ( "registry", "AltUserFile", "", - fn, MAX_PATHNAME_LEN - 1)) - { - _wine_loadreg( HKEY_USERS, fn ); - } - free (fn); + if (PROFILE_GetWineIniString ( "registry", "AltUserFile", "", path, sizeof(path) )) + _wine_loadreg( HKEY_USERS, path ); + /* * Load HKLM, get the registry location from the config * file, if exist, load and keep going. */ - fn = xmalloc ( MAX_PATHNAME_LEN ); - if (PROFILE_GetWineIniString ( "registry", "AltLocalMachineFile", "", - fn, MAX_PATHNAME_LEN - 1)) - { - _wine_loadreg( HKEY_LOCAL_MACHINE, fn ); - } - free (fn); + if (PROFILE_GetWineIniString ( "registry", "AltLocalMachineFile", "", path, sizeof(path) )) + _wine_loadreg( HKEY_LOCAL_MACHINE, path ); } - } /* start the periodic saving timer */ diff --git a/wine.ini b/wine.ini index b2e37409207..cd629f473d9 100644 --- a/wine.ini +++ b/wine.ini @@ -156,9 +156,11 @@ WritetoHomeRegistryFiles=Y ; TRY to write all changes to alt registries WritetoAltRegistryFiles=Y ; Use new file format -UseNewFormat=N +UseNewFormat=Y ; Registry periodic save timeout in seconds ; PeriodicSave=600 +; Save only modified keys +SaveOnlyUpdatedKeys=Y [Tweak.Layout] ;; WineLook=xxx (supported styles are 'Win31'(default), 'Win95', 'Win98')