fix(renhdrum): the release builds renhdrum.dll for Windows, refuses a Linux one, and the game falls back without a Bad Image box #1778

Merged
HumanBean merged 2 commits from HumanBean/Longshot:fix/renhdrum-windows-target into main 2026-11-19 19:17:33 +00:00
Owner

Type: fix · Risk: low · Tested on: none (read only; Linux PC, Windows-only change) · Needs: Windows, any GPU

TL;DR

Since DualSense haptics merged (#405), a Windows build stops at start with a "Bad Image" box naming renhdrum.dll. The release built that file on its Linux runner without saying "for Windows", so it shipped a Linux library under a Windows name. This PR builds it for Windows, makes the release refuse a library of the wrong kind, and lets the game skip an unusable one with no box. Its controllers then keep their motors. A new game-free test fails on main for this reason.

Breakdown

  • Who it helps: every Windows player whose build came from a release made after #405 merged.
  • What was wrong: the release built renhdrum.dll as a Linux library, and Windows won't load one (error 0xc000012f).
  • What changes: the release builds a real Windows DLL and refuses to package anything else, and the game no longer shows a box when the DLL can't load.
  • What does not change: haptics with a good DLL, the Linux AppImage's renhdrum.so (already built with --target linux), defaults and saves.
  • How it was checked: read through; a new test case for each part. No tests or game runs on this PC (see Testing).
  • What is still open: a Windows run, through Beanstalk: a bad renhdrum.dll gives no box, and a good one still loads.
  • Risk: low. CI flag, a stricter package check, and an error mode wrapped around one LoadLibraryExW.

Why

A player's report: longshot.exe - Bad Image: C:\Recomp Library\longshot\Longshot\bin\renhdrum.dll is either not designed to run on Windows or it contains an error. ... Error status 0xc000012f. 0xc000012f is STATUS_INVALID_IMAGE_NOT_MZ: the file isn't a PE at all.

.forgejo/workflows/build-windows.yml runs scripts/renhdrum.py build --llvm-mingw ... with no --target. cmd_build falls back to the system it runs on (a.target or host()), and the release runner is Linux. So it built x86_64-unknown-linux-gnu, an ELF, and --out named it renhdrum.dll. problems() accepts any x86-64 library, ELF or PE, so builder_package.py --renhdrum packaged it. check_windows_files.py only checks that the file is there. A player's build copies it into bin\. host/rumble_renhdrum.c then loads it with no error mode set, so Windows shows its modal box.

How to reproduce

Seen on: Windows, a build from a release made after #405 merged
Settings and switches: defaults
Steps: start the game
Expected: the game starts; a DualSense's haptics come from RenHDrum
Actual: "Bad Image" box for bin\renhdrum.dll, error 0xc000012f. Deleting that file lets the game start, with motors for vibration.

What changed

The release now builds RenHDrum for Windows. Three checks would each have stopped this one: the build, the package step and the zip check. The game also treats an unusable DLL like a missing one.

  • CI: .forgejo/workflows/build-windows.yml passes --target windows.
  • check: problems(data, target) in scripts/renhdrum.py refuses the other system's format ("a Linux (ELF) library, not a Windows DLL"). build passes its target. check takes the target from the file's .dll/.so extension.
  • package: scripts/builder_package.py --renhdrum wants a Windows DLL. scripts/check_windows_files.py wants the zip's tools/third_party/renhdrum/renhdrum.dll to be an x86-64 PE.
  • host: open_library() in host/rumble_renhdrum.c loads under SetThreadErrorMode(SEM_FAILCRITICALERRORS) and puts the thread's mode back afterwards. An unusable file is logged (vibration: RenHDrum: renhdrum.dll would not load (error 193)) and its controllers keep their motors.
  • test: tests/test_renhdrum.py adds three cases. check must refuse an ELF named .dll and a PE named .so. builder_package.package() must refuse an ELF as --renhdrum. The workflow step must pass --target windows. Test and fix are separate commits.

Measurements

Verdict: nothing to measure: a build-step and load-error fix. The game-free test is the evidence, and it wasn't run on this PC (see Testing).

Flags and settings

None.

Testing

Tested: nothing run on this PC: no tests and no game runs, by the PC owner's rule. The change was read through against main. The Build cases in tests/test_renhdrum.py already hand a PE to the Windows build and an ELF to the Linux build, so they match the stricter problems().

Not testable by hand: the host change is Windows-only code, and this PC is Linux. A Linux run of the game wouldn't exercise it. Beanstalk's Windows runners stand in.

Not tested: tests/test_renhdrum.py on main (expected to fail in test_the_other_systems_format, test_the_package (elf.dll) and test_the_release_builds_and_packs_it) and on this branch (expected to pass). Forgejo's CI runs the suite. The release workflow itself runs on the next nightly.

Must be tested:

  • Windows, any GPU: put a Linux library (or any non-PE file) at bin\renhdrum.dll and start the game. Expect no "Bad Image" box, and the log says renhdrum.dll would not load. Then a good renhdrum.dll from this branch's release build: expect renhdrum.dll ... loaded in the log (Test Farm: @Beanstalk windows).
  • The next nightly's renhdrum.dll step logs --target x86_64-pc-windows-gnullvm, and check_windows_files.py passes (by hand: the release run's log).

