IDA local types has a local type like:
struct DEMOTYPE<int>
{
_DWORD dw1;
_DWORD dw2;
}
how to use "DEMOTYPE"(C++ type) just like normal c type? press Y can not Can't achieve the goal since the "<>" in it.
i know if the target is function,we can change the function declaration with its mangled name.
In a word, how can we use the c++ type declaration in the local types to change the type of the local variable?
Below is the code I tried, but the F5 pseudocode view cannot be changed.
def setVarType(lvname, lti, isptr=False):
addr = idc.here()
c = idaapi.decompile(addr)
for v in c.lvars:
if v.name == lvname:
print("find target variable:", v.name)
idati = ida_typeinf.get_idati()
ti = ida_typeinf.tinfo_t()
if ti.get_numbered_type(idati, lti):
print("find local type:", lti, ":", ti)
if isptr:
ti_ptr = ida_typeinf.tinfo_t()
ti_ptr.create_ptr(ti) # ti_ptr = ti *
bret = v.set_final_lvar_type(ti_ptr)
else:
bret = v.set_final_lvar_type(ti)
print(bret)