GP-3544 various changes

This commit is contained in:
ghidra1 2023-06-20 17:28:11 -04:00 committed by Ryan Kurtz
parent 4b075086c2
commit c974d088c0
21 changed files with 452 additions and 71 deletions

View File

@ -364,7 +364,7 @@ public class DataTypeManagerPlugin extends ProgramPlugin
public DataTypesProvider createProvider() {
DataTypesProvider newProvider = new DataTypesProvider(this, SEARCH_PROVIDER_NAME, true);
newProvider.setIncludeDataTypeMembersInFilter(provider.includeDataMembersInSearch());
newProvider.setIncludeDataTypeMembersInFilter(provider.isIncludeDataMembersInSearch());
newProvider.setFilteringArrays(provider.isFilteringArrays());
newProvider.setFilteringPointers(provider.isFilteringPointers());
return newProvider;

View File

@ -57,7 +57,7 @@ import ghidra.util.Swing;
)
//@formatter:on
public class FunctionComparisonPlugin extends ProgramPlugin
implements DomainObjectListener, FunctionComparisonService {
implements DomainObjectListener, FunctionComparisonService {
static final String MENU_PULLRIGHT = "CompareFunctions";
static final String POPUP_MENU_GROUP = "CompareFunction";
@ -132,7 +132,7 @@ public class FunctionComparisonPlugin extends ProgramPlugin
}
private FunctionComparisonProvider getFromSwingBlocking(
Supplier<FunctionComparisonProvider> comparer) {
Supplier<FunctionComparisonProvider> comparer) {
if (Swing.isSwingThread()) {
return comparer.get();
@ -147,13 +147,13 @@ public class FunctionComparisonPlugin extends ProgramPlugin
@Override
public void addFunctionComparisonProviderListener(
ComponentProviderActivationListener listener) {
ComponentProviderActivationListener listener) {
runOnSwingNonBlocking(() -> functionComparisonManager.addProviderListener(listener));
}
@Override
public void removeFunctionComparisonProviderListener(
ComponentProviderActivationListener listener) {
ComponentProviderActivationListener listener) {
runOnSwingNonBlocking(() -> functionComparisonManager.removeProviderListener(listener));
}
@ -167,9 +167,14 @@ public class FunctionComparisonPlugin extends ProgramPlugin
runOnSwingNonBlocking(() -> functionComparisonManager.removeFunction(function, provider));
}
@Override
public FunctionComparisonProvider createFunctionComparisonProvider() {
return getFromSwingBlocking(() -> functionComparisonManager.createProvider());
}
@Override
public FunctionComparisonProvider compareFunctions(Function source,
Function target) {
Function target) {
return getFromSwingBlocking(
() -> functionComparisonManager.compareFunctions(source, target));
}
@ -187,7 +192,7 @@ public class FunctionComparisonPlugin extends ProgramPlugin
@Override
public void compareFunctions(Function source, Function target,
FunctionComparisonProvider provider) {
FunctionComparisonProvider provider) {
runOnSwingNonBlocking(
() -> functionComparisonManager.compareFunctions(source, target, provider));
}

View File

@ -42,7 +42,7 @@ import ghidra.util.HelpLocation;
* creates instances of this provider as-needed.
*/
public class FunctionComparisonProvider extends ComponentProviderAdapter
implements PopupActionProvider, FunctionComparisonModelListener {
implements PopupActionProvider, FunctionComparisonModelListener {
protected static final String HELP_TOPIC = "FunctionComparison";
protected FunctionComparisonPanel functionComparisonPanel;
@ -73,7 +73,7 @@ public class FunctionComparisonProvider extends ComponentProviderAdapter
* @param contextType the type of context supported by this provider; may be null
*/
public FunctionComparisonProvider(Plugin plugin, String name, String owner,
Class<?> contextType) {
Class<?> contextType) {
super(plugin.getTool(), name, owner, contextType);
this.plugin = plugin;
model = new FunctionComparisonModel();
@ -264,4 +264,9 @@ public class FunctionComparisonProvider extends ComponentProviderAdapter
addLocalAction(dockingAction);
}
}
public void removeAddFunctionsAction() {
//TODO this is stupid merge multi and this into one
}
}

View File

@ -59,6 +59,14 @@ public class FunctionComparisonProviderManager implements FunctionComparisonProv
listeners.stream().forEach(l -> l.componentProviderActivated(provider));
}
public FunctionComparisonProvider createProvider() {
FunctionComparisonProvider provider = new MultiFunctionComparisonProvider(plugin);
provider.addToTool();
providers.add(provider);
provider.setVisible(true);
return provider;
}
/**
* Creates a new comparison between the given set of functions
*
@ -69,11 +77,8 @@ public class FunctionComparisonProviderManager implements FunctionComparisonProv
if (functions.isEmpty()) {
return null;
}
FunctionComparisonProvider provider = new MultiFunctionComparisonProvider(plugin);
provider.addToTool();
FunctionComparisonProvider provider = createProvider();
provider.getModel().compareFunctions(functions);
providers.add(provider);
provider.setVisible(true);
return provider;
}
@ -85,7 +90,7 @@ public class FunctionComparisonProviderManager implements FunctionComparisonProv
* @return the new comparison provider
*/
public FunctionComparisonProvider compareFunctions(Function source,
Function target) {
Function target) {
FunctionComparisonProvider provider = new MultiFunctionComparisonProvider(plugin);
provider.addToTool();
provider.getModel().compareFunctions(source, target);
@ -118,7 +123,7 @@ public class FunctionComparisonProviderManager implements FunctionComparisonProv
* @param provider the provider to add the functions to
*/
public void compareFunctions(Function source, Function target,
FunctionComparisonProvider provider) {
FunctionComparisonProvider provider) {
if (provider == null) {
return;
}
@ -221,4 +226,5 @@ public class FunctionComparisonProviderManager implements FunctionComparisonProv
}
}
}
}

View File

