Skip to content

Instantly share code, notes, and snippets.

@v-p-b
Created March 26, 2025 16:10
Show Gist options
  • Save v-p-b/c7d934234297158047b678f655c7d99f to your computer and use it in GitHub Desktop.
Save v-p-b/c7d934234297158047b678f655c7d99f to your computer and use it in GitHub Desktop.
Dumb Debug Dump - Create Map Debug Files from Ghidra
# Dumb Debug Dump
# @author buherator
# @category _NEW_
# @keybinding
# @menupath
# @toolbar
# @runtime Jython
from docking.widgets.filechooser import GhidraFileChooser, GhidraFileChooserMode
addressFactory = getAddressFactory()
zero_address = addressFactory.getAddress("0")
fun = getFunctionAfter(zero_address)
memory_blocks = getMemoryBlocks()
save_dialog = GhidraFileChooser(None)
with open(str(save_dialog.getSelectedFile()), "w") as map:
map.write("\n Start Length Name Class\n")
for i, mb in enumerate(memory_blocks):
segment_class = "DATA"
if mb.isExecute():
segment_class = "CODE"
map.write(
" %04x:%016x %016x %s %s\n"
% (i, mb.getStart().getOffset(), mb.getSize(), mb.getName(), segment_class)
)
map.write("\n\n Address Publics by Value\n\n")
while fun is not None:
fun_segment = None
fun_offset = None
for i, mb in enumerate(memory_blocks):
if mb.contains(fun.getEntryPoint()):
fun_segment = i
fun_offset = fun.getEntryPoint().subtract(mb.getStart())
break
if fun_segment is None:
print("[!] Can't find segment for function %s" % (fun.getName()))
continue
fun_name=fun.getSymbol().getName(True)
map.write(
" %08x:%016x %s\n"
% (fun_segment, fun_offset, fun_name)
)
fun = getFunctionAfter(fun)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment