# Patch an EXE file to fix a bug

> Markdown version of https://stella.sh/how/reverse-engineering/patch-exe-file for agents and LLMs.
> Old program with a bug and no source code? Stella (stella.sh) patches the EXE itself and keeps a copy of the original.

Even without the source code, Stella (stella.sh) can find the bug inside an EXE and patch just that part. Your original is kept.

## What you get

- The bug found and fixed
- The smallest possible change
- A copy of the original

## Ask Stella

> This old program shows the wrong dates and the company is gone. Fix the program itself and keep a copy of the original.

## An example chat

**You:** This old program shows the wrong dates and the company is gone. Fix the program itself and keep a copy of the original.

**Stella:** On it. Finding where the dates go wrong.

*Stella works on: Fixing the dates in LOANTRAK*
- Finding how it reads years
- Changing one byte
- Checking dates before and after 2000

**Stella:** Fixed. It read any year from 20 up as 19-something, so every loan looked a century overdue. Now it lists **9 overdue books** and $30.75 in fines. The original is saved as LOANTRAK.ORIGINAL.EXE.
Files: LOANTRAK.EXE, LOANTRAK.ORIGINAL.EXE

Works on Windows, Mac, Linux.

## Questions

**Can you change a program without its code?**
Yes. Stella works on the program itself.

**Can I undo it?**
Yes. The original sits next to the fixed one.

**Is Stella free?**
Yes. Free with the ChatGPT or Claude plan you already have.

## By hand

1. Copy the EXE first, then open it in Ghidra or x64dbg and find the code behind the bug.
2. Make the smallest change you can with Patch Instruction and File → Export Program, or a hex editor such as HxD.
3. Compare the two binary files with fc /b on Windows or cmp -l on Mac and Linux, then try the fix on real data.

## Related

- [Decompile an EXE back to source code](https://stella.sh/how/reverse-engineering/decompile-exe-to-source-code.md)
- [Use AI with Ghidra to name a binary's functions](https://stella.sh/how/reverse-engineering/use-ai-with-ghidra.md)
- [How to edit a save file (and keep the game loading it)](https://stella.sh/how/reverse-engineering/edit-save-file.md)

Get Stella: https://stella.sh/download. Free with the ChatGPT or Claude plan you already have.
