Skip to content

About

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.

Resources

Stars

3 stars

Watchers

1 watching

Forks

Repository files navigation

Stronghold 2 Unofficial Patch

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.

License: Unlicense

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/


Overview

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

Goals and Non-Goals

Goals

  • 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

Non-Goals (for now)

  • Content additions (new units, buildings, missions)

Current Fixes and Features

v0.7.0

Description Offset Status
Knight/catapult mount crash base+0x1048BB Fixed in v0.1.0
AI opponents in multiplayer lobbies base+0x2A0F69 Added in v0.2.0
Skip Firefly logo intro on launch base+0x4DA9F8, base+0x27BB0D Added in v0.2.0
MP connect-complete crash base+0x3d85c6 Added in v0.3.0
End-of-game statistics overlay base+0x297fa0, base+0x297700 Added in v0.3.0
Stop selected troops hotkey (H) base+0xf3140 Added in v0.4.0
Barracks UI crash on Lord death base+0x2207c6 Fixed in v0.4.0
Attack-move toggle hotkey (Mouse4) base+0x22e7d0, base+0x300e1 Added in v0.5.0
Configurable camera zoom speed (opt-in) base+0x3623D8 Added in v0.5.0
Out-of-bounds troop formation crash base+0x37dd6b Fixed in v0.5.0
Configuration file (sh2-unofficial-patch.ini) — Added in v0.5.0
Shift-click batch recruitment base+0x22083a, base+0x223ca9, base+0x223dc9, base+0x225622, base+0x228539, base+0x5ccba4 Added in v0.6.0
Auto-market with in-game editor (`) base+0x21da50, base+0x1e1160, base+0x37efb0, base+0x6bcfd8 Added in v0.6.0
Siege camp hotkey (J) opens the panel before moving the camera base+0x1f2c65, base+0x1f2c99 Added in v0.6.0
Key combinations (Ctrl/Shift/Alt) for the patch hotkeys, plus the in-game rebind widget — Added in v0.6.0
In-game settings panel for hotkeys and every patch setting (Ctrl+Shift+O) — Added in v0.6.0, extended in v0.7.0
Overlay panels scale to the game's resolution instead of the desktop DPI — Added in v0.6.1
Zoom out to the furthest usable distance (opt-in) base+0x362480 Added in v0.7.0
In-progress games hidden from the multiplayer browser base+0x3e065b, base+0x3e06bf Fixed in v0.7.0
!ping chat command showing per-player latency base+0x24d8e0, base+0x3d88c0 Added in v0.7.0
Configurable camera pan speed (opt-in) base+0x1f9d86 Added in v0.7.0

Roadmap

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

Prerequisites

Linux / WSL (recommended)

sudo apt install gcc-mingw-w64-i686 g++-mingw-w64-i686

Windows (native MinGW)

Install MinGW-w64 with i686 (32-bit) target support and ensure i686-w64-mingw32-g++ is on your PATH.


Building

make          # release build → d3d9.dll
make debug    # debug build   → d3d9.dll (with file logging enabled)
make clean    # remove build artifacts

Installation

  1. Build d3d9.dll (see above)
  2. Copy it into the Stronghold 2 game directory.
  3. Launch the game normally through Steam. The patch loads automatically.

To uninstall: delete d3d9.dll from the game directory.


Configuration (optional)

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 Logging

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


Reporting Bugs

If you've found a crash or other bug, please report it so it can be investigated and fixed.

How to open a report

Option 1 — GitHub (preferred, keeps everything public and trackable):

  1. 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.)
  2. Click the green New issue button.
  3. Give your issue a short title, e.g. "Game crashes when catapult fires at a wall".
  4. 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.

What to include

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:

  1. Press Win + R, type eventvwr, and press Enter. This opens Event Viewer.
  2. In the left panel, expand Windows Logs and click Application.
  3. Look through the list for a red Error entry that appeared around the time of the crash. The source will usually be Application Error.
  4. Double-click that entry to open it.
  5. 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.


Contributing

This is an open reverse-engineering project. Contributions are welcome.

Before submitting a fix:

  1. Document the bug in docs/bugs/ — symptom, disassembly, root cause, game version/offset
  2. Confirm the offset against a clean Steam install
  3. Test the fix by reproducing the original crash scenario and verifying it no longer occurs
  4. Add an entry to CHANGELOG.md and 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.


Acknowledgements

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.


License

This project is released into the public domain under the Unlicense.

About

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.

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages