mirror of
https://github.com/reactos/reactos.git
synced 2025-06-10 04:14:53 +00:00
[SYSSETUP] If creating the default-user hive file fails because the file already exists, make a backup (i.e. rename it) and retry its creation.
This situation happens when one "updates" ReactOS by re-installing it on top of an existing installation.
This commit is contained in:
parent
b2606fd07a
commit
c441de2232
1 changed files with 27 additions and 0 deletions
|
@ -1200,10 +1200,37 @@ SaveDefaultUserHive(VOID)
|
||||||
|
|
||||||
pSetupEnablePrivilege(L"SeBackupPrivilege", TRUE);
|
pSetupEnablePrivilege(L"SeBackupPrivilege", TRUE);
|
||||||
|
|
||||||
|
/* Save the Default hive */
|
||||||
dwError = RegSaveKeyExW(hUserKey,
|
dwError = RegSaveKeyExW(hUserKey,
|
||||||
szDefaultUserHive,
|
szDefaultUserHive,
|
||||||
NULL,
|
NULL,
|
||||||
REG_STANDARD_FORMAT);
|
REG_STANDARD_FORMAT);
|
||||||
|
if (dwError == ERROR_ALREADY_EXISTS)
|
||||||
|
{
|
||||||
|
WCHAR szBackupHive[MAX_PATH];
|
||||||
|
|
||||||
|
/* Build the backup hive file name by replacing the extension */
|
||||||
|
wcscpy(szBackupHive, szDefaultUserHive);
|
||||||
|
wcscpy(&szBackupHive[wcslen(szBackupHive) - 4], L".bak");
|
||||||
|
|
||||||
|
/* Back up the existing default user hive by renaming it, replacing any possible existing old backup */
|
||||||
|
if (!MoveFileExW(szDefaultUserHive,
|
||||||
|
szBackupHive,
|
||||||
|
MOVEFILE_REPLACE_EXISTING))
|
||||||
|
{
|
||||||
|
dwError = GetLastError();
|
||||||
|
DPRINT1("Failed to create a default-user hive backup '%S', MoveFileExW failed (Error %lu)\n",
|
||||||
|
szBackupHive, dwError);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* The backup has been done, retry saving the Default hive */
|
||||||
|
dwError = RegSaveKeyExW(hUserKey,
|
||||||
|
szDefaultUserHive,
|
||||||
|
NULL,
|
||||||
|
REG_STANDARD_FORMAT);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (dwError != ERROR_SUCCESS)
|
if (dwError != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
DPRINT1("RegSaveKeyExW() failed (Error %lu)\n", dwError);
|
DPRINT1("RegSaveKeyExW() failed (Error %lu)\n", dwError);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue