Skip to content

Keep a copy in Downloads from running what lies beside it - #35

Merged
geeooff merged 3 commits into
mainfrom
dll-search
Nov 24, 2026
Merged

geeooff merged 3 commits into
mainfrom
dll-search

Conversation

@geeooff

@geeooff geeooff commented Nov 24, 2026

Copy link
Copy Markdown
Owner

A copy unpacked in Downloads ran or loaded whatever lay beside it. Three commits close the three ways it did.

What changes

  • Windows programs by full path (57e7670): Windows PowerShell (the updater's after-exit shell, purge) and schtasks.exe (the leftover-task check of add-to-startup, remove-from-startup, purge) start from win::system_dir(), which is GetSystemDirectoryW, with no fallback to the name. Given a bare name, std searches the executable's own folder first, as Command::new documents.
  • DLLs from System32 only (16559ab): build.rs links both executables with /DEPENDENTLOADFLAG:0x800. msi.dll, winhttp.dll, bcrypt.dll and VCRUNTIME140.dll are not known DLLs, so they were looked for beside the executable first. build.ps1 build reads the flag back from the PE.
  • The C runtime built in (ffdadba): +crt-static in .cargo/config.toml. VCRUNTIME140.dll comes with the Visual C++ Redistributable, which the package never installed. build.ps1 build checks that no executable imports a DLL of the Redistributable.

Measured (2026-11-24, this machine)

published 0.5.0 this branch
stand-in schtasks.exe beside a copy, purge stopped at its question ran; the plan announced a logon task that does not exist not run
stand-in msi.dll beside a copy, --version loaded, before main not loaded
gamemode-executor.exe size 1,589,760 1,685,504
  • A stand-in bcryptprimitives.dll was loaded by neither, since a system DLL had already loaded Windows' own.
  • A hybrid CRT, with vcruntime linked in and the UCRT from Windows, weighs 1,610,752 and keeps the UCRT serviced by Windows Update, at the price of two linker overrides. It was not chosen; this choice is yours to review.
  • Installed here since 11:33 (build 909f77b7, the same code before a test-only line was added). The watcher started, and msi, winhttp, bcrypt and bcryptprimitives were loaded from System32. No vcruntime140.dll was loaded, and no module came from the install folder.
  • build.ps1 build passes, including the two new steps.

Not verified

  • A start on a Windows without the Redistributable. The import table no longer names it.
  • The setup-command paths end to end. The package path needs an uninstall and install by hand, outside the MSIX container. The zip's after-exit shell and a real purge need the next release. The hidden shell's spawn is covered by the two purge tests that run it for real, and schtasks.exe's by its unit test.

Not in this PR

  • User-configured programs given by bare name (actions.rs; the recipes' schtasks.exe and powercfg.exe) still go through std's search. That fix is handed to another session.

🤖 Generated with Claude Code

geeooff and others added 3 commits November 24, 2026 11:35
Given a bare name, std's Command searches the running executable's own
folder before System32 and PATH, as Command::new documents, so a copy
unpacked in Downloads would have run a powershell.exe or schtasks.exe
lying beside it: the updater's after-exit shell, purge's, and the setup
commands' removal of the old logon task. Both now come from the folder
GetSystemDirectoryW names, with no fallback to the name. win::system_dir
carries the rule, AGENTS.md the pitfall; a test per module checks the
program each builds.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The imports that are not known DLLs -- msi.dll, winhttp.dll, bcrypt.dll,
VCRUNTIME140.dll -- were looked for in the executable's own folder first,
so a copy unpacked in Downloads loaded whatever lay beside it, before
main. build.rs now links both executables with /DEPENDENTLOADFLAG:0x800
(LOAD_LIBRARY_SEARCH_SYSTEM32). Measured with a stand-in msi.dll beside a
copy: the published 0.5.0 loaded it, this build does not.

build.ps1 build reads the flag back from the PE load configuration, since
losing it would change nothing anyone sees.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The dynamic runtime needs VCRUNTIME140.dll, which comes with the Visual
C++ Redistributable, not with Windows, and the package never installed
it: on a Windows without it the program would not start. A
.cargo/config.toml now builds every MSVC target with +crt-static, the
switch Rust documents; each executable grows by 97 KB, to 1.65 MB.

A hybrid (vcruntime static, the UCRT from Windows) would weigh 22 KB and
keep the UCRT serviced by Windows Update, at the price of two linker
overrides; the design record has the figures. build.ps1 build checks
that no executable imports a DLL of the Redistributable.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@geeooff
geeooff merged commit 8863ade into main Nov 24, 2026
2 checks passed
@geeooff
geeooff deleted the dll-search branch November 24, 2026 10:59
@geeooff
geeooff restored the dll-search branch November 24, 2026 11:00
@geeooff
geeooff deleted the dll-search branch November 24, 2026 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant