Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Future of the armory binpatches #546
Comparing two executables against one another, I'm slowly snooping out where Angavrilov's old binary patches go in the current Windows version.
weaponrack-unassign moved down by 0xFF3C0, so the chunks of code in 0x4C05C4 and 0x4C06A1 are now found in 0x5BF984 and 0x5BFA61 respectively. I've manually altered my own .exe and can see it works.
The parts in armorstand-capacity that involve altering old stuff (and not adding extra detours into empty space) look like they have jumped down by 0x24220. The old addresses 0x34D91, 0x34E53 and 0x34EF3 and their surroundings look an awful lot like v40.24's 0x58FB1, 0x59073 and 0x59113. There seem to be empty CC CC CC CC patches offset by 0x24220 like the rest, but I'm still a little uncertain how to make the relocated instructions point to the right places again.
Lethosor put forward the reasonable thought that these should be deprecated in favor of doing the thing with DFHack's own tools, but that's where I'm in over my head. I'm okay at detective work like this, but all I know about C is what Sesame Street taught me.
I've taken a harder look at armorstand-capacity and I think I've managed to reroute all the old links. The problem was that when the old ones were hanging around 0x17000 and then 0x35000, the current version has them closer to 0x2A000 and 0x58000. All the relative-distance CALL and JMP instructions needed new values to account for the much wider and inconsistent gaps between the addresses. One JMP that was pointing to some unmentioned section of original code had to be tracked down too. Thank goodness it was a fairly unique instance of code that showed up quickly.
Well, the fact of the matter is that I failed to bring the armorstand-capacity patch back online. I got a grip on where the important bits were, but couldn't wrangle the assembly instructions to point at the moved empty space. My notes are such a mess that I'd probably have to retrace my steps to say where they were.
I have a functioning version of the critical weapon rack fix for Windows, however. I haven't gotten around to making a pull request, what with the fact that the military currently doesn't feel like doing anything besides training on their days off and the deprecation of binary patches as a thing, but here it is anyway.
Remember how binary patches worked? Put this file (weaponrack-unassign.dif) in /hack/patches/v0.40.24 SDL/ and run it with "binpatch apply weaponrack-unassign".