@ -67,7 +67,7 @@ public class MultiFunctionComparisonPanel extends FunctionComparisonPanel {
* @param tool the active plugin tool
*/
public MultiFunctionComparisonPanel(MultiFunctionComparisonProvider provider,
PluginTool tool) {
PluginTool tool) {
super(provider, tool, null, null);
JPanel choicePanel = new JPanel(new GridLayout(1, 2));
@ -79,6 +79,7 @@ public class MultiFunctionComparisonPanel extends FunctionComparisonPanel {
// comparison panel because the name of the function/data being shown
// is already visible in the combo box
getComparisonPanels().forEach(p -> p.setShowTitles(false));
setPreferredSize(new Dimension(1200, 600));
}
/**
@ -311,7 +312,7 @@ public class MultiFunctionComparisonPanel extends FunctionComparisonPanel {
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index,
boolean isSelected, boolean cellHasFocus) {
boolean isSelected, boolean cellHasFocus) {
if (value == null) {
// It's possible during a close program operation to have this

View File

@ -26,13 +26,15 @@ import ghidra.framework.plugintool.Plugin;
*/
public class MultiFunctionComparisonProvider extends FunctionComparisonProvider {
private DockingAction openFunctionTableAction;
/**
* Constructor
*
* @param plugin the parent plugin
*/
public MultiFunctionComparisonProvider(Plugin plugin) {
super(plugin, "functioncomparisonprovider", plugin.getName());
protected MultiFunctionComparisonProvider(Plugin plugin) {
super(plugin, "Functions Comparison Provider", plugin.getName());
}
@Override
@ -55,7 +57,7 @@ public class MultiFunctionComparisonProvider extends FunctionComparisonProvider
DockingAction nextFunctionAction = new NextFunctionAction(this);
DockingAction previousFunctionAction = new PreviousFunctionAction(this);
DockingAction removeFunctionsAction = new RemoveFunctionsAction(this);
DockingAction openFunctionTableAction = getOpenFunctionTableAction();
openFunctionTableAction = getOpenFunctionTableAction();
DockingAction navigateToAction = new NavigateToFunctionAction(this);
addLocalAction(nextFunctionAction);
@ -75,4 +77,9 @@ public class MultiFunctionComparisonProvider extends FunctionComparisonProvider
protected DockingAction getOpenFunctionTableAction() {
return new OpenFunctionTableAction(tool, this);
}
@Override
public void removeAddFunctionsAction() {
removeLocalAction(openFunctionTableAction);
}
}

View File

@ -22,8 +22,7 @@ import docking.action.MenuData;
import docking.widgets.fieldpanel.internal.FieldPanelCoordinator;
import ghidra.app.util.viewer.util.CodeComparisonPanel;
import ghidra.app.util.viewer.util.CodeComparisonPanelActionContext;
import ghidra.program.model.listing.Function;
import ghidra.program.model.listing.Program;
import ghidra.program.model.listing.*;
import ghidra.program.util.FunctionUtility;
import ghidra.util.*;
import ghidra.util.exception.DuplicateNameException;
@ -109,7 +108,7 @@ public abstract class AbstractApplyFunctionSignatureAction extends DockingAction
* @return true if the non-focused panel is read-only
*/
protected boolean hasReadOnlyNonFocusedSide(
CodeComparisonPanel<? extends FieldPanelCoordinator> codeComparisonPanel) {
CodeComparisonPanel<? extends FieldPanelCoordinator> codeComparisonPanel) {
Function leftFunction = codeComparisonPanel.getLeftFunction();
Function rightFunction = codeComparisonPanel.getRightFunction();
@ -134,7 +133,7 @@ public abstract class AbstractApplyFunctionSignatureAction extends DockingAction
* @return true if the operation was successful
*/
protected boolean updateFunction(ComponentProvider provider, Function destinationFunction,
Function sourceFunction) {
Function sourceFunction) {
Program program = destinationFunction.getProgram();
int txID = program.startTransaction(ACTION_NAME);
@ -144,7 +143,7 @@ public abstract class AbstractApplyFunctionSignatureAction extends DockingAction
FunctionUtility.updateFunction(destinationFunction, sourceFunction);
commit = true;
}
catch (InvalidInputException | DuplicateNameException e) {
catch (InvalidInputException | DuplicateNameException | CircularDependencyException e) {
String message = "Couldn't apply the function signature from " +
sourceFunction.getName() + " to " + destinationFunction.getName() + " @ " +
destinationFunction.getEntryPoint().toString() + ". " + e.getMessage();

View File

@ -39,6 +39,13 @@ import ghidra.program.model.listing.Function;
@ServiceInfo(defaultProvider = FunctionComparisonPlugin.class)
public interface FunctionComparisonService {
/**
* Creates a comparison provider that allows comparisons between a functions.
*
* @return the new comparison provider
*/
public FunctionComparisonProvider createFunctionComparisonProvider();
/**
* Creates a comparison between a set of functions, where each function
* in the list can be compared against any other.
@ -84,7 +91,7 @@ public interface FunctionComparisonService {
* @param provider the provider to add the comparisons to
*/
public void compareFunctions(Set<Function> functions,
FunctionComparisonProvider provider);
FunctionComparisonProvider provider);
/**
* Creates a comparison between two functions and adds it to a given
@ -99,7 +106,7 @@ public interface FunctionComparisonService {
* @param provider the provider to add the comparison to
*/
public void compareFunctions(Function source, Function target,
FunctionComparisonProvider provider);
FunctionComparisonProvider provider);
/**
* Removes a given function from all comparisons across all comparison
@ -132,5 +139,5 @@ public interface FunctionComparisonService {
* @param listener the listener to remove
*/
public void removeFunctionComparisonProviderListener(
ComponentProviderActivationListener listener);
ComponentProviderActivationListener listener);
}

View File

@ -39,6 +39,24 @@ public class FunctionUtility {
private FunctionUtility() {
}
/**
* Applies the name and namespace from source function to the target function
* @param target the function whose name is being changed.
* @param source the source function from which to get name and namespace. The source function
* can be from another program.
* @throws DuplicateNameException if creating a namespace would create a invalid duplicate name
* @throws InvalidInputException if the name or namespace from the source function is invalid
* @throws CircularDependencyException if this function is an ancestor of
* the target namespace. This probably can't happen
*/
public static void applyNameAndNamespace(Function target, Function source)
throws DuplicateNameException, InvalidInputException, CircularDependencyException {
String name = source.getName();
Namespace targetNamespace = getOrCreateSourceNamespaceInTarget(target, source);
Symbol symbol = target.getSymbol();
symbol.setNameAndNamespace(name, targetNamespace, source.getSymbol().getSource());
}
/**
* Updates the destination function so its signature will match the source function's signature
* as closely as possible. This method will try to create conflict names if necessary for the
@ -50,16 +68,17 @@ public class FunctionUtility {
* @throws DuplicateNameException This shouldn't happen since it will try to create conflict
* names for the function and its variables if necessary. Otherwise, this would be because
* the function's name or a variable name already exists.
* @throws CircularDependencyException if namespaces have circular references
*/
public static void updateFunction(Function destinationFunction, Function sourceFunction)
throws InvalidInputException, DuplicateNameException {
throws InvalidInputException, DuplicateNameException, CircularDependencyException {
updateFunctionExceptName(destinationFunction, sourceFunction);
setFunctionName(destinationFunction, sourceFunction);
applyNameAndNamespace(destinationFunction, sourceFunction);
}
private static void updateFunctionExceptName(Function destinationFunction,
Function sourceFunction) throws InvalidInputException, DuplicateNameException {
Function sourceFunction) throws InvalidInputException, DuplicateNameException {
Program sourceProgram = sourceFunction.getProgram();
Program destinationProgram = destinationFunction.getProgram();
@ -78,7 +97,7 @@ public class FunctionUtility {
setUniqueParameterNames(destinationFunction, newParams);
destinationFunction.updateFunction(callingConventionName, returnValue, newParams,
useCustomStorage ? FunctionUpdateType.CUSTOM_STORAGE
: FunctionUpdateType.DYNAMIC_STORAGE_ALL_PARAMS,
: FunctionUpdateType.DYNAMIC_STORAGE_ALL_PARAMS,
force, source);
applyInline(destinationFunction, sourceFunction);
applyNoReturn(destinationFunction, sourceFunction);
@ -98,7 +117,7 @@ public class FunctionUtility {
* @throws DuplicateNameException
*/
public static void setUniqueParameterNames(Function function, List<Parameter> parameters)
throws DuplicateNameException, InvalidInputException {
throws DuplicateNameException, InvalidInputException {
SymbolTable symbolTable = function.getProgram().getSymbolTable();
// Create a set containing all the unique parameter names determined so far so they can
@ -127,7 +146,7 @@ public class FunctionUtility {
* @return a unique parameter name
*/
private static String getUniqueReplacementParameterName(SymbolTable symbolTable,
Function function, String name, Set<String> namesNotToBeUsed) {
Function function, String name, Set<String> namesNotToBeUsed) {
if (name == null || SymbolUtilities.isDefaultParameterName(name)) {
return name;
}
@ -147,7 +166,7 @@ public class FunctionUtility {
* that doesn't conflict with any in the set of names not to be used.
*/
private static String getUniqueNameIgnoringCurrentParameters(SymbolTable symbolTable,
Function function, String baseName, Set<String> namesNotToBeUsed) {
Function function, String baseName, Set<String> namesNotToBeUsed) {
String name = baseName;
if (name != null) {
// establish unique name
@ -192,7 +211,7 @@ public class FunctionUtility {
}
private static void applyCallFixup(Function destinationFunction, Function sourceFunction,
boolean sameLanguage) {
boolean sameLanguage) {
String sourceCallFixup = sourceFunction.getCallFixup();
String destCallFixup = destinationFunction.getCallFixup();
if (SystemUtilities.isEqual(destCallFixup, sourceCallFixup)) {
@ -214,7 +233,7 @@ public class FunctionUtility {
* already exists.
*/
static void setFunctionName(Function destinationFunction, Function sourceFunction)
throws InvalidInputException, DuplicateNameException {
throws InvalidInputException, DuplicateNameException {
String sourceName = sourceFunction.getName();
Address sourceEntryPoint = sourceFunction.getEntryPoint();
Namespace sourceNamespace = sourceFunction.getParentNamespace();
@ -288,13 +307,13 @@ public class FunctionUtility {
}
private static String determineCallingConventionName(Function destinationFunction,
Function sourceFunction, boolean sameLanguageAndCompilerSpec) {
Function sourceFunction, boolean sameLanguageAndCompilerSpec) {
return sameLanguageAndCompilerSpec ? sourceFunction.getCallingConventionName()
: destinationFunction.getCallingConventionName();
: destinationFunction.getCallingConventionName();
}
private static boolean determineCustomStorageUse(Function destinationFunction,
Function sourceFunction, boolean sameLanguage) {
Function sourceFunction, boolean sameLanguage) {
boolean useCustomStorage = sourceFunction.hasCustomVariableStorage();
if (useCustomStorage) {
return sameLanguage; // only use for same language.
@ -303,19 +322,19 @@ public class FunctionUtility {
}
private static Variable determineReturnValue(Function destinationFunction,
Function sourceFunction, boolean useCustomStorage) throws InvalidInputException {
Function sourceFunction, boolean useCustomStorage) throws InvalidInputException {
Program destinationProgram = destinationFunction.getProgram();
Parameter sourceReturn = sourceFunction.getReturn();
DataType dataType = sourceReturn.getDataType();
VariableStorage storage =
(useCustomStorage) ? sourceReturn.getVariableStorage().clone(destinationProgram)
: VariableStorage.UNASSIGNED_STORAGE;
: VariableStorage.UNASSIGNED_STORAGE;
Parameter returnValue = new ReturnParameterImpl(dataType, storage, destinationProgram);
return returnValue;
}
private static List<Parameter> determineParameters(Function destinationFunction,
Function sourceFunction, boolean useCustomStorage) throws InvalidInputException {
Function sourceFunction, boolean useCustomStorage) throws InvalidInputException {
Program destinationProgram = destinationFunction.getProgram();
List<Parameter> parameters = new ArrayList<>();
Parameter[] sourceParameters = sourceFunction.getParameters();
@ -324,7 +343,7 @@ public class FunctionUtility {
DataType dataType = sourceParameter.getDataType();
VariableStorage storage =
(useCustomStorage) ? sourceParameter.getVariableStorage().clone(destinationProgram)
: VariableStorage.UNASSIGNED_STORAGE;
: VariableStorage.UNASSIGNED_STORAGE;
SourceType source = sourceParameter.getSource();
Parameter parameter =
new ParameterImpl(name, dataType, storage, destinationProgram, source);
@ -378,4 +397,43 @@ public class FunctionUtility {
}
return HTMLUtilities.wrapAsHTML(buf.toString());
}
private static Namespace getOrCreateSourceNamespaceInTarget(Function target, Function source)
throws DuplicateNameException, InvalidInputException {
Namespace targetNamespace = target.getParentNamespace();
Namespace sourceNamespace = source.getParentNamespace();
if (targetNamespace.getName(true).equals(sourceNamespace.getName(true))) {
return targetNamespace;
}
return getOrCreateTargetNamespace(target.getProgram(), sourceNamespace);
}
private static Namespace getOrCreateTargetNamespace(Program program, Namespace otherNamespace)
throws DuplicateNameException, InvalidInputException {
if (otherNamespace.isGlobal()) {
return program.getGlobalNamespace();
}
Namespace otherParent = otherNamespace.getParentNamespace();
Namespace parent = getOrCreateTargetNamespace(program, otherParent);
SymbolTable symbolTable = program.getSymbolTable();
String otherName = otherNamespace.getName();
Namespace namespace = symbolTable.getNamespace(otherName, parent);
if (namespace != null) {
return namespace;
}
// not there, we need to create it.
SourceType source = otherNamespace.getSymbol().getSource();
if (otherNamespace instanceof GhidraClass) {
return symbolTable.createClass(parent, otherName, source);
}
else if (otherNamespace instanceof Library) {
return symbolTable.createExternalLibrary(otherName, source);
}
return symbolTable.createNameSpace(parent, otherName, source);
}
}

View File

@ -18,6 +18,9 @@ package ghidra.util.table;
import docking.widgets.table.*;
import docking.widgets.table.threaded.GThreadedTablePanel;
import docking.widgets.table.threaded.ThreadedTableModel;
import ghidra.app.nav.Navigatable;
import ghidra.app.services.GoToService;
import ghidra.framework.plugintool.ServiceProvider;
public class GhidraFilterTable<ROW_OBJECT> extends GFilterTable<ROW_OBJECT> {
@ -33,15 +36,40 @@ public class GhidraFilterTable<ROW_OBJECT> extends GFilterTable<ROW_OBJECT> {
@Override
protected GTableFilterPanel<ROW_OBJECT> createTableFilterPanel(GTable gTable,
RowObjectTableModel<ROW_OBJECT> tableModel) {
RowObjectTableModel<ROW_OBJECT> tableModel) {
return new GhidraTableFilterPanel<ROW_OBJECT>(gTable, tableModel);
}
@Override
protected GThreadedTablePanel<ROW_OBJECT> createThreadedTablePanel(
ThreadedTableModel<ROW_OBJECT, ?> threadedModel) {
ThreadedTableModel<ROW_OBJECT, ?> threadedModel) {
return new GhidraThreadedTablePanel<ROW_OBJECT>(threadedModel);
}
@Override
public GhidraTable getTable() {
return (GhidraTable) super.getTable();
}
public void installNavigation(GoToService goToService, Navigatable nav) {
getTable().installNavigation(goToService, nav);
}
public void installNavigation(GoToService goToService) {
getTable().installNavigation(goToService, goToService.getDefaultNavigatable());
}
public void installNavigation(ServiceProvider provider) {
getTable().installNavigation(provider);
}
public void removeNavigation() {
getTable().removeNavigation();
}
public void setNavigateOnSelectionEnabled(boolean b) {
getTable().setNavigateOnSelectionEnabled(b);
}
}

View File

@ -45,7 +45,7 @@ import utility.function.Callback;
* all the gui elements to appear in the dialog, then use tool.showDialog() to display your dialog.
*/
public class DialogComponentProvider
implements ActionContextProvider, StatusListener, TaskListener {
implements ActionContextProvider, StatusListener, TaskListener {
private static final Color FG_COLOR_ALERT = new GColor("color.fg.dialog.status.alert");
private static final Color FG_COLOR_ERROR = new GColor("color.fg.dialog.status.error");
@ -134,7 +134,7 @@ public class DialogComponentProvider
* doing so.
*/
protected DialogComponentProvider(String title, boolean modal, boolean includeStatus,
boolean includeButtons, boolean canRunTasks) {
boolean includeButtons, boolean canRunTasks) {
this.modal = modal;
this.title = title;
rootPanel = new JPanel(new BorderLayout()) {
@ -736,7 +736,7 @@ public class DialogComponentProvider
}
protected void showProgressBar(String localTitle, boolean hasProgress, boolean canCancel,
int delay) {
int delay) {
taskMonitorComponent.reset();
Runnable r = () -> {
if (delay <= 0) {
@ -852,7 +852,7 @@ public class DialogComponentProvider
* @see #hideTaskMonitorComponent()
*/
public TaskMonitor showTaskMonitorComponent(String localTitle, boolean hasProgress,
boolean canCancel) {
boolean canCancel) {
showProgressBar(localTitle, hasProgress, canCancel, DEFAULT_DELAY);
return taskMonitorComponent;
}

View File

@ -68,6 +68,7 @@ public class IntegerTextField {
private boolean allowsHexPrefix = true;
private boolean showNumbericDecoration = true;
private BigInteger maxValue;
private BigInteger minValue;
private List<ChangeListener> listeners = new ArrayList<>();
@ -366,6 +367,31 @@ public class IntegerTextField {
}
}
/**
* Sets the minimum allowed value. The minimum must be a positive number. Null indicates that
* there is no minimum value.
* <p>
* If negative values are permitted (see {@link #setAllowNegativeValues(boolean)}) this value
* will establish the minimum limit of the absolute value.
*
* @param minValue the minimum value to allow.
*/
public void setMinValue(BigInteger minValue) {
if (minValue != null && minValue.signum() < 0) {
throw new IllegalArgumentException("Min value must be positive");
}
BigInteger currentValue = getValue();
this.minValue = minValue;
if (minValue != null && !passesMinCheck(currentValue)) {
if (currentValue.signum() < 0) {
setValue(minValue.negate());
}
else {
setValue(minValue);
}
}
}
/**
* Returns the JTextField component that this class manages.
*
@ -492,6 +518,16 @@ public class IntegerTextField {
return value.abs().compareTo(maxValue) <= 0;
}
private boolean passesMinCheck(BigInteger value) {
if (value == null) {
return true;
}
if (minValue == null) {
return true;
}
return value.abs().compareTo(minValue) >= 0;
}
private boolean shouldParseAsHex(String text) {
if (allowsHexPrefix) {
// if allowing "0x" prefix, let the incoming text determine if we should parse as hex
@ -596,7 +632,7 @@ public class IntegerTextField {
if (isNonAllowedNegativeNumber(value)) {
return false;
}
if (passesMaxCheck(value)) {
if (passesMaxCheck(value) && passesMinCheck(value)) {
// When the input is valid, update the hex mode to match how the text was parsed.
// See parseAsHex variable comment above.
isHexMode = parseAsHex;

View File

@ -48,7 +48,7 @@ public interface ClientAuthenticator extends KeyStorePasswordProvider {
* @see ChoiceCallback#setSelectedIndex(int)
* A null is specified if no choice is available (password authenticator determined by server configuration).
* @see AnonymousCallback#setAnonymousAccessRequested(boolean)
* @return
* @return true if password provided, false if entry cancelled
*/
public boolean processPasswordCallbacks(String title, String serverType, String serverName,
NameCallback nameCb, PasswordCallback passCb, ChoiceCallback choiceCb,

View File

@ -45,12 +45,17 @@ public class DefaultClientAuthenticator extends PopupKeyStorePasswordProvider
prompt = "Password:";
}
PasswordCallback passCb = new PasswordCallback(prompt, false);
ServerPasswordPrompt pp = new ServerPasswordPrompt("Connection Authentication",
"Server", getRequestingHost(), nameCb, passCb, null, null, null);
SystemUtilities.runSwingNow(pp);
if (pp.okWasPressed()) {
return new PasswordAuthentication(nameCb != null ? nameCb.getName() : null,
passCb.getPassword());
try {
ServerPasswordPrompt pp = new ServerPasswordPrompt("Connection Authentication",
"Server", getRequestingHost(), nameCb, passCb, null, null, null);
SystemUtilities.runSwingNow(pp);
if (pp.okWasPressed()) {
return new PasswordAuthentication(nameCb != null ? nameCb.getName() : null,
passCb.getPassword());
}
}
finally {
passCb.clearPassword();
}
return null;
}

View File

@ -27,7 +27,7 @@ import ghidra.util.exception.AssertException;
public class LoggingInitialization {
private static final String LOG4J2_CONFIGURATION_PROPERTY = "log4j.configurationFile";
public static final String LOG4J2_CONFIGURATION_PROPERTY = "log4j.configurationFile";
private static final String PRODUCTION_LOGGING_CONFIGURATION_FILE = "generic.log4j.xml";
private static final String DEVELOPMENT_LOGGING_CONFIGURATION_FILE = "generic.log4jdev.xml";

View File

@ -65,8 +65,8 @@ public class DefaultLocalGhidraProtocolConnector extends GhidraProtocolConnector
}
@Override
protected String parseRepositoryName() throws MalformedURLException {
return null;
public String getRepositoryName() {
return localStorageLocator.getName();
}
@Override

View File

@ -35,7 +35,7 @@ public abstract class GhidraProtocolConnector {
protected final URL url;
protected final String repositoryName;
protected String repositoryName; // only valid for server repository
protected final String itemPath; // trailing "/" signifies explicit folder path
protected String folderPath;
@ -56,7 +56,7 @@ public abstract class GhidraProtocolConnector {
checkProtocol();
checkUserInfo();
checkHostInfo();
this.repositoryName = parseRepositoryName();
this.repositoryName = GhidraURL.isServerRepositoryURL(url) ? parseRepositoryName() : null;
this.itemPath = parseItemPath();
}
@ -105,7 +105,7 @@ public abstract class GhidraProtocolConnector {
* @return repository name or null if not specified
* @throws MalformedURLException if URL is invalid
*/
protected String parseRepositoryName() throws MalformedURLException {
private String parseRepositoryName() throws MalformedURLException {
String path = url.getPath();

View File

@ -37,6 +37,9 @@ public class GhidraURL {
private static final String PROTOCOL_URL_START = PROTOCOL + ":/";
private static Pattern IS_REMOTE_URL_PATTERN =
Pattern.compile("^" + PROTOCOL_URL_START + "/[^/].*"); // e.g., ghidra://path
private static Pattern IS_LOCAL_URL_PATTERN =
Pattern.compile("^" + PROTOCOL_URL_START + "[^/].*"); // e.g., ghidra:/path
@ -68,6 +71,28 @@ public class GhidraURL {
return str != null && str.startsWith(PROTOCOL_URL_START);
}
/**
* Determine if URL string uses a local format (e.g., {@code ghidra:/path...}).
* Extensive validation is not performed. This method is intended to differentiate
* from a server URL only.
* @param str URL string
* @return true if string appears to be local Ghidra URL, else false
*/
public static boolean isLocalGhidraURL(String str) {
return IS_LOCAL_URL_PATTERN.matcher(str).matches();
}
/**
* Determine if URL string uses a remote server format (e.g., {@code ghidra://host...}).
* Extensive validation is not performed. This method is intended to differentiate
* from a local URL only.
* @param str URL string
* @return true if string appears to be remote server Ghidra URL, else false
*/
public static boolean isServerURL(String str) {
return IS_REMOTE_URL_PATTERN.matcher(str).matches();
}
/**
* Determine if the specified URL is a local project URL.
* No checking is performed as to the existence of the project.
@ -76,7 +101,7 @@ public class GhidraURL {
* project (ghidra:/path/projectName...)
*/
public static boolean isLocalProjectURL(URL url) {
return IS_LOCAL_URL_PATTERN.matcher(url.toExternalForm()).matches();
return isLocalGhidraURL(url.toExternalForm());
}
/**
@ -92,7 +117,7 @@ public class GhidraURL {
}
String path = localProjectURL.getPath(); // assume path always starts with '/'
// if (path.indexOf(":/") == 2 && Character.isLetter(path.charAt(1))) { // check for drive letter after leading '/'
// if (Platform.CURRENT_PLATFORM.getOperatingSystem() == OperatingSystem.WINDOWS) {
// path = path.substring(1); // Strip-off leading '/'
@ -105,7 +130,7 @@ public class GhidraURL {
int index = path.lastIndexOf('/');
String dirPath = index != 0 ? path.substring(0, index) : "/";
String name = path.substring(index + 1);
if (name.length() == 0) {
return null;
@ -177,7 +202,7 @@ public class GhidraURL {
}
/**
* Determine if the specified URL is any type of server URL.
* Determine if the specified URL is any type of supported server Ghidra URL.
* No checking is performed as to the existence of the server or repository.
* @param url ghidra URL
* @return true if specified URL refers to a Ghidra server
@ -424,7 +449,7 @@ public class GhidraURL {
public static URL makeURL(String dirPath, String projectName) {
return makeURL(dirPath, projectName, null, null);
}
/**
* Create a URL which refers to a local Ghidra project
* @param projectLocator absolute project location
@ -434,7 +459,7 @@ public class GhidraURL {
public static URL makeURL(ProjectLocator projectLocator) {
return makeURL(projectLocator, null, null);
}
/**
* Create a URL which refers to a local Ghidra project with optional project file and ref
* @param projectLocation absolute path of project location directory

View File

@ -473,6 +473,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
pl.getString(PREFERRED_ROOT_NAMESPACE_CATEGORY_PROPERTY, null));
}
@Override
protected boolean propertyChanged(String propertyName, Object oldValue, Object newValue) {
if (propertyName.equals(PREFERRED_ROOT_NAMESPACE_CATEGORY_PROPERTY_PATHNAME)) {
String path = (String) newValue;
@ -2028,7 +2029,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
Msg.info(this,
"Updating language version for Program " + getName() + ": " +
language.getLanguageDescription() + " (Version " +
language.getVersion() + "." + language.getMinorVersion());
language.getVersion() + "." + language.getMinorVersion() + ")");
}
if (newCompilerSpecID != null) {

View File

@ -0,0 +1,197 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="generator" content="pandoc">
<title>Mozilla Public License, version 2.0</title>
<style>
body{
font-family:serif;
font-size:110%;
-moz-hyphens:auto;
hyphens:auto;
margin-left:auto;
margin-right:auto;
max-width:30em;
text-align:justify
}
h1,h2,h3{
font-variant:small-caps
}
h1{
font-size:160%;
-moz-hyphens:none;
hyphens:none;
text-align:center
}
h2{
font-size:140%
}
h2,h3{
-moz-hyphens:none;
hyphens:none;
text-align:left
}
h3{
font-size:120%
}
blockquote{
-moz-hyphens:none;
hyphens:none;
text-align:left
}
code{
font-family:mono,monospace
}
em{
background:#fefd80;
border:30px solid #fefd80;
float:left;
font-style:normal;
line-height:1.25em;
margin:-10px 10px 10px
}
dt{
font-size:100%;
font-weight:700
}
</style>
</head>
<body>
<div>
<h2 style="text-align:center">H2 Database Source Distribution</h2>
<p>The H2 source distribution which corresponds to the jar file contained with this distribution
can be found on the <a href="https://github.com/h2database/h2database/releases">h2database
release site</a>.
</div>
<h1 id="mozilla-public-license-version-2.0">Mozilla Public License<br>Version 2.0</h1>
<h2 id="definitions">1. Definitions</h2>
<dl>
<dt>1.1. “Contributor”</dt>
<dd><p>means each individual or legal entity that creates, contributes to the creation of, or owns Covered Software.</p>
</dd>
<dt>1.2. “Contributor Version”</dt>
<dd><p>means the combination of the Contributions of others (if any) used by a Contributor and that particular Contributors Contribution.</p>
</dd>
<dt>1.3. “Contribution”</dt>
<dd><p>means Covered Software of a particular Contributor.</p>
</dd>
<dt>1.4. “Covered Software”</dt>
<dd><p>means Source Code Form to which the initial Contributor has attached the notice in Exhibit A, the Executable Form of such Source Code Form, and Modifications of such Source Code Form, in each case including portions thereof.</p>
</dd>
<dt>1.5. “Incompatible With Secondary Licenses”</dt>
<dd><p>means</p>
<ol type="a">
<li><p>that the initial Contributor has attached the notice described in Exhibit B to the Covered Software; or</p></li>
<li><p>that the Covered Software was made available under the terms of version 1.1 or earlier of the License, but not also under the terms of a Secondary License.</p></li>
</ol>
</dd>
<dt>1.6. “Executable Form”</dt>
<dd><p>means any form of the work other than Source Code Form.</p>
</dd>
<dt>1.7. “Larger Work”</dt>
<dd><p>means a work that combines Covered Software with other material, in a separate file or files, that is not Covered Software.</p>
</dd>
<dt>1.8. “License”</dt>
<dd><p>means this document.</p>
</dd>
<dt>1.9. “Licensable”</dt>
<dd><p>means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently, any and all of the rights conveyed by this License.</p>
</dd>
<dt>1.10. “Modifications”</dt>
<dd><p>means any of the following:</p>
<ol type="a">
<li><p>any file in Source Code Form that results from an addition to, deletion from, or modification of the contents of Covered Software; or</p></li>
<li><p>any new file in Source Code Form that contains any Covered Software.</p></li>
</ol>
</dd>
<dt>1.11. “Patent Claims” of a Contributor</dt>
<dd><p>means any patent claim(s), including without limitation, method, process, and apparatus claims, in any patent Licensable by such Contributor that would be infringed, but for the grant of the License, by the making, using, selling, offering for sale, having made, import, or transfer of either its Contributions or its Contributor Version.</p>
</dd>
<dt>1.12. “Secondary License”</dt>
<dd><p>means either the GNU General Public License, Version 2.0, the GNU Lesser General Public License, Version 2.1, the GNU Affero General Public License, Version 3.0, or any later versions of those licenses.</p>
</dd>
<dt>1.13. “Source Code Form”</dt>
<dd><p>means the form of the work preferred for making modifications.</p>
</dd>
<dt>1.14. “You” (or “Your”)</dt>
<dd><p>means an individual or a legal entity exercising rights under this License. For legal entities, “You” includes any entity that controls, is controlled by, or is under common control with You. For purposes of this definition, “control” means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity.</p>
</dd>
</dl>
<h2 id="license-grants-and-conditions">2. License Grants and Conditions</h2>
<h3 id="grants">2.1. Grants</h3>
<p>Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license:</p>
<ol type="a">
<li><p>under intellectual property rights (other than patent or trademark) Licensable by such Contributor to use, reproduce, make available, modify, display, perform, distribute, and otherwise exploit its Contributions, either on an unmodified basis, with Modifications, or as part of a Larger Work; and</p></li>
<li><p>under Patent Claims of such Contributor to make, use, sell, offer for sale, have made, import, and otherwise transfer either its Contributions or its Contributor Version.</p></li>
</ol>
<h3 id="effective-date">2.2. Effective Date</h3>
<p>The licenses granted in Section&nbsp;2.1 with respect to any Contribution become effective for each Contribution on the date the Contributor first distributes such Contribution.</p>
<h3 id="limitations-on-grant-scope">2.3. Limitations on Grant Scope</h3>
<p>The licenses granted in this Section&nbsp;2 are the only rights granted under this License. No additional rights or licenses will be implied from the distribution or licensing of Covered Software under this License. Notwithstanding Section&nbsp;2.1(b) above, no patent license is granted by a Contributor:</p>
<ol type="a">
<li><p>for any code that a Contributor has removed from Covered Software; or</p></li>
<li><p>for infringements caused by: (i) Your and any other third partys modifications of Covered Software, or (ii) the combination of its Contributions with other software (except as part of its Contributor Version); or</p></li>
<li><p>under Patent Claims infringed by Covered Software in the absence of its Contributions.</p></li>
</ol>
<p>This License does not grant any rights in the trademarks, service marks, or logos of any Contributor (except as may be necessary to comply with the notice requirements in Section&nbsp;3.4).</p>
<h3 id="subsequent-licenses">2.4. Subsequent Licenses</h3>
<p>No Contributor makes additional grants as a result of Your choice to distribute the Covered Software under a subsequent version of this License (see Section&nbsp;10.2) or under the terms of a Secondary License (if permitted under the terms of Section&nbsp;3.3).</p>
<h3 id="representation">2.5. Representation</h3>
<p>Each Contributor represents that the Contributor believes its Contributions are its original creation(s) or it has sufficient rights to grant the rights to its Contributions conveyed by this License.</p>
<h3 id="fair-use">2.6. Fair Use</h3>
<p>This License is not intended to limit any rights You have under applicable copyright doctrines of fair use, fair dealing, or other equivalents.</p>
<h3 id="conditions">2.7. Conditions</h3>
<p>Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in Section&nbsp;2.1.</p>
<h2 id="responsibilities">3. Responsibilities</h2>
<h3 id="distribution-of-source-form">3.1. Distribution of Source Form</h3>
<p>All distribution of Covered Software in Source Code Form, including any Modifications that You create or to which You contribute, must be under the terms of this License. You must inform recipients that the Source Code Form of the Covered Software is governed by the terms of this License, and how they can obtain a copy of this License. You may not attempt to alter or restrict the recipients rights in the Source Code Form.</p>
<h3 id="distribution-of-executable-form">3.2. Distribution of Executable Form</h3>
<p>If You distribute Covered Software in Executable Form then:</p>
<ol type="a">
<li><p>such Covered Software must also be made available in Source Code Form, as described in Section&nbsp;3.1, and You must inform recipients of the Executable Form how they can obtain a copy of such Source Code Form by reasonable means in a timely manner, at a charge no more than the cost of distribution to the recipient; and</p></li>
<li><p>You may distribute such Executable Form under the terms of this License, or sublicense it under different terms, provided that the license for the Executable Form does not attempt to limit or alter the recipients rights in the Source Code Form under this License.</p></li>
</ol>
<h3 id="distribution-of-a-larger-work">3.3. Distribution of a Larger Work</h3>
<p>You may create and distribute a Larger Work under terms of Your choice, provided that You also comply with the requirements of this License for the Covered Software. If the Larger Work is a combination of Covered Software with a work governed by one or more Secondary Licenses, and the Covered Software is not Incompatible With Secondary Licenses, this License permits You to additionally distribute such Covered Software under the terms of such Secondary License(s), so that the recipient of the Larger Work may, at their option, further distribute the Covered Software under the terms of either this License or such Secondary License(s).</p>
<h3 id="notices">3.4. Notices</h3>
<p>You may not remove or alter the substance of any license notices (including copyright notices, patent notices, disclaimers of warranty, or limitations of liability) contained within the Source Code Form of the Covered Software, except that You may alter any license notices to the extent required to remedy known factual inaccuracies.</p>
<h3 id="application-of-additional-terms">3.5. Application of Additional Terms</h3>
<p>You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, You may do so only on Your own behalf, and not on behalf of any Contributor. You must make it absolutely clear that any such warranty, support, indemnity, or liability obligation is offered by You alone, and You hereby agree to indemnify every Contributor for any liability incurred by such Contributor as a result of warranty, support, indemnity or liability terms You offer. You may include additional disclaimers of warranty and limitations of liability specific to any jurisdiction.</p>
<h2 id="inability-to-comply-due-to-statute-or-regulation">4. Inability to Comply Due to Statute or Regulation</h2>
<p>If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Software due to statute, judicial order, or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be placed in a text file included with all distributions of the Covered Software under this License. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it.</p>
<h2 id="termination">5. Termination</h2>
<p>5.1. The rights granted under this License will terminate automatically if You fail to comply with any of its terms. However, if You become compliant, then the rights granted under this License from a particular Contributor are reinstated (a) provisionally, unless and until such Contributor explicitly and finally terminates Your grants, and (b) on an ongoing basis, if such Contributor fails to notify You of the non-compliance by some reasonable means prior to 60 days after You have come back into compliance. Moreover, Your grants from a particular Contributor are reinstated on an ongoing basis if such Contributor notifies You of the non-compliance by some reasonable means, this is the first time You have received notice of non-compliance with this License from such Contributor, and You become compliant prior to 30 days after Your receipt of the notice.</p>
<p>5.2. If You initiate litigation against any entity by asserting a patent infringement claim (excluding declaratory judgment actions, counter-claims, and cross-claims) alleging that a Contributor Version directly or indirectly infringes any patent, then the rights granted to You by any and all Contributors for the Covered Software under Section&nbsp;2.1 of this License shall terminate.</p>
<p>5.3. In the event of termination under Sections&nbsp;5.1 or 5.2 above, all end user license agreements (excluding distributors and resellers) which have been validly granted by You or Your distributors under this License prior to termination shall survive termination.</p>
<h2 id="disclaimer-of-warranty">6. Disclaimer of Warranty</h2>
<p><em>Covered Software is provided under this License on an “as is” basis, without warranty of any kind, either expressed, implied, or statutory, including, without limitation, warranties that the Covered Software is free of defects, merchantable, fit for a particular purpose or non-infringing. The entire risk as to the quality and performance of the Covered Software is with You. Should any Covered Software prove defective in any respect, You (not any Contributor) assume the cost of any necessary servicing, repair, or correction. This disclaimer of warranty constitutes an essential part of this License. No use of any Covered Software is authorized under this License except under this disclaimer.</em></p>
<h2 id="limitation-of-liability">7. Limitation of Liability</h2>
<p><em>Under no circumstances and under no legal theory, whether tort (including negligence), contract, or otherwise, shall any Contributor, or anyone who distributes Covered Software as permitted above, be liable to You for any direct, indirect, special, incidental, or consequential damages of any character including, without limitation, damages for lost profits, loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses, even if such party shall have been informed of the possibility of such damages. This limitation of liability shall not apply to liability for death or personal injury resulting from such partys negligence to the extent applicable law prohibits such limitation. Some jurisdictions do not allow the exclusion or limitation of incidental or consequential damages, so this exclusion and limitation may not apply to You.</em></p>
<h2 id="litigation">8. Litigation</h2>
<p>Any litigation relating to this License may be brought only in the courts of a jurisdiction where the defendant maintains its principal place of business and such litigation shall be governed by laws of that jurisdiction, without reference to its conflict-of-law provisions. Nothing in this Section shall prevent a partys ability to bring cross-claims or counter-claims.</p>
<h2 id="miscellaneous">9. Miscellaneous</h2>
<p>This License represents the complete agreement concerning the subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not be used to construe this License against a Contributor.</p>
<h2 id="versions-of-the-license">10. Versions of the License</h2>
<h3 id="new-versions">10.1. New Versions</h3>
<p>Mozilla Foundation is the license steward. Except as provided in Section&nbsp;10.3, no one other than the license steward has the right to modify or publish new versions of this License. Each version will be given a distinguishing version number.</p>
<h3 id="effect-of-new-versions">10.2. Effect of New Versions</h3>
<p>You may distribute the Covered Software under the terms of the version of the License under which You originally received the Covered Software, or under the terms of any subsequent version published by the license steward.</p>
<h3 id="modified-versions">10.3. Modified Versions</h3>
<p>If you create software not governed by this License, and you want to create a new license for such software, you may create and use a modified version of this License if you rename the license and remove any references to the name of the license steward (except to note that such modified license differs from this License).</p>
<h3 id="distributing-source-code-form-that-is-incompatible-with-secondary-licenses">10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses</h3>
<p>If You choose to distribute Source Code Form that is Incompatible With Secondary Licenses under the terms of this version of the License, the notice described in Exhibit B of this License must be attached.</p>
<h2 id="exhibit-a---source-code-form-license-notice">Exhibit A - Source Code Form License Notice</h2>
<blockquote>
<p>This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.</p>
</blockquote>
<p>If it is not possible or desirable to put the notice in a particular file, then You may include the notice in a location (such as a LICENSE file in a relevant directory) where a recipient would be likely to look for such a notice.</p>
<p>You may add additional accurate notices of copyright ownership.</p>
<h2 id="exhibit-b---incompatible-with-secondary-licenses-notice">Exhibit B - “Incompatible With Secondary Licenses” Notice</h2>
<blockquote>
<p>This Source Code Form is “Incompatible With Secondary Licenses”, as defined by the Mozilla Public License, v. 2.0.</p>
</blockquote>
</body>
</html>

View File

@ -15,6 +15,7 @@ Crystal_Clear_Icons_-_LGPL_2.1.txt||LICENSE||||END|
FAMFAMFAM_Icons_-_CC_2.5.txt||LICENSE||||END|
FAMFAMFAM_Mini_Icons_-_Public_Domain.txt||LICENSE||||END|
GPL_2_With_Classpath_Exception.txt||LICENSE||||END|
H2_Mozilla_License_2.0.html||LICENSE||||END|
INRIA_License.txt||LICENSE||||END|
JDOM_License.txt||LICENSE||||END|
JSch_License.txt||LICENSE||||END|