mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 09:49:23 +02:00
Merge remote-tracking branch 'origin/GP-3814-dragonmacher-vt-api-update--SQUASHED'
This commit is contained in:
commit
a06ccc11ab
68 changed files with 740 additions and 689 deletions
|
@ -151,7 +151,7 @@ public class GhidraState {
|
|||
/**
|
||||
* If it differs, set the current location and fire a {@link ProgramLocationPluginEvent}.
|
||||
*
|
||||
* @param location
|
||||
* @param location the location
|
||||
*/
|
||||
public void setCurrentLocation(ProgramLocation location) {
|
||||
if (SystemUtilities.isEqual(currentLocation, location)) {
|
||||
|
|
|
@ -17,15 +17,14 @@
|
|||
// data and and then save the session.
|
||||
//@category Examples.Version Tracking
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import ghidra.app.script.GhidraScript;
|
||||
import ghidra.feature.vt.api.db.VTSessionDB;
|
||||
import ghidra.feature.vt.api.main.VTSession;
|
||||
import ghidra.feature.vt.api.util.VTOptions;
|
||||
import ghidra.feature.vt.gui.actions.AutoVersionTrackingTask;
|
||||
import ghidra.feature.vt.gui.plugin.*;
|
||||
import ghidra.feature.vt.gui.plugin.VTController;
|
||||
import ghidra.framework.model.DomainFolder;
|
||||
import ghidra.framework.plugintool.Plugin;
|
||||
import ghidra.framework.options.ToolOptions;
|
||||
import ghidra.framework.plugintool.PluginTool;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.util.task.TaskLauncher;
|
||||
|
@ -77,31 +76,19 @@ public class AutoVersionTrackingScript extends GhidraScript {
|
|||
|
||||
folder.createFile(name, session, monitor);
|
||||
|
||||
PluginTool tool = state.getTool();
|
||||
VTPlugin vtPlugin = getPlugin(tool, VTPlugin.class);
|
||||
if (vtPlugin == null) {
|
||||
tool.addPlugin(VTPlugin.class.getName());
|
||||
vtPlugin = getPlugin(tool, VTPlugin.class);
|
||||
}
|
||||
|
||||
VTController controller = new VTControllerImpl(vtPlugin);
|
||||
|
||||
//String description = "AutoVTScript";
|
||||
|
||||
AutoVersionTrackingTask autoVtTask =
|
||||
new AutoVersionTrackingTask(controller, session, 1.0, 10.0);
|
||||
new AutoVersionTrackingTask(session, getOptions(), 1.0, 10.0);
|
||||
|
||||
TaskLauncher.launch(autoVtTask);
|
||||
}
|
||||
|
||||
public static <T extends Plugin> T getPlugin(PluginTool tool, Class<T> c) {
|
||||
List<Plugin> list = tool.getManagedPlugins();
|
||||
for (Plugin p : list) {
|
||||
if (p.getClass() == c) {
|
||||
return c.cast(p);
|
||||
private ToolOptions getOptions() {
|
||||
ToolOptions vtOptions = new VTOptions("Dummy");
|
||||
PluginTool tool = state.getTool();
|
||||
if (tool != null) {
|
||||
vtOptions = tool.getOptions(VTController.VERSION_TRACKING_OPTIONS_NAME);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return vtOptions;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@ import ghidra.feature.vt.api.markuptype.*;
|
|||
import ghidra.feature.vt.api.util.*;
|
||||
import ghidra.framework.model.DomainFolder;
|
||||
import ghidra.framework.options.ToolOptions;
|
||||
import ghidra.framework.plugintool.PluginTool;
|
||||
import ghidra.program.model.address.AddressSet;
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.program.model.listing.Program;
|
||||
|
@ -74,7 +73,6 @@ public class CreateAppliedExactMatchingSessionScript extends GhidraScript {
|
|||
|
||||
int sessionTransaction = session.startTransaction(description);
|
||||
try {
|
||||
PluginTool serviceProvider = state.getTool();
|
||||
VTAssociationManager manager = session.getAssociationManager();
|
||||
|
||||
// should we have convenience methods in VTCorrelator that don't
|
||||
|
@ -87,16 +85,16 @@ public class CreateAppliedExactMatchingSessionScript extends GhidraScript {
|
|||
VTProgramCorrelatorFactory factory;
|
||||
|
||||
factory = new ExactDataMatchProgramCorrelatorFactory();
|
||||
correlateAndPossiblyApply(sourceProgram, destinationProgram, session, serviceProvider,
|
||||
manager, sourceAddressSet, destinationAddressSet, factory);
|
||||
correlateAndPossiblyApply(session, manager, sourceAddressSet, destinationAddressSet,
|
||||
factory);
|
||||
|
||||
factory = new ExactMatchBytesProgramCorrelatorFactory();
|
||||
correlateAndPossiblyApply(sourceProgram, destinationProgram, session, serviceProvider,
|
||||
manager, sourceAddressSet, destinationAddressSet, factory);
|
||||
correlateAndPossiblyApply(session, manager, sourceAddressSet, destinationAddressSet,
|
||||
factory);
|
||||
|
||||
factory = new ExactMatchInstructionsProgramCorrelatorFactory();
|
||||
correlateAndPossiblyApply(sourceProgram, destinationProgram, session, serviceProvider,
|
||||
manager, sourceAddressSet, destinationAddressSet, factory);
|
||||
correlateAndPossiblyApply(session, manager, sourceAddressSet, destinationAddressSet,
|
||||
factory);
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
|
@ -110,8 +108,7 @@ public class CreateAppliedExactMatchingSessionScript extends GhidraScript {
|
|||
}
|
||||
}
|
||||
|
||||
private void correlateAndPossiblyApply(Program sourceProgram, Program destinationProgram,
|
||||
VTSession session, PluginTool serviceProvider, VTAssociationManager manager,
|
||||
private void correlateAndPossiblyApply(VTSession session, VTAssociationManager manager,
|
||||
AddressSetView sourceAddressSet, AddressSetView destinationAddressSet,
|
||||
VTProgramCorrelatorFactory factory)
|
||||
throws CancelledException, VTAssociationStatusException {
|
||||
|
@ -121,7 +118,7 @@ public class CreateAppliedExactMatchingSessionScript extends GhidraScript {
|
|||
AddressSetView restrictedDestinationAddresses =
|
||||
excludeAcceptedMatches(session, destinationAddressSet, false);
|
||||
VTOptions options = factory.createDefaultOptions();
|
||||
VTProgramCorrelator correlator = factory.createCorrelator(serviceProvider, sourceProgram,
|
||||
VTProgramCorrelator correlator = factory.createCorrelator(sourceProgram,
|
||||
restrictedSourceAddresses, destinationProgram, restrictedDestinationAddresses, options);
|
||||
|
||||
VTMatchSet results = correlator.correlate(session, monitor);
|
||||
|
|
|
@ -64,9 +64,9 @@ public class FindChangedFunctionsScript extends GhidraVersionTrackingScript {
|
|||
|
||||
// Make sure the selected programs are not open and locked by Ghidra. If so,
|
||||
// warn the user.
|
||||
if (areProgramsLocked(p1, p2)) {
|
||||
Msg.showError(this, null, "Program is locked!",
|
||||
"One of the programs you selected is locked by Ghidra. Please correct and try again.");
|
||||
if (areProgramsLocked()) {
|
||||
Msg.showError(this, null, "Program is locked!", "One of the programs you selected is " +
|
||||
"locked by Ghidra. Please correct and try again.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -95,11 +95,9 @@ public class FindChangedFunctionsScript extends GhidraVersionTrackingScript {
|
|||
* Note: calling {@link Program#isLocked()} does not work here; we must
|
||||
* check to see if one of the programs is the currently-open program.
|
||||
*
|
||||
* @param p1 the first program
|
||||
* @param p2 the second program
|
||||
* @return true if either program is locked
|
||||
*/
|
||||
private boolean areProgramsLocked(Program p1, Program p2) {
|
||||
private boolean areProgramsLocked() {
|
||||
return p1 == currentProgram || p2 == currentProgram;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,8 +36,8 @@ public abstract class GhidraVersionTrackingScript extends GhidraScript {
|
|||
|
||||
private int transactionID;
|
||||
|
||||
public void createVersionTrackingSession(String sourceProgramPath, String destinationProgramPath)
|
||||
throws Exception {
|
||||
public void createVersionTrackingSession(String sourceProgramPath,
|
||||
String destinationProgramPath) throws Exception {
|
||||
|
||||
if (vtSession != null) {
|
||||
throw new RuntimeException("Attempted to open a new session with one already open!");
|
||||
|
@ -123,8 +123,8 @@ public abstract class GhidraVersionTrackingScript extends GhidraScript {
|
|||
|
||||
}
|
||||
|
||||
public Program openProgram(String path) throws VersionException, CancelledException,
|
||||
IOException {
|
||||
public Program openProgram(String path)
|
||||
throws VersionException, CancelledException, IOException {
|
||||
if (state.getProject() == null) {
|
||||
throw new RuntimeException("No project open.");
|
||||
}
|
||||
|
@ -174,10 +174,10 @@ public abstract class GhidraVersionTrackingScript extends GhidraScript {
|
|||
throw new RuntimeException("You must have an open vt session to run a correlator");
|
||||
}
|
||||
VTProgramCorrelatorFactory correlatorFactory = getCorrelatorFactory(name);
|
||||
VTProgramCorrelator correlator =
|
||||
correlatorFactory.createCorrelator(null, sourceProgram,
|
||||
VTProgramCorrelator correlator = correlatorFactory.createCorrelator(sourceProgram,
|
||||
sourceProgram.getMemory().getLoadedAndInitializedAddressSet(), destinationProgram,
|
||||
destinationProgram.getMemory().getLoadedAndInitializedAddressSet(), new VTOptions("dummy"));
|
||||
destinationProgram.getMemory().getLoadedAndInitializedAddressSet(),
|
||||
new VTOptions("dummy"));
|
||||
correlator.correlate(vtSession, monitor);
|
||||
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ import java.util.List;
|
|||
import ghidra.feature.vt.api.correlator.program.*;
|
||||
import ghidra.feature.vt.api.impl.VTProgramCorrelatorInfo;
|
||||
import ghidra.feature.vt.api.main.*;
|
||||
import ghidra.feature.vt.gui.plugin.VTController;
|
||||
import ghidra.feature.vt.gui.plugin.VTSessionSupplier;
|
||||
import ghidra.framework.options.Options;
|
||||
import ghidra.framework.options.ToolOptions;
|
||||
import ghidra.program.model.listing.Data;
|
||||
|
@ -32,26 +32,25 @@ public class ExactMatchAddressCorrelator implements AddressCorrelator {
|
|||
|
||||
private static final String CORRELATOR_NAME = "ExactMatchAddressCorrelator";
|
||||
private ToolOptions options = new ToolOptions(CORRELATOR_NAME);
|
||||
private VTController controller;
|
||||
private VTSessionSupplier sessionSupplier;
|
||||
|
||||
public ExactMatchAddressCorrelator(VTController controller) {
|
||||
this.controller = controller;
|
||||
public ExactMatchAddressCorrelator(VTSessionSupplier sessionSupplier) {
|
||||
this.sessionSupplier = sessionSupplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized AddressCorrelation correlate(Function sourceFunction,
|
||||
Function destinationFunction) {
|
||||
|
||||
VTSession session = controller.getSession();
|
||||
VTSession session = sessionSupplier.getSession();
|
||||
VTAssociationManager associationManager = session.getAssociationManager();
|
||||
VTAssociation association =
|
||||
associationManager.getAssociation(sourceFunction.getEntryPoint(),
|
||||
destinationFunction.getEntryPoint());
|
||||
VTAssociation association = associationManager.getAssociation(
|
||||
sourceFunction.getEntryPoint(), destinationFunction.getEntryPoint());
|
||||
List<VTMatch> matches = session.getMatches(association);
|
||||
for (VTMatch match : matches) {
|
||||
VTMatchSet matchSet = match.getMatchSet();
|
||||
VTProgramCorrelatorInfo info = matchSet.getProgramCorrelatorInfo();
|
||||
final String correlatorName = info.getName();
|
||||
String correlatorName = info.getName();
|
||||
if (correlatorName.equals(ExactMatchBytesProgramCorrelatorFactory.EXACT_MATCH) ||
|
||||
correlatorName.equals(ExactMatchInstructionsProgramCorrelatorFactory.EXACT_MATCH) ||
|
||||
correlatorName.equals(ExactMatchMnemonicsProgramCorrelatorFactory.EXACT_MATCH)) {
|
||||
|
|
|
@ -17,7 +17,6 @@ package ghidra.feature.vt.api.correlator.program;
|
|||
|
||||
import ghidra.feature.vt.api.main.VTAssociationType;
|
||||
import ghidra.framework.options.ToolOptions;
|
||||
import ghidra.framework.plugintool.ServiceProvider;
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.program.model.symbol.RefType;
|
||||
|
@ -26,12 +25,11 @@ import ghidra.program.model.symbol.Reference;
|
|||
/**
|
||||
* Correlates functions based on previously accepted data and function matches.
|
||||
*/
|
||||
public class CombinedFunctionAndDataReferenceProgramCorrelator extends
|
||||
VTAbstractReferenceProgramCorrelator {
|
||||
public class CombinedFunctionAndDataReferenceProgramCorrelator
|
||||
extends VTAbstractReferenceProgramCorrelator {
|
||||
|
||||
/**
|
||||
* Combined Function and Data Reference Correlator class constructor.
|
||||
* @param serviceProvider The {@code ServiceProvider}.
|
||||
* @param sourceProgram The source {@code Program}.
|
||||
* @param sourceAddressSet The {@code AddressSetView} for the source program.
|
||||
* @param destinationProgram The destination {@code Program}.
|
||||
|
@ -39,11 +37,11 @@ public class CombinedFunctionAndDataReferenceProgramCorrelator extends
|
|||
* @param correlatorName The correlator name string passed from the factory.
|
||||
* @param options {@code ToolOptions}
|
||||
*/
|
||||
public CombinedFunctionAndDataReferenceProgramCorrelator(ServiceProvider serviceProvider,
|
||||
Program sourceProgram, AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
public CombinedFunctionAndDataReferenceProgramCorrelator(Program sourceProgram,
|
||||
AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
AddressSetView destinationAddressSet, String correlatorName, ToolOptions options) {
|
||||
super(serviceProvider, sourceProgram, sourceAddressSet, destinationProgram,
|
||||
destinationAddressSet, correlatorName, options);
|
||||
super(sourceProgram, sourceAddressSet, destinationProgram, destinationAddressSet,
|
||||
correlatorName, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,7 +17,6 @@ package ghidra.feature.vt.api.correlator.program;
|
|||
|
||||
import ghidra.feature.vt.api.main.VTProgramCorrelator;
|
||||
import ghidra.feature.vt.api.util.VTOptions;
|
||||
import ghidra.framework.plugintool.ServiceProvider;
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.program.model.listing.Program;
|
||||
|
||||
|
@ -28,7 +27,6 @@ public class CombinedFunctionAndDataReferenceProgramCorrelatorFactory
|
|||
extends VTAbstractReferenceProgramCorrelatorFactory {
|
||||
|
||||
public CombinedFunctionAndDataReferenceProgramCorrelatorFactory() {
|
||||
super();
|
||||
setName("Combined Function and Data Reference Match");
|
||||
correlatorDescription =
|
||||
"Matches functions based on the accepted data and function matches they have in common.";
|
||||
|
@ -38,10 +36,10 @@ public class CombinedFunctionAndDataReferenceProgramCorrelatorFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
protected VTProgramCorrelator doCreateCorrelator(ServiceProvider serviceProvider,
|
||||
Program sourceProgram, AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
protected VTProgramCorrelator doCreateCorrelator(Program sourceProgram,
|
||||
AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
AddressSetView destinationAddressSet, VTOptions options) {
|
||||
return new CombinedFunctionAndDataReferenceProgramCorrelator(serviceProvider, sourceProgram,
|
||||
return new CombinedFunctionAndDataReferenceProgramCorrelator(sourceProgram,
|
||||
sourceAddressSet, destinationProgram, destinationAddressSet, correlatorName, options);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,12 +15,13 @@
|
|||
*/
|
||||
package ghidra.feature.vt.api.correlator.program;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import ghidra.app.plugin.match.MatchData;
|
||||
import ghidra.app.plugin.match.MatchedData;
|
||||
import ghidra.feature.vt.api.main.*;
|
||||
import ghidra.feature.vt.api.util.VTAbstractProgramCorrelator;
|
||||
import ghidra.framework.options.ToolOptions;
|
||||
import ghidra.framework.plugintool.ServiceProvider;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.program.model.listing.Data;
|
||||
|
@ -28,18 +29,15 @@ import ghidra.program.model.listing.Program;
|
|||
import ghidra.util.exception.CancelledException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DataMatchProgramCorrelator extends VTAbstractProgramCorrelator {
|
||||
private final String name;
|
||||
|
||||
private final boolean oneToOne;
|
||||
|
||||
public DataMatchProgramCorrelator(ServiceProvider serviceProvider, Program sourceProgram,
|
||||
AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
AddressSetView destinationAddressSet, ToolOptions options, String name, boolean oneToOne) {
|
||||
super(serviceProvider, sourceProgram, sourceAddressSet, destinationProgram,
|
||||
destinationAddressSet, options);
|
||||
public DataMatchProgramCorrelator(Program sourceProgram, AddressSetView sourceAddressSet,
|
||||
Program destinationProgram, AddressSetView destinationAddressSet, ToolOptions options,
|
||||
String name, boolean oneToOne) {
|
||||
super(sourceProgram, sourceAddressSet, destinationProgram, destinationAddressSet, options);
|
||||
this.name = name;
|
||||
this.oneToOne = oneToOne;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ package ghidra.feature.vt.api.correlator.program;
|
|||
|
||||
import ghidra.feature.vt.api.main.VTAssociationType;
|
||||
import ghidra.framework.options.ToolOptions;
|
||||
import ghidra.framework.plugintool.ServiceProvider;
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.program.model.symbol.RefType;
|
||||
|
@ -30,7 +29,6 @@ public class DataReferenceProgramCorrelator extends VTAbstractReferenceProgramCo
|
|||
|
||||
/**
|
||||
* Data Reference Correlator class constructor.
|
||||
* @param serviceProvider The {@code ServiceProvider}.
|
||||
* @param sourceProgram The source {@code Program}.
|
||||
* @param sourceAddressSet The {@code AddressSetView} for the source program.
|
||||
* @param destinationProgram The destination {@code Program}.
|
||||
|
@ -38,11 +36,11 @@ public class DataReferenceProgramCorrelator extends VTAbstractReferenceProgramCo
|
|||
* @param correlatorName The correlator name string passed from the factory.
|
||||
* @param options {@code ToolOptions}
|
||||
*/
|
||||
public DataReferenceProgramCorrelator(ServiceProvider serviceProvider, Program sourceProgram,
|
||||
AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
AddressSetView destinationAddressSet, String correlatorName, ToolOptions options) {
|
||||
super(serviceProvider, sourceProgram, sourceAddressSet, destinationProgram,
|
||||
destinationAddressSet, correlatorName, options);
|
||||
public DataReferenceProgramCorrelator(Program sourceProgram, AddressSetView sourceAddressSet,
|
||||
Program destinationProgram, AddressSetView destinationAddressSet, String correlatorName,
|
||||
ToolOptions options) {
|
||||
super(sourceProgram, sourceAddressSet, destinationProgram, destinationAddressSet,
|
||||
correlatorName, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,7 +17,6 @@ package ghidra.feature.vt.api.correlator.program;
|
|||
|
||||
import ghidra.feature.vt.api.main.VTProgramCorrelator;
|
||||
import ghidra.feature.vt.api.util.VTOptions;
|
||||
import ghidra.framework.plugintool.ServiceProvider;
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.program.model.listing.Program;
|
||||
|
||||
|
@ -28,7 +27,6 @@ public class DataReferenceProgramCorrelatorFactory
|
|||
extends VTAbstractReferenceProgramCorrelatorFactory {
|
||||
|
||||
public DataReferenceProgramCorrelatorFactory() {
|
||||
super();
|
||||
setName("Data Reference Match");
|
||||
correlatorDescription =
|
||||
"Matches functions by the accepted data matches they have in common.";
|
||||
|
@ -38,10 +36,10 @@ public class DataReferenceProgramCorrelatorFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
protected VTProgramCorrelator doCreateCorrelator(ServiceProvider serviceProvider,
|
||||
Program sourceProgram, AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
protected VTProgramCorrelator doCreateCorrelator(Program sourceProgram,
|
||||
AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
AddressSetView destinationAddressSet, VTOptions options) {
|
||||
return new DataReferenceProgramCorrelator(serviceProvider, sourceProgram, sourceAddressSet,
|
||||
return new DataReferenceProgramCorrelator(sourceProgram, sourceAddressSet,
|
||||
destinationProgram, destinationAddressSet, correlatorName, options);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ package ghidra.feature.vt.api.correlator.program;
|
|||
import ghidra.feature.vt.api.main.VTProgramCorrelator;
|
||||
import ghidra.feature.vt.api.util.VTAbstractProgramCorrelatorFactory;
|
||||
import ghidra.feature.vt.api.util.VTOptions;
|
||||
import ghidra.framework.plugintool.ServiceProvider;
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.program.model.listing.Program;
|
||||
|
||||
|
@ -36,11 +35,11 @@ public class DuplicateDataMatchProgramCorrelatorFactory extends VTAbstractProgra
|
|||
}
|
||||
|
||||
@Override
|
||||
protected VTProgramCorrelator doCreateCorrelator(ServiceProvider serviceProvider,
|
||||
Program sourceProgram, AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
protected VTProgramCorrelator doCreateCorrelator(Program sourceProgram,
|
||||
AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
AddressSetView destinationAddressSet, VTOptions options) {
|
||||
return new DataMatchProgramCorrelator(serviceProvider, sourceProgram, sourceAddressSet,
|
||||
destinationProgram, destinationAddressSet, options, DUPLICATE_MATCH, false);
|
||||
return new DataMatchProgramCorrelator(sourceProgram, sourceAddressSet, destinationProgram,
|
||||
destinationAddressSet, options, DUPLICATE_MATCH, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,7 +19,6 @@ import ghidra.app.plugin.match.ExactInstructionsFunctionHasher;
|
|||
import ghidra.feature.vt.api.main.VTProgramCorrelator;
|
||||
import ghidra.feature.vt.api.util.VTAbstractProgramCorrelatorFactory;
|
||||
import ghidra.feature.vt.api.util.VTOptions;
|
||||
import ghidra.framework.plugintool.ServiceProvider;
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.program.model.listing.Program;
|
||||
|
||||
|
@ -38,10 +37,10 @@ public class DuplicateFunctionMatchProgramCorrelatorFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
protected VTProgramCorrelator doCreateCorrelator(ServiceProvider serviceProvider,
|
||||
Program sourceProgram, AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
protected VTProgramCorrelator doCreateCorrelator(Program sourceProgram,
|
||||
AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
AddressSetView destinationAddressSet, VTOptions options) {
|
||||
return new FunctionMatchProgramCorrelator(serviceProvider, sourceProgram, sourceAddressSet,
|
||||
return new FunctionMatchProgramCorrelator(sourceProgram, sourceAddressSet,
|
||||
destinationProgram, destinationAddressSet, options, DUPLICATE_MATCH, false,
|
||||
ExactInstructionsFunctionHasher.INSTANCE);
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ package ghidra.feature.vt.api.correlator.program;
|
|||
import ghidra.feature.vt.api.main.VTProgramCorrelator;
|
||||
import ghidra.feature.vt.api.util.VTAbstractProgramCorrelatorFactory;
|
||||
import ghidra.feature.vt.api.util.VTOptions;
|
||||
import ghidra.framework.plugintool.ServiceProvider;
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.program.model.listing.Program;
|
||||
|
||||
|
@ -42,16 +41,15 @@ public class DuplicateSymbolNameProgramCorrelatorFactory
|
|||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
// TODO Auto-generated method stub
|
||||
return 90;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected VTProgramCorrelator doCreateCorrelator(ServiceProvider serviceProvider,
|
||||
Program sourceProgram, AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
protected VTProgramCorrelator doCreateCorrelator(Program sourceProgram,
|
||||
AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
AddressSetView destinationAddressSet, VTOptions options) {
|
||||
return new SymbolNameProgramCorrelator(serviceProvider, sourceProgram, sourceAddressSet,
|
||||
destinationProgram, destinationAddressSet, options, DUP_SYMBOL_MATCH, false);
|
||||
return new SymbolNameProgramCorrelator(sourceProgram, sourceAddressSet, destinationProgram,
|
||||
destinationAddressSet, options, DUP_SYMBOL_MATCH, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,7 +18,6 @@ package ghidra.feature.vt.api.correlator.program;
|
|||
import ghidra.feature.vt.api.main.VTProgramCorrelator;
|
||||
import ghidra.feature.vt.api.util.VTAbstractProgramCorrelatorFactory;
|
||||
import ghidra.feature.vt.api.util.VTOptions;
|
||||
import ghidra.framework.plugintool.ServiceProvider;
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.program.model.listing.Program;
|
||||
|
||||
|
@ -48,11 +47,11 @@ public class ExactDataMatchProgramCorrelatorFactory extends VTAbstractProgramCor
|
|||
}
|
||||
|
||||
@Override
|
||||
protected VTProgramCorrelator doCreateCorrelator(ServiceProvider serviceProvider,
|
||||
Program sourceProgram, AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
protected VTProgramCorrelator doCreateCorrelator(Program sourceProgram,
|
||||
AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
AddressSetView destinationAddressSet, VTOptions options) {
|
||||
return new DataMatchProgramCorrelator(serviceProvider, sourceProgram, sourceAddressSet,
|
||||
destinationProgram, destinationAddressSet, options, EXACT_MATCH, true);
|
||||
return new DataMatchProgramCorrelator(sourceProgram, sourceAddressSet, destinationProgram,
|
||||
destinationAddressSet, options, EXACT_MATCH, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,7 +19,6 @@ import ghidra.app.plugin.match.ExactBytesFunctionHasher;
|
|||
import ghidra.feature.vt.api.main.VTProgramCorrelator;
|
||||
import ghidra.feature.vt.api.util.VTAbstractProgramCorrelatorFactory;
|
||||
import ghidra.feature.vt.api.util.VTOptions;
|
||||
import ghidra.framework.plugintool.ServiceProvider;
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.program.model.listing.Program;
|
||||
|
||||
|
@ -38,10 +37,10 @@ public class ExactMatchBytesProgramCorrelatorFactory extends VTAbstractProgramCo
|
|||
}
|
||||
|
||||
@Override
|
||||
protected VTProgramCorrelator doCreateCorrelator(ServiceProvider serviceProvider,
|
||||
Program sourceProgram, AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
protected VTProgramCorrelator doCreateCorrelator(Program sourceProgram,
|
||||
AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
AddressSetView destinationAddressSet, VTOptions options) {
|
||||
return new FunctionMatchProgramCorrelator(serviceProvider, sourceProgram, sourceAddressSet,
|
||||
return new FunctionMatchProgramCorrelator(sourceProgram, sourceAddressSet,
|
||||
destinationProgram, destinationAddressSet, options, EXACT_MATCH, true,
|
||||
ExactBytesFunctionHasher.INSTANCE);
|
||||
}
|
||||
|
|
|
@ -19,12 +19,11 @@ import ghidra.app.plugin.match.ExactInstructionsFunctionHasher;
|
|||
import ghidra.feature.vt.api.main.VTProgramCorrelator;
|
||||
import ghidra.feature.vt.api.util.VTAbstractProgramCorrelatorFactory;
|
||||
import ghidra.feature.vt.api.util.VTOptions;
|
||||
import ghidra.framework.plugintool.ServiceProvider;
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.program.model.listing.Program;
|
||||
|
||||
public class ExactMatchInstructionsProgramCorrelatorFactory extends
|
||||
VTAbstractProgramCorrelatorFactory {
|
||||
public class ExactMatchInstructionsProgramCorrelatorFactory
|
||||
extends VTAbstractProgramCorrelatorFactory {
|
||||
|
||||
static final String DESC =
|
||||
"Compares code by hashing instructions, looking for identical functions. It reports back any that have ONLY ONE identical match.";
|
||||
|
@ -39,10 +38,10 @@ public class ExactMatchInstructionsProgramCorrelatorFactory extends
|
|||
}
|
||||
|
||||
@Override
|
||||
protected VTProgramCorrelator doCreateCorrelator(ServiceProvider serviceProvider,
|
||||
Program sourceProgram, AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
protected VTProgramCorrelator doCreateCorrelator(Program sourceProgram,
|
||||
AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
AddressSetView destinationAddressSet, VTOptions options) {
|
||||
return new FunctionMatchProgramCorrelator(serviceProvider, sourceProgram, sourceAddressSet,
|
||||
return new FunctionMatchProgramCorrelator(sourceProgram, sourceAddressSet,
|
||||
destinationProgram, destinationAddressSet, options, EXACT_MATCH, true,
|
||||
ExactInstructionsFunctionHasher.INSTANCE);
|
||||
}
|
||||
|
|
|
@ -19,11 +19,11 @@ import ghidra.app.plugin.match.ExactMnemonicsFunctionHasher;
|
|||
import ghidra.feature.vt.api.main.VTProgramCorrelator;
|
||||
import ghidra.feature.vt.api.util.VTAbstractProgramCorrelatorFactory;
|
||||
import ghidra.feature.vt.api.util.VTOptions;
|
||||
import ghidra.framework.plugintool.ServiceProvider;
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.program.model.listing.Program;
|
||||
|
||||
public class ExactMatchMnemonicsProgramCorrelatorFactory extends VTAbstractProgramCorrelatorFactory {
|
||||
public class ExactMatchMnemonicsProgramCorrelatorFactory
|
||||
extends VTAbstractProgramCorrelatorFactory {
|
||||
|
||||
static final String DESC =
|
||||
"Compares code by hashing instructions mnemonics, looking for identical functions. It reports back any that have ONLY ONE identical match.";
|
||||
|
@ -38,10 +38,10 @@ public class ExactMatchMnemonicsProgramCorrelatorFactory extends VTAbstractProgr
|
|||
}
|
||||
|
||||
@Override
|
||||
protected VTProgramCorrelator doCreateCorrelator(ServiceProvider serviceProvider,
|
||||
Program sourceProgram, AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
protected VTProgramCorrelator doCreateCorrelator(Program sourceProgram,
|
||||
AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
AddressSetView destinationAddressSet, VTOptions options) {
|
||||
return new FunctionMatchProgramCorrelator(serviceProvider, sourceProgram, sourceAddressSet,
|
||||
return new FunctionMatchProgramCorrelator(sourceProgram, sourceAddressSet,
|
||||
destinationProgram, destinationAddressSet, options, EXACT_MATCH, true,
|
||||
ExactMnemonicsFunctionHasher.INSTANCE);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ import ghidra.app.plugin.match.MatchFunctions.MatchedFunctions;
|
|||
import ghidra.feature.vt.api.main.*;
|
||||
import ghidra.feature.vt.api.util.VTAbstractProgramCorrelator;
|
||||
import ghidra.framework.options.ToolOptions;
|
||||
import ghidra.framework.plugintool.ServiceProvider;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.program.model.listing.Function;
|
||||
|
@ -38,12 +37,10 @@ public class FunctionMatchProgramCorrelator extends VTAbstractProgramCorrelator
|
|||
private final boolean oneToOne;
|
||||
private final FunctionHasher hasher;
|
||||
|
||||
public FunctionMatchProgramCorrelator(ServiceProvider serviceProvider, Program sourceProgram,
|
||||
AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
AddressSetView destinationAddressSet, ToolOptions options, String name,
|
||||
boolean oneToOne, FunctionHasher hasher) {
|
||||
super(serviceProvider, sourceProgram, sourceAddressSet, destinationProgram,
|
||||
destinationAddressSet, options);
|
||||
public FunctionMatchProgramCorrelator(Program sourceProgram, AddressSetView sourceAddressSet,
|
||||
Program destinationProgram, AddressSetView destinationAddressSet, ToolOptions options,
|
||||
String name, boolean oneToOne, FunctionHasher hasher) {
|
||||
super(sourceProgram, sourceAddressSet, destinationProgram, destinationAddressSet, options);
|
||||
this.name = name;
|
||||
this.oneToOne = oneToOne;
|
||||
this.hasher = hasher;
|
||||
|
|
|
@ -17,7 +17,6 @@ package ghidra.feature.vt.api.correlator.program;
|
|||
|
||||
import ghidra.feature.vt.api.main.VTAssociationType;
|
||||
import ghidra.framework.options.ToolOptions;
|
||||
import ghidra.framework.plugintool.ServiceProvider;
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.program.model.symbol.Reference;
|
||||
|
@ -29,7 +28,6 @@ public class FunctionReferenceProgramCorrelator extends VTAbstractReferenceProgr
|
|||
|
||||
/**
|
||||
* Function Reference Correlator class constructor.
|
||||
* @param serviceProvider The {@code ServiceProvider}.
|
||||
* @param sourceProgram The source {@code Program}.
|
||||
* @param sourceAddressSet The {@code AddressSetView} for the source program.
|
||||
* @param destinationProgram The destination {@code Program}.
|
||||
|
@ -37,12 +35,11 @@ public class FunctionReferenceProgramCorrelator extends VTAbstractReferenceProgr
|
|||
* @param correlatorName The correlator name string passed from the factory.
|
||||
* @param options {@code ToolOptions}
|
||||
*/
|
||||
public FunctionReferenceProgramCorrelator(ServiceProvider serviceProvider,
|
||||
Program sourceProgram,
|
||||
public FunctionReferenceProgramCorrelator(Program sourceProgram,
|
||||
AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
AddressSetView destinationAddressSet, String correlatorName, ToolOptions options) {
|
||||
super(serviceProvider, sourceProgram, sourceAddressSet, destinationProgram,
|
||||
destinationAddressSet, correlatorName, options);
|
||||
super(sourceProgram, sourceAddressSet, destinationProgram, destinationAddressSet,
|
||||
correlatorName, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,7 +17,6 @@ package ghidra.feature.vt.api.correlator.program;
|
|||
|
||||
import ghidra.feature.vt.api.main.VTProgramCorrelator;
|
||||
import ghidra.feature.vt.api.util.VTOptions;
|
||||
import ghidra.framework.plugintool.ServiceProvider;
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.program.model.listing.Program;
|
||||
|
||||
|
@ -27,7 +26,6 @@ import ghidra.program.model.listing.Program;
|
|||
public class FunctionReferenceProgramCorrelatorFactory
|
||||
extends VTAbstractReferenceProgramCorrelatorFactory {
|
||||
public FunctionReferenceProgramCorrelatorFactory() {
|
||||
super();
|
||||
setName("Function Reference Match");
|
||||
correlatorDescription =
|
||||
"Matches functions by the accepted function matches they have in common.";
|
||||
|
@ -37,10 +35,10 @@ public class FunctionReferenceProgramCorrelatorFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
protected VTProgramCorrelator doCreateCorrelator(ServiceProvider serviceProvider,
|
||||
Program sourceProgram, AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
protected VTProgramCorrelator doCreateCorrelator(Program sourceProgram,
|
||||
AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
AddressSetView destinationAddressSet, VTOptions options) {
|
||||
return new FunctionReferenceProgramCorrelator(serviceProvider, sourceProgram,
|
||||
sourceAddressSet, destinationProgram, destinationAddressSet, correlatorName, options);
|
||||
return new FunctionReferenceProgramCorrelator(sourceProgram, sourceAddressSet,
|
||||
destinationProgram, destinationAddressSet, correlatorName, options);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,8 +29,8 @@ public class ImpliedMatchProgramCorrelator extends VTAbstractProgramCorrelator {
|
|||
public static final String NAME = "Implied Match";
|
||||
|
||||
public ImpliedMatchProgramCorrelator(Program sourceProgram, Program destinationProgram) {
|
||||
super(null, sourceProgram, sourceProgram.getMemory(), destinationProgram,
|
||||
destinationProgram.getMemory(), new ToolOptions(NAME));
|
||||
super(sourceProgram, sourceProgram.getMemory(), destinationProgram, destinationProgram.getMemory(),
|
||||
new ToolOptions(NAME));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -29,8 +29,8 @@ public class ManualMatchProgramCorrelator extends VTAbstractProgramCorrelator {
|
|||
public static final String NAME = "Manual Match";
|
||||
|
||||
public ManualMatchProgramCorrelator(Program sourceProgram, Program destinationProgram) {
|
||||
super(null, sourceProgram, sourceProgram.getMemory(), destinationProgram,
|
||||
destinationProgram.getMemory(), new ToolOptions(NAME));
|
||||
super(sourceProgram, sourceProgram.getMemory(), destinationProgram, destinationProgram.getMemory(),
|
||||
new ToolOptions(NAME));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -28,7 +28,6 @@ import generic.lsh.vector.VectorCompare;
|
|||
import ghidra.feature.vt.api.main.*;
|
||||
import ghidra.feature.vt.api.util.VTAbstractProgramCorrelator;
|
||||
import ghidra.framework.options.ToolOptions;
|
||||
import ghidra.framework.plugintool.ServiceProvider;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.program.model.listing.*;
|
||||
|
@ -48,17 +47,14 @@ public class SimilarDataProgramCorrelator extends VTAbstractProgramCorrelator {
|
|||
int featureID = 0;
|
||||
int minDataLength;
|
||||
|
||||
public SimilarDataProgramCorrelator(ServiceProvider serviceProvider, Program sourceProgram,
|
||||
AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
AddressSetView destinationAddressSet, ToolOptions options) {
|
||||
super(serviceProvider, sourceProgram, sourceAddressSet, destinationProgram,
|
||||
destinationAddressSet, options);
|
||||
public SimilarDataProgramCorrelator(Program sourceProgram, AddressSetView sourceAddressSet,
|
||||
Program destinationProgram, AddressSetView destinationAddressSet, ToolOptions options) {
|
||||
super(sourceProgram, sourceAddressSet, destinationProgram, destinationAddressSet, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doCorrelate(VTMatchSet matchSet, TaskMonitor monitor) throws CancelledException {
|
||||
minDataLength =
|
||||
getOptions().getInt(SimilarDataProgramCorrelatorFactory.MIN_NAME_LENGTH,
|
||||
minDataLength = getOptions().getInt(SimilarDataProgramCorrelatorFactory.MIN_NAME_LENGTH,
|
||||
SimilarDataProgramCorrelatorFactory.MIN_NAME_LENGTH_DEFAULT);
|
||||
boolean skipHomogenousData =
|
||||
getOptions().getBoolean(SimilarDataProgramCorrelatorFactory.SKIP_HOMOGENOUS_DATA,
|
||||
|
|
|
@ -19,7 +19,6 @@ import generic.lsh.LSHMemoryModel;
|
|||
import ghidra.feature.vt.api.main.VTProgramCorrelator;
|
||||
import ghidra.feature.vt.api.util.VTAbstractProgramCorrelatorFactory;
|
||||
import ghidra.feature.vt.api.util.VTOptions;
|
||||
import ghidra.framework.plugintool.ServiceProvider;
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.program.model.listing.Program;
|
||||
|
||||
|
@ -41,11 +40,11 @@ public class SimilarDataProgramCorrelatorFactory extends VTAbstractProgramCorrel
|
|||
}
|
||||
|
||||
@Override
|
||||
protected VTProgramCorrelator doCreateCorrelator(ServiceProvider serviceProvider,
|
||||
Program sourceProgram, AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
protected VTProgramCorrelator doCreateCorrelator(Program sourceProgram,
|
||||
AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
AddressSetView destinationAddressSet, VTOptions options) {
|
||||
return new SimilarDataProgramCorrelator(serviceProvider, sourceProgram, sourceAddressSet,
|
||||
destinationProgram, destinationAddressSet, options);
|
||||
return new SimilarDataProgramCorrelator(sourceProgram, sourceAddressSet, destinationProgram,
|
||||
destinationAddressSet, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -26,7 +26,6 @@ import generic.lsh.vector.VectorCompare;
|
|||
import ghidra.feature.vt.api.main.*;
|
||||
import ghidra.feature.vt.api.util.VTAbstractProgramCorrelator;
|
||||
import ghidra.framework.options.ToolOptions;
|
||||
import ghidra.framework.plugintool.ServiceProvider;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.program.model.listing.*;
|
||||
|
@ -46,11 +45,10 @@ public class SimilarSymbolNameProgramCorrelator extends VTAbstractProgramCorrela
|
|||
int featureID = 0;
|
||||
int minNameLength;
|
||||
|
||||
public SimilarSymbolNameProgramCorrelator(ServiceProvider serviceProvider,
|
||||
Program sourceProgram, AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
public SimilarSymbolNameProgramCorrelator(Program sourceProgram,
|
||||
AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
AddressSetView destinationAddressSet, ToolOptions options) {
|
||||
super(serviceProvider, sourceProgram, sourceAddressSet, destinationProgram,
|
||||
destinationAddressSet, options);
|
||||
super(sourceProgram, sourceAddressSet, destinationProgram, destinationAddressSet, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,7 +19,6 @@ import generic.lsh.LSHMemoryModel;
|
|||
import ghidra.feature.vt.api.main.VTProgramCorrelator;
|
||||
import ghidra.feature.vt.api.util.VTAbstractProgramCorrelatorFactory;
|
||||
import ghidra.feature.vt.api.util.VTOptions;
|
||||
import ghidra.framework.plugintool.ServiceProvider;
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.program.model.listing.Program;
|
||||
|
||||
|
@ -37,11 +36,11 @@ public class SimilarSymbolNameProgramCorrelatorFactory extends VTAbstractProgram
|
|||
}
|
||||
|
||||
@Override
|
||||
protected VTProgramCorrelator doCreateCorrelator(ServiceProvider serviceProvider,
|
||||
Program sourceProgram, AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
protected VTProgramCorrelator doCreateCorrelator(Program sourceProgram,
|
||||
AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
AddressSetView destinationAddressSet, VTOptions options) {
|
||||
return new SimilarSymbolNameProgramCorrelator(serviceProvider, sourceProgram,
|
||||
sourceAddressSet, destinationProgram, destinationAddressSet, options);
|
||||
return new SimilarSymbolNameProgramCorrelator(sourceProgram, sourceAddressSet,
|
||||
destinationProgram, destinationAddressSet, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -22,7 +22,6 @@ import ghidra.app.plugin.match.MatchSymbol.MatchedSymbol;
|
|||
import ghidra.feature.vt.api.main.*;
|
||||
import ghidra.feature.vt.api.util.VTAbstractProgramCorrelator;
|
||||
import ghidra.framework.options.ToolOptions;
|
||||
import ghidra.framework.plugintool.ServiceProvider;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.program.model.listing.*;
|
||||
|
@ -36,12 +35,10 @@ public class SymbolNameProgramCorrelator extends VTAbstractProgramCorrelator {
|
|||
|
||||
private final boolean oneToOne;
|
||||
|
||||
public SymbolNameProgramCorrelator(ServiceProvider serviceProvider, Program sourceProgram,
|
||||
AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
AddressSetView destinationAddressSet, ToolOptions options, String name,
|
||||
boolean oneToOne) {
|
||||
super(serviceProvider, sourceProgram, sourceAddressSet, destinationProgram,
|
||||
destinationAddressSet, options);
|
||||
public SymbolNameProgramCorrelator(Program sourceProgram, AddressSetView sourceAddressSet,
|
||||
Program destinationProgram, AddressSetView destinationAddressSet, ToolOptions options,
|
||||
String name, boolean oneToOne) {
|
||||
super(sourceProgram, sourceAddressSet, destinationProgram, destinationAddressSet, options);
|
||||
this.name = name;
|
||||
this.oneToOne = oneToOne;
|
||||
|
||||
|
@ -125,8 +122,9 @@ public class SymbolNameProgramCorrelator extends VTAbstractProgramCorrelator {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof AddressMatch)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ package ghidra.feature.vt.api.correlator.program;
|
|||
import ghidra.feature.vt.api.main.VTProgramCorrelator;
|
||||
import ghidra.feature.vt.api.util.VTAbstractProgramCorrelatorFactory;
|
||||
import ghidra.feature.vt.api.util.VTOptions;
|
||||
import ghidra.framework.plugintool.ServiceProvider;
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.program.model.listing.Program;
|
||||
|
||||
|
@ -43,11 +42,11 @@ public class SymbolNameProgramCorrelatorFactory extends VTAbstractProgramCorrela
|
|||
}
|
||||
|
||||
@Override
|
||||
protected VTProgramCorrelator doCreateCorrelator(ServiceProvider serviceProvider,
|
||||
Program sourceProgram, AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
protected VTProgramCorrelator doCreateCorrelator(Program sourceProgram,
|
||||
AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
AddressSetView destinationAddressSet, VTOptions options) {
|
||||
return new SymbolNameProgramCorrelator(serviceProvider, sourceProgram, sourceAddressSet,
|
||||
destinationProgram, destinationAddressSet, options, EXACT_SYMBOL_MATCH, true);
|
||||
return new SymbolNameProgramCorrelator(sourceProgram, sourceAddressSet, destinationProgram,
|
||||
destinationAddressSet, options, EXACT_SYMBOL_MATCH, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -28,7 +28,6 @@ import generic.lsh.vector.VectorCompare;
|
|||
import ghidra.feature.vt.api.main.*;
|
||||
import ghidra.feature.vt.api.util.VTAbstractProgramCorrelator;
|
||||
import ghidra.framework.options.ToolOptions;
|
||||
import ghidra.framework.plugintool.ServiceProvider;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.program.model.listing.*;
|
||||
|
@ -62,7 +61,6 @@ public abstract class VTAbstractReferenceProgramCorrelator extends VTAbstractPro
|
|||
|
||||
/**
|
||||
* Correlator class constructor.
|
||||
* @param serviceProvider the service provider
|
||||
* @param sourceProgram the source program
|
||||
* @param sourceAddressSet the source addresses to correlate
|
||||
* @param destinationProgram the destination program
|
||||
|
@ -70,13 +68,11 @@ public abstract class VTAbstractReferenceProgramCorrelator extends VTAbstractPro
|
|||
* @param correlatorName the correlator name
|
||||
* @param options the tool options
|
||||
*/
|
||||
public VTAbstractReferenceProgramCorrelator(ServiceProvider serviceProvider,
|
||||
Program sourceProgram,
|
||||
public VTAbstractReferenceProgramCorrelator(Program sourceProgram,
|
||||
AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
AddressSetView destinationAddressSet, String correlatorName, ToolOptions options) {
|
||||
// Call the constructor for the parent class.
|
||||
super(serviceProvider, sourceProgram, sourceAddressSet, destinationProgram,
|
||||
destinationAddressSet, options);
|
||||
super(sourceProgram, sourceAddressSet, destinationProgram, destinationAddressSet, options);
|
||||
this.correlatorName = correlatorName;
|
||||
|
||||
this.sourceProgram = sourceProgram;
|
||||
|
@ -126,8 +122,7 @@ public abstract class VTAbstractReferenceProgramCorrelator extends VTAbstractPro
|
|||
throws CancelledException {
|
||||
|
||||
monitor.initialize(destVectorsByAddress.size());
|
||||
Set<Entry<Address, LSHCosineVectorAccum>> destEntries =
|
||||
destVectorsByAddress.entrySet();
|
||||
Set<Entry<Address, LSHCosineVectorAccum>> destEntries = destVectorsByAddress.entrySet();
|
||||
for (Entry<Address, LSHCosineVectorAccum> destEntry : destEntries) {
|
||||
|
||||
monitor.checkCancelled();
|
||||
|
@ -140,8 +135,7 @@ public abstract class VTAbstractReferenceProgramCorrelator extends VTAbstractPro
|
|||
// Get the set of possible matches, neighbors, in the SourceProgram
|
||||
Map<Address, DominantPair<Double, VectorCompare>> srcNeighbors = new HashMap<>();
|
||||
|
||||
Set<Entry<Address, LSHCosineVectorAccum>> srcEntries =
|
||||
srcVectorsByAddress.entrySet();
|
||||
Set<Entry<Address, LSHCosineVectorAccum>> srcEntries = srcVectorsByAddress.entrySet();
|
||||
for (Entry<Address, LSHCosineVectorAccum> srcEntry : srcEntries) {
|
||||
Address srcAddr = srcEntry.getKey();
|
||||
LSHCosineVectorAccum srcVector = srcEntry.getValue();
|
||||
|
@ -156,8 +150,8 @@ public abstract class VTAbstractReferenceProgramCorrelator extends VTAbstractPro
|
|||
}
|
||||
}
|
||||
|
||||
List<VTMatchInfo> members = transform(matchSet, destFunc, dstVector, srcNeighbors,
|
||||
monitor);
|
||||
List<VTMatchInfo> members =
|
||||
transform(matchSet, destFunc, dstVector, srcNeighbors, monitor);
|
||||
|
||||
for (VTMatchInfo member : members) {
|
||||
if (member != null) {
|
||||
|
@ -294,8 +288,8 @@ public abstract class VTAbstractReferenceProgramCorrelator extends VTAbstractPro
|
|||
* @param program the program
|
||||
* @param address an address represents a location in a program
|
||||
*/
|
||||
private void accumulateFunctionReferences(int depth, Set<Function> list,
|
||||
Program program, Address address) {
|
||||
private void accumulateFunctionReferences(int depth, Set<Function> list, Program program,
|
||||
Address address) {
|
||||
|
||||
if (depth >= MAX_DEPTH) {
|
||||
return;
|
||||
|
@ -389,10 +383,8 @@ public abstract class VTAbstractReferenceProgramCorrelator extends VTAbstractPro
|
|||
private void extractReferenceFeatures(VTMatchSet matchSet, TaskMonitor monitor)
|
||||
throws CancelledException {
|
||||
|
||||
srcVectorsByAddress =
|
||||
LazyMap.lazyMap(new HashMap<>(), addr -> new LSHCosineVectorAccum());
|
||||
destVectorsByAddress =
|
||||
LazyMap.lazyMap(new HashMap<>(), addr -> new LSHCosineVectorAccum());
|
||||
srcVectorsByAddress = LazyMap.lazyMap(new HashMap<>(), addr -> new LSHCosineVectorAccum());
|
||||
destVectorsByAddress = LazyMap.lazyMap(new HashMap<>(), addr -> new LSHCosineVectorAccum());
|
||||
|
||||
FunctionManager srcFuncManager = sourceProgram.getFunctionManager();
|
||||
FunctionManager destFuncManager = destinationProgram.getFunctionManager();
|
||||
|
@ -449,14 +441,12 @@ public abstract class VTAbstractReferenceProgramCorrelator extends VTAbstractPro
|
|||
|
||||
// By the construction above, there may be duplicate functions in the RefMaps
|
||||
for (Function function : sourceRefMap.get(match)) {
|
||||
LSHCosineVectorAccum vector =
|
||||
srcVectorsByAddress.get(function.getEntryPoint());
|
||||
LSHCosineVectorAccum vector = srcVectorsByAddress.get(function.getEntryPoint());
|
||||
vector.addHash(featureID, weight);
|
||||
}
|
||||
|
||||
for (Function function : destinationRefMap.get(match)) {
|
||||
LSHCosineVectorAccum vector =
|
||||
destVectorsByAddress.get(function.getEntryPoint());
|
||||
LSHCosineVectorAccum vector = destVectorsByAddress.get(function.getEntryPoint());
|
||||
vector.addHash(featureID, weight);
|
||||
}
|
||||
|
||||
|
@ -475,8 +465,7 @@ public abstract class VTAbstractReferenceProgramCorrelator extends VTAbstractPro
|
|||
// odd checks here: 1) assuming we do not want to include our own results when checking
|
||||
// matches; 2) why keep only the newest match set data? seems like we should take all
|
||||
// matches and dedup the matches, not the match sets
|
||||
if (name.equals(correlatorName) ||
|
||||
(dedupedMatchSets.containsKey(name) &&
|
||||
if (name.equals(correlatorName) || (dedupedMatchSets.containsKey(name) &&
|
||||
ms.getID() < dedupedMatchSets.get(name).getID())) {
|
||||
continue;
|
||||
}
|
||||
|
@ -489,8 +478,7 @@ public abstract class VTAbstractReferenceProgramCorrelator extends VTAbstractPro
|
|||
|
||||
}
|
||||
|
||||
private void accumulateMatchFunctionReferences(
|
||||
Map<VTMatch, Set<Function>> sourceRefMap,
|
||||
private void accumulateMatchFunctionReferences(Map<VTMatch, Set<Function>> sourceRefMap,
|
||||
Map<VTMatch, Set<Function>> destinationRefMap, VTMatch match) {
|
||||
|
||||
// check match association type and status
|
||||
|
|
|
@ -43,6 +43,7 @@ public interface VTProgramCorrelator {
|
|||
|
||||
/**
|
||||
* Returns a options object populated with the options for this correlator instance.
|
||||
* @return the options
|
||||
*/
|
||||
public ToolOptions getOptions();
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -58,7 +57,6 @@ public interface VTProgramCorrelatorFactory extends ExtensionPoint {
|
|||
|
||||
/**
|
||||
* Returns a VTProgramCorrelator instance created specifically for the given parameters.
|
||||
* @param serviceProvider a service provider to access tool services.
|
||||
* @param sourceProgram the source program for this correlation.
|
||||
* @param sourceAddressSet the set of addresses in the source program to consider in this correlation.
|
||||
* @param destinationProgram the destination program for this correlation.
|
||||
|
@ -67,7 +65,29 @@ public interface VTProgramCorrelatorFactory extends ExtensionPoint {
|
|||
* @param options the options to use for this correlation.
|
||||
* @return a new VTProgramCorrelator instance created specifically for this set of given parameters.
|
||||
*/
|
||||
public VTProgramCorrelator createCorrelator(Program sourceProgram,
|
||||
AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
AddressSetView destinationAddressSet, VTOptions options);
|
||||
|
||||
/**
|
||||
* Deprecated. Use {@link #createCorrelator(Program, AddressSetView, Program, AddressSetView, VTOptions)}
|
||||
* instead.
|
||||
*
|
||||
*
|
||||
* @param serviceProvider a service provider to access tool services.
|
||||
* @param sourceProgram the source program for this correlation.
|
||||
* @param sourceAddressSet the set of addresses in the source program to consider in this correlation.
|
||||
* @param destinationProgram the destination program for this correlation.
|
||||
* @param destinationAddressSet the set of addresses in the destination program to consider in
|
||||
* this correlation.
|
||||
* @param options the options to use for this correlation.
|
||||
* @return a new VTProgramCorrelator instance created specifically for this set of given parameters.
|
||||
* @deprecated Use {@link #createCorrelator(Program, AddressSetView, Program, AddressSetView, VTOptions)}
|
||||
* instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public VTProgramCorrelator createCorrelator(ServiceProvider serviceProvider,
|
||||
Program sourceProgram, AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
AddressSetView destinationAddressSet, VTOptions options);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,15 +15,14 @@
|
|||
*/
|
||||
package ghidra.feature.vt.api.main;
|
||||
|
||||
import ghidra.framework.model.DomainObjectListener;
|
||||
import ghidra.framework.model.UndoableDomainObject;
|
||||
import ghidra.program.model.listing.Program;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import db.util.ErrorHandler;
|
||||
import ghidra.framework.model.DomainObjectListener;
|
||||
import ghidra.framework.model.UndoableDomainObject;
|
||||
import ghidra.program.model.listing.Program;
|
||||
|
||||
/**
|
||||
* Main interface for a Version Tracking Session
|
||||
|
@ -69,11 +67,12 @@ public interface VTSession extends ErrorHandler, UndoableDomainObject {
|
|||
* Returns the name of this VTSession
|
||||
* @return the name of this VTSession
|
||||
*/
|
||||
@Override
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* Saves this VTSession.
|
||||
* @throws IOException
|
||||
* @throws IOException if there is an exception saving
|
||||
*/
|
||||
public void save() throws IOException;
|
||||
|
||||
|
@ -81,12 +80,14 @@ public interface VTSession extends ErrorHandler, UndoableDomainObject {
|
|||
* Adds a DomainObjectListener to this VTSession.
|
||||
* @param domainObjectListener the listener to add.
|
||||
*/
|
||||
@Override
|
||||
public void addListener(DomainObjectListener domainObjectListener);
|
||||
|
||||
/**
|
||||
* Removes a DomainObjectListener from this VTSession.
|
||||
* @param domainObjectListener the listener to remove.
|
||||
*/
|
||||
@Override
|
||||
public void removeListener(DomainObjectListener domainObjectListener);
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,7 +17,6 @@ package ghidra.feature.vt.api.util;
|
|||
|
||||
import ghidra.feature.vt.api.main.*;
|
||||
import ghidra.framework.options.ToolOptions;
|
||||
import ghidra.framework.plugintool.ServiceProvider;
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.util.SystemUtilities;
|
||||
|
@ -37,8 +36,6 @@ public abstract class VTAbstractProgramCorrelator implements VTProgramCorrelator
|
|||
private final AddressSetView destinationAddressSet;
|
||||
private final ToolOptions options;
|
||||
|
||||
protected final ServiceProvider serviceProvider;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param sourceProgram The program that contains functions that are to be looked for in the
|
||||
|
@ -51,10 +48,9 @@ public abstract class VTAbstractProgramCorrelator implements VTProgramCorrelator
|
|||
* @param options An Options object that contains the set of options to be used by the
|
||||
* correlating algorithm.
|
||||
*/
|
||||
public VTAbstractProgramCorrelator(ServiceProvider serviceProvider, Program sourceProgram,
|
||||
AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
AddressSetView destinationAddressSet, ToolOptions options) {
|
||||
this.serviceProvider = serviceProvider;
|
||||
public VTAbstractProgramCorrelator(Program sourceProgram, AddressSetView sourceAddressSet,
|
||||
Program destinationProgram, AddressSetView destinationAddressSet,
|
||||
ToolOptions options) {
|
||||
this.sourceProgram = sourceProgram;
|
||||
this.sourceAddressSet = sourceAddressSet;
|
||||
this.destinationProgram = destinationProgram;
|
||||
|
|
|
@ -68,21 +68,57 @@ public abstract class VTAbstractProgramCorrelatorFactory implements VTProgramCor
|
|||
}
|
||||
|
||||
@Override
|
||||
public final VTProgramCorrelator createCorrelator(ServiceProvider serviceProvider,
|
||||
Program sourceProgram, AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
public final VTProgramCorrelator createCorrelator(Program sourceProgram,
|
||||
AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
AddressSetView destinationAddressSet, VTOptions options) {
|
||||
|
||||
return doCreateCorrelator(serviceProvider, sourceProgram, sourceAddressSet,
|
||||
destinationProgram, destinationAddressSet, options == null ? createDefaultOptions()
|
||||
: (VTOptions) options.copy());
|
||||
return doCreateCorrelator(sourceProgram, sourceAddressSet, destinationProgram,
|
||||
destinationAddressSet,
|
||||
options == null ? createDefaultOptions() : (VTOptions) options.copy());
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is added to the interface to enforce the fact that we want options passed into
|
||||
* this method to be copies so that changes during correlation do not spoil the options
|
||||
* of others.
|
||||
* @param sourceProgram the source program for this correlation.
|
||||
* @param sourceAddressSet the set of addresses in the source program to consider in this
|
||||
* correlation.
|
||||
* @param destinationProgram the destination program for this correlation.
|
||||
* @param destinationAddressSet the set of addresses in the destination program to consider in
|
||||
* this correlation.
|
||||
* @param options the options to use for this correlation.
|
||||
* @return a new VTProgramCorrelator instance created specifically for this set of given
|
||||
* parameters.
|
||||
*/
|
||||
protected abstract VTProgramCorrelator doCreateCorrelator(ServiceProvider serviceProvider,
|
||||
Program sourceProgram, AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
protected abstract VTProgramCorrelator doCreateCorrelator(Program sourceProgram,
|
||||
AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
AddressSetView destinationAddressSet, VTOptions options);
|
||||
|
||||
/**
|
||||
* Deprecated. Use {@link #createCorrelator(Program, AddressSetView, Program, AddressSetView, VTOptions)}
|
||||
* instead.
|
||||
*
|
||||
*
|
||||
* @param sourceProgram the source program for this correlation.
|
||||
* @param sourceAddressSet the set of addresses in the source program to consider in this
|
||||
* correlation.
|
||||
* @param destinationProgram the destination program for this correlation.
|
||||
* @param destinationAddressSet the set of addresses in the destination program to consider in
|
||||
* this correlation.
|
||||
* @param options the options to use for this correlation.
|
||||
* @return a new VTProgramCorrelator instance created specifically for this set of given
|
||||
* parameters.
|
||||
* @deprecated Use {@link #createCorrelator(Program, AddressSetView, Program, AddressSetView, VTOptions)}
|
||||
* instead.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public VTProgramCorrelator createCorrelator(ServiceProvider serviceProvider,
|
||||
Program sourceProgram, AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
AddressSetView destinationAddressSet, VTOptions options) {
|
||||
return doCreateCorrelator(sourceProgram, sourceAddressSet, destinationProgram,
|
||||
destinationAddressSet, options);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,10 +15,10 @@
|
|||
*/
|
||||
package ghidra.feature.vt.api.util;
|
||||
|
||||
import ghidra.framework.options.ToolOptions;
|
||||
|
||||
import org.jdom.Element;
|
||||
|
||||
import ghidra.framework.options.ToolOptions;
|
||||
|
||||
public class VTOptions extends ToolOptions {
|
||||
|
||||
private VTOptions(Element root) {
|
||||
|
@ -37,6 +37,7 @@ public class VTOptions extends ToolOptions {
|
|||
/**
|
||||
* A method that allows subclasses to tell the world where their options contain acceptable
|
||||
* values
|
||||
* @return true if valid
|
||||
*/
|
||||
public boolean validate() {
|
||||
return true;
|
||||
|
|
|
@ -24,9 +24,10 @@ import generic.theme.GIcon;
|
|||
import ghidra.feature.vt.api.main.VTSession;
|
||||
import ghidra.feature.vt.gui.plugin.VTController;
|
||||
import ghidra.feature.vt.gui.plugin.VTPlugin;
|
||||
import ghidra.framework.options.ToolOptions;
|
||||
import ghidra.util.HTMLUtilities;
|
||||
import ghidra.util.HelpLocation;
|
||||
import ghidra.util.task.TaskLauncher;
|
||||
import ghidra.util.task.*;
|
||||
|
||||
/**
|
||||
* This action runs the {@link AutoVersionTrackingTask}
|
||||
|
@ -59,6 +60,7 @@ public class AutoVersionTrackingAction extends DockingAction {
|
|||
public void actionPerformed(ActionContext context) {
|
||||
|
||||
VTSession session = controller.getSession();
|
||||
ToolOptions options = controller.getOptions();
|
||||
|
||||
// In the future we might want to make these user options so the user can change them.
|
||||
// We don't want to make this change until the confidence option in the reference
|
||||
|
@ -68,7 +70,25 @@ public class AutoVersionTrackingAction extends DockingAction {
|
|||
// The current passed values for score and confidence (.95 and 10.0)
|
||||
// get you accepted matches with similarity scores >= .95 and
|
||||
// confidence (log 10) scores 2.0 and up
|
||||
AutoVersionTrackingTask task = new AutoVersionTrackingTask(controller, session, 0.95, 10.0);
|
||||
AutoVersionTrackingTask task = new AutoVersionTrackingTask(session, options, 0.95, 10.0);
|
||||
task.addTaskListener(new TaskListener() {
|
||||
|
||||
@Override
|
||||
public void taskCompleted(Task t) {
|
||||
String message = task.getStatusMsg();
|
||||
if (message != null) {
|
||||
controller.getTool().setStatusInfo(message);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void taskCancelled(Task t) {
|
||||
String message = task.getStatusMsg();
|
||||
if (message != null) {
|
||||
controller.getTool().setStatusInfo(message);
|
||||
}
|
||||
}
|
||||
});
|
||||
TaskLauncher.launch(task);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,11 +23,11 @@ import ghidra.feature.vt.api.correlator.program.*;
|
|||
import ghidra.feature.vt.api.main.*;
|
||||
import ghidra.feature.vt.api.util.VTAssociationStatusException;
|
||||
import ghidra.feature.vt.api.util.VTOptions;
|
||||
import ghidra.feature.vt.gui.plugin.VTController;
|
||||
import ghidra.feature.vt.gui.plugin.AddressCorrelatorManager;
|
||||
import ghidra.feature.vt.gui.task.ApplyMarkupItemTask;
|
||||
import ghidra.feature.vt.gui.util.MatchInfo;
|
||||
import ghidra.feature.vt.gui.util.MatchInfoFactory;
|
||||
import ghidra.framework.options.ToolOptions;
|
||||
import ghidra.framework.plugintool.PluginTool;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.program.model.lang.OperandType;
|
||||
|
@ -69,43 +69,42 @@ public class AutoVersionTrackingTask extends Task {
|
|||
|
||||
private static final String NAME = "Auto Version Tracking Command";
|
||||
private VTSession session;
|
||||
private MatchInfoFactory matchInfoFactory;
|
||||
private AddressCorrelatorManager addressCorrelator;
|
||||
private Program sourceProgram;
|
||||
private Program destinationProgram;
|
||||
private PluginTool serviceProvider;
|
||||
private AddressSetView sourceAddressSet;
|
||||
private AddressSetView destinationAddressSet;
|
||||
private VTController controller;
|
||||
private double minCombinedReferenceCorrelatorScore;
|
||||
private double minCombinedReferenceCorrelatorConfidence;
|
||||
private final ToolOptions applyOptions;
|
||||
private ToolOptions applyOptions;
|
||||
private String statusMsg = null;
|
||||
private static int NUM_CORRELATORS = 8;
|
||||
|
||||
/**
|
||||
* Constructor for a modal/blocking AutoVersionTrackingTask
|
||||
*
|
||||
* @param controller The Version Tracking controller for this session containing option and
|
||||
* tool information needed for this command.
|
||||
|
||||
* @param session The Version Tracking session containing the source, destination, correlator
|
||||
* and match information needed for this command.
|
||||
* @param options the options used when applying matches
|
||||
* @param minCombinedReferenceCorrelatorScore The minimum score used to limit matches created by
|
||||
* the Combined Reference Correlator.
|
||||
* @param minCombinedReferenceCorrelatorConfidence The minimum confidence used to limit matches
|
||||
* created by the Combined Reference Correlator.
|
||||
*/
|
||||
public AutoVersionTrackingTask(VTController controller, VTSession session,
|
||||
public AutoVersionTrackingTask(VTSession session, ToolOptions options,
|
||||
double minCombinedReferenceCorrelatorScore,
|
||||
double minCombinedReferenceCorrelatorConfidence) {
|
||||
super(NAME, true, true, true);
|
||||
this.session = session;
|
||||
this.matchInfoFactory = new MatchInfoFactory();
|
||||
this.addressCorrelator = new AddressCorrelatorManager(() -> session);
|
||||
this.sourceProgram = session.getSourceProgram();
|
||||
this.destinationProgram = session.getDestinationProgram();
|
||||
this.serviceProvider = controller.getTool();
|
||||
this.controller = controller;
|
||||
this.minCombinedReferenceCorrelatorScore = minCombinedReferenceCorrelatorScore;
|
||||
this.minCombinedReferenceCorrelatorConfidence = minCombinedReferenceCorrelatorConfidence;
|
||||
this.applyOptions = controller.getOptions();
|
||||
|
||||
this.applyOptions = options;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -267,8 +266,6 @@ public class AutoVersionTrackingTask extends Task {
|
|||
" with some apply markup errors. See the log or the markup table for more details";
|
||||
}
|
||||
statusMsg = NAME + " completed successfully" + applyMarkupStatus;
|
||||
|
||||
controller.getTool().setStatusInfo(statusMsg);
|
||||
}
|
||||
|
||||
private int getNumberOfDataMatches(TaskMonitor monitor) throws CancelledException {
|
||||
|
@ -323,8 +320,8 @@ public class AutoVersionTrackingTask extends Task {
|
|||
monitor.setMessage(
|
||||
"Finding and applying good " + factory.getName() + " matches and markup.");
|
||||
|
||||
VTProgramCorrelator correlator = factory.createCorrelator(serviceProvider, sourceProgram,
|
||||
sourceAddressSet, destinationProgram, destinationAddressSet, options);
|
||||
VTProgramCorrelator correlator = factory.createCorrelator(sourceProgram, sourceAddressSet,
|
||||
destinationProgram, destinationAddressSet, options);
|
||||
|
||||
VTMatchSet results = correlator.correlate(session, monitor);
|
||||
monitor.initialize(results.getMatchCount());
|
||||
|
@ -353,8 +350,8 @@ public class AutoVersionTrackingTask extends Task {
|
|||
monitor.setMessage(
|
||||
"Finding and applying good " + factory.getName() + " matches and markup.");
|
||||
|
||||
VTProgramCorrelator correlator = factory.createCorrelator(serviceProvider, sourceProgram,
|
||||
sourceAddressSet, destinationProgram, destinationAddressSet, options);
|
||||
VTProgramCorrelator correlator = factory.createCorrelator(sourceProgram, sourceAddressSet,
|
||||
destinationProgram, destinationAddressSet, options);
|
||||
|
||||
VTMatchSet results = correlator.correlate(session, monitor);
|
||||
monitor.initialize(results.getMatchCount());
|
||||
|
@ -395,14 +392,14 @@ public class AutoVersionTrackingTask extends Task {
|
|||
continue;
|
||||
}
|
||||
|
||||
MatchInfo matchInfo = controller.getMatchInfo(match);
|
||||
MatchInfo matchInfo = matchInfoFactory.getMatchInfo(match, addressCorrelator);
|
||||
Collection<VTMarkupItem> markupItems = matchInfo.getAppliableMarkupItems(monitor);
|
||||
if (markupItems == null || markupItems.size() == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ApplyMarkupItemTask markupTask =
|
||||
new ApplyMarkupItemTask(controller.getSession(), markupItems, applyOptions);
|
||||
new ApplyMarkupItemTask(session, markupItems, applyOptions);
|
||||
|
||||
markupTask.run(monitor);
|
||||
boolean currentMatchHasErrors = markupTask.hasErrors();
|
||||
|
@ -538,12 +535,12 @@ public class AutoVersionTrackingTask extends Task {
|
|||
if (tryToSetAccepted(association)) {
|
||||
|
||||
// If accept match succeeds apply the markup for the match
|
||||
MatchInfo matchInfo = controller.getMatchInfo(match);
|
||||
MatchInfo matchInfo = matchInfoFactory.getMatchInfo(match, addressCorrelator);
|
||||
Collection<VTMarkupItem> markupItems = matchInfo.getAppliableMarkupItems(monitor);
|
||||
if (markupItems != null && markupItems.size() != 0) {
|
||||
|
||||
ApplyMarkupItemTask markupTask =
|
||||
new ApplyMarkupItemTask(controller.getSession(), markupItems, applyOptions);
|
||||
new ApplyMarkupItemTask(session, markupItems, applyOptions);
|
||||
markupTask.run(monitor);
|
||||
boolean currentMatchHasErrors = markupTask.hasErrors();
|
||||
if (currentMatchHasErrors) {
|
||||
|
|
|
@ -48,15 +48,13 @@ public class AddressCorrelatorManager {
|
|||
new FixedSizeMRUCachingFactory<Pair<Data, Data>, AddressCorrelation>(
|
||||
key -> getDataCorrelator(key.first, key.second), DATA_CORRELATION_CACHE_SIZE);
|
||||
|
||||
public AddressCorrelatorManager(VTController controller) {
|
||||
public AddressCorrelatorManager(VTSessionSupplier sessionSupplier) {
|
||||
correlatorList = new ArrayList<AddressCorrelator>();
|
||||
initializeAddressCorrelators(controller);
|
||||
initializeAddressCorrelators(sessionSupplier);
|
||||
}
|
||||
|
||||
private void initializeAddressCorrelators(VTController controller) {
|
||||
// Put the CodeCompare address correlator that uses match info to handle exact matches
|
||||
// so it is first in the list.
|
||||
correlatorList.add(new ExactMatchAddressCorrelator(controller));
|
||||
private void initializeAddressCorrelators(VTSessionSupplier sessionSupplier) {
|
||||
correlatorList.add(new ExactMatchAddressCorrelator(sessionSupplier));
|
||||
correlatorList.addAll(initializeAddressCorrelators());
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ import ghidra.program.model.symbol.Symbol;
|
|||
import ghidra.program.util.AddressCorrelation;
|
||||
import ghidra.program.util.ProgramLocation;
|
||||
|
||||
public interface VTController {
|
||||
public interface VTController extends VTSessionSupplier {
|
||||
|
||||
public static final String VERSION_TRACKING_OPTIONS_NAME = "Version Tracking";
|
||||
|
||||
|
@ -43,8 +43,7 @@ public interface VTController {
|
|||
|
||||
public void removeListener(VTControllerListener listener);
|
||||
|
||||
// public VTSessionState getSessionState();
|
||||
|
||||
@Override
|
||||
public VTSession getSession();
|
||||
|
||||
public void openVersionTrackingSession(DomainFile domainFile);
|
||||
|
@ -110,6 +109,7 @@ public interface VTController {
|
|||
/**
|
||||
* Runs VT tasks, listening for destination program changes and updates undo/redo state
|
||||
* accordingly.
|
||||
* @param task the task
|
||||
*/
|
||||
public void runVTTask(VtTask task);
|
||||
|
||||
|
|
|
@ -329,8 +329,8 @@ public class VTControllerImpl
|
|||
return;
|
||||
}
|
||||
|
||||
currentMatchInfo = (match == null) ? null
|
||||
: matchInfoFactory.getMatchInfo(this, match, addressCorrelatorManager);
|
||||
currentMatchInfo =
|
||||
(match == null) ? null : matchInfoFactory.getMatchInfo(match, addressCorrelatorManager);
|
||||
|
||||
fireMatchChanged(currentMatchInfo);
|
||||
}
|
||||
|
@ -338,7 +338,7 @@ public class VTControllerImpl
|
|||
@Override
|
||||
public MatchInfo getMatchInfo(VTMatch match) {
|
||||
return (match == null) ? null
|
||||
: matchInfoFactory.getMatchInfo(this, match, addressCorrelatorManager);
|
||||
: matchInfoFactory.getMatchInfo(match, addressCorrelatorManager);
|
||||
}
|
||||
|
||||
private void fireSessionChanged() {
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
/* ###
|
||||
* 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.
|
||||
*/
|
||||
package ghidra.feature.vt.gui.plugin;
|
||||
|
||||
import ghidra.feature.vt.api.main.VTSession;
|
||||
|
||||
/**
|
||||
* A simple interface that provides a session.
|
||||
*/
|
||||
public interface VTSessionSupplier {
|
||||
public VTSession getSession();
|
||||
}
|
|
@ -15,15 +15,11 @@
|
|||
*/
|
||||
package ghidra.feature.vt.gui.provider.impliedmatches;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import ghidra.feature.vt.api.main.*;
|
||||
import ghidra.feature.vt.gui.plugin.*;
|
||||
import ghidra.feature.vt.gui.util.*;
|
||||
import ghidra.framework.model.DomainObjectChangedEvent;
|
||||
import ghidra.framework.options.Options;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.listing.Function;
|
||||
import ghidra.util.Msg;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
|
@ -40,6 +36,7 @@ public class ImpliedMatchAssociationHook implements AssociationHook, VTControlle
|
|||
Options options = controller.getOptions();
|
||||
autoCreateImpliedMatches =
|
||||
options.getBoolean(VTOptionDefines.AUTO_CREATE_IMPLIED_MATCH, false);
|
||||
|
||||
setSession(controller.getSession());
|
||||
controller.addListener(this);
|
||||
}
|
||||
|
@ -74,39 +71,14 @@ public class ImpliedMatchAssociationHook implements AssociationHook, VTControlle
|
|||
|
||||
try {
|
||||
TaskMonitor monitor = VTTaskMonitor.getTaskMonitor();
|
||||
Set<VTImpliedMatchInfo> impliedMatches = ImpliedMatchUtils.findImpliedMatches(
|
||||
controller, source, destination, session, correlator, monitor);
|
||||
processAssociationAccepted(impliedMatches);
|
||||
ImpliedMatchUtils.updateImpliedMatchForAcceptedAssocation(source, destination, session,
|
||||
correlator, monitor);
|
||||
}
|
||||
catch (CancelledException e) {
|
||||
Msg.info(this, "User cancelled finding implied matches when accepting an assocation");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* When a match is accepted either create associated implied matches or if a match already
|
||||
* exists, increase the vote count
|
||||
* @param impliedMatches The implied matches set to either create or increase vote count
|
||||
*/
|
||||
private void processAssociationAccepted(Set<VTImpliedMatchInfo> impliedMatches) {
|
||||
for (VTImpliedMatchInfo impliedMatch : impliedMatches) {
|
||||
Address sourceAddress = impliedMatch.getSourceAddress();
|
||||
Address destinationAddress = impliedMatch.getDestinationAddress();
|
||||
VTAssociation existingAssociation =
|
||||
session.getAssociationManager().getAssociation(sourceAddress, destinationAddress);
|
||||
|
||||
if (existingAssociation == null) {
|
||||
VTMatchSet impliedMatchSet = session.getImpliedMatchSet();
|
||||
VTMatch match = impliedMatchSet.addMatch(impliedMatch);
|
||||
existingAssociation = match.getAssociation();
|
||||
}
|
||||
if (existingAssociation != null) {
|
||||
existingAssociation.setVoteCount(existingAssociation.getVoteCount() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void associationCleared(VTAssociation association) {
|
||||
Function source = ImpliedMatchUtils.getSourceFunction(session, association);
|
||||
|
@ -122,44 +94,14 @@ public class ImpliedMatchAssociationHook implements AssociationHook, VTControlle
|
|||
AddressCorrelatorManager correlator = controller.getCorrelator();
|
||||
try {
|
||||
TaskMonitor monitor = VTTaskMonitor.getTaskMonitor();
|
||||
Set<VTImpliedMatchInfo> impliedMatches = ImpliedMatchUtils.findImpliedMatches(
|
||||
controller, source, destination, session, correlator, monitor);
|
||||
processAssociationCleared(impliedMatches);
|
||||
ImpliedMatchUtils.updateImpliedMatchForClearedAssocation(source, destination, session,
|
||||
correlator, monitor);
|
||||
}
|
||||
catch (CancelledException e) {
|
||||
Msg.info(this, "User cancelled finding implied matches when clearing an assocation");
|
||||
}
|
||||
}
|
||||
|
||||
private void processAssociationCleared(Set<VTImpliedMatchInfo> impliedMatches) {
|
||||
for (VTImpliedMatchInfo impliedMatch : impliedMatches) {
|
||||
Address sourceAddress = impliedMatch.getSourceAddress();
|
||||
Address destinationAddress = impliedMatch.getDestinationAddress();
|
||||
VTAssociation existingAssociation =
|
||||
session.getAssociationManager().getAssociation(sourceAddress, destinationAddress);
|
||||
|
||||
if (existingAssociation != null) {
|
||||
int newVoteCount = Math.max(0, existingAssociation.getVoteCount() - 1);
|
||||
existingAssociation.setVoteCount(newVoteCount);
|
||||
if (autoCreateImpliedMatches && newVoteCount == 0) {
|
||||
removeImpliedMatch(existingAssociation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void removeImpliedMatch(VTAssociation existingAssociation) {
|
||||
List<VTMatch> matches = session.getMatches(existingAssociation);
|
||||
VTMatchSet impliedMatchSet = session.getImpliedMatchSet();
|
||||
for (VTMatch vtMatch : matches) {
|
||||
if (vtMatch.getMatchSet() == impliedMatchSet) {
|
||||
impliedMatchSet.removeMatch(vtMatch);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void optionsChanged(Options options) {
|
||||
autoCreateImpliedMatches =
|
||||
|
|
|
@ -15,6 +15,10 @@
|
|||
*/
|
||||
package ghidra.feature.vt.gui.provider.impliedmatches;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import docking.widgets.table.DiscoverableTableUtils;
|
||||
import docking.widgets.table.TableColumnDescriptor;
|
||||
import ghidra.docking.settings.Settings;
|
||||
import ghidra.feature.vt.api.db.DeletedMatch;
|
||||
import ghidra.feature.vt.api.main.*;
|
||||
|
@ -22,7 +26,8 @@ import ghidra.feature.vt.api.util.EmptyVTSession;
|
|||
import ghidra.feature.vt.gui.plugin.AddressCorrelatorManager;
|
||||
import ghidra.feature.vt.gui.plugin.VTController;
|
||||
import ghidra.feature.vt.gui.util.AbstractVTMatchTableModel.*;
|
||||
import ghidra.feature.vt.gui.util.*;
|
||||
import ghidra.feature.vt.gui.util.ImpliedMatchUtils;
|
||||
import ghidra.feature.vt.gui.util.MatchInfo;
|
||||
import ghidra.framework.plugintool.ServiceProvider;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.listing.*;
|
||||
|
@ -32,13 +37,8 @@ import ghidra.util.table.AddressBasedTableModel;
|
|||
import ghidra.util.table.field.AbstractProgramBasedDynamicTableColumn;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import docking.widgets.table.DiscoverableTableUtils;
|
||||
import docking.widgets.table.TableColumnDescriptor;
|
||||
|
||||
public class VTImpliedMatchesTableModel extends
|
||||
AddressBasedTableModel<ImpliedMatchWrapperRowObject> {
|
||||
public class VTImpliedMatchesTableModel
|
||||
extends AddressBasedTableModel<ImpliedMatchWrapperRowObject> {
|
||||
private static final String TITLE = "Implied Match Table Model";
|
||||
|
||||
protected VTSession session;
|
||||
|
@ -114,42 +114,42 @@ public class VTImpliedMatchesTableModel extends
|
|||
|
||||
descriptor.addVisibleColumn(new SourceReferenceAddressTableColumn());
|
||||
descriptor.addVisibleColumn(new DestinationReferenceAddressTableColumn());
|
||||
descriptor.addHiddenColumn(DiscoverableTableUtils.adaptColumForModel(this,
|
||||
new SessionNumberTableColumn()));
|
||||
descriptor.addHiddenColumn(
|
||||
DiscoverableTableUtils.adaptColumForModel(this, new SessionNumberTableColumn()));
|
||||
descriptor.addVisibleColumn(
|
||||
DiscoverableTableUtils.adaptColumForModel(this, new StatusTableColumn()), 1, true);
|
||||
descriptor.addVisibleColumn(DiscoverableTableUtils.adaptColumForModel(this,
|
||||
new MatchTypeTableColumn()));
|
||||
descriptor.addVisibleColumn(DiscoverableTableUtils.adaptColumForModel(this,
|
||||
new ScoreTableColumn()));
|
||||
descriptor.addVisibleColumn(DiscoverableTableUtils.adaptColumForModel(this,
|
||||
new ConfidenceScoreTableColumn()));
|
||||
descriptor.addVisibleColumn(DiscoverableTableUtils.adaptColumForModel(this,
|
||||
new ImpliedMatchCountColumn()));
|
||||
descriptor.addVisibleColumn(DiscoverableTableUtils.adaptColumForModel(this,
|
||||
new RelatedMatchCountColumn()));
|
||||
descriptor.addHiddenColumn(DiscoverableTableUtils.adaptColumForModel(this,
|
||||
new MultipleSourceLabelsTableColumn()));
|
||||
descriptor.addVisibleColumn(DiscoverableTableUtils.adaptColumForModel(this,
|
||||
new SourceLabelTableColumn()));
|
||||
descriptor.addVisibleColumn(
|
||||
DiscoverableTableUtils.adaptColumForModel(this, new MatchTypeTableColumn()));
|
||||
descriptor.addVisibleColumn(
|
||||
DiscoverableTableUtils.adaptColumForModel(this, new ScoreTableColumn()));
|
||||
descriptor.addVisibleColumn(
|
||||
DiscoverableTableUtils.adaptColumForModel(this, new ConfidenceScoreTableColumn()));
|
||||
descriptor.addVisibleColumn(
|
||||
DiscoverableTableUtils.adaptColumForModel(this, new ImpliedMatchCountColumn()));
|
||||
descriptor.addVisibleColumn(
|
||||
DiscoverableTableUtils.adaptColumForModel(this, new RelatedMatchCountColumn()));
|
||||
descriptor.addHiddenColumn(
|
||||
DiscoverableTableUtils.adaptColumForModel(this, new MultipleSourceLabelsTableColumn()));
|
||||
descriptor.addVisibleColumn(
|
||||
DiscoverableTableUtils.adaptColumForModel(this, new SourceLabelTableColumn()));
|
||||
descriptor.addVisibleColumn(
|
||||
DiscoverableTableUtils.adaptColumForModel(this, new SourceAddressTableColumn()), 2,
|
||||
true);
|
||||
descriptor.addHiddenColumn(DiscoverableTableUtils.adaptColumForModel(this,
|
||||
new MultipleDestinationLabelsTableColumn()));
|
||||
descriptor.addVisibleColumn(DiscoverableTableUtils.adaptColumForModel(this,
|
||||
new DestinationLabelTableColumn()));
|
||||
descriptor.addVisibleColumn(DiscoverableTableUtils.adaptColumForModel(this,
|
||||
new DestinationAddressTableColumn()));
|
||||
descriptor.addVisibleColumn(DiscoverableTableUtils.adaptColumForModel(this,
|
||||
new AlgorithmTableColumn()));
|
||||
descriptor.addVisibleColumn(
|
||||
DiscoverableTableUtils.adaptColumForModel(this, new DestinationLabelTableColumn()));
|
||||
descriptor.addVisibleColumn(
|
||||
DiscoverableTableUtils.adaptColumForModel(this, new DestinationAddressTableColumn()));
|
||||
descriptor.addVisibleColumn(
|
||||
DiscoverableTableUtils.adaptColumForModel(this, new AlgorithmTableColumn()));
|
||||
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doLoad(Accumulator<ImpliedMatchWrapperRowObject> accumulator, TaskMonitor monitor)
|
||||
throws CancelledException {
|
||||
protected void doLoad(Accumulator<ImpliedMatchWrapperRowObject> accumulator,
|
||||
TaskMonitor monitor) throws CancelledException {
|
||||
MatchInfo matchInfo = controller.getMatchInfo();
|
||||
if (matchInfo == null) {
|
||||
return; // no match selected
|
||||
|
@ -165,9 +165,8 @@ public class VTImpliedMatchesTableModel extends
|
|||
}
|
||||
|
||||
AddressCorrelatorManager correlator = controller.getCorrelator();
|
||||
Set<VTImpliedMatchInfo> matches =
|
||||
ImpliedMatchUtils.findImpliedMatches(controller, sourceFunction, destinationFunction,
|
||||
session, correlator, monitor);
|
||||
Set<VTImpliedMatchInfo> matches = ImpliedMatchUtils.findImpliedMatches(sourceFunction,
|
||||
destinationFunction, session, correlator, monitor);
|
||||
|
||||
monitor.setMessage("Searching for existing matches...");
|
||||
monitor.initialize(matches.size());
|
||||
|
@ -203,8 +202,8 @@ public class VTImpliedMatchesTableModel extends
|
|||
//==================================================================================================
|
||||
|
||||
// Source Ref Address
|
||||
public static class SourceReferenceAddressTableColumn extends
|
||||
AbstractProgramBasedDynamicTableColumn<ImpliedMatchWrapperRowObject, String> {
|
||||
public static class SourceReferenceAddressTableColumn
|
||||
extends AbstractProgramBasedDynamicTableColumn<ImpliedMatchWrapperRowObject, String> {
|
||||
|
||||
@Override
|
||||
public String getColumnName() {
|
||||
|
@ -224,8 +223,8 @@ public class VTImpliedMatchesTableModel extends
|
|||
}
|
||||
|
||||
// Destination Ref Address
|
||||
public static class DestinationReferenceAddressTableColumn extends
|
||||
AbstractProgramBasedDynamicTableColumn<ImpliedMatchWrapperRowObject, String> {
|
||||
public static class DestinationReferenceAddressTableColumn
|
||||
extends AbstractProgramBasedDynamicTableColumn<ImpliedMatchWrapperRowObject, String> {
|
||||
|
||||
@Override
|
||||
public String getColumnName() {
|
||||
|
|
|
@ -158,8 +158,8 @@ public class VTMarkupItemsTableProvider extends ComponentProviderAdapter
|
|||
ListingCodeComparisonPanel dualListingPanel = functionComparisonPanel.getDualListingPanel();
|
||||
if (dualListingPanel != null) {
|
||||
dualListingPanel.setLeftProgramLocationListener(new SourceProgramLocationListener());
|
||||
dualListingPanel.setRightProgramLocationListener(
|
||||
new DestinationProgramLocationListener());
|
||||
dualListingPanel
|
||||
.setRightProgramLocationListener(new DestinationProgramLocationListener());
|
||||
|
||||
sourceHighlightProvider = new VTDualListingHighlightProvider(controller, true);
|
||||
destinationHighlightProvider = new VTDualListingHighlightProvider(controller, false);
|
||||
|
@ -329,8 +329,7 @@ public class VTMarkupItemsTableProvider extends ComponentProviderAdapter
|
|||
if (filteredCount != unfilteredCount) {
|
||||
buffy.append(" (of ")
|
||||
.append(markupItemsTableModel.getUnfilteredRowCount())
|
||||
.append(
|
||||
')');
|
||||
.append(')');
|
||||
}
|
||||
|
||||
setSubTitle(buffy.toString());
|
||||
|
@ -359,8 +358,8 @@ public class VTMarkupItemsTableProvider extends ComponentProviderAdapter
|
|||
splitPane.add(functionComparisonPanel);
|
||||
markupPanel.add(splitPane, BorderLayout.CENTER);
|
||||
if (dualListingPanel != null) {
|
||||
dualListingPanel.setLeftProgramLocationListener(
|
||||
new SourceProgramLocationListener());
|
||||
dualListingPanel
|
||||
.setLeftProgramLocationListener(new SourceProgramLocationListener());
|
||||
dualListingPanel.setRightProgramLocationListener(
|
||||
new DestinationProgramLocationListener());
|
||||
}
|
||||
|
@ -402,8 +401,8 @@ public class VTMarkupItemsTableProvider extends ComponentProviderAdapter
|
|||
parentPanel.add(nameFilterPanel, BorderLayout.CENTER);
|
||||
|
||||
ancillaryFilterButton = new JButton(FILTER_ICON);
|
||||
ancillaryFilterButton.addActionListener(
|
||||
e -> tool.showDialog(ancillaryFilterDialog, component));
|
||||
ancillaryFilterButton
|
||||
.addActionListener(e -> tool.showDialog(ancillaryFilterDialog, component));
|
||||
ancillaryFilterButton.setToolTipText("Filters Dialog");
|
||||
|
||||
parentPanel.add(ancillaryFilterButton, BorderLayout.EAST);
|
||||
|
@ -453,7 +452,7 @@ public class VTMarkupItemsTableProvider extends ComponentProviderAdapter
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<DockingActionIf> getPopupActions(Tool tool, ActionContext context) {
|
||||
public List<DockingActionIf> getPopupActions(Tool t, ActionContext context) {
|
||||
ListingCodeComparisonPanel dualListingPanel = functionComparisonPanel.getDualListingPanel();
|
||||
if (context.getComponentProvider() == this && dualListingPanel != null) {
|
||||
ListingPanel sourcePanel = dualListingPanel.getLeftPanel();
|
||||
|
@ -853,8 +852,8 @@ public class VTMarkupItemsTableProvider extends ComponentProviderAdapter
|
|||
int filteredCount = markupItemsTableModel.getRowCount();
|
||||
int unfilteredCount = markupItemsTableModel.getUnfilteredRowCount();
|
||||
int filteredOutCount = unfilteredCount - filteredCount;
|
||||
ancillaryFilterButton.setToolTipText(
|
||||
"More Filters - " + filteredOutCount + " item(s) hidden");
|
||||
ancillaryFilterButton
|
||||
.setToolTipText("More Filters - " + filteredOutCount + " item(s) hidden");
|
||||
}
|
||||
else {
|
||||
ancillaryFilterButton.setToolTipText("More Filters - no active filters");
|
||||
|
|
|
@ -47,12 +47,7 @@ public class ApplyMarkupItemTask extends VtTask {
|
|||
return markupItems.size() > 20;
|
||||
}
|
||||
|
||||
/**
|
||||
* Template Method pattern to allow subclasses to plug-in to this task.
|
||||
* @param markupItem the markup
|
||||
* @param markupItemOptions
|
||||
* @return
|
||||
*/
|
||||
// Template Method pattern to allow subclasses to plug-in to this task.
|
||||
protected VTMarkupItemApplyActionType getApplyActionType(VTMarkupItem markupItem,
|
||||
ToolOptions markupItemOptions) {
|
||||
VTMarkupType markupType = markupItem.getMarkupType();
|
||||
|
|
|
@ -43,13 +43,10 @@ public class ClearMatchTask extends VtTask {
|
|||
this.controller = controller;
|
||||
this.matches = matches;
|
||||
|
||||
VTSession session = controller.getSession();
|
||||
|
||||
if (!(session instanceof VTSessionDB)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Unexpected condition - VTSession is not a DB object!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.util.*;
|
|||
import ghidra.feature.vt.api.impl.MatchSetImpl;
|
||||
import ghidra.feature.vt.api.main.*;
|
||||
import ghidra.feature.vt.gui.plugin.AddressCorrelatorManager;
|
||||
import ghidra.feature.vt.gui.plugin.VTController;
|
||||
import ghidra.feature.vt.gui.provider.impliedmatches.VTImpliedMatchInfo;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.listing.*;
|
||||
|
@ -38,23 +37,106 @@ import ghidra.util.task.TaskMonitor;
|
|||
*/
|
||||
public class ImpliedMatchUtils {
|
||||
|
||||
/**
|
||||
* Called when a {@link VTAssociation} is accepted. This method will create implied matches in
|
||||
* the current session based on the association.
|
||||
* @param sourceFunction The matched function from the source program
|
||||
* @param destinationFunction The matched function from the destination program
|
||||
* @param session The Version Tracking session
|
||||
* @param correlatorManager Keeps track of which section of the source function corresponds to
|
||||
* the which section of the destination function
|
||||
* @param monitor Handles user cancellations
|
||||
* @throws CancelledException if cancelled
|
||||
*/
|
||||
public static void updateImpliedMatchForAcceptedAssocation(Function sourceFunction,
|
||||
Function destinationFunction, VTSession session,
|
||||
AddressCorrelatorManager correlatorManager, TaskMonitor monitor)
|
||||
throws CancelledException {
|
||||
|
||||
Set<VTImpliedMatchInfo> impliedMatches = findImpliedMatches(sourceFunction,
|
||||
destinationFunction, session, correlatorManager, monitor);
|
||||
|
||||
for (VTImpliedMatchInfo impliedMatch : impliedMatches) {
|
||||
Address sourceAddress = impliedMatch.getSourceAddress();
|
||||
Address destinationAddress = impliedMatch.getDestinationAddress();
|
||||
VTAssociation existingAssociation =
|
||||
session.getAssociationManager().getAssociation(sourceAddress, destinationAddress);
|
||||
|
||||
if (existingAssociation == null) {
|
||||
VTMatchSet impliedMatchSet = session.getImpliedMatchSet();
|
||||
VTMatch match = impliedMatchSet.addMatch(impliedMatch);
|
||||
existingAssociation = match.getAssociation();
|
||||
}
|
||||
if (existingAssociation != null) {
|
||||
existingAssociation.setVoteCount(existingAssociation.getVoteCount() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a {@link VTAssociation} is cleared. This method will create implied matches in
|
||||
* the current session based on the association.
|
||||
* @param sourceFunction The matched function from the source program
|
||||
* @param destinationFunction The matched function from the destination program
|
||||
* @param session The Version Tracking session
|
||||
* @param correlatorManager Keeps track of which section of the source function corresponds to
|
||||
* the which section of the destination function
|
||||
* @param monitor Handles user cancellations
|
||||
* @throws CancelledException if cancelled
|
||||
*/
|
||||
public static void updateImpliedMatchForClearedAssocation(Function sourceFunction,
|
||||
Function destinationFunction, VTSession session,
|
||||
AddressCorrelatorManager correlatorManager, TaskMonitor monitor)
|
||||
throws CancelledException {
|
||||
|
||||
Set<VTImpliedMatchInfo> impliedMatches = ImpliedMatchUtils.findImpliedMatches(
|
||||
sourceFunction, destinationFunction, session, correlatorManager, monitor);
|
||||
|
||||
for (VTImpliedMatchInfo impliedMatch : impliedMatches) {
|
||||
Address sourceAddress = impliedMatch.getSourceAddress();
|
||||
Address destinationAddress = impliedMatch.getDestinationAddress();
|
||||
VTAssociation existingAssociation =
|
||||
session.getAssociationManager().getAssociation(sourceAddress, destinationAddress);
|
||||
|
||||
if (existingAssociation != null) {
|
||||
int newVoteCount = Math.max(0, existingAssociation.getVoteCount() - 1);
|
||||
existingAssociation.setVoteCount(newVoteCount);
|
||||
if (newVoteCount == 0) {
|
||||
removeImpliedMatch(existingAssociation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void removeImpliedMatch(VTAssociation existingAssociation) {
|
||||
VTSession session = existingAssociation.getSession();
|
||||
List<VTMatch> matches = session.getMatches(existingAssociation);
|
||||
VTMatchSet impliedMatchSet = session.getImpliedMatchSet();
|
||||
for (VTMatch vtMatch : matches) {
|
||||
if (vtMatch.getMatchSet() == impliedMatchSet) {
|
||||
impliedMatchSet.removeMatch(vtMatch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method for finding version tracking implied matches given an accepted matched
|
||||
* function. Each referenced data and function that exist in equivalent sections
|
||||
* of the matched source and destination functions will added to the current
|
||||
* version tracking session as an implied match.
|
||||
*
|
||||
* @param controller Version Tracking controller for the current VT tool
|
||||
* @param sourceFunction The matched function from the source program
|
||||
* @param destinationFunction The matched function from the destination program
|
||||
* @param session The Version Tracking session
|
||||
* @param correlationManager Keeps track of which section of the source function corresponds to
|
||||
* @param correlatorManager Keeps track of which section of the source function corresponds to
|
||||
* the which section of the destination function
|
||||
* @param monitor Handles user cancellations
|
||||
* @return a set of VTImpliedMatchInfo objects
|
||||
* @throws CancelledException if cancelled
|
||||
*/
|
||||
public static Set<VTImpliedMatchInfo> findImpliedMatches(VTController controller,
|
||||
Function sourceFunction, Function destinationFunction, VTSession session,
|
||||
public static Set<VTImpliedMatchInfo> findImpliedMatches(Function sourceFunction,
|
||||
Function destinationFunction, VTSession session,
|
||||
AddressCorrelatorManager correlatorManager, TaskMonitor monitor)
|
||||
throws CancelledException {
|
||||
Set<VTImpliedMatchInfo> set = new HashSet<>();
|
||||
|
@ -141,8 +223,9 @@ public class ImpliedMatchUtils {
|
|||
|
||||
if (refType.isData()) {
|
||||
type = DATA;
|
||||
if (sourceFunction.getProgram().getListing().getInstructionAt(
|
||||
srcRefToAddress) != null) {
|
||||
if (sourceFunction.getProgram()
|
||||
.getListing()
|
||||
.getInstructionAt(srcRefToAddress) != null) {
|
||||
if (refType != RefType.DATA) {
|
||||
return null; // read/write reference to instruction - not sure what this is
|
||||
}
|
||||
|
@ -155,8 +238,9 @@ public class ImpliedMatchUtils {
|
|||
}
|
||||
|
||||
if (type == FUNCTION) {
|
||||
if (sourceFunction.getProgram().getFunctionManager().getFunctionAt(
|
||||
srcRefToAddress) == null) {
|
||||
if (sourceFunction.getProgram()
|
||||
.getFunctionManager()
|
||||
.getFunctionAt(srcRefToAddress) == null) {
|
||||
return null; // function may not have been created here.
|
||||
}
|
||||
}
|
||||
|
@ -175,7 +259,7 @@ public class ImpliedMatchUtils {
|
|||
/**
|
||||
* This method checks to see if the given reference is a thunk function and if so returns
|
||||
* the address of the thunked function instead of thunk function
|
||||
* @param program
|
||||
* @param program the program
|
||||
* @param refToAddress The address of the interesting reference
|
||||
* @return Returns either the same address passed in or the address of the thunked function if
|
||||
* the original address refers to a thunk
|
||||
|
@ -196,7 +280,8 @@ public class ImpliedMatchUtils {
|
|||
}
|
||||
|
||||
/**
|
||||
* Updates the length values for the source and dest functions or data in the VTMatchInfo object
|
||||
* Updates the length values for the source and destination functions or data in the
|
||||
* VTMatchInfo object
|
||||
*/
|
||||
private static void updateVTSourceAndDestinationLengths(VTMatchInfo matchInfo) {
|
||||
VTSession session = matchInfo.getMatchSet().getSession();
|
||||
|
|
|
@ -15,17 +15,17 @@
|
|||
*/
|
||||
package ghidra.feature.vt.gui.util;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import ghidra.feature.vt.api.main.*;
|
||||
import ghidra.feature.vt.api.markuptype.*;
|
||||
import ghidra.feature.vt.gui.plugin.AddressCorrelatorManager;
|
||||
import ghidra.feature.vt.gui.plugin.VTController;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.listing.*;
|
||||
import ghidra.program.util.*;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
import ghidra.util.task.*;
|
||||
|
||||
import java.util.*;
|
||||
import ghidra.util.task.CachingSwingWorker;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
public class MatchInfo {
|
||||
|
||||
|
@ -43,7 +43,7 @@ public class MatchInfo {
|
|||
private boolean initCorrelationCache = true;
|
||||
private final AddressCorrelatorManager correlator;
|
||||
|
||||
MatchInfo(VTController controller, VTMatch match, AddressCorrelatorManager correlator) {
|
||||
MatchInfo(VTMatch match, AddressCorrelatorManager correlator) {
|
||||
this.match = match;
|
||||
this.correlator = correlator;
|
||||
VTAssociation association = match.getAssociation();
|
||||
|
@ -54,9 +54,9 @@ public class MatchInfo {
|
|||
VTAssociationType type = association.getType();
|
||||
|
||||
Address sourceAddress = association.getSourceAddress();
|
||||
sourceFunction =
|
||||
(sourceProgram != null) ? sourceProgram.getFunctionManager().getFunctionAt(
|
||||
sourceAddress) : null;
|
||||
sourceFunction = (sourceProgram != null)
|
||||
? sourceProgram.getFunctionManager().getFunctionAt(sourceAddress)
|
||||
: null;
|
||||
if (type == VTAssociationType.FUNCTION && sourceFunction != null) {
|
||||
sourceData = null;
|
||||
sourceAddressSet = sourceFunction.getBody();
|
||||
|
@ -75,9 +75,9 @@ public class MatchInfo {
|
|||
}
|
||||
|
||||
Address destinationAddress = association.getDestinationAddress();
|
||||
destinationFunction =
|
||||
(destinationProgram != null) ? destinationProgram.getFunctionManager().getFunctionAt(
|
||||
destinationAddress) : null;
|
||||
destinationFunction = (destinationProgram != null)
|
||||
? destinationProgram.getFunctionManager().getFunctionAt(destinationAddress)
|
||||
: null;
|
||||
if (type == VTAssociationType.FUNCTION && destinationFunction != null) {
|
||||
destinationData = null;
|
||||
destinationAddressSet = destinationFunction.getBody();
|
||||
|
@ -211,8 +211,7 @@ public class MatchInfo {
|
|||
AddressRange correlatedDestinationRange = null;
|
||||
try {
|
||||
correlatedDestinationRange =
|
||||
addressTranslator.getCorrelatedDestinationRange(sourceAddress,
|
||||
TaskMonitor.DUMMY);
|
||||
addressTranslator.getCorrelatedDestinationRange(sourceAddress, TaskMonitor.DUMMY);
|
||||
}
|
||||
catch (CancelledException e) {
|
||||
// check for null below
|
||||
|
@ -223,7 +222,8 @@ public class MatchInfo {
|
|||
return correlatedDestinationRange.getMinAddress();
|
||||
}
|
||||
|
||||
public VTMarkupItem getCurrentMarkupForLocation(ProgramLocation programLocation, Program program) {
|
||||
public VTMarkupItem getCurrentMarkupForLocation(ProgramLocation programLocation,
|
||||
Program program) {
|
||||
|
||||
VTMarkupType markupType = getMarkupTypeForLocation(programLocation, program);
|
||||
if (markupType == null) {
|
||||
|
@ -248,15 +248,13 @@ public class MatchInfo {
|
|||
}
|
||||
|
||||
for (VTMarkupItem markupItem : list) {
|
||||
ProgramLocation location =
|
||||
isSourceAddress ? markupItem.getSourceLocation()
|
||||
ProgramLocation location = isSourceAddress ? markupItem.getSourceLocation()
|
||||
: markupItem.getDestinationLocation();
|
||||
if (location == null) {
|
||||
continue;
|
||||
}
|
||||
Address markupItemAddress =
|
||||
MatchInfo.getMarkupAddressForLocation(location, (isSourceAddress ? sourceProgram
|
||||
: destinationProgram));
|
||||
Address markupItemAddress = MatchInfo.getMarkupAddressForLocation(location,
|
||||
(isSourceAddress ? sourceProgram : destinationProgram));
|
||||
if (address.equals(markupItemAddress) && (markupItem.getMarkupType() == markupType)) {
|
||||
return markupItem;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ import java.util.Set;
|
|||
import ghidra.feature.vt.api.main.VTAssociation;
|
||||
import ghidra.feature.vt.api.main.VTMatch;
|
||||
import ghidra.feature.vt.gui.plugin.AddressCorrelatorManager;
|
||||
import ghidra.feature.vt.gui.plugin.VTController;
|
||||
import ghidra.util.datastruct.WeakValueHashMap;
|
||||
|
||||
public class MatchInfoFactory {
|
||||
|
@ -32,11 +31,10 @@ public class MatchInfoFactory {
|
|||
*/
|
||||
private WeakValueHashMap<VTMatch, MatchInfo> weakMap = new WeakValueHashMap<>();
|
||||
|
||||
public synchronized MatchInfo getMatchInfo(VTController controller, VTMatch match,
|
||||
AddressCorrelatorManager correlator) {
|
||||
public synchronized MatchInfo getMatchInfo(VTMatch match, AddressCorrelatorManager correlator) {
|
||||
MatchInfo matchInfo = weakMap.get(match);
|
||||
if (matchInfo == null) {
|
||||
matchInfo = new MatchInfo(controller, match, correlator);
|
||||
matchInfo = new MatchInfo(match, correlator);
|
||||
weakMap.put(match, matchInfo);
|
||||
}
|
||||
return matchInfo;
|
||||
|
@ -57,6 +55,7 @@ public class MatchInfoFactory {
|
|||
/**
|
||||
* Clear the cached match info for the given association. This will clear the cache for
|
||||
* multiple matches, if multiple matches exit for the given association.
|
||||
* @param association the association
|
||||
*/
|
||||
public synchronized void clearCacheForAssociation(VTAssociation association) {
|
||||
Set<Entry<VTMatch, MatchInfo>> entrySet = weakMap.entrySet();
|
||||
|
|
|
@ -24,7 +24,6 @@ import ghidra.feature.vt.api.util.VTOptions;
|
|||
import ghidra.feature.vt.gui.plugin.VTController;
|
||||
import ghidra.feature.vt.gui.wizard.ChooseAddressSetEditorPanel.AddressSetChoice;
|
||||
import ghidra.framework.data.DomainObjectAdapterDB;
|
||||
import ghidra.framework.plugintool.ServiceProvider;
|
||||
import ghidra.program.model.address.AddressSet;
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.program.model.listing.Program;
|
||||
|
@ -101,8 +100,6 @@ public class AddToSessionTask extends Task {
|
|||
destinationAddressSet = excludeAcceptedMatches(destinationAddressSet, false);
|
||||
}
|
||||
|
||||
ServiceProvider serviceProvider = controller.getTool();
|
||||
|
||||
int transactionID = startTransaction(session);
|
||||
boolean completedSucessfully = false;
|
||||
try {
|
||||
|
@ -113,8 +110,8 @@ public class AddToSessionTask extends Task {
|
|||
for (int i = 0; i < correlatorFactories.size(); i++) {
|
||||
VTProgramCorrelatorFactory factory = correlatorFactories.get(i);
|
||||
VTProgramCorrelator correlator =
|
||||
factory.createCorrelator(serviceProvider, sourceProgram, sourceAddressSet,
|
||||
destinationProgram, destinationAddressSet, correlatorOptions.get(i));
|
||||
factory.createCorrelator(sourceProgram, sourceAddressSet, destinationProgram,
|
||||
destinationAddressSet, correlatorOptions.get(i));
|
||||
|
||||
VTMatchSet resultSet = correlator.correlate(session, monitor);
|
||||
if (resultSet.getMatchCount() == 0) {
|
||||
|
@ -134,13 +131,15 @@ public class AddToSessionTask extends Task {
|
|||
}
|
||||
catch (CancelledException e) {
|
||||
Throwable cause = e.getCause(); // CancelledException may hide more serious error
|
||||
if (cause == null)
|
||||
if (cause == null) {
|
||||
Msg.showWarn(this, null, "Add to Session Cancelled",
|
||||
"Correlation canceled by user.");
|
||||
else
|
||||
}
|
||||
else {
|
||||
Msg.showError(this, null, "Add to Session Cancelled - Unexpected Exception",
|
||||
"Correlation cancelled due to exception: " + cause.getMessage(), e);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
Msg.showError(this, null, "Add to Session Cancelled - Unexpected Exception",
|
||||
"Correlation cancelled due to exception: " + e.getMessage(), e);
|
||||
|
|
|
@ -781,7 +781,7 @@ public class VTAutoVersionTrackingTest extends AbstractGhidraHeadedIntegrationTe
|
|||
private VTMatch createMatch(Address sourceAddress, Address destinationAddress,
|
||||
boolean setAccepted) throws VTAssociationStatusException {
|
||||
VTProgramCorrelator correlator =
|
||||
VTTestUtils.createProgramCorrelator(null, sourceProgram, destinationProgram);
|
||||
VTTestUtils.createProgramCorrelator(sourceProgram, destinationProgram);
|
||||
|
||||
String transactionName = "Blocked Test";
|
||||
int startTransaction = session.startTransaction(transactionName);
|
||||
|
@ -826,7 +826,7 @@ public class VTAutoVersionTrackingTest extends AbstractGhidraHeadedIntegrationTe
|
|||
private void runAutoVTCommand(double minReferenceCorrelatorScore,
|
||||
double minReferenceCorrelatorConfidence) {
|
||||
|
||||
AutoVersionTrackingTask task = new AutoVersionTrackingTask(controller, session,
|
||||
AutoVersionTrackingTask task = new AutoVersionTrackingTask(session, controller.getOptions(),
|
||||
minReferenceCorrelatorScore, minReferenceCorrelatorConfidence);
|
||||
TaskLauncher.launch(task);
|
||||
waitForSession();
|
||||
|
|
|
@ -52,7 +52,8 @@ import ghidra.program.model.util.CodeUnitInsertionException;
|
|||
import ghidra.test.*;
|
||||
import ghidra.util.SystemUtilities;
|
||||
import ghidra.util.exception.*;
|
||||
import ghidra.util.task.*;
|
||||
import ghidra.util.task.Task;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
public class VTMatchApplyTest extends AbstractGhidraHeadedIntegrationTest {
|
||||
|
||||
|
@ -540,8 +541,8 @@ public class VTMatchApplyTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
VTMatch match = createMatchSetWithOneDataMatch(session, sourceAddress, destinationAddress);
|
||||
|
||||
// data type choices
|
||||
controller.getOptions().setEnum(VTOptionDefines.DATA_MATCH_DATA_TYPE,
|
||||
ReplaceDataChoices.EXCLUDE);
|
||||
controller.getOptions()
|
||||
.setEnum(VTOptionDefines.DATA_MATCH_DATA_TYPE, ReplaceDataChoices.EXCLUDE);
|
||||
|
||||
List<VTMatch> matches = new ArrayList<>();
|
||||
matches.add(match);
|
||||
|
@ -573,7 +574,8 @@ public class VTMatchApplyTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
VTMatch match = createMatchSetWithOneDataMatch(session, sourceAddress, destinationAddress);
|
||||
|
||||
// data type choice
|
||||
controller.getOptions().setEnum(VTOptionDefines.DATA_MATCH_DATA_TYPE,
|
||||
controller.getOptions()
|
||||
.setEnum(VTOptionDefines.DATA_MATCH_DATA_TYPE,
|
||||
ReplaceDataChoices.REPLACE_UNDEFINED_DATA_ONLY);
|
||||
|
||||
List<VTMatch> matches = new ArrayList<>();
|
||||
|
@ -602,7 +604,8 @@ public class VTMatchApplyTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
VTMatch match = createMatchSetWithOneDataMatch(session, sourceAddress, destinationAddress);
|
||||
|
||||
// data type choice
|
||||
controller.getOptions().setEnum(VTOptionDefines.DATA_MATCH_DATA_TYPE,
|
||||
controller.getOptions()
|
||||
.setEnum(VTOptionDefines.DATA_MATCH_DATA_TYPE,
|
||||
ReplaceDataChoices.REPLACE_UNDEFINED_DATA_ONLY);
|
||||
|
||||
List<VTMatch> matches = new ArrayList<>();
|
||||
|
@ -644,7 +647,8 @@ public class VTMatchApplyTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
VTMatch match = createMatchSetWithOneDataMatch(session, sourceAddress, destinationAddress);
|
||||
|
||||
// data type choice
|
||||
controller.getOptions().setEnum(VTOptionDefines.DATA_MATCH_DATA_TYPE,
|
||||
controller.getOptions()
|
||||
.setEnum(VTOptionDefines.DATA_MATCH_DATA_TYPE,
|
||||
ReplaceDataChoices.REPLACE_FIRST_DATA_ONLY);
|
||||
|
||||
List<VTMatch> matches = new ArrayList<>();
|
||||
|
@ -675,7 +679,8 @@ public class VTMatchApplyTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
VTMatch match = createMatchSetWithOneDataMatch(session, sourceAddress, destinationAddress);
|
||||
|
||||
// data type choice
|
||||
controller.getOptions().setEnum(VTOptionDefines.DATA_MATCH_DATA_TYPE,
|
||||
controller.getOptions()
|
||||
.setEnum(VTOptionDefines.DATA_MATCH_DATA_TYPE,
|
||||
ReplaceDataChoices.REPLACE_FIRST_DATA_ONLY);
|
||||
|
||||
List<VTMatch> matches = new ArrayList<>();
|
||||
|
@ -716,8 +721,8 @@ public class VTMatchApplyTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
VTMatch match = createMatchSetWithOneDataMatch(session, sourceAddress, destinationAddress);
|
||||
|
||||
// data type choice
|
||||
controller.getOptions().setEnum(VTOptionDefines.DATA_MATCH_DATA_TYPE,
|
||||
ReplaceDataChoices.REPLACE_ALL_DATA);
|
||||
controller.getOptions()
|
||||
.setEnum(VTOptionDefines.DATA_MATCH_DATA_TYPE, ReplaceDataChoices.REPLACE_ALL_DATA);
|
||||
|
||||
List<VTMatch> matches = new ArrayList<>();
|
||||
matches.add(match);
|
||||
|
@ -761,8 +766,8 @@ public class VTMatchApplyTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
VTMatch match = createMatchSetWithOneDataMatch(session, sourceAddress, destinationAddress);
|
||||
|
||||
// data type choice
|
||||
controller.getOptions().setEnum(VTOptionDefines.DATA_MATCH_DATA_TYPE,
|
||||
ReplaceDataChoices.REPLACE_ALL_DATA);
|
||||
controller.getOptions()
|
||||
.setEnum(VTOptionDefines.DATA_MATCH_DATA_TYPE, ReplaceDataChoices.REPLACE_ALL_DATA);
|
||||
|
||||
List<VTMatch> matches = new ArrayList<>();
|
||||
matches.add(match);
|
||||
|
@ -830,8 +835,8 @@ public class VTMatchApplyTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
assertEquals("FUN_01003f9e", destinationFunction.getName());
|
||||
|
||||
// function name choices
|
||||
controller.getOptions().setEnum(VTOptionDefines.FUNCTION_NAME,
|
||||
FunctionNameChoices.REPLACE_DEFAULT_ONLY);
|
||||
controller.getOptions()
|
||||
.setEnum(VTOptionDefines.FUNCTION_NAME, FunctionNameChoices.REPLACE_DEFAULT_ONLY);
|
||||
|
||||
List<VTMatch> matches = new ArrayList<>();
|
||||
matches.add(match);
|
||||
|
@ -868,8 +873,8 @@ public class VTMatchApplyTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
assertEquals("Bar", destinationFunction.getName());
|
||||
|
||||
// function name choices
|
||||
controller.getOptions().setEnum(VTOptionDefines.FUNCTION_NAME,
|
||||
FunctionNameChoices.REPLACE_DEFAULT_ONLY);
|
||||
controller.getOptions()
|
||||
.setEnum(VTOptionDefines.FUNCTION_NAME, FunctionNameChoices.REPLACE_DEFAULT_ONLY);
|
||||
|
||||
List<VTMatch> matches = new ArrayList<>();
|
||||
matches.add(match);
|
||||
|
@ -897,8 +902,8 @@ public class VTMatchApplyTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
assertEquals("FUN_01003f9e", destinationFunction.getName());
|
||||
|
||||
// function name choices
|
||||
controller.getOptions().setEnum(VTOptionDefines.FUNCTION_NAME,
|
||||
FunctionNameChoices.REPLACE_ALWAYS);
|
||||
controller.getOptions()
|
||||
.setEnum(VTOptionDefines.FUNCTION_NAME, FunctionNameChoices.REPLACE_ALWAYS);
|
||||
|
||||
List<VTMatch> matches = new ArrayList<>();
|
||||
matches.add(match);
|
||||
|
@ -935,8 +940,8 @@ public class VTMatchApplyTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
assertEquals("Bar", destinationFunction.getName());
|
||||
|
||||
// function name choices
|
||||
controller.getOptions().setEnum(VTOptionDefines.FUNCTION_NAME,
|
||||
FunctionNameChoices.REPLACE_ALWAYS);
|
||||
controller.getOptions()
|
||||
.setEnum(VTOptionDefines.FUNCTION_NAME, FunctionNameChoices.REPLACE_ALWAYS);
|
||||
|
||||
List<VTMatch> matches = new ArrayList<>();
|
||||
matches.add(match);
|
||||
|
@ -1063,8 +1068,7 @@ public class VTMatchApplyTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
setComment(destinationProgram, commentAddress, CodeUnit.EOL_COMMENT, destinationComment);
|
||||
|
||||
MatchInfo matchInfo = controller.getMatchInfo(match);
|
||||
Collection<VTMarkupItem> markupItems =
|
||||
matchInfo.getAppliableMarkupItems(TaskMonitor.DUMMY);
|
||||
Collection<VTMarkupItem> markupItems = matchInfo.getAppliableMarkupItems(TaskMonitor.DUMMY);
|
||||
|
||||
List<VTMarkupItem> itemsToApply = new ArrayList<>();
|
||||
for (VTMarkupItem item : markupItems) {
|
||||
|
@ -1142,8 +1146,8 @@ public class VTMatchApplyTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
checkReturnType(dWordDataType, destinationFunction);
|
||||
|
||||
// function name choices
|
||||
controller.getOptions().setEnum(VTOptionDefines.FUNCTION_SIGNATURE,
|
||||
FunctionSignatureChoices.EXCLUDE);
|
||||
controller.getOptions()
|
||||
.setEnum(VTOptionDefines.FUNCTION_SIGNATURE, FunctionSignatureChoices.EXCLUDE);
|
||||
|
||||
List<VTMatch> matches = new ArrayList<>();
|
||||
matches.add(match);
|
||||
|
@ -1173,10 +1177,10 @@ public class VTMatchApplyTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
checkReturnType(dWordDataType, destinationFunction);
|
||||
|
||||
// function name choices
|
||||
controller.getOptions().setEnum(VTOptionDefines.FUNCTION_SIGNATURE,
|
||||
FunctionSignatureChoices.REPLACE);
|
||||
controller.getOptions().setEnum(VTOptionDefines.FUNCTION_RETURN_TYPE,
|
||||
ParameterDataTypeChoices.REPLACE);
|
||||
controller.getOptions()
|
||||
.setEnum(VTOptionDefines.FUNCTION_SIGNATURE, FunctionSignatureChoices.REPLACE);
|
||||
controller.getOptions()
|
||||
.setEnum(VTOptionDefines.FUNCTION_RETURN_TYPE, ParameterDataTypeChoices.REPLACE);
|
||||
|
||||
List<VTMatch> matches = new ArrayList<>();
|
||||
matches.add(match);
|
||||
|
@ -1211,10 +1215,10 @@ public class VTMatchApplyTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
setupParameters(sourceFunction, destinationFunction);
|
||||
|
||||
// function name choices
|
||||
controller.getOptions().setEnum(VTOptionDefines.FUNCTION_SIGNATURE,
|
||||
FunctionSignatureChoices.EXCLUDE);
|
||||
controller.getOptions().setEnum(VTOptionDefines.PARAMETER_NAMES,
|
||||
SourcePriorityChoices.EXCLUDE);
|
||||
controller.getOptions()
|
||||
.setEnum(VTOptionDefines.FUNCTION_SIGNATURE, FunctionSignatureChoices.EXCLUDE);
|
||||
controller.getOptions()
|
||||
.setEnum(VTOptionDefines.PARAMETER_NAMES, SourcePriorityChoices.EXCLUDE);
|
||||
controller.getOptions().setEnum(VTOptionDefines.PARAMETER_COMMENTS, CommentChoices.EXCLUDE);
|
||||
|
||||
List<VTMatch> matches = new ArrayList<>();
|
||||
|
@ -1266,14 +1270,14 @@ public class VTMatchApplyTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
setupParameters(sourceFunction, destinationFunction);
|
||||
|
||||
// function name choices
|
||||
controller.getOptions().setEnum(VTOptionDefines.FUNCTION_SIGNATURE,
|
||||
FunctionSignatureChoices.REPLACE);
|
||||
controller.getOptions().setEnum(VTOptionDefines.FUNCTION_RETURN_TYPE,
|
||||
ParameterDataTypeChoices.REPLACE);
|
||||
controller.getOptions().setEnum(VTOptionDefines.PARAMETER_DATA_TYPES,
|
||||
ParameterDataTypeChoices.REPLACE);
|
||||
controller.getOptions().setEnum(VTOptionDefines.PARAMETER_NAMES,
|
||||
SourcePriorityChoices.EXCLUDE);
|
||||
controller.getOptions()
|
||||
.setEnum(VTOptionDefines.FUNCTION_SIGNATURE, FunctionSignatureChoices.REPLACE);
|
||||
controller.getOptions()
|
||||
.setEnum(VTOptionDefines.FUNCTION_RETURN_TYPE, ParameterDataTypeChoices.REPLACE);
|
||||
controller.getOptions()
|
||||
.setEnum(VTOptionDefines.PARAMETER_DATA_TYPES, ParameterDataTypeChoices.REPLACE);
|
||||
controller.getOptions()
|
||||
.setEnum(VTOptionDefines.PARAMETER_NAMES, SourcePriorityChoices.EXCLUDE);
|
||||
controller.getOptions().setEnum(VTOptionDefines.PARAMETER_COMMENTS, CommentChoices.EXCLUDE);
|
||||
|
||||
List<VTMatch> matches = new ArrayList<>();
|
||||
|
@ -2102,7 +2106,7 @@ public class VTMatchApplyTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
try {
|
||||
testTransactionID = db.startTransaction("Test Match Set Setup");
|
||||
VTMatchSet matchSet = db.createMatchSet(
|
||||
createProgramCorrelator(null, db.getSourceProgram(), db.getDestinationProgram()));
|
||||
createProgramCorrelator(db.getSourceProgram(), db.getDestinationProgram()));
|
||||
for (AssociationPair associationPair : list) {
|
||||
VTMatchInfo info = createRandomMatch(associationPair.getSourceAddress(),
|
||||
associationPair.getDestinationAddress(), db);
|
||||
|
|
|
@ -253,7 +253,7 @@ public abstract class AbstractVTCorrelatorTest extends AbstractGhidraHeadedInteg
|
|||
try {
|
||||
testTransactionID = db.startTransaction("Test Match Set Setup");
|
||||
VTMatchSet matchSet = db.createMatchSet(
|
||||
createProgramCorrelator(null, db.getSourceProgram(), db.getDestinationProgram()));
|
||||
createProgramCorrelator(db.getSourceProgram(), db.getDestinationProgram()));
|
||||
for (VTAssociationPair associationPair : list) {
|
||||
VTMatchInfo info = createRandomMatch(associationPair.getSource(),
|
||||
associationPair.getDestination(), db);
|
||||
|
|
|
@ -201,20 +201,34 @@ public class VTImpliedMatchCorrelatorTest extends AbstractVTCorrelatorTest {
|
|||
|
||||
VTAssociationManager associationManager = session.getAssociationManager();
|
||||
|
||||
assertEquals(1, associationManager.getAssociation(addr(srcProg, "0x00411860"),
|
||||
addr(destProg, "0x00411830")).getVoteCount()); // addPerson
|
||||
assertEquals(1, associationManager.getAssociation(addr(srcProg, "0x004168a0"),
|
||||
addr(destProg, "0x004168a0")).getVoteCount()); // s_Lord_Victor_Quartermaine
|
||||
assertEquals(1, associationManager.getAssociation(addr(srcProg, "0x0041688c"),
|
||||
addr(destProg, "0x00041688c")).getVoteCount()); // s_Lady_Tottington
|
||||
assertEquals(1, associationManager.getAssociation(addr(srcProg, "0x004168a0"),
|
||||
addr(destProg, "0x004168a0")).getVoteCount()); // s_Were_Rabbit
|
||||
assertEquals(1, associationManager.getAssociation(addr(srcProg, "0x0041687c"),
|
||||
addr(destProg, "0x0041687c")).getVoteCount()); // s_Rabbit
|
||||
assertEquals(1, associationManager.getAssociation(addr(srcProg, "0x00416874"),
|
||||
addr(destProg, "0x00416874")).getVoteCount()); // s_Wallace
|
||||
assertEquals(1, associationManager.getAssociation(addr(srcProg, "0x00411b80"),
|
||||
addr(destProg, "0x00411b60")).getVoteCount()); // __RTC_CheckEsp
|
||||
assertEquals(1,
|
||||
associationManager
|
||||
.getAssociation(addr(srcProg, "0x00411860"), addr(destProg, "0x00411830"))
|
||||
.getVoteCount()); // addPerson
|
||||
assertEquals(1,
|
||||
associationManager
|
||||
.getAssociation(addr(srcProg, "0x004168a0"), addr(destProg, "0x004168a0"))
|
||||
.getVoteCount()); // s_Lord_Victor_Quartermaine
|
||||
assertEquals(1,
|
||||
associationManager
|
||||
.getAssociation(addr(srcProg, "0x0041688c"), addr(destProg, "0x00041688c"))
|
||||
.getVoteCount()); // s_Lady_Tottington
|
||||
assertEquals(1,
|
||||
associationManager
|
||||
.getAssociation(addr(srcProg, "0x004168a0"), addr(destProg, "0x004168a0"))
|
||||
.getVoteCount()); // s_Were_Rabbit
|
||||
assertEquals(1,
|
||||
associationManager
|
||||
.getAssociation(addr(srcProg, "0x0041687c"), addr(destProg, "0x0041687c"))
|
||||
.getVoteCount()); // s_Rabbit
|
||||
assertEquals(1,
|
||||
associationManager
|
||||
.getAssociation(addr(srcProg, "0x00416874"), addr(destProg, "0x00416874"))
|
||||
.getVoteCount()); // s_Wallace
|
||||
assertEquals(1,
|
||||
associationManager
|
||||
.getAssociation(addr(srcProg, "0x00411b80"), addr(destProg, "0x00411b60"))
|
||||
.getVoteCount()); // __RTC_CheckEsp
|
||||
|
||||
}
|
||||
|
||||
|
@ -222,7 +236,7 @@ public class VTImpliedMatchCorrelatorTest extends AbstractVTCorrelatorTest {
|
|||
Program sourceProgram, Program destinationProgram, boolean setAccepted)
|
||||
throws VTAssociationStatusException {
|
||||
VTProgramCorrelator correlator =
|
||||
VTTestUtils.createProgramCorrelator(null, sourceProgram, destinationProgram);
|
||||
VTTestUtils.createProgramCorrelator(sourceProgram, destinationProgram);
|
||||
|
||||
String transactionName = "Blocked Test";
|
||||
int startTransaction = session.startTransaction(transactionName);
|
||||
|
@ -237,10 +251,14 @@ public class VTImpliedMatchCorrelatorTest extends AbstractVTCorrelatorTest {
|
|||
info.setConfidenceScore(confidence);
|
||||
VTScore score = new VTScore(1.0);
|
||||
info.setSimilarityScore(score);
|
||||
long sourceLen = sourceProgram.getFunctionManager().getFunctionAt(
|
||||
sourceAddress).getBody().getNumAddresses();
|
||||
long destLen = destinationProgram.getFunctionManager().getFunctionAt(
|
||||
destinationAddress).getBody().getNumAddresses();
|
||||
long sourceLen = sourceProgram.getFunctionManager()
|
||||
.getFunctionAt(sourceAddress)
|
||||
.getBody()
|
||||
.getNumAddresses();
|
||||
long destLen = destinationProgram.getFunctionManager()
|
||||
.getFunctionAt(destinationAddress)
|
||||
.getBody()
|
||||
.getNumAddresses();
|
||||
info.setSourceLength((int) sourceLen);
|
||||
info.setDestinationLength((int) destLen);
|
||||
matchSet.addMatch(info);
|
||||
|
|
|
@ -24,7 +24,6 @@ import ghidra.feature.vt.api.correlator.program.ExactMatchBytesProgramCorrelator
|
|||
import ghidra.feature.vt.api.db.VTSessionDB;
|
||||
import ghidra.feature.vt.api.main.*;
|
||||
import ghidra.feature.vt.api.util.VTOptions;
|
||||
import ghidra.framework.plugintool.PluginTool;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.program.model.listing.*;
|
||||
|
@ -41,7 +40,6 @@ public abstract class AbstractCorrelatorTest extends AbstractGhidraHeadedIntegra
|
|||
protected ArrayList<String> errors;
|
||||
|
||||
public AbstractCorrelatorTest() {
|
||||
super();
|
||||
}
|
||||
|
||||
protected abstract Program getSourceProgram();
|
||||
|
@ -87,7 +85,6 @@ public abstract class AbstractCorrelatorTest extends AbstractGhidraHeadedIntegra
|
|||
try {
|
||||
int sessionTransaction = session.startTransaction(name);
|
||||
try {
|
||||
PluginTool serviceProvider = env.getTool();
|
||||
VTAssociationManager manager = session.getAssociationManager();
|
||||
|
||||
AddressSetView sourceAddressSet =
|
||||
|
@ -98,8 +95,8 @@ public abstract class AbstractCorrelatorTest extends AbstractGhidraHeadedIntegra
|
|||
VTOptions options;
|
||||
VTProgramCorrelator correlator;
|
||||
options = factory.createDefaultOptions();
|
||||
correlator = factory.createCorrelator(serviceProvider, sourceProgram,
|
||||
sourceAddressSet, destinationProgram, destinationAddressSet, options);
|
||||
correlator = factory.createCorrelator(sourceProgram, sourceAddressSet,
|
||||
destinationProgram, destinationAddressSet, options);
|
||||
correlator.correlate(session, TaskMonitor.DUMMY);
|
||||
|
||||
FunctionManager functionManager = sourceProgram.getFunctionManager();
|
||||
|
@ -154,7 +151,6 @@ public abstract class AbstractCorrelatorTest extends AbstractGhidraHeadedIntegra
|
|||
try {
|
||||
int sessionTransaction = session.startTransaction(name);
|
||||
try {
|
||||
PluginTool serviceProvider = env.getTool();
|
||||
VTAssociationManager manager = session.getAssociationManager();
|
||||
|
||||
AddressSetView sourceAddressSet =
|
||||
|
@ -165,8 +161,8 @@ public abstract class AbstractCorrelatorTest extends AbstractGhidraHeadedIntegra
|
|||
VTOptions options;
|
||||
VTProgramCorrelator correlator;
|
||||
options = factory.createDefaultOptions();
|
||||
correlator = factory.createCorrelator(serviceProvider, sourceProgram,
|
||||
sourceAddressSet, destinationProgram, destinationAddressSet, options);
|
||||
correlator = factory.createCorrelator(sourceProgram, sourceAddressSet,
|
||||
destinationProgram, destinationAddressSet, options);
|
||||
correlator.correlate(session, TaskMonitor.DUMMY);
|
||||
|
||||
HashMap<Address, Address> mapCopy = new HashMap<>(map);
|
||||
|
|
|
@ -17,8 +17,7 @@ package ghidra.feature.vt.api.markupitem;
|
|||
|
||||
import static ghidra.feature.vt.db.VTTestUtils.*;
|
||||
import static ghidra.feature.vt.gui.util.VTOptionDefines.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -37,7 +36,6 @@ import ghidra.program.model.address.Address;
|
|||
import ghidra.program.model.address.AddressSet;
|
||||
import ghidra.test.*;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
import ghidra.util.task.TaskMonitorAdapter;
|
||||
|
||||
public abstract class AbstractVTMarkupItemTest extends AbstractGhidraHeadedIntegrationTest {
|
||||
|
||||
|
@ -361,7 +359,7 @@ public abstract class AbstractVTMarkupItemTest extends AbstractGhidraHeadedInteg
|
|||
testTransactionID = db.startTransaction("Test Match Set Setup");
|
||||
VTMatchInfo matchInfo = createRandomMatch(sourceAddress, destinationAddress, db);
|
||||
VTMatchSet matchSet = db.createMatchSet(
|
||||
createProgramCorrelator(null, db.getSourceProgram(), db.getDestinationProgram()));
|
||||
createProgramCorrelator(db.getSourceProgram(), db.getDestinationProgram()));
|
||||
VTMatch addedMatch = matchSet.addMatch(matchInfo);
|
||||
|
||||
// Association markupItemManger expects all markups to be generated though it.
|
||||
|
|
|
@ -55,7 +55,7 @@ public class VTMarkupItemResetTest extends VTBaseTestCase {
|
|||
// destination address is cleared *and not other user-defined values are set*.
|
||||
//
|
||||
VTMatchSet matchSet = db.createMatchSet(
|
||||
createProgramCorrelator(null, db.getSourceProgram(), db.getDestinationProgram()));
|
||||
createProgramCorrelator(db.getSourceProgram(), db.getDestinationProgram()));
|
||||
|
||||
VTMatch match = matchSet.addMatch(createRandomMatch(db));
|
||||
VTMarkupItem markupItem = createRandomMarkupItemStub(match);
|
||||
|
@ -80,7 +80,7 @@ public class VTMarkupItemResetTest extends VTBaseTestCase {
|
|||
// user's considered state is cleared *and not other user-defined values are set*.
|
||||
//
|
||||
VTMatchSet matchSet = db.createMatchSet(
|
||||
createProgramCorrelator(null, db.getSourceProgram(), db.getDestinationProgram()));
|
||||
createProgramCorrelator(db.getSourceProgram(), db.getDestinationProgram()));
|
||||
|
||||
VTMatch match = matchSet.addMatch(createRandomMatch(db));
|
||||
VTMarkupItem markupItem = createRandomMarkupItemStub(match);
|
||||
|
@ -104,7 +104,7 @@ public class VTMarkupItemResetTest extends VTBaseTestCase {
|
|||
// markup item is unapplied *and not other user-defined values are set*.
|
||||
//
|
||||
VTMatchSet matchSet = db.createMatchSet(
|
||||
createProgramCorrelator(null, db.getSourceProgram(), db.getDestinationProgram()));
|
||||
createProgramCorrelator(db.getSourceProgram(), db.getDestinationProgram()));
|
||||
|
||||
VTMatch match = matchSet.addMatch(createRandomMatch(db));
|
||||
VTMarkupItem markupItem = createRandomMarkupItemStub(match);
|
||||
|
@ -146,7 +146,7 @@ public class VTMarkupItemResetTest extends VTBaseTestCase {
|
|||
// is set by the user.
|
||||
//
|
||||
VTMatchSet matchSet = db.createMatchSet(
|
||||
createProgramCorrelator(null, db.getSourceProgram(), db.getDestinationProgram()));
|
||||
createProgramCorrelator(db.getSourceProgram(), db.getDestinationProgram()));
|
||||
|
||||
VTMatch match = matchSet.addMatch(createRandomMatch(db));
|
||||
VTMarkupItem markupItem = createRandomMarkupItemStub(match);
|
||||
|
@ -186,7 +186,7 @@ public class VTMarkupItemResetTest extends VTBaseTestCase {
|
|||
// the the destination address is set by the user.
|
||||
//
|
||||
VTMatchSet matchSet = db.createMatchSet(
|
||||
createProgramCorrelator(null, db.getSourceProgram(), db.getDestinationProgram()));
|
||||
createProgramCorrelator(db.getSourceProgram(), db.getDestinationProgram()));
|
||||
|
||||
VTMatch match = matchSet.addMatch(createRandomMatch(db));
|
||||
VTMarkupItem markupItem = createRandomMarkupItemStub(match);
|
||||
|
@ -216,7 +216,7 @@ public class VTMarkupItemResetTest extends VTBaseTestCase {
|
|||
// cleared, but the considered status was set.
|
||||
//
|
||||
VTMatchSet matchSet = db.createMatchSet(
|
||||
createProgramCorrelator(null, db.getSourceProgram(), db.getDestinationProgram()));
|
||||
createProgramCorrelator(db.getSourceProgram(), db.getDestinationProgram()));
|
||||
|
||||
VTMatch match = matchSet.addMatch(createRandomMatch(db));
|
||||
VTMarkupItem markupItem = createRandomMarkupItemStub(match);
|
||||
|
|
|
@ -20,7 +20,6 @@ import static ghidra.feature.vt.db.VTTestUtils.*;
|
|||
import ghidra.feature.vt.api.main.VTMatchSet;
|
||||
import ghidra.feature.vt.api.util.VTAbstractProgramCorrelator;
|
||||
import ghidra.framework.options.ToolOptions;
|
||||
import ghidra.framework.plugintool.ServiceProvider;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
|
@ -34,21 +33,18 @@ public class DummyTestProgramCorrelator extends VTAbstractProgramCorrelator {
|
|||
this(1);
|
||||
}
|
||||
|
||||
public DummyTestProgramCorrelator(ServiceProvider serviceProvider, Program sourceProgram,
|
||||
AddressSetView sourceAddressSet, Program destinationProgram,
|
||||
AddressSetView destinationAddressSet, ToolOptions options) {
|
||||
super(serviceProvider, sourceProgram, sourceAddressSet, destinationProgram,
|
||||
destinationAddressSet, options);
|
||||
public DummyTestProgramCorrelator(Program sourceProgram, AddressSetView sourceAddressSet,
|
||||
Program destinationProgram, AddressSetView destinationAddressSet, ToolOptions options) {
|
||||
super(sourceProgram, sourceAddressSet, destinationProgram, destinationAddressSet, options);
|
||||
}
|
||||
|
||||
public DummyTestProgramCorrelator(ServiceProvider serviceProvider, Program sourceProgram,
|
||||
Program destinationProgram) {
|
||||
super(serviceProvider, sourceProgram, createAddressSet(), destinationProgram,
|
||||
createAddressSet(), createOptions());
|
||||
public DummyTestProgramCorrelator(Program sourceProgram, Program destinationProgram) {
|
||||
super(sourceProgram, createAddressSet(), destinationProgram, createAddressSet(),
|
||||
createOptions());
|
||||
}
|
||||
|
||||
public DummyTestProgramCorrelator(int matchCount) {
|
||||
super(null, null, createAddressSet(), null, createAddressSet(), createOptions());
|
||||
super(null, createAddressSet(), null, createAddressSet(), createOptions());
|
||||
this.matchCount = matchCount;
|
||||
}
|
||||
|
||||
|
|
|
@ -235,8 +235,7 @@ public class UnappliedMarkupItemStorageDBTest extends VTBaseTestCase {
|
|||
unappliedMarkupItem.setDestinationAddress(destinationAddress);
|
||||
|
||||
VTAssociationDB association = (VTAssociationDB) match.getAssociation();
|
||||
Collection<VTMarkupItem> markupItems =
|
||||
association.getMarkupItems(TaskMonitor.DUMMY);
|
||||
Collection<VTMarkupItem> markupItems = association.getMarkupItems(TaskMonitor.DUMMY);
|
||||
assertEquals(1, markupItems.size());
|
||||
VTMarkupItem foundItem = markupItems.iterator().next();
|
||||
Object storage = getInstanceField("markupItemStorage", foundItem);
|
||||
|
@ -256,8 +255,7 @@ public class UnappliedMarkupItemStorageDBTest extends VTBaseTestCase {
|
|||
|
||||
VTMarkupItem markupItem = createRandomMarkupItemStub(match);
|
||||
VTAssociationDB association = (VTAssociationDB) match.getAssociation();
|
||||
Collection<VTMarkupItem> markupItems =
|
||||
association.getMarkupItems(TaskMonitor.DUMMY);
|
||||
Collection<VTMarkupItem> markupItems = association.getMarkupItems(TaskMonitor.DUMMY);
|
||||
assertEquals(1, markupItems.size());
|
||||
VTMarkupItem foundItem = markupItems.iterator().next();
|
||||
Object storage = getInstanceField("markupItemStorage", foundItem);
|
||||
|
@ -268,7 +266,7 @@ public class UnappliedMarkupItemStorageDBTest extends VTBaseTestCase {
|
|||
private VTMatch createMatchSetWithOneMatch() {
|
||||
VTMatchInfo matchInfo = createRandomMatch(db);
|
||||
VTMatchSet matchSet = db.createMatchSet(
|
||||
createProgramCorrelator(null, db.getSourceProgram(), db.getDestinationProgram()));
|
||||
createProgramCorrelator(db.getSourceProgram(), db.getDestinationProgram()));
|
||||
return matchSet.addMatch(matchInfo);
|
||||
}
|
||||
|
||||
|
|
|
@ -140,7 +140,7 @@ public class VTAssociationDBTest extends VTBaseTestCase {
|
|||
@Test
|
||||
public void testAssociationLocking() {
|
||||
VTMatchSet matchSet = db.createMatchSet(
|
||||
createProgramCorrelator(null, db.getSourceProgram(), db.getDestinationProgram()));
|
||||
createProgramCorrelator(db.getSourceProgram(), db.getDestinationProgram()));
|
||||
|
||||
//
|
||||
// To create our locking scenario we will create associations that are related and
|
||||
|
@ -235,7 +235,7 @@ public class VTAssociationDBTest extends VTBaseTestCase {
|
|||
@Test
|
||||
public void testAddNewCompetingAssociationIsLockedOut() throws Exception {
|
||||
VTMatchSet matchSet = db.createMatchSet(
|
||||
createProgramCorrelator(null, db.getSourceProgram(), db.getDestinationProgram()));
|
||||
createProgramCorrelator(db.getSourceProgram(), db.getDestinationProgram()));
|
||||
|
||||
//
|
||||
// To create our locking scenario we will create associations that are competing. First
|
||||
|
@ -274,7 +274,7 @@ public class VTAssociationDBTest extends VTBaseTestCase {
|
|||
@Test
|
||||
public void testAddNewRelatedAssociationIsAccepted() throws Exception {
|
||||
VTMatchSet matchSet = db.createMatchSet(
|
||||
createProgramCorrelator(null, db.getSourceProgram(), db.getDestinationProgram()));
|
||||
createProgramCorrelator(db.getSourceProgram(), db.getDestinationProgram()));
|
||||
|
||||
//
|
||||
// To create our locking scenario we will create associations that are related. First
|
||||
|
@ -311,7 +311,7 @@ public class VTAssociationDBTest extends VTBaseTestCase {
|
|||
@Test
|
||||
public void testGetRelatedAssociations() {
|
||||
VTMatchSet matchSet = db.createMatchSet(
|
||||
createProgramCorrelator(null, db.getSourceProgram(), db.getDestinationProgram()));
|
||||
createProgramCorrelator(db.getSourceProgram(), db.getDestinationProgram()));
|
||||
|
||||
//
|
||||
// Exercise the lookup routines for finding related matches
|
||||
|
@ -371,7 +371,7 @@ public class VTAssociationDBTest extends VTBaseTestCase {
|
|||
@Test
|
||||
public void testSetAcceptedFailsWhenNotAccepted() throws Exception {
|
||||
VTMatchSet matchSet = db.createMatchSet(
|
||||
createProgramCorrelator(null, db.getSourceProgram(), db.getDestinationProgram()));
|
||||
createProgramCorrelator(db.getSourceProgram(), db.getDestinationProgram()));
|
||||
|
||||
//
|
||||
// To create our locking scenario we will create associations that are related. First
|
||||
|
@ -418,7 +418,7 @@ public class VTAssociationDBTest extends VTBaseTestCase {
|
|||
@Test
|
||||
public void testSetAssocaiationAccepted_WithNoCompetingAssociations() throws Exception {
|
||||
VTMatchSet matchSet = db.createMatchSet(
|
||||
createProgramCorrelator(null, db.getSourceProgram(), db.getDestinationProgram()));
|
||||
createProgramCorrelator(db.getSourceProgram(), db.getDestinationProgram()));
|
||||
|
||||
//
|
||||
// The accepted association
|
||||
|
@ -435,7 +435,7 @@ public class VTAssociationDBTest extends VTBaseTestCase {
|
|||
@Test
|
||||
public void testSetAssocaiationAccepted_WithCompetingAssociations() throws Exception {
|
||||
VTMatchSet matchSet = db.createMatchSet(
|
||||
createProgramCorrelator(null, db.getSourceProgram(), db.getDestinationProgram()));
|
||||
createProgramCorrelator(db.getSourceProgram(), db.getDestinationProgram()));
|
||||
|
||||
//
|
||||
// The accepted association
|
||||
|
@ -462,7 +462,7 @@ public class VTAssociationDBTest extends VTBaseTestCase {
|
|||
@Test
|
||||
public void testClearAccepted_WithNoCompetingAssociations() throws Exception {
|
||||
VTMatchSet matchSet = db.createMatchSet(
|
||||
createProgramCorrelator(null, db.getSourceProgram(), db.getDestinationProgram()));
|
||||
createProgramCorrelator(db.getSourceProgram(), db.getDestinationProgram()));
|
||||
|
||||
//
|
||||
// The accepted association
|
||||
|
@ -482,7 +482,7 @@ public class VTAssociationDBTest extends VTBaseTestCase {
|
|||
@Test
|
||||
public void testClearAccepted_WithCompetingAssociations() throws Exception {
|
||||
VTMatchSet matchSet = db.createMatchSet(
|
||||
createProgramCorrelator(null, db.getSourceProgram(), db.getDestinationProgram()));
|
||||
createProgramCorrelator(db.getSourceProgram(), db.getDestinationProgram()));
|
||||
|
||||
//
|
||||
// The accepted association
|
||||
|
@ -513,7 +513,7 @@ public class VTAssociationDBTest extends VTBaseTestCase {
|
|||
@Test
|
||||
public void testClearAcceptedFailsWithAppliedMatches() throws Exception {
|
||||
VTMatchSet matchSet = db.createMatchSet(
|
||||
createProgramCorrelator(null, db.getSourceProgram(), db.getDestinationProgram()));
|
||||
createProgramCorrelator(db.getSourceProgram(), db.getDestinationProgram()));
|
||||
|
||||
//
|
||||
// The accepted association
|
||||
|
@ -561,7 +561,7 @@ public class VTAssociationDBTest extends VTBaseTestCase {
|
|||
@Test
|
||||
public void testAcceptingAnEmptyAssociationSetsTheFullyAppliedStatus() throws Exception {
|
||||
VTMatchSet matchSet = db.createMatchSet(
|
||||
createProgramCorrelator(null, db.getSourceProgram(), db.getDestinationProgram()));
|
||||
createProgramCorrelator(db.getSourceProgram(), db.getDestinationProgram()));
|
||||
|
||||
VTMatchInfo mainMatchInfo = createRandomMatch(db);
|
||||
VTMatch mainMatch = addMatch(matchSet, mainMatchInfo);
|
||||
|
@ -679,7 +679,7 @@ public class VTAssociationDBTest extends VTBaseTestCase {
|
|||
@Test
|
||||
public void testVotes() throws Exception {
|
||||
VTMatchSet matchSet = db.createMatchSet(
|
||||
createProgramCorrelator(null, db.getSourceProgram(), db.getDestinationProgram()));
|
||||
createProgramCorrelator(db.getSourceProgram(), db.getDestinationProgram()));
|
||||
|
||||
VTMatchInfo mainMatchInfo = createRandomMatch(db);
|
||||
VTMatch mainMatch = addMatch(matchSet, mainMatchInfo);
|
||||
|
@ -698,7 +698,7 @@ public class VTAssociationDBTest extends VTBaseTestCase {
|
|||
public void testAssociationHook() throws Exception {
|
||||
|
||||
VTMatchSet matchSet = db.createMatchSet(
|
||||
createProgramCorrelator(null, db.getSourceProgram(), db.getDestinationProgram()));
|
||||
createProgramCorrelator(db.getSourceProgram(), db.getDestinationProgram()));
|
||||
VTMatchInfo mainMatchInfo = createRandomMatch(db);
|
||||
VTMatch mainMatch = addMatch(matchSet, mainMatchInfo);
|
||||
SpyAssociationHook spyHook = new SpyAssociationHook();
|
||||
|
@ -715,7 +715,7 @@ public class VTAssociationDBTest extends VTBaseTestCase {
|
|||
public void testRejectingAssociation() throws Exception {
|
||||
// reject
|
||||
VTMatchSet matchSet = db.createMatchSet(
|
||||
createProgramCorrelator(null, db.getSourceProgram(), db.getDestinationProgram()));
|
||||
createProgramCorrelator(db.getSourceProgram(), db.getDestinationProgram()));
|
||||
|
||||
VTMatchInfo mainMatchInfo = createRandomMatch(db);
|
||||
VTMatch mainMatch = addMatch(matchSet, mainMatchInfo);
|
||||
|
@ -734,7 +734,7 @@ public class VTAssociationDBTest extends VTBaseTestCase {
|
|||
@Test
|
||||
public void testRejectingAssociation_CannotApplyMarkupItems() throws Exception {
|
||||
VTMatchSet matchSet = db.createMatchSet(
|
||||
createProgramCorrelator(null, db.getSourceProgram(), db.getDestinationProgram()));
|
||||
createProgramCorrelator(db.getSourceProgram(), db.getDestinationProgram()));
|
||||
|
||||
VTMatchInfo mainMatchInfo = createRandomMatch(db);
|
||||
VTMatch mainMatch = addMatch(matchSet, mainMatchInfo);
|
||||
|
@ -761,7 +761,7 @@ public class VTAssociationDBTest extends VTBaseTestCase {
|
|||
public void testRejectingAssocation_CannotRejectAssociationWithAppliedMarkupItems()
|
||||
throws Exception {
|
||||
VTMatchSet matchSet = db.createMatchSet(
|
||||
createProgramCorrelator(null, db.getSourceProgram(), db.getDestinationProgram()));
|
||||
createProgramCorrelator(db.getSourceProgram(), db.getDestinationProgram()));
|
||||
|
||||
VTMatchInfo mainMatchInfo = createRandomMatch(db);
|
||||
VTMatch mainMatch = addMatch(matchSet, mainMatchInfo);
|
||||
|
@ -823,7 +823,7 @@ public class VTAssociationDBTest extends VTBaseTestCase {
|
|||
private VTMatch createMatchSetWithOneMatch() {
|
||||
VTMatchInfo match = createRandomMatch(db);
|
||||
VTMatchSet matchSet = db.createMatchSet(
|
||||
createProgramCorrelator(null, db.getSourceProgram(), db.getDestinationProgram()));
|
||||
createProgramCorrelator(db.getSourceProgram(), db.getDestinationProgram()));
|
||||
return addMatch(matchSet, match);
|
||||
}
|
||||
|
||||
|
|
|
@ -314,7 +314,7 @@ public class VTDomainObjectEventsTest extends VTBaseTestCase {
|
|||
|
||||
private VTMatchSet createMatchSet() {
|
||||
VTProgramCorrelator correlator =
|
||||
createProgramCorrelator(null, db.getSourceProgram(), db.getDestinationProgram());
|
||||
createProgramCorrelator(db.getSourceProgram(), db.getDestinationProgram());
|
||||
return db.createMatchSet(correlator);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package ghidra.feature.vt.db;
|
||||
|
||||
import static ghidra.feature.vt.db.VTTestUtils.createProgramCorrelator;
|
||||
import static ghidra.feature.vt.db.VTTestUtils.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.Collection;
|
||||
|
@ -51,7 +51,7 @@ public class VTMatchSetDBTest extends VTBaseTestCase {
|
|||
@Test
|
||||
public void testAddMatch() throws Exception {
|
||||
VTProgramCorrelator correlator =
|
||||
createProgramCorrelator(null, db.getSourceProgram(), db.getDestinationProgram());
|
||||
createProgramCorrelator(db.getSourceProgram(), db.getDestinationProgram());
|
||||
VTMatchSet matchSet = db.createMatchSet(correlator);
|
||||
assertNotNull(matchSet);
|
||||
|
||||
|
@ -70,7 +70,7 @@ public class VTMatchSetDBTest extends VTBaseTestCase {
|
|||
@Test
|
||||
public void testRejectAvailableMatch() throws Exception {
|
||||
VTProgramCorrelator correlator =
|
||||
createProgramCorrelator(null, db.getSourceProgram(), db.getDestinationProgram());
|
||||
createProgramCorrelator(db.getSourceProgram(), db.getDestinationProgram());
|
||||
VTMatchSet matchSet = db.createMatchSet(correlator);
|
||||
assertNotNull(matchSet);
|
||||
|
||||
|
@ -100,7 +100,7 @@ public class VTMatchSetDBTest extends VTBaseTestCase {
|
|||
@Test
|
||||
public void testRejectAcceptedMatchFailure() throws Exception {
|
||||
VTProgramCorrelator correlator =
|
||||
createProgramCorrelator(null, db.getSourceProgram(), db.getDestinationProgram());
|
||||
createProgramCorrelator(db.getSourceProgram(), db.getDestinationProgram());
|
||||
VTMatchSet matchSet = db.createMatchSet(correlator);
|
||||
assertNotNull(matchSet);
|
||||
|
||||
|
@ -144,7 +144,7 @@ public class VTMatchSetDBTest extends VTBaseTestCase {
|
|||
@Test
|
||||
public void testRejectBlockedMatch() throws Exception {
|
||||
VTProgramCorrelator correlator =
|
||||
createProgramCorrelator(null, db.getSourceProgram(), db.getDestinationProgram());
|
||||
createProgramCorrelator(db.getSourceProgram(), db.getDestinationProgram());
|
||||
VTMatchSet matchSet = db.createMatchSet(correlator);
|
||||
assertNotNull(matchSet);
|
||||
|
||||
|
|
|
@ -15,8 +15,7 @@
|
|||
*/
|
||||
package ghidra.feature.vt.db;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -45,8 +44,8 @@ public class VTSessionDBTest extends VTBaseTestCase {
|
|||
|
||||
@Test
|
||||
public void testCreateAndGetMatchSet() throws Exception {
|
||||
VTProgramCorrelator correlator = VTTestUtils.createProgramCorrelator(null,
|
||||
db.getSourceProgram(), db.getDestinationProgram());
|
||||
VTProgramCorrelator correlator =
|
||||
VTTestUtils.createProgramCorrelator(db.getSourceProgram(), db.getDestinationProgram());
|
||||
VTMatchSet matchSet = db.createMatchSet(correlator);
|
||||
assertNotNull(matchSet);
|
||||
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
*/
|
||||
package ghidra.feature.vt.db;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
//import generic.test.GenericTestCase;
|
||||
import generic.test.AbstractGenericTest;
|
||||
import ghidra.feature.vt.api.db.VTAssociationDB;
|
||||
|
@ -25,27 +27,24 @@ import ghidra.feature.vt.api.main.*;
|
|||
import ghidra.feature.vt.api.markupitem.MarkupTypeTestStub;
|
||||
import ghidra.feature.vt.api.markuptype.VTMarkupType;
|
||||
import ghidra.feature.vt.api.markuptype.VTMarkupTypeFactory;
|
||||
import ghidra.framework.plugintool.ServiceProvider;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class VTTestUtils {
|
||||
|
||||
private static String[] randomTags = { "TAG1", "TAG2", "TAG3" };
|
||||
private static GenericAddressSpace space = new GenericAddressSpace("Test", 32,
|
||||
AddressSpace.TYPE_RAM, 3);
|
||||
private static GenericAddressSpace space =
|
||||
new GenericAddressSpace("Test", 32, AddressSpace.TYPE_RAM, 3);
|
||||
|
||||
private VTTestUtils() {
|
||||
// utility class
|
||||
}
|
||||
|
||||
public static VTProgramCorrelator createProgramCorrelator(ServiceProvider serviceProvider,
|
||||
Program sourceProgram, Program destinationProgram) {
|
||||
return new DummyTestProgramCorrelator(serviceProvider, sourceProgram, destinationProgram);
|
||||
public static VTProgramCorrelator createProgramCorrelator(Program sourceProgram,
|
||||
Program destinationProgram) {
|
||||
return new DummyTestProgramCorrelator(sourceProgram, destinationProgram);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -149,7 +148,8 @@ public class VTTestUtils {
|
|||
|
||||
VTMarkupItem markupItem = new MarkupItemImpl(associationDB, markupType, sourceAddress);
|
||||
|
||||
Object markupItemManager = AbstractGenericTest.getInstanceField("markupManager", associationDB);
|
||||
Object markupItemManager =
|
||||
AbstractGenericTest.getInstanceField("markupManager", associationDB);
|
||||
if (!(markupItemManager instanceof MarkupItemManagerImplDummy)) {
|
||||
|
||||
// Odd Code Alert: we don't want the MarkupItemManager actually looking for markup items
|
||||
|
@ -193,9 +193,8 @@ public class VTTestUtils {
|
|||
try {
|
||||
testTransactionID = db.startTransaction("Test Match Set Setup");
|
||||
VTMatchInfo info = createRandomMatch(sourceAddress, destinationAddress, db);
|
||||
VTMatchSet matchSet =
|
||||
db.createMatchSet(createProgramCorrelator(null, db.getSourceProgram(),
|
||||
db.getDestinationProgram()));
|
||||
VTMatchSet matchSet = db.createMatchSet(
|
||||
createProgramCorrelator(db.getSourceProgram(), db.getDestinationProgram()));
|
||||
return matchSet.addMatch(info);
|
||||
}
|
||||
finally {
|
||||
|
@ -210,9 +209,8 @@ public class VTTestUtils {
|
|||
testTransactionID = db.startTransaction("Test Create Data Match Set");
|
||||
VTMatchInfo info = createRandomMatch(sourceAddress, destinationAddress, db);
|
||||
info.setAssociationType(VTAssociationType.DATA);
|
||||
VTMatchSet matchSet =
|
||||
db.createMatchSet(createProgramCorrelator(null, db.getSourceProgram(),
|
||||
db.getDestinationProgram()));
|
||||
VTMatchSet matchSet = db.createMatchSet(
|
||||
createProgramCorrelator(db.getSourceProgram(), db.getDestinationProgram()));
|
||||
return matchSet.addMatch(info);
|
||||
}
|
||||
finally {
|
||||
|
@ -243,8 +241,8 @@ public class VTTestUtils {
|
|||
VTMarkupItemStatus.values()[getRandomInt(1, VTMarkupItemStatus.values().length - 1)];
|
||||
|
||||
while (status == statusSeed) {
|
||||
status =
|
||||
VTMarkupItemStatus.values()[getRandomInt(1, VTMarkupItemStatus.values().length - 1)];
|
||||
status = VTMarkupItemStatus.values()[getRandomInt(1,
|
||||
VTMarkupItemStatus.values().length - 1)];
|
||||
}
|
||||
|
||||
return status;
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
package ghidra.feature.vt.gui;
|
||||
|
||||
import static docking.test.AbstractDockingTest.*;
|
||||
import static generic.test.AbstractGenericTest.*;
|
||||
import static generic.test.AbstractGuiTest.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -69,7 +71,7 @@ public class VTTestEnv extends TestEnv {
|
|||
|
||||
session = VTSessionDB.createVTSession("Test", sourceProgram, destinationProgram, getTool());
|
||||
|
||||
VTProgramCorrelator correlator = factory.createCorrelator(getTool(), sourceProgram,
|
||||
VTProgramCorrelator correlator = factory.createCorrelator(sourceProgram,
|
||||
sourceProgram.getMemory(), destinationProgram, destinationProgram.getMemory(), null);
|
||||
|
||||
int id = session.startTransaction("Correlate");
|
||||
|
@ -85,7 +87,7 @@ public class VTTestEnv extends TestEnv {
|
|||
throw new AssertionFailedError("You must create the session before you can add items");
|
||||
}
|
||||
|
||||
VTProgramCorrelator correlator = factory.createCorrelator(getTool(), sourceProgram,
|
||||
VTProgramCorrelator correlator = factory.createCorrelator(sourceProgram,
|
||||
sourceProgram.getMemory(), destinationProgram, destinationProgram.getMemory(), null);
|
||||
|
||||
int id = session.startTransaction("Correlate");
|
||||
|
@ -120,7 +122,7 @@ public class VTTestEnv extends TestEnv {
|
|||
|
||||
public VTProgramCorrelator correlate(VTProgramCorrelatorFactory factory, VTOptions options,
|
||||
TaskMonitor monitor) throws CancelledException {
|
||||
VTProgramCorrelator correlator = factory.createCorrelator(getTool(), sourceProgram,
|
||||
VTProgramCorrelator correlator = factory.createCorrelator(sourceProgram,
|
||||
sourceProgram.getMemory(), destinationProgram, destinationProgram.getMemory(), options);
|
||||
|
||||
int id = session.startTransaction("Correlate");
|
||||
|
|
|
@ -459,7 +459,7 @@ public class TagFilterTest extends VTBaseTestCase {
|
|||
|
||||
public static VTProgramCorrelator createProgramCorrelator(ServiceProvider serviceProvider,
|
||||
Program sourceProgram, Program destinationProgram) {
|
||||
return new DummyTestProgramCorrelator(serviceProvider, sourceProgram, destinationProgram);
|
||||
return new DummyTestProgramCorrelator(sourceProgram, destinationProgram);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -34,8 +33,10 @@ public interface AddressCorrelation {
|
|||
*
|
||||
* @param sourceAddress
|
||||
* the source program address
|
||||
* @param monitor the task monitor
|
||||
* @return the destination program address range, or null if the source program address maps
|
||||
* to one that is "deleted" in the destination program
|
||||
* @throws CancelledException if cancelled
|
||||
*/
|
||||
public AddressRange getCorrelatedDestinationRange(Address sourceAddress, TaskMonitor monitor)
|
||||
throws CancelledException;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue