hle: Get and SetEnvironmentVariable over the process environment #75
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-26T13:41:22Z.
What 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)Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T14:55:56Z.
Review: CHANGES_REQUESTED
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).Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-26T15:01:20Z.
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.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T16:03:55Z.
Review: APPROVED
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.