mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-09-28 17:11:11 -09:00
GP-4559 Creating new Memory Search Feature that include dynamic change
detection
This commit is contained in:
@@ -4,9 +4,9 @@
|
||||
* 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.
|
||||
@@ -17,17 +17,17 @@ package help.screenshot;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import docking.DialogComponentProvider;
|
||||
import docking.action.DockingActionIf;
|
||||
import generic.theme.GThemeDefaults.Colors.Palette;
|
||||
import ghidra.app.plugin.core.codebrowser.CodeBrowserPlugin;
|
||||
import ghidra.app.plugin.core.codebrowser.CodeViewerProvider;
|
||||
import ghidra.app.plugin.core.searchmem.mask.MnemonicSearchPlugin;
|
||||
import ghidra.features.base.memsearch.format.SearchFormat;
|
||||
import ghidra.features.base.memsearch.gui.MemorySearchProvider;
|
||||
import ghidra.features.base.memsearch.gui.SearchSettings;
|
||||
import ghidra.features.base.memsearch.mnemonic.MnemonicSearchPlugin;
|
||||
import ghidra.program.model.address.*;
|
||||
|
||||
/**
|
||||
@@ -51,119 +51,46 @@ public class MemorySearchScreenShots extends AbstractSearchScreenShots {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchMemoryHex() {
|
||||
|
||||
moveTool(500, 500);
|
||||
|
||||
performAction("Search Memory", "MemSearchPlugin", false);
|
||||
public void testMemorySearchProvider() {
|
||||
performAction("Memory Search", "MemorySearchPlugin", false);
|
||||
waitForSwing();
|
||||
|
||||
DialogComponentProvider dialog = getDialog();
|
||||
JTextField textField = (JTextField) getInstanceField("valueField", dialog);
|
||||
setText(textField, "12 34");
|
||||
MemorySearchProvider provider = getComponentProvider(MemorySearchProvider.class);
|
||||
|
||||
JToggleButton button = (JToggleButton) getInstanceField("advancedButton", dialog);
|
||||
pressButton(button);
|
||||
runSwing(() -> provider.setSearchInput("12 34"));
|
||||
|
||||
waitForSwing();
|
||||
captureIsolatedProvider(provider, 700, 400);
|
||||
|
||||
captureDialog(DialogComponentProvider.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchMemoryRegex() {
|
||||
|
||||
moveTool(500, 500);
|
||||
|
||||
performAction("Search Memory", "MemSearchPlugin", false);
|
||||
public void testMemorySearchProviderWithOptionsOn() {
|
||||
performAction("Memory Search", "MemorySearchPlugin", false);
|
||||
waitForSwing();
|
||||
|
||||
DialogComponentProvider dialog = getDialog();
|
||||
JRadioButton regexRadioButton =
|
||||
(JRadioButton) findAbstractButtonByText(dialog.getComponent(), "Regular Expression");
|
||||
pressButton(regexRadioButton);
|
||||
MemorySearchProvider provider = getComponentProvider(MemorySearchProvider.class);
|
||||
|
||||
JTextField textField = (JTextField) getInstanceField("valueField", dialog);
|
||||
setText(textField, "\\x50.{0,10}\\x55");
|
||||
runSwing(() -> {
|
||||
provider.setSearchInput("12 34");
|
||||
provider.showOptions(true);
|
||||
});
|
||||
|
||||
JToggleButton button = (JToggleButton) getInstanceField("advancedButton", dialog);
|
||||
pressButton(button);
|
||||
|
||||
waitForSwing();
|
||||
|
||||
captureDialog(DialogComponentProvider.class);
|
||||
captureIsolatedProvider(provider, 700, 650);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchMemoryBinary() {
|
||||
|
||||
moveTool(500, 500);
|
||||
|
||||
performAction("Search Memory", "MemSearchPlugin", false);
|
||||
public void testMemorySearchProviderWithScanPanelOn() {
|
||||
performAction("Memory Search", "MemorySearchPlugin", false);
|
||||
waitForSwing();
|
||||
|
||||
DialogComponentProvider dialog = getDialog();
|
||||
JRadioButton binaryRadioButton =
|
||||
(JRadioButton) findAbstractButtonByText(dialog.getComponent(), "Binary");
|
||||
pressButton(binaryRadioButton);
|
||||
MemorySearchProvider provider = getComponentProvider(MemorySearchProvider.class);
|
||||
|
||||
JTextField textField = (JTextField) getInstanceField("valueField", dialog);
|
||||
setText(textField, "10xx0011");
|
||||
runSwing(() -> {
|
||||
provider.setSearchInput("12 34");
|
||||
provider.showScanPanel(true);
|
||||
});
|
||||
|
||||
JToggleButton button = (JToggleButton) getInstanceField("advancedButton", dialog);
|
||||
pressButton(button);
|
||||
|
||||
waitForSwing();
|
||||
|
||||
captureDialog(DialogComponentProvider.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchMemoryDecimal() {
|
||||
|
||||
moveTool(500, 500);
|
||||
|
||||
performAction("Search Memory", "MemSearchPlugin", false);
|
||||
waitForSwing();
|
||||
|
||||
DialogComponentProvider dialog = getDialog();
|
||||
JRadioButton decimalRadioButton =
|
||||
(JRadioButton) findAbstractButtonByText(dialog.getComponent(), "Decimal");
|
||||
pressButton(decimalRadioButton);
|
||||
|
||||
JTextField textField = (JTextField) getInstanceField("valueField", dialog);
|
||||
setText(textField, "1234");
|
||||
|
||||
JToggleButton button = (JToggleButton) getInstanceField("advancedButton", dialog);
|
||||
pressButton(button);
|
||||
|
||||
waitForSwing();
|
||||
|
||||
captureDialog(DialogComponentProvider.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchMemoryString() {
|
||||
|
||||
moveTool(500, 500);
|
||||
|
||||
performAction("Search Memory", "MemSearchPlugin", false);
|
||||
waitForSwing();
|
||||
|
||||
DialogComponentProvider dialog = getDialog();
|
||||
JRadioButton stringRadioButton =
|
||||
(JRadioButton) findAbstractButtonByText(dialog.getComponent(), "String");
|
||||
pressButton(stringRadioButton);
|
||||
|
||||
JTextField textField = (JTextField) getInstanceField("valueField", dialog);
|
||||
setText(textField, "Hello");
|
||||
|
||||
JToggleButton button = (JToggleButton) getInstanceField("advancedButton", dialog);
|
||||
pressButton(button);
|
||||
|
||||
waitForSwing();
|
||||
|
||||
captureDialog(DialogComponentProvider.class);
|
||||
captureIsolatedProvider(provider, 700, 500);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -208,6 +135,21 @@ public class MemorySearchScreenShots extends AbstractSearchScreenShots {
|
||||
image = tf.getImage();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchMemoryRegex() {
|
||||
performAction("Memory Search", "MemorySearchPlugin", false);
|
||||
waitForSwing();
|
||||
|
||||
MemorySearchProvider provider = getComponentProvider(MemorySearchProvider.class);
|
||||
|
||||
runSwing(() -> {
|
||||
provider.setSettings(new SearchSettings().withSearchFormat(SearchFormat.REG_EX));
|
||||
provider.setSearchInput("\\x50.{0,10}\\x55");
|
||||
});
|
||||
|
||||
captureIsolatedProvider(provider, 700, 300);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchInstructionsExcludeOperands() {
|
||||
Font font = new Font("Monospaced", Font.PLAIN, 14);
|
||||
|
||||
Reference in New Issue
Block a user