Skip to content

Commit

Permalink
Load possible BinaryID from options on program activation
Browse files Browse the repository at this point in the history
  • Loading branch information
fmagin committed Jun 14, 2024
1 parent 335f623 commit 21a2552
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
15 changes: 12 additions & 3 deletions src/main/java/ai/reveng/toolkit/ghidra/core/CorePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import docking.widgets.filechooser.GhidraFileChooser;
import docking.widgets.filechooser.GhidraFileChooserMode;
import ghidra.framework.plugintool.util.PluginStatus;
import ghidra.program.model.listing.Program;
import ghidra.util.Msg;
import ghidra.util.task.MonitoredRunnable;
import ghidra.util.task.RunManager;
Expand Down Expand Up @@ -204,11 +205,19 @@ private void connectToExistingAnalysis(ProgramActionContext context) {
private void connectToAnalysis(BinaryID binID) {
revengService.addBinaryIDforProgram(currentProgram, binID);
Msg.showInfo(this,null, "", "Connected to binary id: " + binID.toString());


}


@Override
protected void programActivated(Program program) {
super.programActivated(program);

if (!revengService.isKnownProgram(program)){
revengService.getBinaryIDFor(program).ifPresentOrElse(
binID -> Msg.info(this, "Program has saved binary ID: " + binID),
() -> Msg.info(this, "Program has no saved binary ID")
);
}
}

@Override
public void init() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,11 @@ public void addBinaryIDforProgram(Program program, BinaryID binID){
/**
* Tries to find a BinaryID for a given program
* If the program already has a BinaryID associated with it, it will return that
* If the program has no BinaryID associated with it and the API doesn't know it, it will return empty
*
* @param program
* @return
*/
private Optional<BinaryID> getBinaryIDFor(Program program){
public Optional<BinaryID> getBinaryIDFor(Program program){
if (programMap.containsKey(program)){
return Optional.of(programMap.get(program));
}
Expand Down

0 comments on commit 21a2552

Please sign in to comment.