https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e7340a28008647b7287fe64854e270038fb9c88b

commit e7340a28008647b7287fe64854e270038fb9c88b
Author:     Eric Kohl <[email protected]>
AuthorDate: Wed May 30 08:18:55 2018 +0200
Commit:     Eric Kohl <[email protected]>
CommitDate: Wed May 30 08:18:55 2018 +0200

    [SYSSETUP] Save the HKEY_USERS\.DEFAULT hive in the ntuser.dat file of the 
default user profile
---
 dll/win32/syssetup/install.c | 48 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/dll/win32/syssetup/install.c b/dll/win32/syssetup/install.c
index e5b5530c43..ad14449a56 100644
--- a/dll/win32/syssetup/install.c
+++ b/dll/win32/syssetup/install.c
@@ -1171,6 +1171,52 @@ done:
 }
 
 
+static
+DWORD
+SaveDefaultUserHive(VOID)
+{
+    WCHAR szDefaultUserHive[MAX_PATH];
+    HKEY hUserKey = NULL;
+    DWORD cchSize;
+    DWORD dwError;
+
+    DPRINT("SaveDefaultUserHive()\n");
+
+    cchSize = ARRAYSIZE(szDefaultUserHive);
+    GetDefaultUserProfileDirectoryW(szDefaultUserHive, &cchSize);
+
+    wcscat(szDefaultUserHive, L"\\ntuser.dat");
+
+    dwError = RegOpenKeyExW(HKEY_USERS,
+                            L".DEFAULT",
+                            0,
+                            KEY_READ,
+                            &hUserKey);
+    if (dwError != ERROR_SUCCESS)
+    {
+        DPRINT1("RegOpenKeyExW() failed (Error %lu)\n", dwError);
+        return dwError;
+    }
+
+    pSetupEnablePrivilege(L"SeBackupPrivilege", TRUE);
+
+    dwError = RegSaveKeyExW(hUserKey,
+                            szDefaultUserHive,
+                            NULL,
+                            REG_STANDARD_FORMAT);
+    if (dwError != ERROR_SUCCESS)
+    {
+        DPRINT1("RegSaveKeyExW() failed (Error %lu)\n", dwError);
+    }
+
+    pSetupEnablePrivilege(L"SeBackupPrivilege", FALSE);
+
+    RegCloseKey(hUserKey);
+
+    return dwError;
+}
+
+
 static
 DWORD
 InstallReactOS(VOID)
@@ -1233,6 +1279,8 @@ InstallReactOS(VOID)
         CreateDirectory(szBuffer, NULL);
     }
 
+    SaveDefaultUserHive();
+
     hHotkeyThread = CreateThread(NULL, 0, HotkeyThread, NULL, 0, NULL);
 
     /* Hack: Install TCP/IP protocol driver */

Reply via email to