Tutorial  Updated

Patching CIA Executable

I will show you how to patch a CIA's executable, this will allow you to do things like install SaltySD without NTR.

Requirements:
  • Ctrtool (in tools.zip)
  • 3dstool (Also in tools.zip)
  • makerom (guess where?)
  • Hex editor
  • CIA you want to patch
  • CFW
  • Decrypt9WIP

Step 1: Decrypt the CIA
You may skip this if your CIA is decrypted already!

Copy your the CIA that you want to decrypt into D9game on the root of your SD card.
h6nKMjU.png


Then go into Decrypt9, Game Decryptor Options->CIA Decrypter (deep) and wait.
a7hn7Jp.jpg

lFCyn0u.jpg


Now copy that back to your PC, it is now decrypted!

Step 2: Extract the CIA
Execute "ctrtool --contents=contents [CIA].cia", with [CIA].cia replaced with the proper file.
gi4kaAX.png


Take note of the content file names, this will be important while remaking the CIA.

Next we need to extract the primary content file, this should be called contents.0000.XXXXXXXX, like the Smash 1.1.5 update it is called contents.0000.00000014. Execute "3dstool -xvtf cxi [CONTENTS] --header ncch.header --exh exheader.bin --exefs exefs.bin --romfs romfs.bin --plain plain.bin" with [CONTENTS] replaced with the contents file. This should generate a warning about "logoregion", it is safe to ignore this.
Y5IBJ7D.png


Next we need to extract the exefs, execute "3dstool -xvtf exefs exefs.bin --exefs-dir exefs --header exefs.header".
w4d7Q9V.png


The final extraction step is to decompress the code, execute "3dstool -uvf exefs/code.bin --compress-type blz --compress-out code-orig.bin"
FlqU0WS.png

Step 3: Modify the code
Copy the code-orig.bin file wherever you need it, modify it, and copy it back as
code-patched.bin.

Step 4: Repack the CIA
First we need to compress the modified code, execute "3dstool -zvf code-patched.bin --compress-type blz --compress-out exefs/code.bin"
ijVispo.png


Then we need to create the exefs. Execute "3dstool -cvtf exefs exefs2.bin --exefs-dir exefs --header exefs.header"
C36eh76.png


We need to make the modified CXI, execute "3dstool -cvtf cxi patched.cxi --header ncch.header --exh exheader.bin --exefs exefs2.bin --romfs romfs.bin --plain plain.bin"
70eTIGx.png


Finally we need to create the CIA file, this is where the name of the content files is needed. Execute "makerom -f cia -o [PATCHED].cia -content patched.cxi:0" with all the content files appended to it with "-content contents.xxxx.yyyyyyyy:x" EXCEPT for contents.0000.yyyyyyyy. For my SaltySD patch it would be "makerom -f cia -o SmashUpdate.NaCl.decrypted.cia -content patched.cxi:0 -content contents.0001.0000000f:1"

Step 5: Fix Versions (optional, but recommended)
Open the decrypted CIA in a hex editor, and locate the two bytes at offset 0x00002F9C and copy those.
gdr3K2g.png

Copy that to the modified CIA at 0x00002F9C.
XMaKeV3.png

Step 6: Encrypt The CIA
Now that the cia has been modified, we need to encrypt it; some things will break if the CIA is not encrypted. Copy the modified CIA to D9game again, launch Decrypt9WIP and goto Game Decryptor Options->CIA Encryptor (NCCH) and wait.
a7hn7Jp.jpg

R1TLjZy.jpg

Step 7: Profit
Dtlm9vp.jpg


If someone has a capture device, I would love some screenshots of D9!
 

Attachments

  • tools.zip
    418.4 KB · Views: 450
Last edited by gudenau,

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • K3Nv2 @ K3Nv2:
    Psps still going for $100 on ebay lol
  • ZeroT21 @ ZeroT21:
    i'll consider it
  • ZeroT21 @ ZeroT21:
    if only i can backport the game meself
  • K3Nv2 @ K3Nv2:
    Pretty sure the new flip one can do psp if you don't mind the sp design
  • ZeroT21 @ ZeroT21:
    resistance still has jerky gameplay on emu
  • K3Nv2 @ K3Nv2:
    1gb of ram probably won't help
  • ZeroT21 @ ZeroT21:
    guess i'll stick to playing helldivers 2 for awhile
  • K3Nv2 @ K3Nv2:
    Do people still hate that game or did they fix it
  • ZeroT21 @ ZeroT21:
    fix? there were fixes?
  • ZeroT21 @ ZeroT21:
    i never heard or notice any fix
  • NO111ONE @ NO111ONE:
    @Xdqwerty crashd was the exploit for LG TVs to root practically any.
    I got word of it this january and rooted my TV. Was pretty impressed.
    Since then LG patched the command to root and then the developer mode app itself from making vulnerabilities.

    And then I found out that having a rooted TV lets you use PPPwn to jailbreak a PS4 on firmware 11. Finally uses for my rooted LG (I hate the playstation as such the use is gone)
    +1
  • K3Nv2 @ K3Nv2:
    @NO111ONE, Did you have a arch64 base?
  • NO111ONE @ NO111ONE:
    Honestly didn't care to even poke. The board is W18H
  • K3Nv2 @ K3Nv2:
    I got a 2023 Model turned off update in the homebrew channel maybe if I restore it and run the script again but it might auto update during the process
  • ZeroT21 @ ZeroT21:
    play it safe, keep it off
  • K3Nv2 @ K3Nv2:
    Script keeps getting stuck at Heap grooming now
  • ZeroT21 @ ZeroT21:
    nowadays i just keep my jailbroken ps4 for some exclusives i don't play on pc
  • K3Nv2 @ K3Nv2:
    The youtube adblocker looks nice in the homebrew channel but I pay for premium for like $4 a month under vpn lol
  • ZeroT21 @ ZeroT21:
    i dont even YT much, Net flix is just another bother
  • K3Nv2 @ K3Nv2:
    YT music apps pointless tbh
  • ZeroT21 @ ZeroT21:
    playing old music mostly while browsing/going through comics at archive.org
  • ZeroT21 @ ZeroT21:
    me doin' simple stuff
  • K3Nv2 @ K3Nv2:
    Don't always need a bunch of electronics to enjoy electronics
    +1
  • K3Nv2 @ K3Nv2:
    Issue is we want new and best then it piles up
  • ZeroT21 @ ZeroT21:
    i'm all gud if my browser don't lag
    ZeroT21 @ ZeroT21: i'm all gud if my browser don't lag