Created
September 27, 2020 16:59
-
-
Save pawlos/a0f5f05c1ca146affb5212c9ad9cfadf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#exceptional | |
from ghidra.program.model.listing import CodeUnitFormat, CodeUnitFormatOptions | |
from ghidra.program.model.symbol import RefType | |
codeUnitFormat = CodeUnitFormat(CodeUnitFormatOptions(CodeUnitFormatOptions.ShowBlockName.ALWAYS,CodeUnitFormatOptions.ShowNamespace.ALWAYS,"",True,True,True,True,True,True,True)) | |
addr = toAddr('<start_address>') | |
limiter = 0 | |
instruction = currentProgram.getListing().getInstructionAt(addr) | |
while True: | |
t = instruction.getFlowType() | |
if t == RefType.UNCONDITIONAL_CALL: | |
dest_addr = toAddr(int(str(instruction)[7:],16)) | |
sym = currentProgram.symbolTable.getPrimarySymbol(dest_addr) | |
if 'FUN_' in str(sym): | |
addr = dest_addr | |
instruction = currentProgram.getListing().getInstructionAt(addr) | |
continue | |
print(codeUnitFormat.getRepresentationString(instruction)) | |
instruction = instruction.getNext() | |
limiter += 1 | |
if limiter > 50: | |
break | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment