Esempio n. 1
0
        private static RegistryKey LoadDefaultUserHive()
        {
            var loadExitCode = SystemUtils.RunProcessBlocking(
                "reg", $@"load ""{DEFAULT_USER_HIVE_PATH}"" ""C:\Users\Default\NTUSER.DAT"""
                );

            if (loadExitCode.IsNotSuccessful())
            {
                throw new Exception("无法加载默认用户注册表配置单元.");
            }

            AssemblyLoadContext.Default.Unloading += _ => UnloadDefaultUserHive();
            return(Registry.Users.OpenSubKeyWritable("_loaded_Default"));
        }
Esempio n. 2
0
 private static void UnloadDefaultUserHive()
 {
     defaultUserKey?.Close();
     SystemUtils.RunProcessBlocking("reg", $@"unload ""{DEFAULT_USER_HIVE_PATH}""");
 }