kylewlacy / GhidraNes

Ghidra extension for loading iNES 1.0 NES ROMs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Opening ROM creates an UnimplementedNesMapperException

iwillreku3206 opened this issue · comments

ROM: Tetris (U).nes

Error details:


java.lang.RuntimeException: ghidranes.errors.UnimplementedNesMapperException: Tried to load ROM with unimplemented mapper 1
	at ghidranes.GhidraNesLoader.load(GhidraNesLoader.java:102)
	at ghidra.app.util.opinion.AbstractLibrarySupportLoader.doLoad(AbstractLibrarySupportLoader.java:346)
	at ghidra.app.util.opinion.AbstractLibrarySupportLoader.loadProgram(AbstractLibrarySupportLoader.java:83)
	at ghidra.app.util.opinion.AbstractProgramLoader.load(AbstractProgramLoader.java:112)
	at ghidra.plugin.importer.ImporterUtilities.importSingleFile(ImporterUtilities.java:401)
	at ghidra.plugin.importer.ImporterDialog.lambda$okCallback$7(ImporterDialog.java:351)
	at ghidra.util.task.TaskLauncher$1.run(TaskLauncher.java:90)
	at ghidra.util.task.Task.monitoredRun(Task.java:126)
	at ghidra.util.task.TaskRunner.lambda$startTaskThread$1(TaskRunner.java:94)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
	at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: ghidranes.errors.UnimplementedNesMapperException: Tried to load ROM with unimplemented mapper 1
	at ghidranes.mappers.NesMapper.getMapper(NesMapper.java:21)
	at ghidranes.GhidraNesLoader.load(GhidraNesLoader.java:99)
	... 11 more


Build Date: 2020-Feb-12 1149 EST
Ghidra Version: 9.1.2
Java Home: C:\Program Files\Java\jdk-15.0.1
JVM Version: Oracle Corporation 15.0.1
OS: Windows 10 10.0 amd64
Workstation: DESKTOP-SPQJ3UK

So far, I've only implemented one mapper (mapper 0, a.k.a NROM), so trying to load any NES ROM that uses a different mapper will fail with this error.

It shouldn't be too hard to add other mappers, but there are a lot of them (~200), so it would take a lot of work to support all of them. That said, the most popular games in the NES library only use a handful of different mappers (mapper 1 is a pretty common one IIRC).

I don't really have any spare capacity to work through even the common ones, but I might try to tackle it when my plate is more clear. I'll leave this issue open to track any progress at least.

I'm curious if you documented anything about how you implemented mapper 0, or if you are interested in pointing me in the right direction to get started helping with this project. I'd like to work on making it compatible with other mappers and can help out if you give me a starting point. If you have a discord or anywhere else this is discussed I'd be happy to join that and we can talk there.

@StunningRob I'd like to sit down and write docs for all this stuff soon (got some other stuff in-flight at the moment), but I think it'll take some time to get something written up for it. Unfortunately, mapper 0 is one of the few "simple" mappers-- most of the rest have some sort of bankswitching in place. I started working on another mapper a long time ago before putting it on hiatus, but I remember working with bankswitching in Ghidra being kind of painful.

Very cool. When you have time to work on a guide or something to help me get started I'm interested in helping work on other mappers.

Tryed to implement mapper 30. It was a pain and didn't really land on anything usable. If anyone has any resource on how bankswitching on Ghidra may work please share the resource!

Thanks for the loader btw :)

...it's been a while since I've come back to this project. When I first started working on it, I tried implementing mapper 2 (UxROM). I believe I got something that was kind of working, but I remember that it was pretty clunky, and dealing with bank switching in the disassembly was very much a manual and tedious process. The code I had for that was on the wip/uxrom branch, although that was written before Ghidra 10 and I think there's been some breakage since then.

Unfortunately, it's been long enough since then that I really don't remember any of the details. I still definitely have a passive interest in the NES dev space, but my original motivation for this was when I was actively working on my NES emulator (Lochnes). Since I reached what I felt was a good stopping point with my emulator, I haven't had the motivation to come back and revisit this project. I won't rule out the possibility that I do come back to this project, if I get a particularly strong emulation/reverse engineering itch again!

As far as other resources go, I found this Reddit thread, which links to another Ghidra loader that does handle bankswitching, although it sounds like it's tailored to SMB3 specifically. I haven't looked at that project at all yet, so I can't speak to the approach used for it.

I was using your NES loader to solve a CTF challenge. I was able to solve it already just by looking at the assembly although it was quite a pain to do so haha.

My interest on this at the moment is merely getting to know more about Ghidra and NES but I no longer need the mapper. Depending on my needs, I may get back to it if I find some free time to tinker with Ghidra now that I have more resources to look at!