An unofficial community patch for Stronghold 2 (Firefly Studios, 2005) fixing crashes, restoring missing functionality, and improving quality of life — all while remaining fully compatible with vanilla saves and stock installs.
Playing rather than building? The player site has install instructions and a plain-English list of everything the patch fixes: https://b1naryvision.github.io/sh2-unofficial-patch/
The patch is delivered as a d3d9.dll that sits in the game directory. Windows loads it automatically via DLL search order before the system d3d9.dll. It forwards all legitimate d3d9.dll API calls to the real system library, then installs targeted detour hooks to fix specific bugs in the game binary.
No game files are modified. Removing the DLL restores the original behavior completely.
- Target: Stronghold 2, Steam build v1.5.0
- Architecture: 32-bit x86 Windows PE
- Development environment: Linux/WSL with MinGW cross-compiler
- Fix crashes and memory corruption bugs
- Restore suppressed or broken functionality to its intended state
- Improve quality of life
- Remain compatible with vanilla Steam installs and existing saves
- Remain unobtrusive — zero overhead in release builds
- Balance changes or rebalancing of existing mechanics
- Content additions (new units, buildings, missions)
Items under active investigation or queued for a future release.
The following are implemented but excluded from the build until the patch has broader adoption — all of them require all players to run the same patch version to avoid multiplayer desyncs:
| Description | Notes |
|---|---|
| Field ballista auto-fire restore | Modifies unit health state each tick |
| Unit cap raise (550 in all lobby sizes) | Per-player cap enforced locally; patched vs unpatched clients diverge |
| Disband peasant duplication fix | Rapid-clicking Disband refunds a peasant per click instead of per unit; the fix changes how many peasants the campfire gets back, so patched vs unpatched clients diverge |
The following is on hold, excluded from the build pending further work in a future release:
| Description | Notes |
|---|---|
| Multiplayer recovery saves | Save engine works, but calling it live kicks a networked match to the lobby; being redesigned to save at session-end (graceful drops only). See the doc's verification log |
| Priority | Type | Description | Requested by |
|---|---|---|---|
| Medium | Bug fix | Wheat Farmers and Candle Makers should not be eligible to become criminals — they get permanently stuck inside buildings | TheSettler |
| Low | Feature | Checkbox to disable market placement in No Market multiplayer games | Ignite |
sudo apt install gcc-mingw-w64-i686 g++-mingw-w64-i686Install MinGW-w64 with i686 (32-bit) target support and ensure i686-w64-mingw32-g++ is on your PATH.
make # release build → d3d9.dll
make debug # debug build → d3d9.dll (with file logging enabled)
make clean # remove build artifacts- Build
d3d9.dll(see above) - Copy it into the Stronghold 2 game directory.
- Launch the game normally through Steam. The patch loads automatically.
To uninstall: delete d3d9.dll from the game directory.
Copy sh2-unofficial-patch.ini next to d3d9.dll
in the game directory to rebind or disable the hotkeys and to opt into a
faster camera zoom, a faster camera pan or a higher zoom-out limit. Every
setting is documented inside the file; without it the defaults apply (Stop
troops: H, attack-move toggle: Mouse4, stock camera speeds and zoom-out
limit).
Every one of those settings can also be changed in game with Ctrl+Shift+O,
which applies it to the running game and writes it back to the ini — see
docs/features/settings-overlay.md.
See docs/features/configuration.md
for details.
Debug builds (make debug) write a patch_debug.txt log to the working directory when the game runs. This records the register context at each hooked call site. Release builds produce no log output and have zero logging overhead.
Log location: <Stronghold 2 game directory>\patch_debug.txt
If you've found a crash or other bug, please report it so it can be investigated and fixed.
Option 1 — GitHub (preferred, keeps everything public and trackable):
- Go to the Issues page on GitHub. (GitHub is a free website — you'll need to create an account if you don't have one.)
- Click the green New issue button.
- Give your issue a short title, e.g. "Game crashes when catapult fires at a wall".
- Fill in the description using the information below, then click Submit new issue.
Option 2 — Discord (if you'd rather not sign up for GitHub):
Send a direct message to BinaryVision (196165954042986496) on Discord with the same details listed below.
Required — describe what happened:
- What were you doing when the crash or bug occurred? For example: Multiplayer, Kingmaker or a mission? Which units were involved, and roughly how far into the game it happened.
- What steps would someone else need to take to make it happen again? The more specific the better — "it crashed randomly" is hard to investigate; "it always crashes when I fire the catapult at knights in the process of mounting" can be fixed.
Required — attach the Windows error log:
Windows automatically records crash details. Here's how to find them:
- Press Win + R, type
eventvwr, and press Enter. This opens Event Viewer. - In the left panel, expand Windows Logs and click Application.
- Look through the list for a red Error entry that appeared around the time of the crash. The source will usually be
Application Error. - Double-click that entry to open it.
- Copy the full text from the General tab and paste it into your report. The lines that start with Faulting application name and Fault offset are the most important.
If there is also a patch_debug.txt file in your Stronghold 2 game folder, please attach that too. (See Debug Logging above for where to find it.)
Optional but very helpful:
- A short video or screen recording of the crash happening — even 10–15 seconds showing what you were doing just before the crash can make a big difference.
The more detail you can provide, the faster a fix can be found and verified.
This is an open reverse-engineering project. Contributions are welcome.
Before submitting a fix:
- Document the bug in
docs/bugs/— symptom, disassembly, root cause, game version/offset - Confirm the offset against a clean Steam install
- Test the fix by reproducing the original crash scenario and verifying it no longer occurs
- Add an entry to
CHANGELOG.mdand the fix table in this README
See docs/architecture.md for technical background on the hook infrastructure, naming conventions, and safe patching patterns.
If an antivirus product flags a release, see docs/antivirus-false-positive.md for why it happens and the report template to send the vendor.
TheSettler — Primary multiplayer co-tester, invaluable in verifying that each release stays fully compatible with vanilla Stronghold 2 installs. Also a key source of ideas for improvements to the game.
Ignite — Ongoing assistance debugging patch loading issues on Windows 10, and a steady stream of ideas for features and fixes that have shaped the project's direction.
SD7804 — Instrumental in finding the relevant memory locations for the end-of-game statistics feature.
This project is released into the public domain under the Unlicense.