CensoredUsername / unrpyc

A ren'py script decompiler
Other
820 stars 149 forks source link

[Feature Suggestion] Nintendo switch "Official SDK" injection support #165

Open baconwaifu opened 1 year ago

baconwaifu commented 1 year ago

With the removal of python 2 from distros, running it "standalone" is getting harder, so injection seems preferable. The switch is a fairly bog-standard renpy environment, just with a few "interesting" limitations:

Injection can't be done through file insertion, must be done either through replacement or pickle save-bombing (The latter being my preferred technique for dealing with their custom 'zng' image encoding, will attach my tools when I have time to get to the machine they're on). EDIT: can't be done through rpyc overwrite either, you have to overwrite bytecode.rpyb and probably update the ~INDEX file. Or you can just backup and clobber the persistent store pickle instead, it's loaded at around the same time, and isn't subject to the various index-hells.

Another limitation is a complete lack of arbitrary file writing; the interpreter blackholes file writes from python. There is however, a way to get files out: It has to be able to write to savegames somehow, and that happens to be done in pure-python. They also have a custom binary index for those as well, though, so you have to either figure out how to "create" savegames, or overwrite an existing one.

EDIT: more details on insertion points (debugging a mod, game does not like itself trying to update bytecode.rpyb)

CensoredUsername commented 6 days ago

I just noticed I never replied to this.

It is still possible to run it with python 2, it might not be the standard distribution anymore but you can easily compile it yourself when needed. That said, we're now supporting python 3 for a significant amount of games as well.

Loading unrpyc through a save sounds possible, and wouldn't be that hard to implement. But this seems like a lot of work and I don't have the required hardware (or time) to work on this. But if you need some tips where to start, I can help.

baconwaifu commented 6 days ago

I just realized that if you only want to dump the scripts, you can also just copy-paste the rpyc files into a PC renpy 'skeleton' and inject into that instead. Possibly just add that 'workaround' to the documentation instead? I should probably still document my "picklebomb" technique for decoding the images though, even if it's only really useful for switch-only releases (using a picklebomb to inject a stub that loads all the images and saves them out into the save file as normal PNGs)