diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/script/GhidraState.java b/Ghidra/Features/Base/src/main/java/ghidra/app/script/GhidraState.java index 32b7161418..1fff5f7b64 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/script/GhidraState.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/script/GhidraState.java @@ -131,7 +131,7 @@ public class GhidraState { /** * If it differs, set the current location to the given address and fire a {@link ProgramLocationPluginEvent}. - * + * * @param address the address */ public void setCurrentAddress(Address address) { @@ -150,8 +150,8 @@ 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)) { @@ -173,7 +173,7 @@ public class GhidraState { /** * Set the currently highlighted selection and fire a {@link ProgramHighlightPluginEvent}. - * + * * @param highlight the selection */ public void setCurrentHighlight(ProgramSelection highlight) { @@ -199,7 +199,7 @@ public class GhidraState { /** * Set the current selection and fire a {@link ProgramSelectionPluginEvent}. - * + * * @param selection the selection */ public void setCurrentSelection(ProgramSelection selection) { diff --git a/Ghidra/Features/VersionTracking/ghidra_scripts/AutoVersionTrackingScript.java b/Ghidra/Features/VersionTracking/ghidra_scripts/AutoVersionTrackingScript.java index 3b82a56a54..142f80bfc1 100644 --- a/Ghidra/Features/VersionTracking/ghidra_scripts/AutoVersionTrackingScript.java +++ b/Ghidra/Features/VersionTracking/ghidra_scripts/AutoVersionTrackingScript.java @@ -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 getPlugin(PluginTool tool, Class c) { - List 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; } } diff --git a/Ghidra/Features/VersionTracking/ghidra_scripts/CreateAppliedExactMatchingSessionScript.java b/Ghidra/Features/VersionTracking/ghidra_scripts/CreateAppliedExactMatchingSessionScript.java index 25f98b517b..bcb3f993a3 100644 --- a/Ghidra/Features/VersionTracking/ghidra_scripts/CreateAppliedExactMatchingSessionScript.java +++ b/Ghidra/Features/VersionTracking/ghidra_scripts/CreateAppliedExactMatchingSessionScript.java @@ -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); diff --git a/Ghidra/Features/VersionTracking/ghidra_scripts/FindChangedFunctionsScript.java b/Ghidra/Features/VersionTracking/ghidra_scripts/FindChangedFunctionsScript.java index 11e6e4db18..7fe1034a00 100644 --- a/Ghidra/Features/VersionTracking/ghidra_scripts/FindChangedFunctionsScript.java +++ b/Ghidra/Features/VersionTracking/ghidra_scripts/FindChangedFunctionsScript.java @@ -51,7 +51,7 @@ public class FindChangedFunctionsScript extends GhidraVersionTrackingScript { } // Prompt the user to load the two programs that will be analyzed. - // This will only allow you to select programs from the currently-open + // This will only allow you to select programs from the currently-open // project in Ghidra, so import them if you haven't already. p1 = askProgram("Program1_Version1"); if (p1 == null) { @@ -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; } @@ -94,12 +94,10 @@ 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; } } diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/GhidraVersionTrackingScript.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/GhidraVersionTrackingScript.java index 5a7360d1c1..744f6b18f0 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/GhidraVersionTrackingScript.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/GhidraVersionTrackingScript.java @@ -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, - sourceProgram.getMemory().getLoadedAndInitializedAddressSet(), destinationProgram, - destinationProgram.getMemory().getLoadedAndInitializedAddressSet(), new VTOptions("dummy")); + VTProgramCorrelator correlator = correlatorFactory.createCorrelator(sourceProgram, + sourceProgram.getMemory().getLoadedAndInitializedAddressSet(), destinationProgram, + destinationProgram.getMemory().getLoadedAndInitializedAddressSet(), + new VTOptions("dummy")); correlator.correlate(vtSession, monitor); } @@ -205,20 +205,20 @@ public abstract class GhidraVersionTrackingScript extends GhidraScript { //================================================================================================== // Potential Methods -//================================================================================================== +//================================================================================================== -// to not correlate the entire program +// to not correlate the entire program // public void runCorrelator(String name, AddressSet addresSet) // TODO - // -a way to allow users to apply markup of matches, given some filtering criteria + // -a way to allow users to apply markup of matches, given some filtering criteria // (maybe via a callback) // -a way to allow users to specify the **options** for applying, since this is how - // we perform applying now + // we perform applying now //================================================================================================== // Private Methods -//================================================================================================== +//================================================================================================== private VTProgramCorrelatorFactory getCorrelatorFactory(String name) { List generateList = getVTProgramCorrelatorFactory(); diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/address/ExactMatchAddressCorrelator.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/address/ExactMatchAddressCorrelator.java index 6bd95ba994..80b1b2e332 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/address/ExactMatchAddressCorrelator.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/address/ExactMatchAddressCorrelator.java @@ -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 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)) { diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/CombinedFunctionAndDataReferenceProgramCorrelator.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/CombinedFunctionAndDataReferenceProgramCorrelator.java index b3ac2456ec..e3817f42c1 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/CombinedFunctionAndDataReferenceProgramCorrelator.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/CombinedFunctionAndDataReferenceProgramCorrelator.java @@ -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 diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/CombinedFunctionAndDataReferenceProgramCorrelatorFactory.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/CombinedFunctionAndDataReferenceProgramCorrelatorFactory.java index 9a2a062f47..ce62fe8cbf 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/CombinedFunctionAndDataReferenceProgramCorrelatorFactory.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/CombinedFunctionAndDataReferenceProgramCorrelatorFactory.java @@ -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); } } diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/DataMatchProgramCorrelator.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/DataMatchProgramCorrelator.java index c0b2d0c45d..208ae6b91c 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/DataMatchProgramCorrelator.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/DataMatchProgramCorrelator.java @@ -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; } diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/DataReferenceProgramCorrelator.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/DataReferenceProgramCorrelator.java index d4692b887d..3c4fb0b09c 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/DataReferenceProgramCorrelator.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/DataReferenceProgramCorrelator.java @@ -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 diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/DataReferenceProgramCorrelatorFactory.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/DataReferenceProgramCorrelatorFactory.java index 0b2a75aeb9..139e634b73 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/DataReferenceProgramCorrelatorFactory.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/DataReferenceProgramCorrelatorFactory.java @@ -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); } diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/DuplicateDataMatchProgramCorrelatorFactory.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/DuplicateDataMatchProgramCorrelatorFactory.java index 19bab2a12c..29273375ee 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/DuplicateDataMatchProgramCorrelatorFactory.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/DuplicateDataMatchProgramCorrelatorFactory.java @@ -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 diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/DuplicateFunctionMatchProgramCorrelatorFactory.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/DuplicateFunctionMatchProgramCorrelatorFactory.java index 3638dcf8ad..e97362207b 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/DuplicateFunctionMatchProgramCorrelatorFactory.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/DuplicateFunctionMatchProgramCorrelatorFactory.java @@ -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); } diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/DuplicateSymbolNameProgramCorrelatorFactory.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/DuplicateSymbolNameProgramCorrelatorFactory.java index 77f13816a6..766568dbe5 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/DuplicateSymbolNameProgramCorrelatorFactory.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/DuplicateSymbolNameProgramCorrelatorFactory.java @@ -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 diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/ExactDataMatchProgramCorrelatorFactory.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/ExactDataMatchProgramCorrelatorFactory.java index 5f7131a131..c35ddfd7f1 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/ExactDataMatchProgramCorrelatorFactory.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/ExactDataMatchProgramCorrelatorFactory.java @@ -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 diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/ExactMatchBytesProgramCorrelatorFactory.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/ExactMatchBytesProgramCorrelatorFactory.java index 6f62265f15..7b05e806fc 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/ExactMatchBytesProgramCorrelatorFactory.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/ExactMatchBytesProgramCorrelatorFactory.java @@ -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); } diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/ExactMatchInstructionsProgramCorrelatorFactory.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/ExactMatchInstructionsProgramCorrelatorFactory.java index 019b81b55c..12d5a6f36a 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/ExactMatchInstructionsProgramCorrelatorFactory.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/ExactMatchInstructionsProgramCorrelatorFactory.java @@ -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); } diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/ExactMatchMnemonicsProgramCorrelatorFactory.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/ExactMatchMnemonicsProgramCorrelatorFactory.java index 88626be8e4..65716b7393 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/ExactMatchMnemonicsProgramCorrelatorFactory.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/ExactMatchMnemonicsProgramCorrelatorFactory.java @@ -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); } diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/FunctionMatchProgramCorrelator.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/FunctionMatchProgramCorrelator.java index 2865aff018..b9fbecf47c 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/FunctionMatchProgramCorrelator.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/FunctionMatchProgramCorrelator.java @@ -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; diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/FunctionReferenceProgramCorrelator.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/FunctionReferenceProgramCorrelator.java index 095ebcd13e..b45cb516c1 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/FunctionReferenceProgramCorrelator.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/FunctionReferenceProgramCorrelator.java @@ -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 diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/FunctionReferenceProgramCorrelatorFactory.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/FunctionReferenceProgramCorrelatorFactory.java index b8a5d3030f..cb4cc469ca 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/FunctionReferenceProgramCorrelatorFactory.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/FunctionReferenceProgramCorrelatorFactory.java @@ -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); } } diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/ImpliedMatchProgramCorrelator.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/ImpliedMatchProgramCorrelator.java index 18867d1ae6..75fe5d83fc 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/ImpliedMatchProgramCorrelator.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/ImpliedMatchProgramCorrelator.java @@ -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 diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/ManualMatchProgramCorrelator.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/ManualMatchProgramCorrelator.java index b8e085f323..d3e13804fe 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/ManualMatchProgramCorrelator.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/ManualMatchProgramCorrelator.java @@ -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 diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/SimilarDataProgramCorrelator.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/SimilarDataProgramCorrelator.java index fd7f0cfaa7..f238396d43 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/SimilarDataProgramCorrelator.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/SimilarDataProgramCorrelator.java @@ -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,18 +47,15 @@ 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, - SimilarDataProgramCorrelatorFactory.MIN_NAME_LENGTH_DEFAULT); + minDataLength = getOptions().getInt(SimilarDataProgramCorrelatorFactory.MIN_NAME_LENGTH, + SimilarDataProgramCorrelatorFactory.MIN_NAME_LENGTH_DEFAULT); boolean skipHomogenousData = getOptions().getBoolean(SimilarDataProgramCorrelatorFactory.SKIP_HOMOGENOUS_DATA, SimilarDataProgramCorrelatorFactory.SKIP_HOMOGENOUS_DATA_DEFAULT); diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/SimilarDataProgramCorrelatorFactory.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/SimilarDataProgramCorrelatorFactory.java index 32084dbd41..b3dbce186b 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/SimilarDataProgramCorrelatorFactory.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/SimilarDataProgramCorrelatorFactory.java @@ -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 diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/SimilarSymbolNameProgramCorrelator.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/SimilarSymbolNameProgramCorrelator.java index 9fe6ccc5c9..ffda750fff 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/SimilarSymbolNameProgramCorrelator.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/SimilarSymbolNameProgramCorrelator.java @@ -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 diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/SimilarSymbolNameProgramCorrelatorFactory.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/SimilarSymbolNameProgramCorrelatorFactory.java index 5ff78db217..08946b42a5 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/SimilarSymbolNameProgramCorrelatorFactory.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/SimilarSymbolNameProgramCorrelatorFactory.java @@ -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 diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/SymbolNameProgramCorrelator.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/SymbolNameProgramCorrelator.java index 059507c23b..c16f39c3a2 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/SymbolNameProgramCorrelator.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/SymbolNameProgramCorrelator.java @@ -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; @@ -97,7 +94,7 @@ public class SymbolNameProgramCorrelator extends VTAbstractProgramCorrelator { } /** - * This class contains the escense of a symbol match which does not preserve + * This class contains the escense of a symbol match which does not preserve * the actual symbol but only its location and match-type (DATA or FUNCTION). * This class is used to aid the deduping of matches produced by a symbol * correlator. @@ -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; } diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/SymbolNameProgramCorrelatorFactory.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/SymbolNameProgramCorrelatorFactory.java index 50992b7990..6bd0e15db9 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/SymbolNameProgramCorrelatorFactory.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/SymbolNameProgramCorrelatorFactory.java @@ -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 diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/VTAbstractReferenceProgramCorrelator.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/VTAbstractReferenceProgramCorrelator.java index 8d148ede77..30cc6f09cd 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/VTAbstractReferenceProgramCorrelator.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/VTAbstractReferenceProgramCorrelator.java @@ -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; @@ -95,7 +91,7 @@ public abstract class VTAbstractReferenceProgramCorrelator extends VTAbstractPro * First generates the sourceDictionary from the source program and matchSet, * then finds the destinations corresponding to the matchSet and the * sourceDictionary using the preset similarity and confidence thresholds. - * + * * @param matchSet contains all existing matches * @param monitor the task monitor * @throws CancelledException if cancelled @@ -114,10 +110,10 @@ public abstract class VTAbstractReferenceProgramCorrelator extends VTAbstractPro * findDestinations updates matchSet with non-null VTMatchInfo members returned from transform. * For each of the entries in the destinationMap = {destMatchAddr:[list of source references]}, * we test all pairs [list of source references] x [list of destination references] - * + * *
* Note: {@code destinationMap} is a class variable set by {@code extractReferenceFeatures} - * + * * @param matchSet The {@code VTMatchSet} for the current session (non-transitive) * @param monitor task monitor * @throws CancelledException if cancelled @@ -126,8 +122,7 @@ public abstract class VTAbstractReferenceProgramCorrelator extends VTAbstractPro throws CancelledException { monitor.initialize(destVectorsByAddress.size()); - Set> destEntries = - destVectorsByAddress.entrySet(); + Set> destEntries = destVectorsByAddress.entrySet(); for (Entry 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> srcNeighbors = new HashMap<>(); - Set> srcEntries = - srcVectorsByAddress.entrySet(); + Set> srcEntries = srcVectorsByAddress.entrySet(); for (Entry srcEntry : srcEntries) { Address srcAddr = srcEntry.getKey(); LSHCosineVectorAccum srcVector = srcEntry.getValue(); @@ -156,8 +150,8 @@ public abstract class VTAbstractReferenceProgramCorrelator extends VTAbstractPro } } - List members = transform(matchSet, destFunc, dstVector, srcNeighbors, - monitor); + List members = + transform(matchSet, destFunc, dstVector, srcNeighbors, monitor); for (VTMatchInfo member : members) { if (member != null) { @@ -172,7 +166,7 @@ public abstract class VTAbstractReferenceProgramCorrelator extends VTAbstractPro * Scoring Mechanism: determines destination similarity and confidence for each of the * sourceNeighbors and if similarity and confidence pass the threshold, then VTMatchInfo will * be created and added to the result. - * + * * @param matchSet match set for this correlator * @param destinationFunction function in the destination program that references an existing accepted match * @param destinationVector the destination function's feature vector @@ -288,14 +282,14 @@ public abstract class VTAbstractReferenceProgramCorrelator extends VTAbstractPro /** * Recursively traces the reference chains from a given address and returns by reference a * list of functions found along the reference chain. - * + * * @param depth the initial recursion depth * @param list a function accumulation list that is updated by this function * @param program the program * @param address an address represents a location in a program */ - private void accumulateFunctionReferences(int depth, Set list, - Program program, Address address) { + private void accumulateFunctionReferences(int depth, Set list, Program program, + Address address) { if (depth >= MAX_DEPTH) { return; @@ -362,7 +356,7 @@ public abstract class VTAbstractReferenceProgramCorrelator extends VTAbstractPro /** * Used to check that a match association is of the correct type (e.g. DATA or FUNCTION) for * the given correlator. - * + * * @param associationType the type of match * @return true if the correct type */ @@ -371,7 +365,7 @@ public abstract class VTAbstractReferenceProgramCorrelator extends VTAbstractPro /** * Used to check that a match association is of the correct type (e.g. DATA or FUNCTION) for * the given correlator. - * + * * @param ref the reference * @return true if the correct type */ @@ -382,17 +376,15 @@ public abstract class VTAbstractReferenceProgramCorrelator extends VTAbstractPro * becomes a unique feature. At the end, all the source and destination functions will have * "vectors" of these features, which are unique match ids. Then the LSH dictionary can be * made from the source and we can look for matches in the destination. - * + * * @param matchSet the match set of previously user-accepted matches * @param monitor the monitor */ 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,9 +465,8 @@ 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) && - ms.getID() < dedupedMatchSets.get(name).getID())) { + 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> sourceRefMap, + private void accumulateMatchFunctionReferences(Map> sourceRefMap, Map> destinationRefMap, VTMatch match) { // check match association type and status @@ -538,7 +526,7 @@ public abstract class VTAbstractReferenceProgramCorrelator extends VTAbstractPro * In order to account unmatched/unaccepted matches that appear in the key set that * consists of possibly correlated functions, we can consider the cost of a reference * switching and the cost of a reference being dropped or picked up between versions. - * + * * Theoretically this should be dependent on the probability of the referenced element * occurring, but for the moment we'll consider the model for a generalized switch and * drop/pickup. diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/main/VTProgramCorrelator.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/main/VTProgramCorrelator.java index a27829c8c7..f32c9c5a15 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/main/VTProgramCorrelator.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/main/VTProgramCorrelator.java @@ -26,11 +26,11 @@ public interface VTProgramCorrelator { /** * Performs the correlation between two programs looking for how well functions in one program * correlate to functions in another program. - * @param session An existing manager that may contain previous results that may + * @param session An existing manager that may contain previous results that may * influence this correlation. * @param monitor a task monitor for reporting progress during the correlation. * @return the match set created by this correlator used to store results. - * + * * @throws CancelledException if the user cancels the correlation via the task monitor. */ public VTMatchSet correlate(VTSession session, TaskMonitor monitor) throws CancelledException; @@ -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(); diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/main/VTProgramCorrelatorFactory.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/main/VTProgramCorrelatorFactory.java index 281569bad6..c71514236e 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/main/VTProgramCorrelatorFactory.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/main/VTProgramCorrelatorFactory.java @@ -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); + } diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/main/VTSession.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/main/VTSession.java index 3bc4a8ab1e..9fa6ce990a 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/main/VTSession.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/main/VTSession.java @@ -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 @@ -39,7 +37,7 @@ public interface VTSession extends ErrorHandler, UndoableDomainObject { public VTAssociationManager getAssociationManager(); /** - * Creates a new VTMatchSet that will contain all the matches discovered by some + * Creates a new VTMatchSet that will contain all the matches discovered by some * ProgramCorrletor algorithm run. * @param correlator the VTProgramCorrelator used to generate this set of matches that will * be added to this VTMatchSet. @@ -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); /** diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/util/VTAbstractProgramCorrelator.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/util/VTAbstractProgramCorrelator.java index 13514f6d7a..e9eb01199b 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/util/VTAbstractProgramCorrelator.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/util/VTAbstractProgramCorrelator.java @@ -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; @@ -25,8 +24,8 @@ import ghidra.util.exception.CancelledException; import ghidra.util.task.TaskMonitor; /** - * Interface for Algorithms that correlate items (primarily functions) from one program to another, - * typically for purposes of version tracking. + * Interface for Algorithms that correlate items (primarily functions) from one program to another, + * typically for purposes of version tracking. * */ public abstract class VTAbstractProgramCorrelator implements VTProgramCorrelator { @@ -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 @@ -46,15 +43,14 @@ public abstract class VTAbstractProgramCorrelator implements VTProgramCorrelator * to the destination program. * @param sourceAddressSet The set of addresses to use in the correlation. * @param destinationProgram The program to search, looking for functions that match functions - * in the source program. Typically, this is the program that markup is to be applied. + * in the source program. Typically, this is the program that markup is to be applied. * @param destinationAddressSet The set of addresses to search within the destination program. - * @param options An Options object that contains the set of options to be used by the + * @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; @@ -65,7 +61,7 @@ public abstract class VTAbstractProgramCorrelator implements VTProgramCorrelator /** * Performs the correlation between two programs looking for how well functions in one program * correlate to functions in another program. - * @param session An existing manager that may contain previous results that may + * @param session An existing manager that may contain previous results that may * influence this correlation. * @param monitor a task monitor for reporting progress during the correlation. * @throws CancelledException if the user cancels the correlation via the task monitor. diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/util/VTAbstractProgramCorrelatorFactory.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/util/VTAbstractProgramCorrelatorFactory.java index 3e0cb212c0..9ad2a4331d 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/util/VTAbstractProgramCorrelatorFactory.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/util/VTAbstractProgramCorrelatorFactory.java @@ -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); + } + } diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/util/VTOptions.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/util/VTOptions.java index 6f0f9e9f5c..b026f6fc04 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/util/VTOptions.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/util/VTOptions.java @@ -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; diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/actions/AutoVersionTrackingAction.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/actions/AutoVersionTrackingAction.java index 6a9651cbfe..4749987e38 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/actions/AutoVersionTrackingAction.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/actions/AutoVersionTrackingAction.java @@ -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); } diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/actions/AutoVersionTrackingTask.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/actions/AutoVersionTrackingTask.java index 47e3c8e2d7..2426da1573 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/actions/AutoVersionTrackingTask.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/actions/AutoVersionTrackingTask.java @@ -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 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(); @@ -473,7 +470,7 @@ public class AutoVersionTrackingTask extends Task { // instructions as each other but not necessarily the same operands. Set relatedMatches = getRelatedMatches(match, matches, monitor); - // remove related matches from the copy of set of matches which gets checked + // remove related matches from the copy of set of matches which gets checked // and skipped if not in the set removeMatches(copyOfMatches, relatedMatches); @@ -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 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) { diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/plugin/AddressCorrelatorManager.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/plugin/AddressCorrelatorManager.java index 14eb803346..f4b7ea5758 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/plugin/AddressCorrelatorManager.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/plugin/AddressCorrelatorManager.java @@ -48,15 +48,13 @@ public class AddressCorrelatorManager { new FixedSizeMRUCachingFactory, AddressCorrelation>( key -> getDataCorrelator(key.first, key.second), DATA_CORRELATION_CACHE_SIZE); - public AddressCorrelatorManager(VTController controller) { + public AddressCorrelatorManager(VTSessionSupplier sessionSupplier) { correlatorList = new ArrayList(); - 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()); } diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/plugin/VTController.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/plugin/VTController.java index 9e87a339e3..4ddfb9bc80 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/plugin/VTController.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/plugin/VTController.java @@ -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); diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/plugin/VTControllerImpl.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/plugin/VTControllerImpl.java index c1dd149fe9..8687fae84d 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/plugin/VTControllerImpl.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/plugin/VTControllerImpl.java @@ -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() { diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/plugin/VTSessionSupplier.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/plugin/VTSessionSupplier.java new file mode 100644 index 0000000000..62654aed73 --- /dev/null +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/plugin/VTSessionSupplier.java @@ -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(); +} diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/provider/impliedmatches/ImpliedMatchAssociationHook.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/provider/impliedmatches/ImpliedMatchAssociationHook.java index 18a36e61e6..e326557108 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/provider/impliedmatches/ImpliedMatchAssociationHook.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/provider/impliedmatches/ImpliedMatchAssociationHook.java @@ -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 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 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 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 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 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 = diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/provider/impliedmatches/VTImpliedMatchesTableModel.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/provider/impliedmatches/VTImpliedMatchesTableModel.java index 6aca23cee7..ac23f649d0 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/provider/impliedmatches/VTImpliedMatchesTableModel.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/provider/impliedmatches/VTImpliedMatchesTableModel.java @@ -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 { +public class VTImpliedMatchesTableModel + extends AddressBasedTableModel { private static final String TITLE = "Implied Match Table Model"; protected VTSession session; @@ -95,7 +95,7 @@ public class VTImpliedMatchesTableModel extends if (deletedSourceAddress.equals(matchSourceAddres) && deletedDestinationAddress.equals(matchDestinationAddress)) { - // try to update the match contained by the row object + // try to update the match contained by the row object rowObject.setMatch(ImpliedMatchUtils.resolveImpliedMatch(rowObject, 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 accumulator, TaskMonitor monitor) - throws CancelledException { + protected void doLoad(Accumulator 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 matches = - ImpliedMatchUtils.findImpliedMatches(controller, sourceFunction, destinationFunction, - session, correlator, monitor); + Set matches = ImpliedMatchUtils.findImpliedMatches(sourceFunction, + destinationFunction, session, correlator, monitor); monitor.setMessage("Searching for existing matches..."); monitor.initialize(matches.size()); @@ -200,11 +199,11 @@ public class VTImpliedMatchesTableModel extends //================================================================================================== // Inner Classes -//================================================================================================== +//================================================================================================== // Source Ref Address - public static class SourceReferenceAddressTableColumn extends - AbstractProgramBasedDynamicTableColumn { + public static class SourceReferenceAddressTableColumn + extends AbstractProgramBasedDynamicTableColumn { @Override public String getColumnName() { @@ -224,8 +223,8 @@ public class VTImpliedMatchesTableModel extends } // Destination Ref Address - public static class DestinationReferenceAddressTableColumn extends - AbstractProgramBasedDynamicTableColumn { + public static class DestinationReferenceAddressTableColumn + extends AbstractProgramBasedDynamicTableColumn { @Override public String getColumnName() { diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/provider/markuptable/VTMarkupItemsTableProvider.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/provider/markuptable/VTMarkupItemsTableProvider.java index 556588d2a5..c92981b47c 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/provider/markuptable/VTMarkupItemsTableProvider.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/provider/markuptable/VTMarkupItemsTableProvider.java @@ -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); @@ -234,8 +234,8 @@ public class VTMarkupItemsTableProvider extends ComponentProviderAdapter } try { - // Need the following flag to prevent selection changing when selecting - // in the markup table, if another of the same markup type exists with + // Need the following flag to prevent selection changing when selecting + // in the markup table, if another of the same markup type exists with // the same destination address. processingMarkupItemSelected = true; @@ -329,8 +329,7 @@ public class VTMarkupItemsTableProvider extends ComponentProviderAdapter if (filteredCount != unfilteredCount) { buffy.append(" (of ") .append(markupItemsTableModel.getUnfilteredRowCount()) - .append( - ')'); + .append(')'); } setSubTitle(buffy.toString()); @@ -343,7 +342,7 @@ public class VTMarkupItemsTableProvider extends ComponentProviderAdapter /** * Displays or hides the function comparison panel within the markup items provider. - * @param show true indicates to show the function comparison within the provider. + * @param show true indicates to show the function comparison within the provider. * Otherwise, hide it. */ private void showComparisonPanelWithinProvider(boolean show) { @@ -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 getPopupActions(Tool tool, ActionContext context) { + public List getPopupActions(Tool t, ActionContext context) { ListingCodeComparisonPanel dualListingPanel = functionComparisonPanel.getDualListingPanel(); if (context.getComponentProvider() == this && dualListingPanel != null) { ListingPanel sourcePanel = dualListingPanel.getLeftPanel(); @@ -640,7 +639,7 @@ public class VTMarkupItemsTableProvider extends ComponentProviderAdapter int sourceLength = match.getSourceLength(); int destinationLength = match.getDestinationLength(); - // We need to possibly adjust the source and destination start addresses to the beginning + // We need to possibly adjust the source and destination start addresses to the beginning // of the code units containing them or we won't display anything in the comparison panel. VTSession session = association.getSession(); Program sourceProgram = session.getSourceProgram(); @@ -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"); @@ -875,26 +874,26 @@ public class VTMarkupItemsTableProvider extends ComponentProviderAdapter } } -// pretty slick code to force a table to repaint before doing some long running task +// pretty slick code to force a table to repaint before doing some long running task // private void forceTableToRepaintEmptyWhileLoading() { -// JScrollPane pane = (JScrollPane) component.getComponent( 0 ); +// JScrollPane pane = (JScrollPane) component.getComponent( 0 ); // Rectangle paneBounds = pane.getBounds(); // Insets insets = pane.getInsets(); // int paneWidth = paneBounds.width - (insets.left + insets.right); -// +// // // force the table to resize with no data -// Rectangle tableBounds = markupItemsTable.getBounds(); +// Rectangle tableBounds = markupItemsTable.getBounds(); // tableBounds.width = paneWidth; // tableBounds.height = 0; // markupItemsTable.setBounds( tableBounds ); // markupItemsTable.doLayout(); -// +// // // force the view to resize with no data (hide the scrollbars) // JViewport viewport = pane.getViewport(); // Rectangle viewportBounds = viewport.getBounds(); // viewportBounds.width = paneWidth; -// viewport.setBounds( viewportBounds ); -// +// viewport.setBounds( viewportBounds ); +// // // force the view's header to resize with no data // JViewport columnHeader = pane.getColumnHeader(); // Rectangle columnHeaderBounds = columnHeader.getBounds(); @@ -902,12 +901,12 @@ public class VTMarkupItemsTableProvider extends ComponentProviderAdapter // columnHeader.setBounds( columnHeaderBounds ); // // component.doLayout(); -// component.paintImmediately( component.getBounds() ); +// component.paintImmediately( component.getBounds() ); // } //================================================================================================== // FilterDialogModel Methods -//================================================================================================== +//================================================================================================== @Override public void addFilter(Filter filter) { @@ -916,7 +915,7 @@ public class VTMarkupItemsTableProvider extends ComponentProviderAdapter markupItemsTableModel.addFilter(filter); } - /** + /** * Forces a refilter, even though filtering operations may be disabled. The reload * is necessary since the model contents may have changed */ @@ -997,7 +996,7 @@ public class VTMarkupItemsTableProvider extends ComponentProviderAdapter } /** - * Gets the function comparison panel component that possibly contains multiple different views + * Gets the function comparison panel component that possibly contains multiple different views * for comparing code such as a dual listing. * @return the function comparison panel */ diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/task/ApplyMarkupItemTask.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/task/ApplyMarkupItemTask.java index 53faca8c77..bc1fc25a14 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/task/ApplyMarkupItemTask.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/task/ApplyMarkupItemTask.java @@ -41,18 +41,13 @@ public class ApplyMarkupItemTask extends VtTask { this.markupItems = markupItems; this.options = options; } - + @Override protected boolean shouldSuspendSessionEvents() { 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(); diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/task/ClearMatchTask.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/task/ClearMatchTask.java index 062f54573a..7a41086f56 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/task/ClearMatchTask.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/task/ClearMatchTask.java @@ -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 diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/util/ImpliedMatchUtils.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/util/ImpliedMatchUtils.java index 460eca8ec7..907950d4b5 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/util/ImpliedMatchUtils.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/util/ImpliedMatchUtils.java @@ -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.*; @@ -34,27 +33,110 @@ import ghidra.util.task.TaskMonitor; /** * Utility class 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. + * and destination functions will added to the current version tracking session as an implied match. */ 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 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 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 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 findImpliedMatches(VTController controller, - Function sourceFunction, Function destinationFunction, VTSession session, + public static Set findImpliedMatches(Function sourceFunction, + Function destinationFunction, VTSession session, AddressCorrelatorManager correlatorManager, TaskMonitor monitor) throws CancelledException { Set set = new HashSet<>(); @@ -88,7 +170,7 @@ public class ImpliedMatchUtils { Function sourceFunction, Function destinationFunction, Reference sourceRef, VTMatchSet possibleMatchSet, TaskMonitor monitor) throws CancelledException { - // Get the reference type of the passed in reference and make sure it is either a call or + // Get the reference type of the passed in reference and make sure it is either a call or // data reference RefType refType = sourceRef.getReferenceType(); if (!(refType.isCall() || refType.isData())) { @@ -102,14 +184,14 @@ public class ImpliedMatchUtils { return null; } - // Get corrected source reference "to" address if necessary (ie if thunk get the thunked + // Get corrected source reference "to" address if necessary (ie if thunk get the thunked // function) srcRefToAddress = getReference(sourceFunction.getProgram(), srcRefToAddress); - + // Get the source reference's "from" address (where the reference itself is located) Address srcRefFromAddress = sourceRef.getFromAddress(); - // Get the destination reference address corresponding to the given source reference address + // Get the destination reference address corresponding to the given source reference address AddressRange range = correlator.getCorrelatedDestinationRange(srcRefFromAddress, monitor); if (range == null) { return null; @@ -121,11 +203,11 @@ public class ImpliedMatchUtils { if (destinationRef == null) { return null; } - + // Get the destination reference's "to" address Address destRefToAddress = destinationRef.getToAddress(); - - // Get corrected destination reference "to" address if necessary (ie if thunk get the + + // Get corrected destination reference "to" address if necessary (ie if thunk get the // thunked function) destRefToAddress = getReference(destinationFunction.getProgram(), destRefToAddress); @@ -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. } } @@ -173,11 +257,11 @@ public class ImpliedMatchUtils { } /** - * This method checks to see if the given reference is a thunk function and if so returns + * 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 + * @return Returns either the same address passed in or the address of the thunked function if * the original address refers to a thunk */ private static Address getReference(Program program, Address refToAddress) { @@ -185,18 +269,19 @@ public class ImpliedMatchUtils { // If the function is a thunk - get the thunked to function and make that the implied match // source not the thunk - // if the reference is a thunk function change the refToAddress to the THUNKED function + // if the reference is a thunk function change the refToAddress to the THUNKED function // address instead of the thunk function address Function referencedFunction = program.getFunctionManager().getFunctionAt(refToAddress); if ((referencedFunction != null) && (referencedFunction.isThunk())) { refToAddress = referencedFunction.getThunkedFunction(true).getEntryPoint(); } - + return refToAddress; } /** - * 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(); @@ -292,7 +377,7 @@ public class ImpliedMatchUtils { /** * Returns the source function given a version tracking session and association pair * - * @param session The Version Tracking session + * @param session The Version Tracking session * @param association The association pair for a match * @return the source function given a version tracking session and association pair */ @@ -306,7 +391,7 @@ public class ImpliedMatchUtils { /** * Returns the destination function given a version tracking session and association pair * - * @param session The Version Tracking session + * @param session The Version Tracking session * @param association The association pair for a match * @return the destination function given a version tracking session and association pair */ diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/util/MatchInfo.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/util/MatchInfo.java index 72e06a3f72..5abec88cbf 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/util/MatchInfo.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/util/MatchInfo.java @@ -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(); @@ -93,7 +93,7 @@ public class MatchInfo { Address minAddress = codeUnit.getMinAddress(); Address maxAddress = codeUnit.getMaxAddress(); - // Adjust the maxAddress for the destination addressSet to show multiple code units + // Adjust the maxAddress for the destination addressSet to show multiple code units // if it is smaller than the source. We want to know what gets overwritten if applied. if (destinationData != null) { int sourceLength = (sourceData != null) ? sourceData.getLength() : 0; @@ -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) { @@ -242,21 +242,19 @@ public class MatchInfo { List list = markupItemsCache.getCachedValue(); if (list == null) { - // not sure how this could happen--perhaps after + // not sure how this could happen--perhaps after // the cache has been cleared, before we are again loaded? return null; } for (VTMarkupItem markupItem : list) { - ProgramLocation location = - isSourceAddress ? markupItem.getSourceLocation() - : markupItem.getDestinationLocation(); + 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; } diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/util/MatchInfoFactory.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/util/MatchInfoFactory.java index 683b0bb982..b044b4d7ff 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/util/MatchInfoFactory.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/util/MatchInfoFactory.java @@ -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 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> entrySet = weakMap.entrySet(); diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/wizard/AddToSessionTask.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/wizard/AddToSessionTask.java index 572b15b867..b32adf5aba 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/wizard/AddToSessionTask.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/wizard/AddToSessionTask.java @@ -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,12 +131,14 @@ 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", diff --git a/Ghidra/Features/VersionTracking/src/test.slow/java/ghidra/feature/vt/api/VTAutoVersionTrackingTest.java b/Ghidra/Features/VersionTracking/src/test.slow/java/ghidra/feature/vt/api/VTAutoVersionTrackingTest.java index f32f740005..cad69eb18a 100644 --- a/Ghidra/Features/VersionTracking/src/test.slow/java/ghidra/feature/vt/api/VTAutoVersionTrackingTest.java +++ b/Ghidra/Features/VersionTracking/src/test.slow/java/ghidra/feature/vt/api/VTAutoVersionTrackingTest.java @@ -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(); diff --git a/Ghidra/Features/VersionTracking/src/test.slow/java/ghidra/feature/vt/api/VTMatchApplyTest.java b/Ghidra/Features/VersionTracking/src/test.slow/java/ghidra/feature/vt/api/VTMatchApplyTest.java index 3a4bb2f60e..c8ffcb69b7 100644 --- a/Ghidra/Features/VersionTracking/src/test.slow/java/ghidra/feature/vt/api/VTMatchApplyTest.java +++ b/Ghidra/Features/VersionTracking/src/test.slow/java/ghidra/feature/vt/api/VTMatchApplyTest.java @@ -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 matches = new ArrayList<>(); matches.add(match); @@ -573,8 +574,9 @@ public class VTMatchApplyTest extends AbstractGhidraHeadedIntegrationTest { VTMatch match = createMatchSetWithOneDataMatch(session, sourceAddress, destinationAddress); // data type choice - controller.getOptions().setEnum(VTOptionDefines.DATA_MATCH_DATA_TYPE, - ReplaceDataChoices.REPLACE_UNDEFINED_DATA_ONLY); + controller.getOptions() + .setEnum(VTOptionDefines.DATA_MATCH_DATA_TYPE, + ReplaceDataChoices.REPLACE_UNDEFINED_DATA_ONLY); List matches = new ArrayList<>(); matches.add(match); @@ -602,8 +604,9 @@ public class VTMatchApplyTest extends AbstractGhidraHeadedIntegrationTest { VTMatch match = createMatchSetWithOneDataMatch(session, sourceAddress, destinationAddress); // data type choice - controller.getOptions().setEnum(VTOptionDefines.DATA_MATCH_DATA_TYPE, - ReplaceDataChoices.REPLACE_UNDEFINED_DATA_ONLY); + controller.getOptions() + .setEnum(VTOptionDefines.DATA_MATCH_DATA_TYPE, + ReplaceDataChoices.REPLACE_UNDEFINED_DATA_ONLY); List matches = new ArrayList<>(); matches.add(match); @@ -644,8 +647,9 @@ public class VTMatchApplyTest extends AbstractGhidraHeadedIntegrationTest { VTMatch match = createMatchSetWithOneDataMatch(session, sourceAddress, destinationAddress); // data type choice - controller.getOptions().setEnum(VTOptionDefines.DATA_MATCH_DATA_TYPE, - ReplaceDataChoices.REPLACE_FIRST_DATA_ONLY); + controller.getOptions() + .setEnum(VTOptionDefines.DATA_MATCH_DATA_TYPE, + ReplaceDataChoices.REPLACE_FIRST_DATA_ONLY); List matches = new ArrayList<>(); matches.add(match); @@ -666,7 +670,7 @@ public class VTMatchApplyTest extends AbstractGhidraHeadedIntegrationTest { Address destinationAddress = addr("0x0100808c", destinationProgram); Listing destinationListing = destinationProgram.getListing(); - // force known values for the test + // force known values for the test DataType sourceDataType = new DWordDataType(); DataType destinationDataType1 = new StringDataType(); setData(sourceDataType, 4, sourceAddress, sourceProgram); @@ -674,9 +678,10 @@ public class VTMatchApplyTest extends AbstractGhidraHeadedIntegrationTest { VTMatch match = createMatchSetWithOneDataMatch(session, sourceAddress, destinationAddress); - // data type choice - controller.getOptions().setEnum(VTOptionDefines.DATA_MATCH_DATA_TYPE, - ReplaceDataChoices.REPLACE_FIRST_DATA_ONLY); + // data type choice + controller.getOptions() + .setEnum(VTOptionDefines.DATA_MATCH_DATA_TYPE, + ReplaceDataChoices.REPLACE_FIRST_DATA_ONLY); List matches = new ArrayList<>(); matches.add(match); @@ -687,9 +692,9 @@ public class VTMatchApplyTest extends AbstractGhidraHeadedIntegrationTest { assertEquals(VTAssociationStatus.ACCEPTED, status); checkDataMatchDataType(sourceDataType, 4, destinationAddress, destinationListing); - // - // Now test the unapply - // + // + // Now test the unapply + // ClearMatchTask unapplyTask = new ClearMatchTask(controller, matches); runTask(unapplyTask); @@ -706,7 +711,7 @@ public class VTMatchApplyTest extends AbstractGhidraHeadedIntegrationTest { Address destinationAddress = addr("0x0100808c", destinationProgram); Listing destinationListing = destinationProgram.getListing(); - // force known values for the test + // force known values for the test DataType sourceDataType = new DWordDataType(); DataType destinationDataType1 = new StringDataType(); setData(sourceDataType, 4, sourceAddress, sourceProgram); @@ -715,9 +720,9 @@ 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); + // data type choice + controller.getOptions() + .setEnum(VTOptionDefines.DATA_MATCH_DATA_TYPE, ReplaceDataChoices.REPLACE_ALL_DATA); List matches = new ArrayList<>(); matches.add(match); @@ -733,7 +738,7 @@ public class VTMatchApplyTest extends AbstractGhidraHeadedIntegrationTest { int txID = program.startTransaction("Creating instruction"); boolean commit = false; try { - // Create instruction here. + // Create instruction here. DisassembleCommand cmd = new DisassembleCommand(address, new AddressSet(address, address.add(length)), false); cmd.applyTo(program); @@ -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 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 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 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 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 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 markupItems = - matchInfo.getAppliableMarkupItems(TaskMonitor.DUMMY); + Collection markupItems = matchInfo.getAppliableMarkupItems(TaskMonitor.DUMMY); List 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 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 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 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 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); diff --git a/Ghidra/Features/VersionTracking/src/test.slow/java/ghidra/feature/vt/gui/provider/AbstractVTCorrelatorTest.java b/Ghidra/Features/VersionTracking/src/test.slow/java/ghidra/feature/vt/gui/provider/AbstractVTCorrelatorTest.java index 5806fcc9b7..a8e5015797 100644 --- a/Ghidra/Features/VersionTracking/src/test.slow/java/ghidra/feature/vt/gui/provider/AbstractVTCorrelatorTest.java +++ b/Ghidra/Features/VersionTracking/src/test.slow/java/ghidra/feature/vt/gui/provider/AbstractVTCorrelatorTest.java @@ -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); diff --git a/Ghidra/Features/VersionTracking/src/test.slow/java/ghidra/feature/vt/gui/provider/VTImpliedMatchCorrelatorTest.java b/Ghidra/Features/VersionTracking/src/test.slow/java/ghidra/feature/vt/gui/provider/VTImpliedMatchCorrelatorTest.java index 935f7c4160..25ef7055cd 100644 --- a/Ghidra/Features/VersionTracking/src/test.slow/java/ghidra/feature/vt/gui/provider/VTImpliedMatchCorrelatorTest.java +++ b/Ghidra/Features/VersionTracking/src/test.slow/java/ghidra/feature/vt/gui/provider/VTImpliedMatchCorrelatorTest.java @@ -36,7 +36,7 @@ public class VTImpliedMatchCorrelatorTest extends AbstractVTCorrelatorTest { } /* - * Run the Exact Function Bytes Match correlator and accept all matches, + * Run the Exact Function Bytes Match correlator and accept all matches, * then check to see that the expected implied matches are created */ @Test @@ -61,7 +61,7 @@ public class VTImpliedMatchCorrelatorTest extends AbstractVTCorrelatorTest { Assert.assertNotEquals("vtMatchSet does not exist", null, testMatchSet); - /* + /* * Test that only non-thunks are in this set */ @@ -110,7 +110,7 @@ public class VTImpliedMatchCorrelatorTest extends AbstractVTCorrelatorTest { } /* - * Run the Exact Function Instructions Match correlator and accept all matches, + * Run the Exact Function Instructions Match correlator and accept all matches, * then make sure there are no implied match thunks */ @Test @@ -135,12 +135,12 @@ public class VTImpliedMatchCorrelatorTest extends AbstractVTCorrelatorTest { Assert.assertNotEquals("vtMatchSet does not exist", null, testMatchSet); - /* + /* * Test that only non-thunks are in this set */ - // too many to check them all individually so iterate over all the matches and test to see - // that none are thunks + // too many to check them all individually so iterate over all the matches and test to see + // that none are thunks FunctionManager srcFunctionManager = session.getSourceProgram().getFunctionManager(); FunctionManager destFunctionManager = session.getDestinationProgram().getFunctionManager(); @@ -169,17 +169,17 @@ public class VTImpliedMatchCorrelatorTest extends AbstractVTCorrelatorTest { String exactSymbolMatchCorrelator = "Exact Symbol Name Match"; runTestCorrelator(exactSymbolMatchCorrelator); - // Now Run the Exact Function Instruction Correlator to get all possible exact instruction + // Now Run the Exact Function Instruction Correlator to get all possible exact instruction // function matches String exactMatchCorrelator = "Exact Function Instructions Match"; runTestCorrelator(exactMatchCorrelator); - // accept/apply just the "addPeople" function match which will attempt to create implied + // accept/apply just the "addPeople" function match which will attempt to create implied // matches just for this match - // Note: This function has the implied matches that were all already found by either the - // symbol name correlator or the exact function instruction match correlator so we do not - // expect to have any implied matches created. However, the vote count for the matches that + // Note: This function has the implied matches that were all already found by either the + // symbol name correlator or the exact function instruction match correlator so we do not + // expect to have any implied matches created. However, the vote count for the matches that // would have been implied matches should now be 1 VTMatch match = createMatch(addr(srcProg, "0x411700"), addr(destProg, "0x004116f0"), srcProg, destProg, true); @@ -191,30 +191,44 @@ public class VTImpliedMatchCorrelatorTest extends AbstractVTCorrelatorTest { runTask(task); // get the resulting implied matches and verify that none of the matches that were already - // created + // created VTMatchSet impliedMatchSet = getVTMatchSet("Implied Match"); Assert.assertNotEquals("vtMatchSet does not exist", null, impliedMatchSet); - // Now test that only the expected items are in this set for the given function we just + // Now test that only the expected items are in this set for the given function we just // applied assertEquals(0, impliedMatchSet.getMatchCount()); 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); diff --git a/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/api/AbstractCorrelatorTest.java b/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/api/AbstractCorrelatorTest.java index a3ba617cf6..9ae0b43285 100644 --- a/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/api/AbstractCorrelatorTest.java +++ b/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/api/AbstractCorrelatorTest.java @@ -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 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 mapCopy = new HashMap<>(map); diff --git a/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/api/markupitem/AbstractVTMarkupItemTest.java b/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/api/markupitem/AbstractVTMarkupItemTest.java index d519225b8b..4e6bcdfe87 100644 --- a/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/api/markupitem/AbstractVTMarkupItemTest.java +++ b/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/api/markupitem/AbstractVTMarkupItemTest.java @@ -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. diff --git a/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/api/markupitem/VTMarkupItemResetTest.java b/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/api/markupitem/VTMarkupItemResetTest.java index 23ba3341d2..f1d6c085f2 100644 --- a/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/api/markupitem/VTMarkupItemResetTest.java +++ b/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/api/markupitem/VTMarkupItemResetTest.java @@ -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); diff --git a/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/db/DummyTestProgramCorrelator.java b/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/db/DummyTestProgramCorrelator.java index 4b9e227245..195c1975f1 100644 --- a/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/db/DummyTestProgramCorrelator.java +++ b/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/db/DummyTestProgramCorrelator.java @@ -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; } diff --git a/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/db/UnappliedMarkupItemStorageDBTest.java b/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/db/UnappliedMarkupItemStorageDBTest.java index b801595dc6..e18d486e3d 100644 --- a/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/db/UnappliedMarkupItemStorageDBTest.java +++ b/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/db/UnappliedMarkupItemStorageDBTest.java @@ -235,8 +235,7 @@ public class UnappliedMarkupItemStorageDBTest extends VTBaseTestCase { unappliedMarkupItem.setDestinationAddress(destinationAddress); VTAssociationDB association = (VTAssociationDB) match.getAssociation(); - Collection markupItems = - association.getMarkupItems(TaskMonitor.DUMMY); + Collection 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 markupItems = - association.getMarkupItems(TaskMonitor.DUMMY); + Collection 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); } diff --git a/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/db/VTAssociationDBTest.java b/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/db/VTAssociationDBTest.java index 95cd0c3a93..737a9f9973 100644 --- a/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/db/VTAssociationDBTest.java +++ b/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/db/VTAssociationDBTest.java @@ -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); } diff --git a/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/db/VTDomainObjectEventsTest.java b/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/db/VTDomainObjectEventsTest.java index d8868b068b..c3bf25d141 100644 --- a/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/db/VTDomainObjectEventsTest.java +++ b/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/db/VTDomainObjectEventsTest.java @@ -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); } } diff --git a/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/db/VTMatchSetDBTest.java b/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/db/VTMatchSetDBTest.java index a2439a3956..8497243840 100644 --- a/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/db/VTMatchSetDBTest.java +++ b/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/db/VTMatchSetDBTest.java @@ -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); @@ -163,7 +163,7 @@ public class VTMatchSetDBTest extends VTBaseTestCase { //================================================================================================== // Private Methods -//================================================================================================== +//================================================================================================== private void assertEquivalent(String failureMessage, VTMatchInfo info, VTMatch match) { VTAssociation association = match.getAssociation(); diff --git a/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/db/VTSessionDBTest.java b/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/db/VTSessionDBTest.java index 003030a648..12aee340f2 100644 --- a/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/db/VTSessionDBTest.java +++ b/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/db/VTSessionDBTest.java @@ -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); @@ -60,7 +59,7 @@ public class VTSessionDBTest extends VTBaseTestCase { } // - // This methods allows us to test that we can create/save/and restore version tracking + // This methods allows us to test that we can create/save/and restore version tracking // managers...it takes a while, so we don't wanna do it all the time...plus this code is // ultimately tested during usage...we did it here for TDD purposes. // @@ -68,23 +67,23 @@ public class VTSessionDBTest extends VTBaseTestCase { // assertEquals( "Untitled", db.getName() ); // // db.endTransaction( testTransactionID, false ); -// +// // GhidraProject project = GhidraProject.createProject( "C:\\Temp\\", "GhidrProject", true ); // DomainFolder rootFolder = project.getRootFolder(); // DomainFile file = rootFolder.createFile( "foop", db, TaskMonitor.DUMMY ); -// +// // Program sourceProgram = db.getSourceProgram(); // Program destinationProgram = db.getDestinationProgram(); -// +// // db.close(); -// -// DomainObject domainObject = file.getDomainObject( null, false, false, +// +// DomainObject domainObject = file.getDomainObject( null, false, false, // TaskMonitor.DUMMY ); // assertTrue( domainObject instanceof VTSessionDB ); // assertEquals( "foop", domainObject.getName() ); -// +// // db = (VTSessionDB) domainObject; -// +// // Program unrelatedProgram = createProgram( "TEST" ); // try { // db.setPrograms( unrelatedProgram, unrelatedProgram); @@ -93,9 +92,9 @@ public class VTSessionDBTest extends VTBaseTestCase { // catch (IllegalArgumentException e) { // // expected case // } -// +// // db.setPrograms(sourceProgram, destinationProgram ); -// +// // testTransactionID = db.startTransaction( "Test" ); // for cleanup // } } diff --git a/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/db/VTTestUtils.java b/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/db/VTTestUtils.java index 9f14270b2a..132e5fe0ca 100644 --- a/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/db/VTTestUtils.java +++ b/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/db/VTTestUtils.java @@ -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); } /** @@ -99,7 +98,7 @@ public class VTTestUtils { /** * Create a random match. - * @param session the match set manager to use when creating a random tag or + * @param session the match set manager to use when creating a random tag or * null if you don't want to create a random tag. * @return the match */ @@ -110,7 +109,7 @@ public class VTTestUtils { /** * Create a random match * @param association the association to use for the source and destination address. - * @param session the match set manager to use when creating a random tag or + * @param session the match set manager to use when creating a random tag or * null if you don't want to create a random tag. * @return the match */ @@ -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; diff --git a/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/gui/VTTestEnv.java b/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/gui/VTTestEnv.java index b8bbb53fb3..5ebbe71619 100644 --- a/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/gui/VTTestEnv.java +++ b/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/gui/VTTestEnv.java @@ -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"); diff --git a/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/gui/filters/TagFilterTest.java b/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/gui/filters/TagFilterTest.java index 9188c41b20..a54b2f6980 100644 --- a/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/gui/filters/TagFilterTest.java +++ b/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/gui/filters/TagFilterTest.java @@ -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); } } diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/util/AddressCorrelation.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/util/AddressCorrelation.java index 1771693445..6c47ad339d 100644 --- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/util/AddressCorrelation.java +++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/util/AddressCorrelation.java @@ -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. @@ -22,7 +21,7 @@ import ghidra.util.exception.CancelledException; import ghidra.util.task.TaskMonitor; /** - * Interface representing the address mapping for any means of correlating addresses + * Interface representing the address mapping for any means of correlating addresses * between a source program and a destination program. * */ @@ -31,11 +30,13 @@ public interface AddressCorrelation { /** * Returns the AddressRange of a set of addresses in the destination * program that correlates to corresponding range in the source program. - * + * * @param sourceAddress * the source program address - * @return the destination program address range, or null if the source program address maps + * @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;