MCPcopy Create free account
hub / github.com/JHUAPL/CodeCut / writeToFile

Function writeToFile

codecut-gui/ghidra_scripts/std.py:142–166  ·  view source on GitHub ↗
(filename, extern, label)

Source from the content-addressed store, hash-verified

140
141# Wrapper function to write to file
142def writeToFile(filename, extern, label):
143 file = open(filename,'w')
144 # External functions
145 print >>file, """#include "ghidra.h"\n"""
146 for item in extern:
147 print("extern:",item)
148 functionList = getGlobalFunctions(item)
149 print(functionList)
150 if len(functionList) > 0:
151 function = functionList[0]
152 #if function is not None:
153 results = function.getSignature().getPrototypeString()
154 results = "extern " + results + ";"
155 print("Results:", results)
156 print >>file, results
157
158 # Decompiled functions
159 for item in label:
160 # function = getGlobalFunctions(item)[0]
161 function = currentProgram.getFunctionManager().getFunctionAt(getAddress(item))
162 results = ifc.decompileFunction(function, 0, ConsoleTaskMonitor())
163 filedata = results.getDecompiledFunction().getC()
164 file.write(filedata)
165
166 file.close()

Callers

nothing calls this directly

Calls 1

getAddressFunction · 0.85

Tested by

no test coverage detected