mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 09:49:23 +02:00
Merge remote-tracking branch 'origin/patch'
Conflicts: Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerPlugin.java
This commit is contained in:
commit
d428f30a85
2 changed files with 45 additions and 50 deletions
|
@ -455,7 +455,7 @@ public abstract class ByteViewerComponentProvider extends ComponentProviderAdapt
|
||||||
* @param message non-html text to display
|
* @param message non-html text to display
|
||||||
*/
|
*/
|
||||||
void setStatusMessage(String message) {
|
void setStatusMessage(String message) {
|
||||||
plugin.setStatusMessage(message, this);
|
plugin.setStatusMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setEditMode(boolean isEditable) {
|
void setEditMode(boolean isEditable) {
|
||||||
|
|
|
@ -20,7 +20,6 @@ import java.util.*;
|
||||||
import org.jdom.Element;
|
import org.jdom.Element;
|
||||||
|
|
||||||
import docking.ActionContext;
|
import docking.ActionContext;
|
||||||
import docking.ComponentProvider;
|
|
||||||
import docking.action.DockingAction;
|
import docking.action.DockingAction;
|
||||||
import docking.action.ToolBarData;
|
import docking.action.ToolBarData;
|
||||||
import ghidra.app.CorePluginPackage;
|
import ghidra.app.CorePluginPackage;
|
||||||
|
@ -37,6 +36,7 @@ import ghidra.program.util.ProgramLocation;
|
||||||
import ghidra.program.util.ProgramSelection;
|
import ghidra.program.util.ProgramSelection;
|
||||||
import ghidra.util.SystemUtilities;
|
import ghidra.util.SystemUtilities;
|
||||||
import resources.ResourceManager;
|
import resources.ResourceManager;
|
||||||
|
import utility.function.Callback;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Visible Plugin to show ByteBlock data in various formats.
|
* Visible Plugin to show ByteBlock data in various formats.
|
||||||
|
@ -62,7 +62,7 @@ import resources.ResourceManager;
|
||||||
public class ByteViewerPlugin extends Plugin {
|
public class ByteViewerPlugin extends Plugin {
|
||||||
|
|
||||||
private Program currentProgram;
|
private Program currentProgram;
|
||||||
private boolean restoringTransientState;
|
private boolean areEventsDisabled;
|
||||||
private ProgramLocation currentLocation;
|
private ProgramLocation currentLocation;
|
||||||
|
|
||||||
private ProgramByteViewerComponentProvider connectedProvider;
|
private ProgramByteViewerComponentProvider connectedProvider;
|
||||||
|
@ -155,11 +155,12 @@ public class ByteViewerPlugin extends Plugin {
|
||||||
|
|
||||||
public void fireProgramLocationPluginEvent(ProgramByteViewerComponentProvider provider,
|
public void fireProgramLocationPluginEvent(ProgramByteViewerComponentProvider provider,
|
||||||
ProgramLocationPluginEvent event) {
|
ProgramLocationPluginEvent event) {
|
||||||
|
|
||||||
if (SystemUtilities.isEqual(event.getLocation(), currentLocation)) {
|
if (SystemUtilities.isEqual(event.getLocation(), currentLocation)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
currentLocation = event.getLocation();
|
|
||||||
|
|
||||||
|
currentLocation = event.getLocation();
|
||||||
if (provider == connectedProvider) {
|
if (provider == connectedProvider) {
|
||||||
firePluginEvent(event);
|
firePluginEvent(event);
|
||||||
}
|
}
|
||||||
|
@ -190,30 +191,35 @@ public class ByteViewerPlugin extends Plugin {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void readDataState(SaveState saveState) {
|
public void readDataState(SaveState saveState) {
|
||||||
ProgramManager programManagerService = tool.getService(ProgramManager.class);
|
|
||||||
|
|
||||||
connectedProvider.readDataState(saveState);
|
doWithEventsDisabled(() -> {
|
||||||
|
|
||||||
int numDisconnected = saveState.getInt("Num Disconnected", 0);
|
ProgramManager programManagerService = tool.getService(ProgramManager.class);
|
||||||
for (int i = 0; i < numDisconnected; i++) {
|
|
||||||
Element xmlElement = saveState.getXmlElement("Provider" + i);
|
connectedProvider.readDataState(saveState);
|
||||||
SaveState providerSaveState = new SaveState(xmlElement);
|
|
||||||
String programPath = providerSaveState.getString("Program Path", "");
|
int numDisconnected = saveState.getInt("Num Disconnected", 0);
|
||||||
DomainFile file = tool.getProject().getProjectData().getFile(programPath);
|
for (int i = 0; i < numDisconnected; i++) {
|
||||||
if (file == null) {
|
Element xmlElement = saveState.getXmlElement("Provider" + i);
|
||||||
continue;
|
SaveState providerSaveState = new SaveState(xmlElement);
|
||||||
|
String programPath = providerSaveState.getString("Program Path", "");
|
||||||
|
DomainFile file = tool.getProject().getProjectData().getFile(programPath);
|
||||||
|
if (file == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Program program = programManagerService.openProgram(file);
|
||||||
|
if (program != null) {
|
||||||
|
ProgramByteViewerComponentProvider provider =
|
||||||
|
new ProgramByteViewerComponentProvider(tool, this, false);
|
||||||
|
provider.doSetProgram(program);
|
||||||
|
provider.readConfigState(providerSaveState);
|
||||||
|
provider.readDataState(providerSaveState);
|
||||||
|
tool.showComponentProvider(provider, true);
|
||||||
|
addProvider(provider);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Program program = programManagerService.openProgram(file);
|
|
||||||
if (program != null) {
|
});
|
||||||
ProgramByteViewerComponentProvider provider =
|
|
||||||
new ProgramByteViewerComponentProvider(tool, this, false);
|
|
||||||
provider.doSetProgram(program);
|
|
||||||
provider.readConfigState(providerSaveState);
|
|
||||||
provider.readDataState(providerSaveState);
|
|
||||||
tool.showComponentProvider(provider, true);
|
|
||||||
addProvider(provider);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -290,8 +296,6 @@ public class ByteViewerPlugin extends Plugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getTransientState() {
|
public Object getTransientState() {
|
||||||
Object[] state = new Object[2];
|
Object[] state = new Object[2];
|
||||||
|
@ -305,40 +309,31 @@ public class ByteViewerPlugin extends Plugin {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
* @see ghidra.framework.plugintool.Plugin#restoreTransientState(java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void restoreTransientState(Object objectState) {
|
public void restoreTransientState(Object objectState) {
|
||||||
restoringTransientState = true;
|
|
||||||
try {
|
doWithEventsDisabled(() -> {
|
||||||
Object[] state = (Object[]) objectState;
|
Object[] state = (Object[]) objectState;
|
||||||
|
|
||||||
connectedProvider.restoreLocation((SaveState) state[0]);
|
connectedProvider.restoreLocation((SaveState) state[0]);
|
||||||
|
|
||||||
connectedProvider.setSelection((ProgramSelection) state[1]);
|
connectedProvider.setSelection((ProgramSelection) state[1]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doWithEventsDisabled(Callback callback) {
|
||||||
|
areEventsDisabled = true;
|
||||||
|
try {
|
||||||
|
callback.call();
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
restoringTransientState = false;
|
areEventsDisabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
private boolean eventsDisabled() {
|
||||||
// *** package-level methods ***
|
return areEventsDisabled;
|
||||||
/////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
boolean isRestoringTransientState() {
|
|
||||||
return restoringTransientState;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
void setStatusMessage(String msg) {
|
||||||
* Set the status info on the tool.
|
|
||||||
*
|
|
||||||
* @param msg text to display
|
|
||||||
* @param provider not used
|
|
||||||
*/
|
|
||||||
void setStatusMessage(String msg, ComponentProvider provider) {
|
|
||||||
tool.setStatusInfo(msg);
|
tool.setStatusInfo(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,7 +379,7 @@ public class ByteViewerPlugin extends Plugin {
|
||||||
public void updateLocation(ProgramByteViewerComponentProvider provider,
|
public void updateLocation(ProgramByteViewerComponentProvider provider,
|
||||||
ProgramLocationPluginEvent event, boolean export) {
|
ProgramLocationPluginEvent event, boolean export) {
|
||||||
|
|
||||||
if (isRestoringTransientState()) {
|
if (eventsDisabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue