From 5cdd36cf13042876022fe4641d09e7ef8cc50846 Mon Sep 17 00:00:00 2001 From: "DESKTOP-0Q3GGGJ\\Anthony" Date: Tue, 4 Jun 2024 15:21:23 -0600 Subject: [PATCH] move all comparable name checks into Name property --- FlashpointSecurePlayer/RegistryStates.cs | 15 +++++++-------- FlashpointSecurePlayer/Shared.cs | 22 +++++++++++----------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/FlashpointSecurePlayer/RegistryStates.cs b/FlashpointSecurePlayer/RegistryStates.cs index a8ddb16..6ed97b3 100644 --- a/FlashpointSecurePlayer/RegistryStates.cs +++ b/FlashpointSecurePlayer/RegistryStates.cs @@ -1544,11 +1544,10 @@ private void ModificationAdded(RegistryTraceData registryTraceData) { //if (!modificationsElement.ElementInformation.IsPresent) { //return; //} - - // comparable names, since registry key/value names shouldn't have null bytes in them according to Win32 + RegistryStateElement registryStateElement = new RegistryStateElement { - KeyName = GetComparableName(registryTraceData.KeyName), - ValueName = GetComparableName(registryTraceData.ValueName) + KeyName = registryTraceData.KeyName, + ValueName = registryTraceData.ValueName }; // KeyHandle is meant to be a uint32, so we discard the rest @@ -1741,8 +1740,8 @@ private void ModificationRemoved(RegistryTraceData registryTraceData) { // create filler element to get name RegistryStateElement registryStateElement = new RegistryStateElement { - KeyName = GetComparableName(registryTraceData.KeyName), - ValueName = GetComparableName(registryTraceData.ValueName) + KeyName = registryTraceData.KeyName, + ValueName = registryTraceData.ValueName }; ulong safeKeyHandle = registryTraceData.KeyHandle & 0x00000000FFFFFFFF; @@ -1796,7 +1795,7 @@ private void KCBStarted(RegistryTraceData registryTraceData) { kcbModificationKeyNames = new Dictionary(); } - kcbModificationKeyNames[safeKeyHandle] = GetComparableName(registryTraceData.KeyName); + kcbModificationKeyNames[safeKeyHandle] = registryTraceData.KeyName; } private void KCBStopped(RegistryTraceData registryTraceData) { @@ -1855,7 +1854,7 @@ private void KCBStopped(RegistryTraceData registryTraceData) { registryStateElement = registryStateElements[j]; keyName = GetRedirectedKeyValueName( - GetKeyValueNameFromKernelRegistryString(GetComparableName(registryTraceData.KeyName) + "\\" + registryStateElement.KeyName), + GetKeyValueNameFromKernelRegistryString(registryTraceData.KeyName + "\\" + registryStateElement.KeyName), modificationsElement.RegistryStates.BinaryType ); diff --git a/FlashpointSecurePlayer/Shared.cs b/FlashpointSecurePlayer/Shared.cs index 0561200..584d420 100644 --- a/FlashpointSecurePlayer/Shared.cs +++ b/FlashpointSecurePlayer/Shared.cs @@ -977,6 +977,15 @@ public static HttpClient HttpClient { // (preferably, no more than eight at a time) private static SemaphoreSlim downloadSemaphoreSlim = new SemaphoreSlim(1, 1); + public static string GetComparableName(string name) { + if (name == null) { + return name; + } + + int comparableNameLength = name.IndexOf('\0'); + return comparableNameLength == -1 ? name : name.Substring(0, comparableNameLength); + } + // it'd be nice to move all the configuration, template, section stuff to their own class one day // http://social.msdn.microsoft.com/Forums/vstudio/en-US/0f3557ee-16bd-4a36-a4f3-00efbeae9b0d/app-config-multiple-sections-in-sectiongroup-with-same-name?forum=csharpgeneral private static FlashpointSecurePlayerSection flashpointSecurePlayerSection = null; @@ -1640,13 +1649,13 @@ public string _ValueExpanded { // delimiter for a primary key (value names can contain them) public string Name { get { - string keyName = KeyName; + string keyName = GetComparableName(KeyName); if (!String.IsNullOrEmpty(keyName)) { keyName = keyName.ToUpperInvariant(); } - string valueName = ValueName; + string valueName = GetComparableName(ValueName); if (!String.IsNullOrEmpty(valueName)) { valueName = valueName.ToUpperInvariant(); @@ -2054,15 +2063,6 @@ public string this[string shortPath] { public PathNamesLong Long { get; } = new PathNamesLong(); } - public static string GetComparableName(string name) { - if (name == null) { - return name; - } - - int comparableNameLength = name.IndexOf('\0'); - return comparableNameLength == -1 ? name : name.Substring(0, comparableNameLength); - } - public static string GetEnvironmentVariablePreference(List names) { string preferenceString = null;