Git Product home page Git Product logo

ghidra-segasaturn-loader's Introduction

Ghidra Sega Saturn Loader

A (WIP) Ghidra loader for the Sega Saturn. Currently supports:

  • ISO disc images
  • Mednafen Save States (MC)
  • Yabause Save States (YSS)

Grab from Releases or build from source.

Screenshots

Loader screenshot
Loader

Disassembly View w/Decompiler Disassembly View

How to Use

Sega Saturn ISOs

  • Select any Sega Saturn ISO file
  • At the "Container file detected" prompt, select "Single file"
  • The loader will create functions for main, initial program (the code that runs during the Sega logo), and security_check
  • Pros: Easy to use, useful for debugging game initialization, works great on Saturn homewbrew
  • Cons: Doesn't load any file after the first file on disc

Mednafen Save States (MC)

  • gunzip the Mednafen save state
  • Select the unzipped file in Ghidra
  • The loader will load backup cart memory, high work RAM, and low work RAM to the correct places
  • The loader will add labels for SH-2s PC, PR, and R15 registers

Yabause Save States (YSS)

  • Select any Yabause Save State (YSS)
  • The loader will load backup cart memory, high work RAM, and low work RAM to the correct places
  • The loader will add labels for SH-2s PC, PR, and R15 registers

Applying Sega Saturn Library Signatures

  • After loading in Ghidra, open "Script Manager" and execute ApplySig.py
  • Select the signature file to apply

Issues

  • Code quality needs serious improvement and refactoring
  • Memory map doesn't handle mirrored regions
  • Adding the onchip register region (0xffffffe00-0xffffffff) to the memory map made decompilation worse. So it's disabled.
  • It would be useful to label some globals to assist reversing
  • Mednafen memory cart data doesn't match Yabause's.

Building

  • gradle -PGHIDRA_INSTALL_DIR=<Absolute path to Ghidra>
  • The output zip file will be created within /dist

Installation

  • Ghidra 9.1 added SH-1/SH-2 support.
  • Copy the zip file to <Ghidra install directory>/Extensions/Ghidra.
  • Start Ghidra and use the "Install Extensions" dialog to finish the installation. (File -> Install Extensions...).
  • (Optional but recommended) Install the ApplySig script so you can use Sega Saturn library signatures. Copy to a ghidra_scripts directory.
  • (Optional but recommended) Download CyberWarriorX's Sega Saturn library signatures

Credits/References

ghidra-segasaturn-loader's People

Contributors

vgkintsugi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ghidra-segasaturn-loader's Issues

"Too many sections big!!" error when loading Mednafen save state

Here is a Mednafen save state for Dungeons & Dragons Collection, Disc 1. It fails to load with this error:

----- Loading /C:/Games/Mednafen/mcs/Dungeons & Dragons Collection (Japan) (Disc 1) (Tower of Doom).458e98aeae4d21ae821a665722d2e5b9.mc0 -----
Too many sections big!!
java.io.IOException: Too many sections big!!
	at segasaturnloader.SegaSaturnLoader.mssMakeSectionMap(SegaSaturnLoader.java:1325)
	at segasaturnloader.SegaSaturnLoader.loadMednafenSaveState(SegaSaturnLoader.java:1689)
	at segasaturnloader.SegaSaturnLoader.load(SegaSaturnLoader.java:128)
	at ghidra.app.util.opinion.AbstractLibrarySupportLoader.doLoad(AbstractLibrarySupportLoader.java:724)
	at ghidra.app.util.opinion.AbstractLibrarySupportLoader.loadProgram(AbstractLibrarySupportLoader.java:98)
	at ghidra.app.util.opinion.AbstractProgramLoader.load(AbstractProgramLoader.java:126)
	at ghidra.plugin.importer.ImporterUtilities.importSingleFile(ImporterUtilities.java:368)
	at ghidra.plugin.importer.ImporterDialog.lambda$okCallback$7(ImporterDialog.java:351)
	at ghidra.util.task.TaskBuilder$TaskBuilderTask.run(TaskBuilder.java:306)
	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:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)

Failed to parse MSS sections!
java.io.IOException: Failed to parse MSS sections!
	at segasaturnloader.SegaSaturnLoader.loadMednafenSaveState(SegaSaturnLoader.java:1692)
	at segasaturnloader.SegaSaturnLoader.load(SegaSaturnLoader.java:128)
	at ghidra.app.util.opinion.AbstractLibrarySupportLoader.doLoad(AbstractLibrarySupportLoader.java:724)
	at ghidra.app.util.opinion.AbstractLibrarySupportLoader.loadProgram(AbstractLibrarySupportLoader.java:98)
	at ghidra.app.util.opinion.AbstractProgramLoader.load(AbstractProgramLoader.java:126)
	at ghidra.plugin.importer.ImporterUtilities.importSingleFile(ImporterUtilities.java:368)
	at ghidra.plugin.importer.ImporterDialog.lambda$okCallback$7(ImporterDialog.java:351)
	at ghidra.util.task.TaskBuilder$TaskBuilderTask.run(TaskBuilder.java:306)
	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:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)

Presumably this has something to do with the game's support for the 4MB RAM cartridge. I tried disabling the emulation of that, but got the same error.

Is there anything else I can do to work around this?

Thanks for reading, and for making this loader - I use it all the time!

Attempt to reconstruct sections.

The Saturn SDK examples(entry.s) show bss start and end locations, perhaps this can be used to reconstruct at least some sections?
I haven't checked Saturn binaries with symbols much, but maybe something refs text and data section ranges as well?

Add Support for Loading the Bios

Detect and load the BIOS if supplied by the user. It should be sufficient to check the first 12 bytes of the file.

Also consider a method to load the BIOS in addition to a save state or ISO specified by the user.

Support for loading binaries extracted from discs.

Command & Conquer for the Saturn is a example of a game this plugin can't load.
The game needs to be ripped as bin/cue to retain the CD audio it has.
It has a single binary called 0_CNCSAT.BIN that holds all the game code.

Update List of Mednafen Sections

The list of Mednafen save state sections has significantly changed. Look into updating. For the time being the MSS_MAX_SECTIONS check has been disabled.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.