joncampbell123 / dosbox-x

DOSBox-X fork of the DOSBox project
GNU General Public License v2.0
2.56k stars 373 forks source link

Idea: Patch files for executables and files #4430

Open joncampbell123 opened 10 months ago

joncampbell123 commented 10 months ago

Is your feature request related to a problem? Please describe.

Just an idea that might help bug fixing or "ROM" hacking for DOS games in more or less the same way people have been ROM hacking NES games for two decades by this point.

What you want

It might be a nice idea for bug fixing or "ROM" hacking purposes to allow a way for DOSBox-X to load an EXE or COM file and then patch the image in memory before executing.

We could start with the common *.ips patch format.

If you run GAME.EXE, and patching is enabled, and GAME.EXE.IPS exists, then the image is loaded into memory and then patched from the EXE base using the contents of the IPS file.

Perhaps later, an IPS patching "overlay" could be made for arbitrary files (executable or data), but that's more complicated.

Describe alternatives you've considered

No response

Additional information

No response

Have you checked that no similar feature request(s) exist?

Code of Conduct & Contributing Guidelines

rderooy commented 10 months ago

But DOS games are not like ROM games. They can load data and resources at any time. In fact, as I'm sure you know, some games load an intro first before they load the actual game.

Perhaps a better solution would be to use the overlay filesystem support to apply game patches.

joncampbell123 commented 10 months ago

But DOS games are not like ROM games. They can load data and resources at any time. In fact, as I'm sure you know, some games load an intro first before they load the actual game.

My initial idea is that the patching could be done on load and execute for COM/EXE files. DOSBox-X would load the image into memory, apply the patch data, and then fixup relocations and execute.

Patching would be done BEFORE the EXE relocation table is applied so that the patch can be correct no matter where the EXE is loaded into memory.

Perhaps a better solution would be to use the overlay filesystem support to apply game patches.

Intercept file I/O to replace some data with other data, correct? I suppose that makes sense.

NebularNerd commented 10 months ago

This could be handy for many purposes. From patching Games or Applications with weird installers (Stellar 7 and F-29 Retaliator both are annoying to install from floppies if the images are not 'just so'), to trainers, to bypassing overly annoying protection (#3789 Cool World)

Potential issues would be much like you used to get with an Action Replay on PC, stuff is not always in the same place as before. A patch which works on one configuration could potentially break on another. As @rderooy suggests using the overlay system would be one way to go, packed .exe's would create some interesting issues however.

Maybe a hybrid mix would be in order, track a file as it loads into memory to see where it lands in the memory space, then patch before handing control back to the OS/Game/Application.