From ba938609eae307a7e85495572aaec6d7247fec3f Mon Sep 17 00:00:00 2001 From: mahaloz Date: Thu, 2 Nov 2023 18:06:09 -0700 Subject: [PATCH] Add Ghidra header --- yodalib/decompilers/ghidra/interface.py | 42 ++++++++++++------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/yodalib/decompilers/ghidra/interface.py b/yodalib/decompilers/ghidra/interface.py index f2e77086..5eacc745 100644 --- a/yodalib/decompilers/ghidra/interface.py +++ b/yodalib/decompilers/ghidra/interface.py @@ -136,47 +136,47 @@ def _functions(self) -> Dict[int, Function]: } return funcs - - # - # TODO: REMOVE ME THIS IS THE BINSYNC CODE - # Filler/Setter API - # - - def fill_function(self, func_addr, user=None, artifact=None, **kwargs): - decompilation = self._ghidra_decompile(self._get_nearest_function(func_addr)) - changes = super().fill_function( - func_addr, user=user, artifact=artifact, decompilation=decompilation, **kwargs - ) - - return changes - @ghidra_transaction - def fill_function_header(self, func_addr, user=None, artifact=None, decompilation=None, **kwargs): + def _set_function_header(self, fheader: FunctionHeader, decompilation=None, **kwargs) -> bool: changes = False - func_header: FunctionHeader = artifact + func_addr = fheader.addr ghidra_func = decompilation.getFunction() if decompilation else self._get_nearest_function(func_addr) src_type = self.ghidra.import_module_object("ghidra.program.model.symbol", "SourceType") # func name - if func_header.name and func_header.name != ghidra_func.getName(): - ghidra_func.setName(func_header.name, src_type.USER_DEFINED) + if fheader.name and fheader.name != ghidra_func.getName(): + ghidra_func.setName(fheader.name, src_type.USER_DEFINED) changes = True # return type - if func_header.type and decompilation is not None: - parsed_type = self.typestr_to_gtype(func_header.type) + if fheader.type and decompilation is not None: + parsed_type = self.typestr_to_gtype(fheader.type) if parsed_type is not None and \ parsed_type != str(decompilation.highFunction.getFunctionPrototype().getReturnType()): ghidra_func.setReturnType(parsed_type, src_type.USER_DEFINED) changes = True # args - if func_header.args and decompilation is not None: + if fheader.args and decompilation is not None: # TODO: do arg names and types pass return changes + + # + # TODO: REMOVE ME THIS IS THE BINSYNC CODE + # Filler/Setter API + # + + def fill_function(self, func_addr, user=None, artifact=None, **kwargs): + decompilation = self._ghidra_decompile(self._get_nearest_function(func_addr)) + changes = super().fill_function( + func_addr, user=user, artifact=artifact, decompilation=decompilation, **kwargs + ) + + return changes + @ghidra_transaction def fill_struct(self, struct_name, header=True, members=True, artifact=None, **kwargs): struct: Struct = artifact;