Risks

What could break: a stricter check could refuse a good DLL if pe_info misreads one. It already reads the same file today, so the only new refusal is an ELF under .dll or a non-ELF under .so.

Turning it off: revert the commit.

Compatibility: the next build replaces the bad renhdrum.dll in bin\, since copy_renhdrum and the finish's staging compare size and bytes. Nothing else changes.

Checklist

Everyone

  • One topic.
  • The title is a Conventional Commit (type(scope): description) of the status line's type.
  • Why gives the reason plainly and links the issues that fit (the tracker searched).
  • Tested on my own PC where it runs (in the game, for a change the game runs), as Testing's Tested says; what
    can't be run by hand is in Testing's Not testable by hand, with why. (Windows-only change, Linux PC: Beanstalk asked)
  • Measurements has a verdict, or one line saying why there is nothing to measure.
  • Nothing gets worse that I know of: any cost (speed, latency, memory, a setup that worked before) is measured and
    in Risks.
  • Testing names what was tested, what wasn't, and what must still be tested, where and how.
  • Rebased on current main.
  • python -I -B tests/run_all.py passes (any failure that also fails on main is named). (not run on this PC: Forgejo's CI)
  • No game files, dumps, build output or generated files.
  • third_party/ untouched (a new folder with a PROVENANCE.md instead).
  • The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled.

When it applies

  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.
  • A game-free test added for the fix, failing on main and passing here. (added; not run on this PC)
  • A check under tests/ that reads changed source updated in this PR, not weakened.
  • Host code builds on both Windows (llvm-mingw) and Linux, with UTF-8 paths. (not compiled here; the change is inside #ifdef _WIN32, and SetThreadErrorMode is in mingw's windows.h)

🤖 Generated with Claude Code

**Type:** fix · **Risk:** low · **Tested on:** none (read only; Linux PC, Windows-only change) · **Needs:** Windows, any GPU ## TL;DR Since DualSense haptics merged ([#405](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/405)), a Windows build stops at start with a "Bad Image" box naming `renhdrum.dll`. The release built that file on its Linux runner without saying "for Windows", so it shipped a Linux library under a Windows name. This PR builds it for Windows, makes the release refuse a library of the wrong kind, and lets the game skip an unusable one with no box. Its controllers then keep their motors. A new game-free test fails on main for this reason. ## Breakdown - **Who it helps:** every Windows player whose build came from a release made after #405 merged. - **What was wrong:** the release built `renhdrum.dll` as a Linux library, and Windows won't load one (error 0xc000012f). - **What changes:** the release builds a real Windows DLL and refuses to package anything else, and the game no longer shows a box when the DLL can't load. - **What does not change:** haptics with a good DLL, the Linux AppImage's `renhdrum.so` (already built with `--target linux`), defaults and saves. - **How it was checked:** read through; a new test case for each part. No tests or game runs on this PC (see Testing). - **What is still open:** a Windows run, through Beanstalk: a bad `renhdrum.dll` gives no box, and a good one still loads. - **Risk:** low. CI flag, a stricter package check, and an error mode wrapped around one `LoadLibraryExW`. ## Why A player's report: `longshot.exe - Bad Image: C:\Recomp Library\longshot\Longshot\bin\renhdrum.dll is either not designed to run on Windows or it contains an error. ... Error status 0xc000012f.` 0xc000012f is `STATUS_INVALID_IMAGE_NOT_MZ`: the file isn't a PE at all. `.forgejo/workflows/build-windows.yml` runs `scripts/renhdrum.py build --llvm-mingw ...` with no `--target`. `cmd_build` falls back to the system it runs on (`a.target or host()`), and the `release` runner is Linux. So it built `x86_64-unknown-linux-gnu`, an ELF, and `--out` named it `renhdrum.dll`. `problems()` accepts any x86-64 library, ELF or PE, so `builder_package.py --renhdrum` packaged it. `check_windows_files.py` only checks that the file is there. A player's build copies it into `bin\`. `host/rumble_renhdrum.c` then loads it with no error mode set, so Windows shows its modal box. ## How to reproduce **Seen on:** Windows, a build from a release made after #405 merged **Settings and switches:** defaults **Steps:** start the game **Expected:** the game starts; a DualSense's haptics come from RenHDrum **Actual:** "Bad Image" box for `bin\renhdrum.dll`, error 0xc000012f. Deleting that file lets the game start, with motors for vibration. ## What changed The release now builds RenHDrum for Windows. Three checks would each have stopped this one: the build, the package step and the zip check. The game also treats an unusable DLL like a missing one. - CI: `.forgejo/workflows/build-windows.yml` passes `--target windows`. - check: `problems(data, target)` in `scripts/renhdrum.py` refuses the other system's format ("a Linux (ELF) library, not a Windows DLL"). `build` passes its target. `check` takes the target from the file's `.dll`/`.so` extension. - package: `scripts/builder_package.py --renhdrum` wants a Windows DLL. `scripts/check_windows_files.py` wants the zip's `tools/third_party/renhdrum/renhdrum.dll` to be an x86-64 PE. - host: `open_library()` in `host/rumble_renhdrum.c` loads under `SetThreadErrorMode(SEM_FAILCRITICALERRORS)` and puts the thread's mode back afterwards. An unusable file is logged (`vibration: RenHDrum: renhdrum.dll would not load (error 193)`) and its controllers keep their motors. - test: `tests/test_renhdrum.py` adds three cases. `check` must refuse an ELF named `.dll` and a PE named `.so`. `builder_package.package()` must refuse an ELF as `--renhdrum`. The workflow step must pass `--target windows`. Test and fix are separate commits. ## Measurements **Verdict:** nothing to measure: a build-step and load-error fix. The game-free test is the evidence, and it wasn't run on this PC (see Testing). ### Flags and settings None. ## Testing **Tested:** nothing run on this PC: no tests and no game runs, by the PC owner's rule. The change was read through against main. The `Build` cases in `tests/test_renhdrum.py` already hand a PE to the Windows build and an ELF to the Linux build, so they match the stricter `problems()`. **Not testable by hand:** the host change is Windows-only code, and this PC is Linux. A Linux run of the game wouldn't exercise it. Beanstalk's Windows runners stand in. **Not tested:** `tests/test_renhdrum.py` on main (expected to fail in `test_the_other_systems_format`, `test_the_package` (`elf.dll`) and `test_the_release_builds_and_packs_it`) and on this branch (expected to pass). Forgejo's CI runs the suite. The release workflow itself runs on the next nightly. **Must be tested:** - Windows, any GPU: put a Linux library (or any non-PE file) at `bin\renhdrum.dll` and start the game. Expect no "Bad Image" box, and the log says `renhdrum.dll would not load`. Then a good `renhdrum.dll` from this branch's release build: expect `renhdrum.dll ... loaded` in the log (Test Farm: @Beanstalk windows). - The next nightly's `renhdrum.dll` step logs `--target x86_64-pc-windows-gnullvm`, and `check_windows_files.py` passes (by hand: the release run's log). ## Risks **What could break:** a stricter check could refuse a good DLL if `pe_info` misreads one. It already reads the same file today, so the only new refusal is an ELF under `.dll` or a non-ELF under `.so`. **Turning it off:** revert the commit. **Compatibility:** the next build replaces the bad `renhdrum.dll` in `bin\`, since `copy_renhdrum` and the finish's staging compare size and bytes. Nothing else changes. ## Checklist ### Everyone - [x] One topic. - [x] The title is a Conventional Commit (`type(scope): description`) of the status line's type. - [x] Why gives the reason plainly and links the issues that fit (the tracker searched). - [ ] Tested on my own PC where it runs (in the game, for a change the game runs), as Testing's Tested says; what can't be run by hand is in Testing's Not testable by hand, with why. (Windows-only change, Linux PC: Beanstalk asked) - [x] Measurements has a verdict, or one line saying why there is nothing to measure. - [x] Nothing gets worse that I know of: any cost (speed, latency, memory, a setup that worked before) is measured and in Risks. - [x] Testing names what was tested, what wasn't, and what must still be tested, where and how. - [x] Rebased on current `main`. - [ ] `python -I -B tests/run_all.py` passes (any failure that also fails on `main` is named). (not run on this PC: Forgejo's CI) - [x] No game files, dumps, build output or generated files. - [x] `third_party/` untouched (a new folder with a `PROVENANCE.md` instead). - [x] The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled. ### When it applies - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. - [ ] A game-free test added for the fix, failing on `main` and passing here. (added; not run on this PC) - [x] A check under `tests/` that reads changed source updated in this PR, not weakened. - [ ] Host code builds on both Windows (llvm-mingw) and Linux, with UTF-8 paths. (not compiled here; the change is inside `#ifdef _WIN32`, and `SetThreadErrorMode` is in mingw's `windows.h`) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The Windows release's renhdrum.dll step ran scripts/renhdrum.py build with no --target on the
Linux release runner, so it built an x86-64 ELF and named it renhdrum.dll. The check accepted
any x86-64 library, so builder_package.py shipped it, and Windows refuses to load it with a
"Bad Image" box (0xc000012f) at the game's start. Fails on main.

Assisted-by: Claude Code
Co-Authored-By: Claude Opus 5.5 <[email protected]>
fix(renhdrum): the release builds renhdrum.dll for Windows, refuses a Linux one, and the game falls back without a Bad Image box
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request_target) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 15s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 20s
CI / Workflow lint (actionlint) (pull_request) Successful in 21s
Third-party parts / As their notes say (pull_request) Successful in 24s
beanstalk/approval needs a second approval (sensitive paths)
PR description / Description follows the template (pull_request_target) Failing after 9s
fc7a0722b3
The Windows release built RenHDrum on its Linux runner with no --target, so renhdrum.dll was an
x86-64 ELF. Windows refused it at the game's start with "renhdrum.dll is either not designed to
run on Windows or it contains an error. Error status 0xc000012f".

- build-windows.yml: --target windows.
- scripts/renhdrum.py: problems() takes the system the library is for and refuses the other
  system's format; check infers it from .dll/.so, build passes its target.
- builder_package.py --renhdrum: wants a Windows DLL. check_windows_files.py: the zip's
  renhdrum.dll is an x86-64 PE.
- host/rumble_renhdrum.c: the load runs with SEM_FAILCRITICALERRORS, so a file Windows can't
  load is logged and its controllers keep their motors, with no dialog.

Assisted-by: Claude Code
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Owner

@Beanstalk on Windows (any GPU), with this branch's build: (1) replace bin\renhdrum.dll with a file that is not a Windows DLL (for example renhdrum.so from the Linux AppImage, renamed) and start the game: expect no "Bad Image" box, the game reaching the title screen, and "vibration: RenHDrum: renhdrum.dll would not load" in longshot_log.txt; (2) put back the renhdrum.dll this branch's build placed and start again: expect "renhdrum.dll ... loaded" in the log.

@Beanstalk on Windows (any GPU), with this branch's build: (1) replace bin\renhdrum.dll with a file that is not a Windows DLL (for example renhdrum.so from the Linux AppImage, renamed) and start the game: expect no "Bad Image" box, the game reaching the title screen, and "vibration: RenHDrum: renhdrum.dll would not load" in longshot_log.txt; (2) put back the renhdrum.dll this branch's build placed and start again: expect "renhdrum.dll ... loaded" in the log.
Member

@HumanBean approval of fc7a072 recorded. This diff touches sensitive paths, so a second member of BigBeans must approve it too.

@HumanBean approval of `fc7a072` recorded. This diff touches sensitive paths, so a second member of `BigBeans` must approve it too.
Member

Beanstalk test farm

Commit fc7a072 · tier untrusted · approved by HumanBean · dashboard

This diff touches sensitive paths, so it needs two members of BigBeans: .forgejo/workflows/build-windows.yml

A member of BigBeans can review this commit and comment @Beanstalk to test it.

<!-- beanstalk:sticky --> ### Beanstalk test farm Commit `fc7a072` · tier **untrusted** · approved by HumanBean · [dashboard](https://beanstalk.magicbean.dev/prs/1778) This diff touches sensitive paths, so it needs two members of `BigBeans`: `.forgejo/workflows/build-windows.yml` A member of `BigBeans` can review this commit and comment `@Beanstalk` to test it.
HumanBean changed title from WIP: fix(renhdrum): the release builds renhdrum.dll for Windows, refuses a Linux one, and the game falls back without a Bad Image box to fix(renhdrum): the release builds renhdrum.dll for Windows, refuses a Linux one, and the game falls back without a Bad Image box 2026-11-19 19:17:26 +00:00
HumanBean deleted branch fix/renhdrum-windows-target 2026-11-19 19:17:33 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!1778
No description provided.