Files
ghidra/Ghidra/Features/DecompilerDependent/ghidra_scripts/ExportFunctionPcodeViaDecoderScript.java
d-millar 5a18cda21e GP-7062: final pass
GP-7062: comments on intent
GP-7062: post-review
GP-7062: cleanup
GP-7062: rename
GP-7062: edges
GP-7062: slight revert; bug fix
GP-7062: single function task
GP-7062: first pass
GP-7062: some progressGP-7062: workingishGP-7062: works for geditGP-7062: script -> classesGP-7062: script -> classesGP-7062: typesGP-7062: towards testingGP-7062: towards testingGP-7062: datalog addsGP-7062: datalog addsGP-7062: slow progressGP-7062: getting thereGP-7062: better vnode logicGP-7062: better vnode logicGP-7062: yay, working (at least a little)GP-7062: sane PCODE_ resultsGP-7062: on to sarif resultsGP-7062: sarif workingGP-7062: maybe fixed?GP-7062: mo' betta'GP-7062: probably a lot more to doGP-7062: cleanup for hvar/vnode
2026-09-02 17:04:43 +00:00

62 lines
1.9 KiB
Java

/* ###
* IP: GHIDRA
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//Decompile the function at the cursor and its callees, then output facts files corresponding to the pcodes
//@category PCode
import java.io.File;
import ghidra.app.plugin.core.decompiler.export.ExportDecompilationTask;
import ghidra.app.script.GhidraScript;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.listing.Function;
import ghidra.program.model.listing.FunctionManager;
import ghidra.util.task.TaskLauncher;
public class ExportFunctionPcodeViaDecoderScript extends GhidraScript {
File outputDirectory;
@Override
protected void run() throws Exception {
String[] args = getScriptArgs();
PluginTool tool = state.getTool();
if (tool == null) {
println("Script is not running in GUI");
}
if (args.length >= 1) {
outputDirectory = new File(args[0]);
}
else {
outputDirectory = askDirectory("Select Directory for Results", "OK");
}
long startTime = System.nanoTime();
FunctionManager functionManager = currentProgram.getFunctionManager();
Function currentFunction = functionManager.getFunctionContaining(currentAddress);
ExportDecompilationTask task =
new ExportDecompilationTask("Export Pcode", currentProgram, currentFunction,
outputDirectory);
TaskLauncher.launch(task);
long endTime = System.nanoTime();
long duration = (endTime - startTime) / 1000000;
println("total duration: " + Long.toString(duration));
}
}