-
Notifications
You must be signed in to change notification settings - Fork 6
/
CtrlPQuicklaunchScript.java
41 lines (37 loc) · 1.59 KB
/
CtrlPQuicklaunchScript.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import ghidra.app.script.GhidraScript;
import java.awt.*;
import javax.swing.JFrame;
import generic.jar.ResourceFile;
import ghidra.app.script.*;
import ghidra.app.services.*;
import ghidra.framework.plugintool.*;
import ghidra.util.task.*;
public class CtrlPQuicklaunchScript extends GhidraScript {
@Override
public void run() throws Exception {
String expectedName = "CtrlP - " + getCurrentProgram().getDomainFile().toString();
for (Window window : Window.getWindows()) {
if (window instanceof JFrame) {
JFrame frame = (JFrame) window;
if (frame.getTitle().equals(expectedName) && frame.isDisplayable()) {
if (frame.isShowing()) {
frame.setVisible(false);
} else {
frame.setVisible(true);
}
return;
}
}
}
println("CtrlP window not found, launching it: " + expectedName);
ConsoleService consoleService = state.getTool().getService(ConsoleService.class);
ResourceFile script = GhidraScriptUtil.findScriptByName("ctrlp.py");
if (script == null) {
println("ctrl.py script not found - install it, or run it manually if you changed the filename");
return;
}
GhidraScriptProvider provider = GhidraScriptUtil.getProvider(script);
GhidraScript scriptInstance = provider.getScriptInstance(script, consoleService.getStdOut());
scriptInstance.execute(state, TaskMonitor.DUMMY, consoleService.getStdOut());
}
}