I am using IDA Pro 7.6 on win32 x86 binaries.
I'm trying to use the ida_hexrays interface to decompile subroutines. I want all of the local variables and arguments of the subroutine to have integral types, no pointer types. I made this function to do all the processing for me
import ida_hexrays
import ida_typeinf as ida_type
import ida_lines
def decompile_function( function_location ):
decompile_handle = ida_hexrays.decompile( function_location, flags = ida_hexrays.DECOMP_NO_CACHE )
for local_variable in decompile_handle.lvars:
type_info = local_variable.type()
try:
if ida_type.is_type_ptr( type_info.get_decltype() ):
pointed_object = type_info.get_pointed_object()
if ida_type.is_type_integral( pointed_object.get_decltype() ):
local_variable.set_lvar_type( type_info.get_pointed_object() )
except:
pass
decompile_handle.refresh_func_ctext()
pseudo_code = decompile_handle.get_pseudocode()
decompile_result = ""
for code_line in pseudo_code:
decompile_result = decompile_result + ida_lines.tag_remove( code_line.line ) + "\n";
return decompile_result
When I decompile, I can see in the variable list that all of the variables are integral types
unsigned __int8 v7; // al
int v10; // eax
unsigned int v11; // esi
const char v12; // cl
_DWORD v13; // eax
v13 = (_DWORD *)v11;
However, as you may notice above, v13 = (_DWORD *)v11
v13 is improperly being set as a pointer. As it turns out, none of the code except the variable declarations gets changed. This happens for every subroutine that I try to decompile with this.
But when I right-click and use reset pointer value, the code changes and it would look like v13 = v11;
. What is the issue with my code, or is IDAPython/IDAHexrays to blame? How do I make it actually reset the pointer value and not just in the declaration list?