Question

Imagine a modern PC game for example. I'm using this example because typically the executable file is fairly large, and especially in modern games the resource files are also pretty big.

Patching a resource file is fairly simple because depending on the file format it could just be a case of replacing one contiguously stored resource with another. But what about if you wanted to change one line of code in a bulky executable?

When the code is compiled, it's optimised and rearranged to allow for structures not present in lower level languages, and so generally the resulting code file is very rarely a line-by-line translation of the high level code. So with this in mind if you wanted to change one particular line to fix a bug, would the update then contain a new version of the entire executable, or can it work like some sort of difference-spotting technique like a source control system?

Was it helpful?

Solution

Yes and no, both mechanisms work.

The easiest way to patch a product is by replacing a component (eg a dll) with a new version of it. This usually requires the program to be stopped so its useful for a game or other program that is run occasionally but not so good for OS components.

So various techniques have been developed to directly patch a running executable (or dll). Microsoft does this by creating all dlls with a space before each function so it can be overwritten by a "jump to a new location" patch, the new function can be shipped and the location changed so all running programs will start to use the new code once patched. (Technical details here) This occurs at runtime, so stopping the patched program will require the patch to be re-applied (this either occurs automatically or the component is upgraded once the program is stopped - ie on a reboot the new dll replaces the old so the runtime patching is no longer required).

OTHER TIPS

When the executable is changed, it's often easier to replace the entire executable, rather than modify it. This makes it possible to patch the executable no matter which version it's at (unlike binary difference patchers). The vast majority of modern games do it like this.

In modern games, the size of the executable pales in comparison to the resource files, so there is little to gain by modifying the executable.

Licensed under: CC-BY-SA with attribution
scroll top