Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/Ghidra_11.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanmkurtz committed May 13, 2024
2 parents c7c3ed3 + 420f2f0 commit 9911db9
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,17 @@ protected void savePaths(String[] paths) {

@Override
protected PathnameTablePanel newPathnameTablePanel() {
PathnameTablePanel tablePanel = new ScriptPathsPanel(this::reset);
tablePanel.setFileChooserProperties(getTitle(), "DebuggerLaunchScriptDirectory",
PathnameTablePanel panel = new ScriptPathsPanel(loadPaths(), this::reset);
panel.setFileChooserProperties(getTitle(), "DebuggerLaunchScriptDirectory",
GhidraFileChooserMode.DIRECTORIES_ONLY, true, null);
return tablePanel;
return panel;
}
}

protected class ScriptPathsPanel extends PathnameTablePanel {
public ScriptPathsPanel(Callback resetCallback) {
public ScriptPathsPanel(String[] paths, Callback resetCallback) {
// disable edits, top/bottom irrelevant, unordered
super(null, resetCallback, false, false, false);
super(paths, resetCallback, false, false, false);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ protected void savePaths(String[] paths) {
@Override
protected PathnameTablePanel newPathnameTablePanel() {
// disable edits, add to top, ordered
PathnameTablePanel tablePanel =
new PathnameTablePanel(null, this::reset, false, true, true);
tablePanel.setFileChooserProperties("Select Directory or Filesystem",
PathnameTablePanel panel =
new PathnameTablePanel(loadPaths(), this::reset, false, true, true);
panel.setFileChooserProperties("Select Directory or Filesystem",
"LibrarySearchDirectory", GhidraFileChooserMode.FILES_AND_DIRECTORIES, false, null);
return tablePanel;
return panel;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,20 @@ private Set<Function> filterFunctions(Program program, DataType dt, TaskMonitor
callers.addAll(callingFunctions);
}

results.addAll(callers);

// Add any callers to external function that use any form of the data type
it = listing.getExternalFunctions();
callers = new HashSet<>();
for (Function f : it) {
monitor.checkCancelled();

if (usesAnyType(f, types)) {
Set<Function> callingFunctions = f.getCallingFunctions(monitor);
callers.addAll(callingFunctions);
}
}

results.addAll(callers);

return results;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,11 @@ private DecompilerVariable getMatchingVarialbe(DataType dt, DecompilerVariable v
// the thing that contains it. So, if you have:
// foo.bar
// then the 'bar' field will have a data type of Foo. Unfortunately, this is not always
// the case. For now, when the variable is global, we need to check the field. Sad face
// the case. For now, if there is a high variable, we need to check the field. Sad face
// emoji.
//
HighVariable highVariable = var.variable.getHighVariable();
if (highVariable instanceof HighGlobal) {
if (highVariable != null) {
if (matchesParentType(potentialField, dt)) {
DtrfDbg.println(this, indent + "MATCHED on parent type: " + dt);
return potentialField;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,15 @@
*/
package ghidra.feature.vt.gui.provider.onetomany;

import java.awt.Adjustable;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.*;
import java.util.List;
import java.util.Set;

import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollBar;
import javax.swing.JTable;
import javax.swing.JToggleButton;
import javax.swing.ListSelectionModel;

import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
import javax.swing.table.*;

import docking.ActionContext;
import docking.action.builder.ActionBuilder;
Expand All @@ -50,30 +35,17 @@
import generic.theme.GIcon;
import ghidra.app.services.FunctionComparisonService;
import ghidra.feature.vt.api.impl.VTEvent;
import ghidra.feature.vt.api.main.VTMarkupItem;
import ghidra.feature.vt.api.main.VTMatch;
import ghidra.feature.vt.api.main.VTSession;
import ghidra.feature.vt.gui.actions.AcceptMatchAction;
import ghidra.feature.vt.gui.actions.ClearMatchAction;
import ghidra.feature.vt.gui.actions.SetVTMatchFromOneToManyAction;
import ghidra.feature.vt.gui.filters.Filter;
import ghidra.feature.vt.api.main.*;
import ghidra.feature.vt.gui.actions.*;
import ghidra.feature.vt.gui.filters.*;
import ghidra.feature.vt.gui.filters.Filter.FilterEditingStatus;
import ghidra.feature.vt.gui.filters.FilterDialogModel;
import ghidra.feature.vt.gui.filters.FilterStatusListener;
import ghidra.feature.vt.gui.plugin.VTController;
import ghidra.feature.vt.gui.plugin.VTControllerListener;
import ghidra.feature.vt.gui.plugin.VTPlugin;
import ghidra.feature.vt.gui.plugin.VTSubToolManager;
import ghidra.feature.vt.gui.plugin.VTSubToolManagerListener;
import ghidra.feature.vt.gui.plugin.*;
import ghidra.feature.vt.gui.provider.markuptable.DisplayableListingAddress;
import ghidra.feature.vt.gui.provider.matchtable.MatchTableRenderer;
import ghidra.feature.vt.gui.util.AbstractVTMatchTableModel.StatusTableColumn;
import ghidra.feature.vt.gui.util.MatchInfo;
import ghidra.feature.vt.gui.util.MatchStatusRenderer;
import ghidra.framework.model.DomainObjectChangeRecord;
import ghidra.framework.model.DomainObjectChangedEvent;
import ghidra.framework.model.DomainObjectEvent;
import ghidra.framework.model.EventType;
import ghidra.framework.model.*;
import ghidra.framework.options.Options;
import ghidra.framework.plugintool.ComponentProviderAdapter;
import ghidra.framework.plugintool.PluginTool;
Expand Down Expand Up @@ -184,6 +156,8 @@ private boolean isValidFunctionComparison(VTMatchOneToManyContext context) {

private void compareFunctions(VTMatchOneToManyContext c) {
List<VTMatch> selectedMatches = c.getSelectedMatches();
Set<Function> leftFunctions = new HashSet<>();
Set<Function> rightFunctions = new HashSet<>();

for (VTMatch match : selectedMatches) {
MatchInfo matchInfo = controller.getMatchInfo(match);
Expand All @@ -196,10 +170,16 @@ private void compareFunctions(VTMatchOneToManyContext c) {
leftFunction = matchInfo.getDestinationFunction();
rightFunction = matchInfo.getSourceFunction();
}
leftFunctions.add(leftFunction);
rightFunctions.add(rightFunction);

FunctionComparisonService service = tool.getService(FunctionComparisonService.class);
service.compareFunctions(leftFunction, rightFunction);
}
// NOTE: in this case the left functions will always be the same function (ie the one in the
// current codebrowser) so leftFunctions will be size one. The rightFunctions will be one or
// more since the src/dst match tables contain all possible matches to the current listing
// function.
FunctionComparisonService service = tool.getService(FunctionComparisonService.class);
service.compareFunctions(leftFunctions, rightFunctions);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/
package docking.widgets.pathmanager;

import javax.swing.JComponent;

import docking.DialogComponentProvider;

public abstract class AbstractPathsDialog extends DialogComponentProvider {
Expand All @@ -26,7 +24,7 @@ public abstract class AbstractPathsDialog extends DialogComponentProvider {
protected AbstractPathsDialog(String title) {
super(title);
tablePanel = newPathnameTablePanel();
addWorkPanel(buildWorkPanel());
addWorkPanel(tablePanel);
addOKButton();
addCancelButton();
setPreferredSize(600, 400);
Expand All @@ -44,11 +42,6 @@ protected void reset() {
tablePanel.setPaths(paths);
}

protected JComponent buildWorkPanel() {
reset();
return tablePanel;
}

@Override
protected void okCallback() {
String[] paths = tablePanel.getPaths();
Expand Down

0 comments on commit 9911db9

Please sign in to comment.