hle: Get and SetEnvironmentVariable over the process environment #75
No reviewers
Labels
No labels
accessibility
bug
claimed
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
tester report
urgent
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LakshanSivakumar--Native-Victory-macOS!75
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-75"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Olima34 on GitHub · 2026-11-26 13:41 UTC · original
Olima34:feat/hle-environment-variables→main· +149 −1 · 2 files · 3 commits · merged 2026-11-26 17:05 UTCWhat this changes
Both Series S tester logs (#66, #68) show the AMD FidelityFX upscaler DLL calling
GetEnvironmentVariableAandSetEnvironmentVariableAthroughapi-ms-win-core-processenvironment-l1-1-0.dll, which fell to the unimplemented-import stub returning 0. The A and W forms are now insystem.rs, as Microsoft documents them: the length without the NUL, the room the value and its NUL need when the buffer is too small,ERROR_ENVVAR_NOT_FOUNDfor a missing variable, and a null value removes it. Names match ignoring case.They work on the process environment the C runtime's
getenvand_putenvalready use, so a variable set either way is seen both ways. Windows' CRT keeps its own copy, whichSetEnvironmentVariabledoes not update; this is noted in docs/native-host.md. Names containing=are refused, since the host environment cannot hold them (Windows' hidden=C:variables).New test
environment_variables_are_set_read_and_removed_ignoring_case, which also checks that the API set resolves the functions.How it was tested
cargo test --target x86_64-apple-darwin -p victory-hle -p victory-loader -p victory(all pass, native probe tests included)cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings, also with--all-features; clippy forx86_64-apple-darwinreports nothing in the files touched (host_posixis not built for Windows)cargo test --workspaceandcargo xtask policymainand passes with the changeChecklist
VICTORY_*variable and documented (none added)@LakshanSivakumar on GitHub · 2026-11-26 14:55 UTC · original · requested changes
Get/SetEnvironmentVariable A/W look right. One issue: set_env in system.rs calls std::env::set_var/remove_var from title threads, which races with concurrent getenv. Please guard it with a lock (or add a
shortcut:comment explaining the limit).@Olima34 on GitHub · 2026-11-26 15:01 UTC · original
Done in the latest commit. A lock alone would not stop the race you describe:
std::env::set_var/varalready take std's own environment lock, and both the C runtime'sgetenv(env_value) andGetEnvironmentVariablego throughstd::env. What can still race is host C code calling libc'sgetenvdirectly, which no lock of ours covers, so that limit is now ashortcut:comment. I did add a lock where it does help:set_envholds it across finding the existing name (ignoring case) and setting it, so two title threads settingFooandFOOcan no longer make two variables.@LakshanSivakumar on GitHub · 2026-11-26 16:03 UTC · original · approved these changes
Agreed that a lock would add nothing over std's own environment lock; the commit now says what still races (host C code calling libc getenv directly). CI is green. Approving.