From 3b1806c03871bcabd3a5cada280d99c5b05c7b67 Mon Sep 17 00:00:00 2001 From: Michael Grafnetter Date: Sat, 25 Feb 2023 06:35:54 +0100 Subject: [PATCH] Fixed #47: Error parsing corrupted registry hives --- .../Cryptography/BootKeyRetriever.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Src/DSInternals.DataStore/Cryptography/BootKeyRetriever.cs b/Src/DSInternals.DataStore/Cryptography/BootKeyRetriever.cs index 0c4dff5..4cb64f4 100644 --- a/Src/DSInternals.DataStore/Cryptography/BootKeyRetriever.cs +++ b/Src/DSInternals.DataStore/Cryptography/BootKeyRetriever.cs @@ -105,7 +105,15 @@ namespace DSInternals.DataStore { using (var ccsKey = systemKey.OpenSubKey(CurrentControlSetKey)) { - return (int)ccsKey.GetValue(CurrentControlSetValue, DefaultControlSetId); + if(ccsKey != null) + { + return (int)ccsKey.GetValue(CurrentControlSetValue, DefaultControlSetId); + } + else + { + // The "Select" value may be absent in SYSTEM registry hives that were copied from live systems without the corresponding transaction logs. + return DefaultControlSetId; + } } }