mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 17:59:46 +02:00
Merge remote-tracking branch
'origin/GP-5604_James_bsim_overview_listener--SQUASHED' (Closes #7903)
This commit is contained in:
commit
ce8835ef7d
4 changed files with 40 additions and 11 deletions
|
@ -98,7 +98,8 @@ public class BSimOverviewModel extends AddressBasedTableModel<BSimOverviewRowObj
|
||||||
|
|
||||||
for (SimilarityVectorResult result : response.result) {
|
for (SimilarityVectorResult result : response.result) {
|
||||||
Address addr = BSimMatchResultsModel.recoverAddress(result.getBase(), program);
|
Address addr = BSimMatchResultsModel.recoverAddress(result.getBase(), program);
|
||||||
BSimOverviewRowObject row = new BSimOverviewRowObject(result, addr, vectorFactory);
|
BSimOverviewRowObject row =
|
||||||
|
new BSimOverviewRowObject(result, addr, vectorFactory, program);
|
||||||
addObject(row);
|
addObject(row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,7 +114,8 @@ public class BSimOverviewModel extends AddressBasedTableModel<BSimOverviewRowObj
|
||||||
results.clear();
|
results.clear();
|
||||||
for (SimilarityVectorResult result : response.result) {
|
for (SimilarityVectorResult result : response.result) {
|
||||||
Address addr = BSimMatchResultsModel.recoverAddress(result.getBase(), program);
|
Address addr = BSimMatchResultsModel.recoverAddress(result.getBase(), program);
|
||||||
BSimOverviewRowObject row = new BSimOverviewRowObject(result, addr, vectorFactory);
|
BSimOverviewRowObject row =
|
||||||
|
new BSimOverviewRowObject(result, addr, vectorFactory, program);
|
||||||
results.add(row);
|
results.add(row);
|
||||||
}
|
}
|
||||||
super.reload();
|
super.reload();
|
||||||
|
|
|
@ -15,6 +15,9 @@
|
||||||
*/
|
*/
|
||||||
package ghidra.features.bsim.gui.overview;
|
package ghidra.features.bsim.gui.overview;
|
||||||
|
|
||||||
|
import static ghidra.framework.model.DomainObjectEvent.*;
|
||||||
|
import static ghidra.program.util.ProgramEvent.*;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
|
@ -36,6 +39,7 @@ import ghidra.features.bsim.gui.search.dialog.BSimSearchSettings;
|
||||||
import ghidra.features.bsim.gui.search.results.BSimSearchInfoDisplayDialog;
|
import ghidra.features.bsim.gui.search.results.BSimSearchInfoDisplayDialog;
|
||||||
import ghidra.features.bsim.query.BSimServerInfo;
|
import ghidra.features.bsim.query.BSimServerInfo;
|
||||||
import ghidra.features.bsim.query.protocol.ResponseNearestVector;
|
import ghidra.features.bsim.query.protocol.ResponseNearestVector;
|
||||||
|
import ghidra.framework.model.DomainObjectListener;
|
||||||
import ghidra.framework.plugintool.ComponentProviderAdapter;
|
import ghidra.framework.plugintool.ComponentProviderAdapter;
|
||||||
import ghidra.program.model.address.Address;
|
import ghidra.program.model.address.Address;
|
||||||
import ghidra.program.model.listing.Program;
|
import ghidra.program.model.listing.Program;
|
||||||
|
@ -62,6 +66,7 @@ public class BSimOverviewProvider extends ComponentProviderAdapter {
|
||||||
private BSimServerInfo serverInfo;
|
private BSimServerInfo serverInfo;
|
||||||
|
|
||||||
private BSimSearchSettings settings;
|
private BSimSearchSettings settings;
|
||||||
|
private DomainObjectListener listener;
|
||||||
|
|
||||||
public BSimOverviewProvider(BSimSearchPlugin plugin, BSimServerInfo serverInfo, Program program,
|
public BSimOverviewProvider(BSimSearchPlugin plugin, BSimServerInfo serverInfo, Program program,
|
||||||
LSHVectorFactory vFactory, BSimSearchSettings settings) {
|
LSHVectorFactory vFactory, BSimSearchSettings settings) {
|
||||||
|
@ -87,6 +92,13 @@ public class BSimOverviewProvider extends ComponentProviderAdapter {
|
||||||
|
|
||||||
createActions();
|
createActions();
|
||||||
updateSubTitle();
|
updateSubTitle();
|
||||||
|
listener = ev -> {
|
||||||
|
if (ev.contains(SYMBOL_RENAMED, RESTORED)) {
|
||||||
|
overviewModel.fireTableDataChanged();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
program.addListener(listener);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Program getProgram() {
|
public Program getProgram() {
|
||||||
|
@ -217,6 +229,7 @@ public class BSimOverviewProvider extends ComponentProviderAdapter {
|
||||||
public void componentHidden() {
|
public void componentHidden() {
|
||||||
super.componentHidden();
|
super.componentHidden();
|
||||||
if (plugin != null) {
|
if (plugin != null) {
|
||||||
|
program.removeListener(listener);
|
||||||
plugin.providerClosed(this);
|
plugin.providerClosed(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,21 +21,31 @@ import ghidra.features.bsim.query.description.FunctionDescription;
|
||||||
import ghidra.features.bsim.query.description.SignatureRecord;
|
import ghidra.features.bsim.query.description.SignatureRecord;
|
||||||
import ghidra.features.bsim.query.protocol.SimilarityVectorResult;
|
import ghidra.features.bsim.query.protocol.SimilarityVectorResult;
|
||||||
import ghidra.program.model.address.Address;
|
import ghidra.program.model.address.Address;
|
||||||
|
import ghidra.program.model.listing.Function;
|
||||||
|
import ghidra.program.model.listing.Program;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Table row object for BSim Overview results table
|
* Table row object for BSim Overview results table
|
||||||
*/
|
*/
|
||||||
public class BSimOverviewRowObject {
|
public class BSimOverviewRowObject {
|
||||||
private Address addr;
|
private Address addr;
|
||||||
private FunctionDescription func;
|
|
||||||
private SimilarityVectorResult simvec;
|
private SimilarityVectorResult simvec;
|
||||||
private double selfsignif; // Maximum significance score a query with this function could return
|
private double selfsignif; // Maximum significance score a query with this function could return
|
||||||
private long vectorHash;
|
private long vectorHash;
|
||||||
|
private Function function;
|
||||||
|
|
||||||
public BSimOverviewRowObject(SimilarityVectorResult result,Address ad,LSHVectorFactory vectorFactory) {
|
/**
|
||||||
|
* Constructor.
|
||||||
|
* @param result results for queried function
|
||||||
|
* @param ad address of function
|
||||||
|
* @param vectorFactory vectoryFactory
|
||||||
|
* @param program program containing queried function
|
||||||
|
*/
|
||||||
|
public BSimOverviewRowObject(SimilarityVectorResult result, Address ad,
|
||||||
|
LSHVectorFactory vectorFactory, Program program) {
|
||||||
addr = ad;
|
addr = ad;
|
||||||
simvec = result;
|
simvec = result;
|
||||||
func = simvec.getBase();
|
FunctionDescription func = simvec.getBase();
|
||||||
selfsignif = 0.0;
|
selfsignif = 0.0;
|
||||||
SignatureRecord sigrec = func.getSignatureRecord();
|
SignatureRecord sigrec = func.getSignatureRecord();
|
||||||
if (sigrec != null) {
|
if (sigrec != null) {
|
||||||
|
@ -43,11 +53,14 @@ public class BSimOverviewRowObject {
|
||||||
}
|
}
|
||||||
LSHVector lshVector = func.getSignatureRecord().getLSHVector();
|
LSHVector lshVector = func.getSignatureRecord().getLSHVector();
|
||||||
vectorHash = lshVector.calcUniqueHash();
|
vectorHash = lshVector.calcUniqueHash();
|
||||||
|
function = program.getFunctionManager().getFunctionAt(ad);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFunctionName() {
|
public String getFunctionName() {
|
||||||
return func.getFunctionName();
|
if (function == null || function.isDeleted()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return function.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Address getFunctionEntryPoint() {
|
public Address getFunctionEntryPoint() {
|
||||||
|
|
|
@ -127,6 +127,7 @@ public class BSimSearchResultsProvider extends ComponentProviderAdapter {
|
||||||
public void componentHidden() {
|
public void componentHidden() {
|
||||||
super.componentHidden();
|
super.componentHidden();
|
||||||
if (plugin != null) {
|
if (plugin != null) {
|
||||||
|
program.removeListener(listener);
|
||||||
plugin.providerClosed(this);
|
plugin.providerClosed(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue