Hot answers tagged

5

The firmware is incorrectly dumped. In your file all occurrences of the byte 0A have been replaced with 0D 0A. Looks like a line ending issue. May be the tool which you have used to dump the firmware have prepended a 0D to each 0A. After replacing all instances of 0D 0A with 0A, it has an exact size of 256 KiB (262144 bytes) as it should be. Previously it ...


5

You can use currentProgram.getImageBase() to obtain the base address. This returns an Address object. Example >>> currentProgram.getImageBase() 00400000 >>> type(currentProgram.getImageBase()) <type 'ghidra.program.model.address.GenericAddress'> >>> currentProgram.getImageBase().getOffset() 4194304L >>> hex(...


3

You can obtain the list of all defined basic blocks using BasicBlockModel Example from ghidra.program.model.block import BasicBlockModel from ghidra.util.task import TaskMonitor bbm = BasicBlockModel(currentProgram) blocks = bbm.getCodeBlocks(TaskMonitor.DUMMY) block = blocks.next() while block: print "Label: {}".format(block.name) print "Min ...


3

TL;DR: This is not an error from Ghidra. The values are just a naming convention, and the real instructions are correctly disassembled. Ghidra assigns variable names based on the function entry point, and displays offsets based on that. It seems Ghidra behaviour is like this to have a universal way to assign names, independently from the compiler. As ...


2

Yaldi already mentioned the important first step of Commit Locals for finer variable scoping. If your Ghidra version has at least the commit https://github.com/NationalSecurityAgency/ghidra/commit/885402bbc3618b895c4b9b8f09300d3120a9abe8 which will probably be in the 9.2 release you can explicitly split a variable after Commit Locals, by right clicking the ...


2

@0xec's answer is great. This script will help you get blocks function wise. from ghidra.program.model.block import BasicBlockModel blockiterator = BasicBlockModel(currentProgram).getCodeBlocks(monitor) # dictionary contains function wise basic block information functions = {} def add_block(function, block): if function not in functions: ...


1

0xec has answered you but if you are interested in functions you can iterate as below #TODO Lists Functions in a given program #@author blabb #@category _NEW_ funcs = currentProgram.getFunctionManager().getFunctions(True) f1 = funcs.next() print("Function Name",f1.getName()) print("Function Body" , f1.getBody()) print("Function Entry" , f1.getEntryPoint()...


1

This workaround is suggested by GitHub user ubitux, here: https://github.com/NationalSecurityAgency/ghidra/issues/1510, and I can confirm it works around the problem to some degrees. When you "Commit Locals" for the function, some variable types and the names will be fixed, and the variable scopes will become smaller, so that one variable will be ...


1

This is a feature that isn't in the current (March 2020) release (9.1.2) and requires at least the commit https://github.com/NationalSecurityAgency/ghidra/commit/885402bbc3618b895c4b9b8f09300d3120a9abe8 This will most like be contained in the 9.2 release, for now you would need to build from master. For registers you can do it: Right click in the ...


Only top voted, non community-wiki answers of a minimum length are eligible