Adubbz / Ghidra-Switch-Loader

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

Unable to load Mariko 16.1.0 kernel (secure_monitor.bin) #49

Closed lucasaf04 closed 8 months ago

lucasaf04 commented 8 months ago

The file begins with the sequence 0xDF 0x4F 0x03 0xD5, but Raw Binary is the only option available. I've modified this line because it wasn't working. else if (java.util.Arrays.equals(reader.readByteArray(0, 4), new byte[]{(byte) 0xDF, (byte) 0x4F, (byte) 0x03, (byte) 0xD5})) But now I'm getting this error:

2023-12-10  18:08:44    ERROR   (LoaderService) Unexpected Loader exception from Nintendo Switch Binary java.lang.RuntimeException: Failed to find map offset
            at adubbz.nx.loader.knx.KNXAdapter.read(KNXAdapter.java:62)
            at adubbz.nx.loader.knx.KNXAdapter.<init>(KNXAdapter.java:36)
            at adubbz.nx.loader.SwitchLoader$BinaryType.createAdapter(SwitchLoader.java:211)
            at adubbz.nx.loader.SwitchLoader.findSupportedLoadSpecs(SwitchLoader.java:89)
            at ghidra.app.util.opinion.LoaderService.getSupportedLoadSpecs(LoaderService.java:47)
            at ghidra.app.util.opinion.LoaderService.getAllSupportedLoadSpecs(LoaderService.java:71)
            at ghidra.plugin.importer.ImporterUtilities.importSingleFile(ImporterUtilities.java:286)
            at ghidra.plugin.importer.ImporterUtilities.showImportDialog(ImporterUtilities.java:154)
            at ghidra.plugin.importer.ImporterUtilities.lambda$showImportDialog$0(ImporterUtilities.java:106)
            at ghidra.util.task.TaskLauncher$2.run(TaskLauncher.java:117)
            at ghidra.util.task.Task.monitoredRun(Task.java:134)
            at ghidra.util.task.TaskRunner.lambda$startTaskThread$0(TaskRunner.java:106)
            at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
            at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
            at java.base/java.lang.Thread.run(Thread.java:1583)

I've found this secmon loader but its only for IDA Pro https://github.com/SciresM/nx_secmon_ida_loader/blob/master/nx_secmon.py

Thanks.

Adubbz commented 8 months ago

The secure monitor is not the same thing as the kernel and support has not been added for loading secure monitor binaries. Someone is more than welcome to submit a PR for this if they are interested in it, though it's not something I plan on working on myself.