Skip to content

AddMemoryBlocks ​

Tool tools/ghidra/AddMemoryBlocks.java (ghidra, Ghidra scripts). Build a program's memory from raw pieces: a booter game's load map, an unpacked memory dump, a console's ROM banks, or overlays loaded at run time.

A Ghidra script: scripts/ghidra-export.sh and scripts/ghidra-run.sh run it headless. Source on GitHub.

Its own help ​

This is the help text in the tool itself, as ./gameframe tool AddMemoryBlocks prints it.

text
Build a program's memory from raw pieces: a booter game's load map, an unpacked memory dump,
a console's ROM banks, or overlays loaded at run time. Each piece becomes a memory block at
its address, so references between the pieces resolve and Ghidra can analyse them as one.

Usage: analyzeHeadless PROJECT NAME -import FIRST.bin -loader BinaryLoader \
  -loader-baseAddr ADDR -processor LANGUAGE -postScript AddMemoryBlocks.java MAP.tsv
or, on a program already in a project: scripts/ghidra-run.sh BINARY blocks OUT MAP.tsv

MAP.tsv has one line per piece: file<TAB>address[<TAB>offset[<TAB>length[<TAB>name[<TAB>code]]]].
"code" in the last column disassembles from the piece's first byte and makes a function there.
Paths are relative to the map file. Addresses take Ghidra's form, such as 0x8000 or 1000:0000
for 16-bit segmented code. A piece that overlaps an existing block is added as an overlay
block, as for code banks that share an address range. Lines starting with # are comments.
The script writes a short report to OUTPUT when one is given before the map (ghidra-run.sh).

Code: Apache 2.0. Content: CC0 1.0. No game material: bring your own copy.