-
I'm trying to retrieve a function at a specific address in Ghidra, but Is there a way to programmatically retrieve or treat an undefined function at an address as a function? Ideally, I'd like to decompile it: Here's my hacked script: import re
from time import sleep
import ghidra
def collect_and_print_matches():
pattern = r'L"([^"]+)"' # Regex to capture wide string literals
refs = getReferencesTo(toAddr(0x112A7EB0))
decomp = ghidra.app.decompiler.DecompInterface()
decomp.openProgram(currentProgram)
valid_function_count = 0 # Counter for valid functions
for ref in refs:
func = getFunctionContaining(ref.getFromAddress())
if not func:
# ???
else:
decomp_results = decomp.decompileFunction(func, 30, monitor)
if decomp_results.decompileCompleted():
fn_code = decomp_results.getDecompiledFunction().getC()
matches = re.findall(pattern, fn_code) |
Beta Was this translation helpful? Give feedback.
Answered by
astrelsky
Mar 11, 2025
Replies: 1 comment 4 replies
-
|
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
bukowa
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ghidra.util.UndefinedFunction.findFunction(Program program, Address address, TaskMonitor monitor)