Adubbz / Ghidra-Switch-Loader

Nintendo Switch loader for Ghidra
ISC License
278 stars 41 forks source link

Add support for 17.0.0 (64-bit only) #46

Closed TSRBerry closed 10 months ago

TSRBerry commented 11 months ago

This PR adds support for read-only relocations which were added in 17.0.0 binaries.

These changes were ported from SciresM's changes to nxo64.py/ipcserver.py here, which is why I added him as a co-author to these commits.

The nxo64 changes are already done, but I need to figure out how to port the ipcserver changes, since they involve reading values from the IPCEmulator and I'm currently trying to understand how this could be done here. I currently think the emulator is set up in one function and only used there, which differs from the way ipcserver seems to handle it.

I'll mark this PR as draft until I either figure this out or somebody else figures it out before me and wants to add the solution here.


Aside from these changes I made a minor adjustment to the way plt entries are handled, so no exceptions can be thrown there and the user instead just receives a note about missing support for CFI-enabled binaries.

This closes #41, but doesn't solve the underlying issue that we currently can't find the plt for the binaries mentioned above.

Adubbz commented 11 months ago

I would actually support IPCEmulator being removed (unless someone actually does rely upon it). I don't think it has been completely functional since much earlier versions of HOS,and the value added was fairly limited to begin with

TSRBerry commented 11 months ago

Maybe I should try making nxo-utils/ipcserver.py compatible with Ghidra instead if you want to replace IPCEmulator entirely.

I have the ipcserver changes almost done already, but I'm currently running into a few bugs that I need to fix before I can push that.

I should check if we are able to make analyzers in python as well or if these scripts need to be ported to Java.

Adubbz commented 11 months ago

Where possible porting to Java remains ideal in my mind, given Ghidra continues to only package outdated Python 2/Jython support

TSRBerry commented 10 months ago

I tested these changes with ghidra version 10.4 and the ldn sysmodule for 16.1.0 and 17.0.0 and compared the results against ipcserver.py.

I'd say this is working correctly now and is ready for review!

The build.gradle changes made working on this a lot easier since I could just launch ghidra from within the project and I didn't have to restart it twice to install a new extension as I needed to do before.