Borderlands 2 Hex Editor

This is a page which details some deprecated information about how to go aboutenabling modding on Linux for Borderlands 2 and Borderlands: The Pre-Sequel.This information is still technically valid, but the recommended methods foraccomplishing all of this is catalogued out on the mainpage.

Feb 01, 2013  The only way you can mod a save that dose that is with a Hex editor. From What I have been reading Hex Editing Borderlands 2 in the early days people made There own Hex editors That had builtin Decriptors and they charged money for the Hex editors But what I read today Gearbox patched there work in the last patch.

The Short Version

This page is pretty wordy and probably doesn't need to be. Here'sa barebones version of what you'll want to do. The overly-verbosestuff will follow, if you want more details!

  1. Edit your~/.local/share/aspyr-media/<game>/willowgame/config/willowinput.inito include a keybinding like ConsoleKey=Tilde
  2. Patch the game's steamassets/willowgame/cookedpcconsole/engine.upkin one of two ways:
    1. Download a pre-patched engine.upk:
      • Borderlands 2:https://github.com/bugworm/BorderlandsPatcher/blob/master/engine.upk
      • The Pre-Sequel:https://github.com/c0dycode/BLTPSModStuff/blob/master/TPS%20Set%20and%20Say-Patched%20UPKs.zip
    2. Hex-edit the engine.upk yourself:
      1. Decompress the game's steamassets/willowgame/cookedpcconsole/engine.upk using Unreal Package Decompressor (using Wine)
      2. Hex-edit the decompressed file, replacing these hex strings (there will be two instances in the file which need replacing):
        • Borderlands 2:1B E9 471B A5 14
        • Pre-Sequel:1B 0A 491B A2 14
  3. Replace engine.upk with your patched version
  4. Rename/move engine.upk.uncompressed_size out of the way
  5. Place the UCP patch inside the game's steamassets/binariesdirectory, with an all-lowercase filename
  6. Load the patch every time you start the game, using the followingtechnique:
    1. Start the game, click any key to get to the main menu
    2. At the main menu, hit escape and say Yes to get backto the loading screen.
    3. Bring down the console, run: exec patch.txt(Or whateverfilename you used)
  7. Optional: If you want full mod/patch compatibility, you will then need to ensurethat the game's steamassets/dlc directory natively sorts itselfin alphabetical order, which would almost certainly require setting up acustom mountpoint just for DLC data. See the main pagefor details. Note that the vast majority of mods/patches are unlikely torequire this, though some UCP statements will fail without.
  8. Optional: Disable 'sanity checks' by hex-editing the maingame binary. Seec0dycode'sBL Mac/Linux github project for information and a little Python scriptto automate that.

As promised, the much wordier version follows:

Step 1: Configure a Console Hotkey

This is the easiest of the steps. Simply open up your willowinput.inifile, which will be found here:

Then locate the [Engine.Console] section and set the following line:

You could also use F6 or some other key, though for console accessin FPSes, using the tilde/backtick key is customary. Neethane en ponvasantham full movie hd 1080p free download.

At this point, you'll be able to bring up the console, but the actually-usefulconsole commands won't be active: the game will pretend you wanted to 'say'that command in the ingame chat and just send it out there, rather thanactually running anything. So the next step is to get rid of that behavior.

Step 2 (option A): Enable the Fully-Featured Console (by Downloading a Pre-Patched File)

