Reverse Engineering Asked by brainstorm on August 11, 2021
I figured it’d be more appropriate to ask this question here:
https://github.com/NationalSecurityAgency/ghidra/issues/2530#issuecomment-785007613
Given this linear address space a particular MCU:
It’s not easily definable as-is on the memory manager, see:
memory = currentProgram.getMemory()
fb = memory.getAllFileBytes()
blk = memory.getBlock(toAddr(0x0))
memory.removeBlock(blk, monitor)
memory.createUninitializedBlock("internal_ram",toAddr(0x3ff8000),0x2fff,False)
memory.createUninitializedBlock("peripherals", toAddr(0x3ffefff),0xfff, False)
memory.createInitializedBlock("rom", toAddr(0x0), fb[0], 0, 0x1000000, False)
disassemble(toAddr(0x0))
Yields:
Traceback (most recent call last):
File "python", line 1, in <module>
at ghidra.program.database.mem.MemoryMapDB.checkBlock(MemoryMapDB.java:1043)
at ghidra.program.database.mem.MemoryMapDB.removeBlock(MemoryMapDB.java:1850)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: Blocks do not belong to this program
ghidra.program.database.mem.MemoryBlockDB@6f03ae13
ghidra.program.database.mem.MemoryBlockDB@38d5ac1c
ghidra.program.database.mem.MemoryBlockDB@6ad8b9ac
What would be the correct sequence of arguments/flags/(instruction ordering?) to have a correct representation of a loaded V850 16MB firmware (size 0x1000000) on Ghidra? What am I doing wrong?
Note to self, when running memory.removeBlock(blk, monitor)
make sure that the memory map is not empty from previous wipes/redefinitions (iterations of the script).
In other words, opening a file creates a default memory map, but the script wasn't contemplating the case where the address map was empty to begin with.
Correct answer by brainstorm on August 11, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP