Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Help with binary patch  (Read 1599 times)

Sparhafoc

  • Escaped Lunatic
    • View Profile
Help with binary patch
« on: November 28, 2012, 02:13:37 pm »

Hello all. First post here.

I just found DF a couple of weeks ago, and have played it non-stop since. It is a fantastic game - really love the detail and concept. My gratitude to the developer for sharing this with everyone.

It really has such a steep learning curve, but I've slowly worked my way up to the point that I think I know what's going on, how to be successful, and how to get there. There's one big problem I can't find a way to work around though, except by exploits which I don't want to use. That problem is the military bug described here: http://www.bay12games.com/dwarves/mantisbt/view.php?id=3190

Within 6 months, all my soldiers have depressed thoughts about long patrols - and while I make sure they're well fed and watered, and have high class rooms and barracks full of shiny things - it still is a bit of a game-breaker as one small thing can instantly lead to a cascade of tantrums.

So I was really happy to see the binary patch there. The problem is that I am too dense to know what to do with it. I downloaded a binary viewer... tried to find the number 007E46EC : 00 1E 53.... I presume I have to edit those last 6 numbers to be 90 BB 42 instead.

However, I have searched all the files and can find nothing. I am also not exactly sure how to edit them, whether I can just type over the top, or what.

I would be really grateful if someone could take the time to explain in depth and in extremely simple language exactly what it is one needs to do to get this bit patched.

Thanks in advance.
Logged

Bloodyharbinger

  • Bay Watcher
    • View Profile
Re: Help with binary patch
« Reply #1 on: November 28, 2012, 02:26:03 pm »

You are correct. Find a Hex editor and just change the values. It will really help.
Logged

Sparhafoc

  • Escaped Lunatic
    • View Profile
Re: Help with binary patch
« Reply #2 on: November 28, 2012, 04:07:23 pm »

You are correct. Find a Hex editor and just change the values. It will really help.

I've tried two different hex editor programs and can't find the numbers in any file. I have literally no idea what I am doing here, so if anyone can explain or link me to an explanation, that would be great.
Logged

Lord_Phoenix

  • Bay Watcher
    • View Profile
Re: Help with binary patch
« Reply #3 on: November 28, 2012, 04:15:53 pm »

Need to open the executable for DF in the viewer and then find line # 007E46EC, which is hexadecimal, so line # 8,275,692.  Should be a find/go to line number function somewhere where you can enter the line number you want as a hexadecimal number.  Then find those values on that line and change them.
Logged

Sparhafoc

  • Escaped Lunatic
    • View Profile
Re: Help with binary patch
« Reply #4 on: November 28, 2012, 04:28:15 pm »

Thank you very much Lord_Phoenix... I was looking in the wrong file, and looking for it the wrong way. I've now found them and updated. Thanks kindly.
Logged

Noodz

  • Bay Watcher
    • View Profile
Re: Help with binary patch
« Reply #5 on: November 29, 2012, 11:02:22 am »

Or alternatively, check this: http://dffd.wimbli.com/file.php?id=6741

df sdl 34.11 with several binaries appplied, including the long patrol fix ;)
Logged

roguester

  • Bay Watcher
    • View Profile
Re: Help with binary patch
« Reply #6 on: January 19, 2013, 04:25:11 pm »

I'm going to resurrect this since it's not that old.

I too have found a binary patch that applies a fix I want to use. Actually a couple of them, the ones listed as fixes to this bug: http://www.bay12games.com/dwarves/mantisbt/view.php?id=1445

However I haven't been able to find any instructions on how to use them, it doesn't seem to be as simple as pasting hex. Would someone who knows point me in the right direction please, alternately does anyone have a binary that already has these applied?
Logged

Malkyne

  • Bay Watcher
    • View Profile
Re: Help with binary patch
« Reply #7 on: March 07, 2013, 12:40:46 am »

However I haven't been able to find any instructions on how to use them, it doesn't seem to be as simple as pasting hex. Would someone who knows point me in the right direction please, alternately does anyone have a binary that already has these applied?

Binary editing is a skill I am always willing to share.

My favorite old hex editor is Frhed, which can be found here: http://frhed.sourceforge.net/en/

First, BACK UP YOUR DF DIRECTORY, or, at the very least, any binaries you're going to be hacking.  Hacking binaries can cause the wrong kind of FUN.

Then, open up your Dwarf Fortress.exe file in Frhed (or the hex editor of your choice).

Now, search for the address of the patch.  An address is just a location in the file -- only we programmers put it in fancy-pants hexadecimal, because that's how we roll.  The address is the first value in the patch instruction.  So, for example, if it looks like this:

Code: [Select]
007E5CFC : B0 C0 42 -> 20 4F 7D
The address will be 007E5CFC.  In Fhred, you can get there by Edit > Go To... or Ctrl-G.  You'll want to punch a little "x" in front of it, to indicate that it's hexadecimal.

Now, if you have the correct version, and the correct patch, you should now see the values after the address, and before the little arrow.  Those are the values you want to replace.  Be SUPER CAREFUL, here.  This is not just data.  This is a binary program executable.  These are machine instructions.  If you goof them up, there is no telling what will happen.

So, in my example above, we should see "b0 c0 42" in Frhed.  If you are at the right address, you can literally type the corrected values (in this case, "20 4f 7d") right into the editor.  Yes, it is that easy.  Be afraid.  Be very afraid.

Now, save, and try it out.

You now have phenomenal cosmic power.  Use it wisely.
Logged

Darchitect

  • Bay Watcher
    • View Profile
Re: Help with binary patch
« Reply #8 on: March 07, 2013, 06:40:20 pm »

Save yourself a crap load of work and download Modest Mod. Binary patches are already applied with many other nice fixes!

http://www.bay12forums.com/smf/index.php?topic=105871.0
Logged

i2amroy

  • Bay Watcher
  • Cats, ruling the world one dwarf at a time
    • View Profile
Re: Help with binary patch
« Reply #9 on: March 07, 2013, 11:28:15 pm »

DFHack can also apply several if you look through the readme.
Logged
Quote from: PTTG
It would be brutally difficult and probably won't work. In other words, it's absolutely dwarven!
Cataclysm: Dark Days Ahead - A fun zombie survival rougelike that I'm dev-ing for.

Xinael

  • Bay Watcher
    • View Profile
Re: Help with binary patch
« Reply #10 on: March 08, 2013, 08:16:41 am »

The dfhack patches don't actually edit the exe though, do they? I've not used them because I assumed they wouldn't be permanent.
Logged

Quietust

  • Bay Watcher
  • Does not suffer fools gladly
    • View Profile
    • QMT Productions
Re: Help with binary patch
« Reply #11 on: March 08, 2013, 08:53:00 am »

The dfhack patches don't actually edit the exe though, do they? I've not used them because I assumed they wouldn't be permanent.
If you use the "binpatch.exe" that comes with DFHack, then they will be permanent, but if you use the "binpatch" command within DFHack then they will be temporary (though with the advantage of being able to apply the patch without exiting and restarting DF).
Logged
P.S. If you don't get this note, let me know and I'll write you another.
It's amazing how dwarves can make a stack of bones completely waterproof and magmaproof.
It's amazing how they can make an entire floodgate out of the bones of 2 cats.