Homebrew WIP SXPD - Switch eXecutable Patch Delta, a new file format for exe patching + a patch utility.

  • Thread starter Thread starter SimonMKWii
  • Start date Start date
  • Views Views 18,469
  • Replies Replies 67
  • Likes Likes 11
Why is the sha256 of the patched file in the metadata? It's not like the same patch suddenly does something different if the source-file is confirmed to be the correct one.
Also having an human-readable patch-format wouldn't be that hard and makes combining patches much less painful.

Imo just including the old value (and a bit of the values around that, like gnu-patch does it) and then only applying if that matches would be much better since it would allow you to apply multiple patches to a game while still making sure that the patch isn't applied to an incompatible elf.

Also pretty much anything other than vb would have been better because vb is strictly windows-only so porting your tool essentially means a full rewrite.
The SHA256 of the patched file is to confirm that it was patched correctly, there are numerous factors which could cause a bad patch.
I even experienced one myself, turns out I ran out of disk space on my C: drive, therefore the file was incomplete and hashed to a different value.
Also, VB can be transpiled to C# natively, so in my opinion, it's a non-issue.
 
Last edited by SimonMKWii,
The SHA256 of the patched file is to confirm that it was patched correctly, there are numerous factors which could cause a bad patch.
I even experienced one myself, turns out I ran out of disk space on my C: drive, therefore the file was incomplete and hashed to a different value.
Also, VB can be transpiled to C# natively, so in my opinion, it's a non-issue.
C# is also mostly a Windows only language. It can run mostly with mono on other platforms but it's not perfect. So I would still consider it an issue.

Should we start a database of game patches? I'm looking forward to some Breath of the Wild ones myself.
 
This should make patching executables a lot easier (and a whole lot more legal!)

Switch eXecutable Patch Delta format notes:

This is an LE (little-endian) file format.
For use with .elf files generated with nx2elf from an NSO.

[HEADER, 0x00, 0x50]
0x0, 0x4 = Magic number: "SXPD"
0x4, 0x4 = Number of instructions to patch (in hex)
0x8, 0x20 = SHA256 hash of original .elf
0x28, 0x20 = SHA256 hash of patched .elf
0x48, 0x8 = Data start magic number: "BEGINDAT"

[LISTINGS, 0x50, (variable length)]
Each listing is 0x8 in length.
0x0, 0x4 = Offset of instruction (in the .elf)
0x4, 0x4 = ARM instruction (as hex)

Note: this format is specifically designed for ARM instructions, and could potentially be used for real-time patching.

Attached is a WIP utility (Sexep - Switch executable patcher) to patch games, it includes a sample .sxpd for Super Mario Odyssey 1.2.0 (no damage and can walk on lava, poison etc).
Currently it can only patch games, but soon you will be able to make your own patches as well. (You can make them now if you follow the format notes!)
I'll be posting a few more sample patches a bit later on.
I'm unable to download the zip currently. May I recommend adding a section to the OP stating how to use the patches?

EDIT: Manged to find a PC. Looks like it similar to patching GBA roms. So should be pretty simple. I can't wait to use this with some binding of isaac mods!
 
Last edited by ,
Sadly I don't have Visual Studio 2015 debug installed and it asks for ucrtbased.dll vcruntime140d.dll msvcp140d.dll for nx2elf :(
 
Please don't spread misinformation.
On your Micro SD card, inside the Atmosphere/titles/ directory, make a new folder named the title ID of the game you wish to patch (I.E. Super Mario Odyssey, 0100000000010000).
Inside that folder, make another folder called "exefs" and put the patched NSO in, and make sure it's named "main".
Then run the hekate payload, go into CFW and run the game!
I thought booting games while in "CFW" would crash? Has that been fixed since I last tried? Or do games only boot without crashing if using an .nso on the SD card? Anyway, this is pretty cool. :) Thanks, and good job making it.
 
What kind of patches could we expect to see/make using this in BotW? Could we alter things like item durability or how many weapon/bow/shield slots you have?

I'm starting a new game in BotW after beating it and I'd like it to play a bit differently by making items unbreakable and reducing how many item slots I start out with (also motorcycle at the beginning of the game instead of the end, but I was able to accomplish that with a save editor)
 
So, erm, why make a new file patching format when .ips exists? Sure theres somes benefits like the hash, but you could literally just apply the patch to the exefs using countless tools. Plus, if atmosphere's layeredfs will be anything like luma3ds's, surely it'll support .IPS too, making the patches easily future proof?
 
So, erm, why make a new file patching format when .ips exists? Sure theres somes benefits like the hash, but you could literally just apply the patch to the exefs using countless tools. Plus, if atmosphere's layeredfs will be anything like luma3ds's, surely it'll support .IPS too, making the patches easily future proof?

How big can the elf files get that are used in patching? .IPS files only support up to 2047 Mb.
 
How big can the elf files get that are used in patching? .IPS files only support up to 2047 Mb.
Realistically, you're not going to have so many edits that the ips file will be 2GB though lmao
Plus the main file (that has the games code) itself is only around 14mb or something
 
Realistically, you're not going to have so many edits that the ips file will be 2GB though lmao
Plus the main file (that has the games code) itself is only around 14mb or something

2047 Mb max for the target file, the individual internal IPS patches are supposed to be less than 7.99 Mb (Not sure why that would make a difference though), and if its that realistic I can easily make an app for ips files, heck I'll start working on it now ;).
 
Last edited by JordantheBuizel,

Site & Scene News

Popular threads in this forum