Any way to automate a set of hex edits? (from a batch file or similar)

0 votes
asked Mar 28, 2017 by psykotenshi (120 points)

The instructions I want to automate are:
- open Borderlands2.exe (with hex editor)
- search hex value 83C40C85C0751A6A
- edit search result to 83C40C85FF751A6A
- search text value 'say' with match case enabled
- edit search result to 0's
- save file
These are part of the required steps to get the Borderlands 2 Community Patch working, as described on this video: https://www.youtube.com/watch?v=o_ee3BM1TQQ
Problem is, I haven't found any hex editor that allows running it and making edits from a script.

If such a thing does not exist for whatever reason, I... guess I'll have to take the super roundabout way of making an executable ahk script to do every individual keystroke involved. Which would be a sloppy and really fragile way to do it (since a single click or keystroke from the user can disrupt the installation).
But I really rather not to.

Thanks in advance for any help.

1 Answer

0 votes
answered Mar 28, 2017 by andreas (1,480 points)

There are scripting functions that allow to search inside a file and modify it.

Here you find some sample scripts: https://www.synalysis.net/scripts.html

These are the steps:

  • open the script editor (in the Script menu
  • create a script working on files (type "File")
  • create a ByteView object using the byteArray parameter
  • call findByteSequence() to search for the sequence you mentioned
  • call replaceByte() to replace the 0xC0 with 0xFF
  • ...

It should also be possible to use a generic script (doesn't operate on the current file) and

  • create an empty ByteArray object
  • call appendFile("path/to/Borderlands2.exe"
  • do the steps above
  • call writeToFile("path/to/Borderlands-modified.exe")

Does this help?

...