I am using the hexray api to get all the items of the AST tree (the ctree) obtained by decompiling a function.
Unfortunately, the treeitems vector is always empty. Specifically, the function paaaa in this code returns always '0' or 'E'.
from idautils import *
from idaapi import *
import idc
import ida_hexrays as hexray
def load_hex_ray():
if not init_hexrays_plugin():
idc.RunPlugin("hexx64", 0)
if not init_hexrays_plugin():
idc.RunPlugin("hexrays", 0)
if not init_hexrays_plugin():
idc.RunPlugin("hexarm", 0)
def paaaaa(address):
try:
cfun=hexray.decompile(address)
#if I print cfun it shows correct decompiled code.
cfun.refcnt=cfun.refcnt+1
cfun.build_c_tree()
return str((cfun.treeitems.size()))
except:
return 'E'
load_hex_ray()
#code that compute functions addresses and calls paaaaa
Any idea on what can be wrong? I am using an old version of IDA 7.0