Modding Tip: Attaching a Debugger to a Steam Game

Problem

When attaching a debugger to a Steam game process, the game crashes as soon as it tries to stop at a breakpoint.

I encountered this while working on the FRIK mod for Fallout 4 VR. I could attach to the process, pause it, and even break on exceptions — but any attempt to hit a breakpoint resulted in an immediate crash. A quick Google search didn’t yield anything useful, so I’m hoping this post will help others facing the same issue.

Reason

Steam games use Steam DRM, also known as SteamStub, via the Steamworks SDK. It’s intended to protect games from piracy, cheating, and unauthorized early access. However, from what I’ve seen, these protections are relatively weak — it’s not hard to strip them.

Steam DRM works by optionally encrypting and wrapping the game’s executable. When the modified executable is launched, a DRM “stub” runs first. This stub:

  1. Verifies that the game is being launched through an authenticated Steam instance.
  2. (If applicable) Decrypts the original game code.
  3. Passes control to the original game code.

From that point onward, the game runs DRM-free, just as it was originally compiled.

I don’t know for certain whether the crash is due to relocation of the game code, changes to the .bind section, or explicit anti-debugger checks. But the root cause is clear: Steam DRM is interfering with debugging.

Solution

Use Steamless to remove the Steam DRM.

Thankfully, Steamless is very easy to use. I didn’t need to change any settings — just select the executable, click Unpack, and it created Fallout4.exe.unpacked.exe next to the original file.

Steamless example

Running a Stripped Game with a Script Extender

A small caveat: for Bethesda games that use a script extender, like F4SE for Fallout 4, which are launched via a loader executable (e.g., f4sevr_loader.exe), you’ll need to add the -ForceSteamLoader argument.

This flag ensures that the Steam loader is still used — otherwise, the script extender may fail to initialize, and you’ll get errors like “mods failed to load.”

Example:  

buffout4 failed


Example using MO2:

MO2 forcesteamloader

Sources

Leave a comment