fix(registry): prioritize HKEY_CURRENT_USER over HKEY_LOCAL_MACHINE #1844
fix(registry): prioritize HKEY_CURRENT_USER over HKEY_LOCAL_MACHINE #1844bobtista wants to merge 3 commits intoTheSuperHackers:mainfrom
Conversation
…o prevent stale values
|
Imagine the following:
could this be an issue, or is there a key generated for user2 as well? |
Ok changed it so: This is good enough for this issue/change IMHO - Eventually, we should probably have intentional “is this setting global or per-user?” code in the game logic rather than relying on whether the user ran the game as admin or not. |
|
|
||
| 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)) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
|
| Filename | Overview |
|---|---|
| Core/Libraries/Source/WWVegas/WWDownload/registry.cpp | Correctly prioritizes HKCU over HKLM for both reads and writes. Minor formatting issue with @ symbols in comments. |
| Generals/Code/GameEngine/Source/Common/System/registry.cpp | Correctly prioritizes HKCU over HKLM for read operations. No write functions present in this file. |
| GeneralsMD/Code/GameEngine/Source/Common/System/registry.cpp | Correctly prioritizes HKCU over HKLM for read operations. No write functions present in this file. |
Flowchart
flowchart TD
A[Registry Read Request] --> B{Check HKEY_CURRENT_USER}
B -->|Found| C[Return Value]
B -->|Not Found| D{Check HKEY_LOCAL_MACHINE}
D -->|Found| C
D -->|Not Found| E[Return Failure]
F[Registry Write Request] --> G{Try Write to HKEY_CURRENT_USER}
G -->|Success| H[Return Success]
G -->|Failure| I{Try Write to HKEY_LOCAL_MACHINE}
I -->|Success| H
I -->|Failure| J[Return Failure]
style B fill:#90EE90
style G fill:#90EE90
style D fill:#FFB6C1
style I fill:#FFB6C1
Last reviewed commit: 4d47837
| 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 |
There was a problem hiding this comment.
Wrap @fix in backticks to prevent platform mention interpretation.
| // 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.| 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 |
There was a problem hiding this comment.
Wrap @fix in backticks to prevent platform mention interpretation.
| // 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.
Per-user settings (e.g. HTTP Proxy) should always go in HKEY_CURRENT_USER.
Flips both read and write priority to prefer HKCU over HKLM across all registry helpers, with HKLM as fallback. This prevents stale HKCU values when the game is run with admin privileges.