From 4f4d124a5fed188936c5068dc3d7e5e551a46544 Mon Sep 17 00:00:00 2001 From: Bobby Battista Date: Wed, 12 Nov 2025 23:38:47 -0500 Subject: [PATCH 1/3] fix(registry): prioritize HKEY_CURRENT_USER over HKEY_LOCAL_MACHINE to prevent stale values --- .../Source/WWVegas/WWDownload/registry.cpp | 14 ++++---------- .../GameEngine/Source/Common/System/registry.cpp | 8 ++++---- .../GameEngine/Source/Common/System/registry.cpp | 12 ++++++------ 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/Core/Libraries/Source/WWVegas/WWDownload/registry.cpp b/Core/Libraries/Source/WWVegas/WWDownload/registry.cpp index 494e09ecb29..e37944c0f70 100644 --- a/Core/Libraries/Source/WWVegas/WWDownload/registry.cpp +++ b/Core/Libraries/Source/WWVegas/WWDownload/registry.cpp @@ -120,12 +120,12 @@ bool GetStringFromRegistry(std::string path, std::string key, std::string& val) #endif fullPath.append(path); - if (getStringFromRegistry(HKEY_LOCAL_MACHINE, fullPath.c_str(), key.c_str(), val)) + if (getStringFromRegistry(HKEY_CURRENT_USER, fullPath.c_str(), key.c_str(), val)) { return true; } - return getStringFromRegistry(HKEY_CURRENT_USER, fullPath.c_str(), key.c_str(), val); + return getStringFromRegistry(HKEY_LOCAL_MACHINE, fullPath.c_str(), key.c_str(), val); } bool GetUnsignedIntFromRegistry(std::string path, std::string key, unsigned int& val) @@ -137,12 +137,12 @@ bool GetUnsignedIntFromRegistry(std::string path, std::string key, unsigned int& #endif fullPath.append(path); - if (getUnsignedIntFromRegistry(HKEY_LOCAL_MACHINE, fullPath.c_str(), key.c_str(), val)) + if (getUnsignedIntFromRegistry(HKEY_CURRENT_USER, fullPath.c_str(), key.c_str(), val)) { return true; } - return getUnsignedIntFromRegistry(HKEY_CURRENT_USER, fullPath.c_str(), key.c_str(), val); + return getUnsignedIntFromRegistry(HKEY_LOCAL_MACHINE, fullPath.c_str(), key.c_str(), val); } bool SetStringInRegistry( std::string path, std::string key, std::string val) @@ -154,9 +154,6 @@ bool SetStringInRegistry( std::string path, std::string key, std::string val) #endif fullPath.append(path); - if (setStringInRegistry( HKEY_LOCAL_MACHINE, fullPath, key, val)) - return true; - return setStringInRegistry( HKEY_CURRENT_USER, fullPath, key, val ); } @@ -169,9 +166,6 @@ bool SetUnsignedIntInRegistry( std::string path, std::string key, unsigned int v #endif fullPath.append(path); - if (setUnsignedIntInRegistry( HKEY_LOCAL_MACHINE, fullPath, key, val)) - return true; - return setUnsignedIntInRegistry( HKEY_CURRENT_USER, fullPath, key, val ); } diff --git a/Generals/Code/GameEngine/Source/Common/System/registry.cpp b/Generals/Code/GameEngine/Source/Common/System/registry.cpp index df4ab5f2ef0..cf35683ba13 100644 --- a/Generals/Code/GameEngine/Source/Common/System/registry.cpp +++ b/Generals/Code/GameEngine/Source/Common/System/registry.cpp @@ -121,12 +121,12 @@ Bool GetStringFromRegistry(AsciiString path, AsciiString key, AsciiString& val) fullPath.concat(path); DEBUG_LOG(("GetStringFromRegistry - looking in %s for key %s", fullPath.str(), key.str())); - if (getStringFromRegistry(HKEY_LOCAL_MACHINE, fullPath.str(), key.str(), val)) + if (getStringFromRegistry(HKEY_CURRENT_USER, fullPath.str(), key.str(), val)) { return TRUE; } - return getStringFromRegistry(HKEY_CURRENT_USER, fullPath.str(), key.str(), val); + return getStringFromRegistry(HKEY_LOCAL_MACHINE, fullPath.str(), key.str(), val); } Bool GetUnsignedIntFromRegistry(AsciiString path, AsciiString key, UnsignedInt& val) @@ -135,12 +135,12 @@ Bool GetUnsignedIntFromRegistry(AsciiString path, AsciiString key, UnsignedInt& fullPath.concat(path); DEBUG_LOG(("GetUnsignedIntFromRegistry - looking in %s for key %s", fullPath.str(), key.str())); - if (getUnsignedIntFromRegistry(HKEY_LOCAL_MACHINE, fullPath.str(), key.str(), val)) + if (getUnsignedIntFromRegistry(HKEY_CURRENT_USER, fullPath.str(), key.str(), val)) { return TRUE; } - return getUnsignedIntFromRegistry(HKEY_CURRENT_USER, fullPath.str(), key.str(), val); + return getUnsignedIntFromRegistry(HKEY_LOCAL_MACHINE, fullPath.str(), key.str(), val); } AsciiString GetRegistryLanguage(void) diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/registry.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/registry.cpp index 339423da85b..86773aed81d 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/System/registry.cpp +++ b/GeneralsMD/Code/GameEngine/Source/Common/System/registry.cpp @@ -121,12 +121,12 @@ Bool GetStringFromGeneralsRegistry(AsciiString path, AsciiString key, AsciiStrin fullPath.concat(path); DEBUG_LOG(("GetStringFromRegistry - looking in %s for key %s", fullPath.str(), key.str())); - if (getStringFromRegistry(HKEY_LOCAL_MACHINE, fullPath.str(), key.str(), val)) + if (getStringFromRegistry(HKEY_CURRENT_USER, fullPath.str(), key.str(), val)) { return TRUE; } - return getStringFromRegistry(HKEY_CURRENT_USER, fullPath.str(), key.str(), val); + return getStringFromRegistry(HKEY_LOCAL_MACHINE, fullPath.str(), key.str(), val); } Bool GetStringFromRegistry(AsciiString path, AsciiString key, AsciiString& val) @@ -135,12 +135,12 @@ Bool GetStringFromRegistry(AsciiString path, AsciiString key, AsciiString& val) fullPath.concat(path); DEBUG_LOG(("GetStringFromRegistry - looking in %s for key %s", fullPath.str(), key.str())); - if (getStringFromRegistry(HKEY_LOCAL_MACHINE, fullPath.str(), key.str(), val)) + if (getStringFromRegistry(HKEY_CURRENT_USER, fullPath.str(), key.str(), val)) { return TRUE; } - return getStringFromRegistry(HKEY_CURRENT_USER, fullPath.str(), key.str(), val); + return getStringFromRegistry(HKEY_LOCAL_MACHINE, fullPath.str(), key.str(), val); } Bool GetUnsignedIntFromRegistry(AsciiString path, AsciiString key, UnsignedInt& val) @@ -149,12 +149,12 @@ Bool GetUnsignedIntFromRegistry(AsciiString path, AsciiString key, UnsignedInt& fullPath.concat(path); DEBUG_LOG(("GetUnsignedIntFromRegistry - looking in %s for key %s", fullPath.str(), key.str())); - if (getUnsignedIntFromRegistry(HKEY_LOCAL_MACHINE, fullPath.str(), key.str(), val)) + if (getUnsignedIntFromRegistry(HKEY_CURRENT_USER, fullPath.str(), key.str(), val)) { return TRUE; } - return getUnsignedIntFromRegistry(HKEY_CURRENT_USER, fullPath.str(), key.str(), val); + return getUnsignedIntFromRegistry(HKEY_LOCAL_MACHINE, fullPath.str(), key.str(), val); } AsciiString GetRegistryLanguage(void) From 1af72c52ed0abf4291f74822d7b9d81ddacfe4c4 Mon Sep 17 00:00:00 2001 From: Bobby Battista Date: Mon, 15 Dec 2025 11:16:23 -0500 Subject: [PATCH 2/3] fix(registry): prefer HKCU on read while keeping HKLM+HKCU writes --- Core/Libraries/Source/WWVegas/WWDownload/registry.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Core/Libraries/Source/WWVegas/WWDownload/registry.cpp b/Core/Libraries/Source/WWVegas/WWDownload/registry.cpp index e37944c0f70..670a4e3f697 100644 --- a/Core/Libraries/Source/WWVegas/WWDownload/registry.cpp +++ b/Core/Libraries/Source/WWVegas/WWDownload/registry.cpp @@ -154,6 +154,9 @@ bool SetStringInRegistry( std::string path, std::string key, std::string val) #endif fullPath.append(path); + if (setStringInRegistry( HKEY_LOCAL_MACHINE, fullPath, key, val)) + return true; + return setStringInRegistry( HKEY_CURRENT_USER, fullPath, key, val ); } @@ -166,6 +169,9 @@ bool SetUnsignedIntInRegistry( std::string path, std::string key, unsigned int v #endif fullPath.append(path); + if (setUnsignedIntInRegistry( HKEY_LOCAL_MACHINE, fullPath, key, val)) + return true; + return setUnsignedIntInRegistry( HKEY_CURRENT_USER, fullPath, key, val ); } From 4d47837a639817ce2c81826136b1149a463537c8 Mon Sep 17 00:00:00 2001 From: Bobby Battista Date: Mon, 16 Feb 2026 13:34:38 -0500 Subject: [PATCH 3/3] fix(registry): Prefer HKCU for writes to match read priority --- Core/Libraries/Source/WWVegas/WWDownload/registry.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Core/Libraries/Source/WWVegas/WWDownload/registry.cpp b/Core/Libraries/Source/WWVegas/WWDownload/registry.cpp index 670a4e3f697..4b9b10ee2b8 100644 --- a/Core/Libraries/Source/WWVegas/WWDownload/registry.cpp +++ b/Core/Libraries/Source/WWVegas/WWDownload/registry.cpp @@ -154,10 +154,11 @@ bool SetStringInRegistry( std::string path, std::string key, std::string val) #endif fullPath.append(path); - if (setStringInRegistry( HKEY_LOCAL_MACHINE, fullPath, key, val)) + // TheSuperHackers @fix bobtista 12/02/2026 Prefer HKCU for writes to match read priority + if (setStringInRegistry( HKEY_CURRENT_USER, fullPath, key, val)) return true; - return setStringInRegistry( HKEY_CURRENT_USER, fullPath, key, val ); + return setStringInRegistry( HKEY_LOCAL_MACHINE, fullPath, key, val ); } bool SetUnsignedIntInRegistry( std::string path, std::string key, unsigned int val) @@ -169,9 +170,10 @@ bool SetUnsignedIntInRegistry( std::string path, std::string key, unsigned int v #endif fullPath.append(path); - if (setUnsignedIntInRegistry( HKEY_LOCAL_MACHINE, fullPath, key, val)) + // TheSuperHackers @fix bobtista 12/02/2026 Prefer HKCU for writes to match read priority + if (setUnsignedIntInRegistry( HKEY_CURRENT_USER, fullPath, key, val)) return true; - return setUnsignedIntInRegistry( HKEY_CURRENT_USER, fullPath, key, val ); + return setUnsignedIntInRegistry( HKEY_LOCAL_MACHINE, fullPath, key, val ); }