NationalSecurityAgency / ghidra

Ghidra is a software reverse engineering (SRE) framework
https://www.nsa.gov/ghidra
Apache License 2.0
51.17k stars 5.83k forks source link

getPcodeOps(Address refAddr) method returns NULL because hfunction is NULL #4277

Open Yash0day opened 2 years ago

Yash0day commented 2 years ago

I have been using a small python script to access the pcodes of each function using Ghidra scripting engine. The script works fine for small binaries(I think) but doesn't work for large binaries. It is because the hfunction returns NULL resulting in error(Screenshot below). Ghidra Github: https://github.com/NationalSecurityAgency/ghidra/blob/master/Ghidra/Features/Decompiler/ghidra_scripts/ShowCCallsScript.java image

This error comes after the hfunction == None as given below: image

However, this was not happening with small binaries. I have tested this is 750 KB binaries where it was working fine. Whereas for 1350 KB, I was getting the error. (I can be wrong).

The python script along with both kind of binaries are kept in the ghidra repo given below. The large file is the one getting error whereas the smaller one gives a proper output with the python script. https://github.com/Yash0day/Ghidrapython

I have tried increasing the Decompiler Timeout from 30 to 240 and still having the error.

mumbel commented 2 years ago

no, your high_func is None, if hFunction was null in the snippet above it would exit early.

Yash0day commented 2 years ago

Do you know why is that happening? high = res.getHighFunction() from my piece of .py code gives NONE. Hence, getHighFunction() is faulty.