Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions Core/Libraries/Source/WWVegas/WWDownload/registry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include <string>

#define WIN32_LEAN_AND_MEAN

Check warning on line 25 in Core/Libraries/Source/WWVegas/WWDownload/registry.cpp

View workflow job for this annotation

GitHub Actions / Build GeneralsMD / vc6-profile+t+e

'WIN32_LEAN_AND_MEAN' : macro redefinition

Check warning on line 25 in Core/Libraries/Source/WWVegas/WWDownload/registry.cpp

View workflow job for this annotation

GitHub Actions / Build Generals / vc6-profile+t+e

'WIN32_LEAN_AND_MEAN' : macro redefinition

Check warning on line 25 in Core/Libraries/Source/WWVegas/WWDownload/registry.cpp

View workflow job for this annotation

GitHub Actions / Build Generals / vc6+t+e

'WIN32_LEAN_AND_MEAN' : macro redefinition

Check warning on line 25 in Core/Libraries/Source/WWVegas/WWDownload/registry.cpp

View workflow job for this annotation

GitHub Actions / Build GeneralsMD / vc6+t+e

'WIN32_LEAN_AND_MEAN' : macro redefinition

Check warning on line 25 in Core/Libraries/Source/WWVegas/WWDownload/registry.cpp

View workflow job for this annotation

GitHub Actions / Build GeneralsMD / vc6-releaselog+t+e

'WIN32_LEAN_AND_MEAN' : macro redefinition

Check warning on line 25 in Core/Libraries/Source/WWVegas/WWDownload/registry.cpp

View workflow job for this annotation

GitHub Actions / Build GeneralsMD / win32-vcpkg-debug+t+e

'WIN32_LEAN_AND_MEAN': macro redefinition

Check warning on line 25 in Core/Libraries/Source/WWVegas/WWDownload/registry.cpp

View workflow job for this annotation

GitHub Actions / Build GeneralsMD / win32-debug+t+e

'WIN32_LEAN_AND_MEAN': macro redefinition

Check warning on line 25 in Core/Libraries/Source/WWVegas/WWDownload/registry.cpp

View workflow job for this annotation

GitHub Actions / Build GeneralsMD / win32-profile+t+e

'WIN32_LEAN_AND_MEAN': macro redefinition

Check warning on line 25 in Core/Libraries/Source/WWVegas/WWDownload/registry.cpp

View workflow job for this annotation

GitHub Actions / Build GeneralsMD / win32+t+e

'WIN32_LEAN_AND_MEAN': macro redefinition

Check warning on line 25 in Core/Libraries/Source/WWVegas/WWDownload/registry.cpp

View workflow job for this annotation

GitHub Actions / Build GeneralsMD / win32-vcpkg+t+e

'WIN32_LEAN_AND_MEAN': macro redefinition

Check warning on line 25 in Core/Libraries/Source/WWVegas/WWDownload/registry.cpp

View workflow job for this annotation

GitHub Actions / Build GeneralsMD / win32-vcpkg-profile+t+e

'WIN32_LEAN_AND_MEAN': macro redefinition
#include <windows.h>

#include "Registry.h"
Expand Down Expand Up @@ -120,12 +120,12 @@
#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)
Expand All @@ -137,12 +137,12 @@
#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))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I am not mistaken this will be wrong when HKEY_CURRENT_USER var is set to something and game is run with Admin privileges and writing to HKEY_LOCAL_MACHINE. Then it will not update HKEY_CURRENT_USER and its value never changes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the write functions (SetStringInRegistry, SetUnsignedIntInRegistry) were still preferring HKLM, so running as admin would write to HKLM while reads would return the stale HKCU value. Fixed by flipping the write priority to also prefer HKCU, matching the read side. So now both SetStringInRegistry and SetUnsignedIntInRegistry to try HKCU first

{
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)
Expand All @@ -154,10 +154,11 @@
#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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrap @fix in backticks to prevent platform mention interpretation.

Suggested change
// TheSuperHackers @fix bobtista 12/02/2026 Prefer HKCU for writes to match read priority
// TheSuperHackers `@fix` bobtista 12/02/2026 Prefer HKCU for writes to match read priority

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: Core/Libraries/Source/WWVegas/WWDownload/registry.cpp
Line: 157:157

Comment:
Wrap `@fix` in backticks to prevent platform mention interpretation.

```suggestion
	// TheSuperHackers `@fix` bobtista 12/02/2026 Prefer HKCU for writes to match read priority
```

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

How can I resolve this? If you propose a fix, please make it concise.

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)
Expand All @@ -169,9 +170,10 @@
#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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrap @fix in backticks to prevent platform mention interpretation.

Suggested change
// TheSuperHackers @fix bobtista 12/02/2026 Prefer HKCU for writes to match read priority
// TheSuperHackers `@fix` bobtista 12/02/2026 Prefer HKCU for writes to match read priority

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: Core/Libraries/Source/WWVegas/WWDownload/registry.cpp
Line: 173:173

Comment:
Wrap `@fix` in backticks to prevent platform mention interpretation.

```suggestion
	// TheSuperHackers `@fix` bobtista 12/02/2026 Prefer HKCU for writes to match read priority
```

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

How can I resolve this? If you propose a fix, please make it concise.

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 );
}

8 changes: 4 additions & 4 deletions Generals/Code/GameEngine/Source/Common/System/registry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions GeneralsMD/Code/GameEngine/Source/Common/System/registry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
Loading