2323import com .google .security .zynamics .BinExport .BinExport2 ;
2424import com .google .security .zynamics .BinExport .BinExport2 .Builder ;
2525import ghidra .app .nav .NavigationUtils ;
26- import ghidra .program .database .function .OverlappingFunctionException ;
2726import ghidra .program .database .symbol .EquateDB ;
27+ import ghidra .program .flatapi .FlatProgramAPI ;
2828import ghidra .program .model .address .Address ;
2929import ghidra .program .model .address .AddressSetView ;
3030import ghidra .program .model .block .BasicBlockModel ;
6161import ghidra .program .util .DefinedDataIterator ;
6262import ghidra .util .UndefinedFunction ;
6363import ghidra .util .exception .CancelledException ;
64- import ghidra .util .exception .InvalidInputException ;
6564import ghidra .util .task .TaskMonitor ;
6665import java .io .File ;
6766import java .util .ArrayList ;
@@ -749,6 +748,7 @@ private void buildBasicBlocks(
749748
750749 private void promoteUndefinedFunctions () throws CancelledException {
751750 FunctionManager funcManager = program .getFunctionManager ();
751+ FlatProgramAPI flatProgramApi = new FlatProgramAPI (program );
752752
753753 for (var bbIter = bbModel .getCodeBlocks (monitor ); bbIter .hasNext (); ) {
754754 CodeBlock bb = bbIter .next ();
@@ -761,22 +761,12 @@ private void promoteUndefinedFunctions() throws CancelledException {
761761 UndefinedFunction undefinedFunction =
762762 UndefinedFunction .findFunction (program , bbEntryPoint , monitor );
763763 if (undefinedFunction != null ) {
764- try {
765- Function newFunc =
766- funcManager .createFunction (
767- undefinedFunction .getName (),
768- undefinedFunction .getEntryPoint (),
769- undefinedFunction .getBody (),
770- undefinedFunction .getSignatureSource ());
771- if (newFunc != null ) {
772- monitor .setMessage (
773- String .format ("Created undefined function at %x" , getMappedAddress (bbEntryPoint )));
774- System .out .printf ("newUndefinedFunction: %x%n" , getMappedAddress (bbEntryPoint ));
775- }
776- } catch (InvalidInputException | OverlappingFunctionException e ) {
764+ Function newFunc =
765+ flatProgramApi .createFunction (
766+ undefinedFunction .getEntryPoint (), undefinedFunction .getName ());
767+ if (newFunc != null ) {
777768 monitor .setMessage (
778- String .format (
779- "Failed to create undefined function at %x" , getMappedAddress (bbEntryPoint )));
769+ String .format ("Created undefined function at %x" , getMappedAddress (bbEntryPoint )));
780770 }
781771 }
782772 }
0 commit comments