In online directions for Windows users, you'll see instructions to use a hexeditor on Borderlands2.exe or the like, but the hex strings theyspecify don't actually exist in the Linux binaries for the game (which isn'treally surprising).

Instead, you've got to patch the file engine.upk, which will befound in this location:

The quickest way to accomplish this will be to simply download a pre-patchedfile online, assuming you trust these sources. As of February 2018, I canconfirm that both of these are valid and patch the file properly.

  • Borderlands 2:https://github.com/bugworm/BorderlandsPatcher/blob/master/engine.upk
    sha256sum: 2b781b3abfa3caf91adf7d30bac4b5de27c8323e84099d8dfd86f48a56a8f110
  • The Pre-Sequel:https://github.com/c0dycode/BLTPSModStuff/blob/master/TPS%20Set%20and%20Say-Patched%20UPKs.zip
    sha256sum: 4153dd1f15ffc41ff1a1f86cbe5d21c491cc4a9738109acc3894753a5b54fafa

Step 2 (option B): Enable the Fully-Featured Console (by Hex-Editing Yourself)

Alternatively, it's not difficult to hex-edit that engine.upk fileyourself:

The game's packaged engine.upk is compressed, and you have to hex-edit the uncompressed version of the file. At the moment, I only know of one way to do this: using the 'Unreal Package Decompressor' found athttp://www.gildor.org/downloads.That's a Windows program which must be run viaWine, but it works quite well.

So, download decompress.zip, unzip it to get decompress.exe,and then run it against engine.upk like so:

That will create a new directory named unpacked, and inside thatdirectory will be the uncompressed engine.upk.

Now edit the uncompressed engine.upk inside a hex editor. Ipersonally just use the bare-bones console hex editor namedhexedit, which I assume isavailable on most distros. The value you want to change depends onwhether you're editing the file for Borderlands 2 or The Pre-Sequel, thoughin either case there are two locations in the file whereyou need to change it:

Change FromChange To
Borderlands 2:1B E9 471B A5 14
The Pre-Sequel:1B 0A 491B A2 14

Again, remember that there will be two locations inthe file which require that change.

Now that you have a patched engine.upk, rename/move theoriginal engine.upk out of the way, replace it with youredited engine.upk. Also rename/move the accompanying file,engine.upk.uncompressed_size (see Step 2.5, below).

Note: One of the Reddit posts I linked to also talks about hex-editingwillowgame.upk. This is not actually necessary for the UCP, orfor other mods found online. The edits to willowgame.upk justenable some special development commands like changing levels, settingplayer level/money, etc.

At this point, you should be able to launch BL2/TPS and find out if thepatching worked. Pull down the console and type some nonsense like 'foo'.Without the patching, the game will just put 'foo' into the ingame chat.If the patching was successful, you'll get a notice in the console saying'Command not recognized: foo'.

Step 2.5: Move/Rename 'engine.upk.uncompressed_size'

Once you have the updated engine.upk file in place, be sure torename or move the file engine.upk.uncompressed_size so that itdoesn't exist with that name anymore. Otherwise, Borderlands willthink that your engine.upk is still compressed, and have problemsstarting.

Step 3: Install and run the patch!

Okay, we're through the tricky bits! All you've got to do at this pointis put the patch file (using an all-lowercase filename)inside the game's binaries directory, which will be at:

Then, from the game's console, on the main loading screen, you can sendit the following command, substituting the filename for whatever you used:

If it worked, there should be a brief pause while the game executes all the commands saved in the patch file. If you get about four errors on the console about 'No objects found using command (foo)', you're running up against a crossplatform issue which is annoying to fix -- check Step 5, below, for ways around that. Note that the majority of the patch will continue to work just fine even with those errors, so you'll generally be all right without fixing it.

There are two gotchas which you'll want to keep in mind:

  1. The Linux version of B2/TPS requires thatthe filename be in all-lowercase. When you use the console to specifythe filename, it'll silently convert what you typed into lowercase whentrying to load, even if you type it in uppercase. (This will result ina confusing error message, since the error message will retain your uppercasecharacters.)
  2. The patches will only actually work if you load them fromthe main 'loading' screen, which just has the big ol' Borderlands logo onit with 'Press any Key' at the bottom, not from the mainmenu. You'll also want to only load the patch after the game hasdiscovered all your DLC, so the whole loading procedure should be:
    1. Start the game, click any key to get to the main menu
    2. At the main menu, hit escape and say Yes to get backto the loading screen.
    3. Then load the patch.
    If you load the patch file from the main menu, there'll be no indicationthat anything failed, but the patch won't actually have taken effect. (Theeasiest way to verify is to observe that Eridium/Moonstone doesn'tautomatically get picked up like money.)

Note that you'll have to run the 'exec patch.txt' command onceevery time you launch B2/TPS. I think I saw something about a techniqueto have it auto-execute, but I didn't look into it and don't currentlycare enough to dig around more.

Conclusion

So, that's it! Not a trivial amount of work to get going, really, thoughin the end it's pretty straightforward. The main hurdle that I had wasthat all the information to get this going on Linux was spread out overa number of different places online, and it took awhile to aggregate allthe info and figure out what needed doing.

Sources

  • The overall method for enabling these patches on Linux comes from thisReddit post:https://www.reddit.com/r/Borderlands/comments/5y35js/community_patch_for_linuxand_probably_mac/
  • The details about the hex-editing required comes from this Reddit post:https://www.reddit.com/r/Borderlands2/comments/42vs9v/developer_console_commands/
  • The particular information about what bytes to look for while hex-editingthe Pre-Sequel data file I've so far only found in one place - the videodescription of this YouTube video:https://www.youtube.com/watch?v=pPm8OMK3WaE
  • A rather amusing and relatable account of trying to find those Pre-Sequelhex values can be found in thisblog post by Anna Harren. I'm thankful that those chronicled effortssaved me the trouble of going through the same routine myself!
  • A trick to allow the 'FilterTool' application to run on Linux was found inthis bug reportfrom the BLCM project. It turns out to be the same as the instructionsfor runningFilterTool on Macs.
  • c0dycodediscovered the sanity check bypasses for Linux (well, and all the otherplatforms as well).

Changelog

  • Moved this info from the main page to the legacy page