shinyquagsire23 / SaltySD

A collection of SD redirect patches for 3DS games
74 stars 14 forks source link

Crashes on European copies of smash #3

Closed CorBond closed 8 years ago

CorBond commented 8 years ago

Whenever i load a patched update on my european copy of smash, it crashes to the home menu with "an error has occured, forcing the software to close." it then restarts the system.

How to reproduce:

  1. patch European 1.1.4 update with SaltySD
  2. Install newly created .cia with BBM
  3. attempt to start European copy of smash

i won't be suprised if it's also incompatible with the japanese version, to be honest.

ghost commented 8 years ago

Europese? I think you mean European...

Sterillo commented 8 years ago

Make sure you modify the actual CIA of the game instead of the update. It is compatible with the update 1.1.4, but that doesn't mean you can launch it using a custom update. I.E. Backup rom, extract the exefs, modify it, rebuild into cia, install cia, update game before playing.

CorBond commented 8 years ago

@Sterillo huh? the only tutorials i have seen for using SaltySD did it by editing the update .cia instead of the main game. guess i'll try patching the main game later then.

shinyquagsire23 commented 8 years ago

@Sterillo I've only ever tested repacking the actual update, not the game. I'll see if I can get my hands on the EUR update for this so I can validate if the code is actually different or not. If it is, then I'll have to adjust accordingly.

shinyquagsire23 commented 8 years ago

OK the codebin is definitely different, RIP me. Time to find equivalent offsets for this stuff, or better yet use it as motivation to make a script to automatically find offsets or something. It'll be a while though, especially considering I can't test this myself (or I guess maybe I could if I repacked EUR's codebase as a US update, but no idea how well that would go).

shinyquagsire23 commented 8 years ago

OK so all functions from 0x1091b8 to 0x1a4c24 are shifted 8 bytes forward. I'll probably hold off on adding these into the guide since I'd rather have a more permanent fix for region differences, but for now just add 8 bytes to all patch offsets within that range and it should work. I'll close this issue once I finish making a proper patcher which Just Works on any codebin you give it.

EDIT: This includes function offsets in the .asm files. .data, .bss and .rodata offsets should be identical. Just as a check, lib::Resource::load should be at 0x13F4B8 (0x3F4B8 in a hex editor) and should start with F0 43 2D E9 00 20 A0 E1 14 D0.

So you'll want to update https://github.com/shinyquagsire23/SaltySD/blob/master/smash/lock.asm#L8-L27, https://github.com/shinyquagsire23/SaltySD/blob/master/smash/lock.asm#L53, https://github.com/shinyquagsire23/SaltySD/blob/master/smash/lock.asm#L88, all ldr lr, bx lr function loads (ie https://github.com/shinyquagsire23/SaltySD/blob/master/smash/lock.asm#L303-L304). If the address falls in the shifted range, add 8, otherwise don't.

CorBond commented 8 years ago

hold up, do i only need to edit lock.asm?

shinyquagsire23 commented 8 years ago

@CorBond57 No, all the .asm files need to be edited, and their hook locations adjusted appropriately as well.

CorBond commented 8 years ago

@shinyquagsire23 This is probably too confusing for me to pull this off. bzybhli 1 You say it's moved by eight bytes, except according to my codebin it ends at 0x13F4B9 instead of beginning at 0x13F4B8 like you said.

CorBond commented 8 years ago

any updates on this?

shinyquagsire23 commented 8 years ago

I just moved all version-specific offsets to common.asm, now what I'll need to end up doing is writing a script to scan for all my functions I import and all the hook offsets. I also went ahead and took a look at the Smash demo and v1.0.1, and it turns out their resource loading functions are changed slightly, so I might have to clean things up and try to accommodate for that.

shinyquagsire23 commented 8 years ago

I just updated and added commit https://github.com/shinyquagsire23/SaltySD/commit/934fdfe85c1fd0a8f5488d0f3499d83fa3abcb6d, let me know if that fixes it. Just drop the EUR 1.1.4 code.bin into smash/ and then run Make, it'll handle the rest and generate a code_saltysd.bin.

CorBond commented 8 years ago

@shinyquagsire23 Running make gives me this error: Traceback (most recent call last): File "scan.py", line 58, in resource_is_exist = f.find(resource_is_exist_sig_legacy if f.find(resource_is_exist_sig ) == -1 else resource_is_exist_sig) NameError: name 'resource_is_exist_sig_legacy' is not defined Make: *\ [all] Error 1

From what i deduced, you seemed to have forgotten to put in resource_is_exist_sig_legacy in scan.py and patch.py, because making a copy of resource_is_exist_sig and adding _legacy to it seemed to make it run without errors. Building it now.

EDIT: it ended up getting stuck on the 3ds logo when booting the game.

shinyquagsire23 commented 8 years ago

If it gets stuck on the 3DS logo, it's more likely that it repacked improperly, but I have a EUR and JP codebin so I should be able to test this some time today. And I think I just got carried away with copying, I don't think that function differed between older builds and current ones.

shinyquagsire23 commented 8 years ago

Any updates on this?

CorBond commented 8 years ago

Still stuck on the 3ds logo with the newest commit. does it need to be encrypted or something?

shinyquagsire23 commented 8 years ago

Hm, it really shouldn't be getting stuck at the 3DS logo, at least if it was an error on the part of my code injections. I use the following to repack my .CIA and it works like a charm:

makerom -f cxi -target t -rsf gw_workaround.rsf -o smash-114t.cxi -exheader exheader.bin -code exefs-salt/code.bin -romfs romfs.bin -icon exefs-salt/icon.icn -banner exefs-salt/banner.bnr -alignwr
Exinjector.exe -rom smash-114t.cxi -exheader exheader.bin -sd
makerom -f cia -target t -content smash-114t.cxi:0:0 -o smash-114t.cia

and for unpacking I'll use

ctrtool -p --exefs=exefs.bin --romfs=romfs.bin --exheader=exheader.bin <decrypted update from SD>.app
3dstool -x -t romfs --romfs-dir romfs -f romfs.bin
3dstool -x -u -t exefs --exefs-dir exefs -f exefs.bin

Where exefs-salt/ is a copy of the extracted exefs/ but with the patched code.bin. and https://gist.github.com/shinyquagsire23/95260617901c13d66719 is my gw_workaround.rsf.

CorBond commented 8 years ago

I use makerom.exe -f cxi -rsf smash_update_repack.rsf -exheader DecryptedExHeader.bin -code exe/code.bin -icon exe/icon.bin -banner exe/banner.bin -romfs DecryptedRomFS.bin -o smash_customupdate.cxi then i just open Exinjector instead of doing it via command line, and then i do

makerom.exe -f cia -o smash_customupdate.cia -content smash_customupdate.cxi:0:0 -minor 20 -micro 0 adding the -minor and -micro tags seem to remove the update nag too. my .rsf's an european one though, instead of an american one .(https://gist.github.com/CorBond57/f165171ec8515a3acd9b)

CorBond commented 8 years ago

any updates on this?