mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 09:49:23 +02:00
Merge remote-tracking branch 'origin/patch'
This commit is contained in:
commit
fe0f67cd5e
8 changed files with 131 additions and 102 deletions
|
@ -302,16 +302,13 @@ public class DisassemblerPlugin extends Plugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDefaultContext(ListingActionContext context) {
|
public void setDefaultContext(ListingActionContext context) {
|
||||||
|
|
||||||
Program contextProgram = context.getProgram();
|
Program contextProgram = context.getProgram();
|
||||||
Register baseContextReg = contextProgram.getLanguage().getContextBaseRegister();
|
Register baseContextReg = contextProgram.getLanguage().getContextBaseRegister();
|
||||||
if (baseContextReg != null && baseContextReg.hasChildren()) {
|
if (baseContextReg != null && baseContextReg.hasChildren()) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
tool.showDialog(new ProcessorStateDialog(contextProgram.getProgramContext()),
|
tool.showDialog(new ProcessorStateDialog(contextProgram.getProgramContext()),
|
||||||
context.getComponentProvider());
|
context.getComponentProvider());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasContextRegisters(Program currentProgram) {
|
public boolean hasContextRegisters(Program currentProgram) {
|
||||||
Register baseContextReg = currentProgram.getLanguage().getContextBaseRegister();
|
Register baseContextReg = currentProgram.getLanguage().getContextBaseRegister();
|
||||||
|
|
|
@ -100,9 +100,11 @@ public class CreateRtti1BackgroundCmd extends AbstractCreateDataBackgroundCmd<Rt
|
||||||
Program program = model.getProgram();
|
Program program = model.getProgram();
|
||||||
TypeDescriptorModel rtti0Model = model.getRtti0Model();
|
TypeDescriptorModel rtti0Model = model.getRtti0Model();
|
||||||
|
|
||||||
monitor.checkCanceled();
|
if (rtti0Model == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (rtti0Model != null) {
|
monitor.checkCanceled();
|
||||||
|
|
||||||
String suffix = "";
|
String suffix = "";
|
||||||
try {
|
try {
|
||||||
|
@ -115,21 +117,21 @@ public class CreateRtti1BackgroundCmd extends AbstractCreateDataBackgroundCmd<Rt
|
||||||
handleError(message);
|
handleError(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Plate Comment
|
|
||||||
EHDataTypeUtilities.createPlateCommentIfNeeded(program,
|
|
||||||
RttiUtil.getDescriptorTypeNamespace(rtti0Model) + Namespace.DELIMITER, RTTI_1_NAME,
|
|
||||||
suffix, getDataAddress(), applyOptions);
|
|
||||||
|
|
||||||
monitor.checkCanceled();
|
|
||||||
|
|
||||||
// Label
|
// Label
|
||||||
|
boolean shouldCreateComment = true;
|
||||||
if (applyOptions.shouldCreateLabel()) {
|
if (applyOptions.shouldCreateLabel()) {
|
||||||
String rtti1Suffix = RTTI_1_NAME + suffix;
|
String rtti1Suffix = RTTI_1_NAME + suffix;
|
||||||
rtti1Suffix = SymbolUtilities.replaceInvalidChars(rtti1Suffix, true);
|
rtti1Suffix = SymbolUtilities.replaceInvalidChars(rtti1Suffix, true);
|
||||||
RttiUtil.createSymbolFromDemangledType(program, getDataAddress(), rtti0Model,
|
shouldCreateComment = RttiUtil.createSymbolFromDemangledType(program, getDataAddress(), rtti0Model,
|
||||||
rtti1Suffix);
|
rtti1Suffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Plate Comment
|
||||||
|
if (shouldCreateComment) {
|
||||||
|
// comment created if a label was created, or createLabel option off
|
||||||
|
EHDataTypeUtilities.createPlateCommentIfNeeded(program,
|
||||||
|
RttiUtil.getDescriptorTypeNamespace(rtti0Model) + Namespace.DELIMITER, RTTI_1_NAME,
|
||||||
|
suffix, getDataAddress(), applyOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -113,19 +113,26 @@ public class CreateRtti2BackgroundCmd extends AbstractCreateDataBackgroundCmd<Rt
|
||||||
Program program = model.getProgram();
|
Program program = model.getProgram();
|
||||||
TypeDescriptorModel rtti0Model = model.getRtti0Model();
|
TypeDescriptorModel rtti0Model = model.getRtti0Model();
|
||||||
|
|
||||||
monitor.checkCanceled();
|
if (rtti0Model == null) {
|
||||||
|
return true;
|
||||||
// Plate Comment
|
}
|
||||||
EHDataTypeUtilities.createPlateCommentIfNeeded(program,
|
|
||||||
RttiUtil.getDescriptorTypeNamespace(rtti0Model) + Namespace.DELIMITER,
|
|
||||||
RTTI_2_NAME, null, getDataAddress(), applyOptions);
|
|
||||||
|
|
||||||
monitor.checkCanceled();
|
monitor.checkCanceled();
|
||||||
|
|
||||||
// Label
|
// Label
|
||||||
|
boolean shouldCreateComment = true;
|
||||||
if (applyOptions.shouldCreateLabel()) {
|
if (applyOptions.shouldCreateLabel()) {
|
||||||
RttiUtil.createSymbolFromDemangledType(program, getDataAddress(), rtti0Model, RTTI_2_NAME);
|
shouldCreateComment = RttiUtil.createSymbolFromDemangledType(program, getDataAddress(), rtti0Model, RTTI_2_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Plate Comment
|
||||||
|
if (shouldCreateComment) {
|
||||||
|
// comment created if a label was created, or createLabel option off
|
||||||
|
EHDataTypeUtilities.createPlateCommentIfNeeded(program,
|
||||||
|
RttiUtil.getDescriptorTypeNamespace(rtti0Model) + Namespace.DELIMITER,
|
||||||
|
RTTI_2_NAME, null, getDataAddress(), applyOptions);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,23 +98,27 @@ public class CreateRtti3BackgroundCmd extends AbstractCreateDataBackgroundCmd<Rt
|
||||||
Program program = model.getProgram();
|
Program program = model.getProgram();
|
||||||
TypeDescriptorModel rtti0Model = model.getRtti0Model();
|
TypeDescriptorModel rtti0Model = model.getRtti0Model();
|
||||||
|
|
||||||
monitor.checkCanceled();
|
if (rtti0Model == null) {
|
||||||
|
return true;
|
||||||
if (rtti0Model != null) {
|
}
|
||||||
|
|
||||||
// Plate Comment
|
|
||||||
EHDataTypeUtilities.createPlateCommentIfNeeded(program,
|
|
||||||
RttiUtil.getDescriptorTypeNamespace(rtti0Model) + Namespace.DELIMITER,
|
|
||||||
RTTI_3_NAME, null, getDataAddress(), applyOptions);
|
|
||||||
|
|
||||||
monitor.checkCanceled();
|
monitor.checkCanceled();
|
||||||
|
|
||||||
// Label
|
// Label
|
||||||
|
boolean shouldCreateComment = true;
|
||||||
if (applyOptions.shouldCreateLabel()) {
|
if (applyOptions.shouldCreateLabel()) {
|
||||||
RttiUtil.createSymbolFromDemangledType(program, getDataAddress(), rtti0Model, RTTI_3_NAME);
|
shouldCreateComment = RttiUtil.createSymbolFromDemangledType(program, getDataAddress(), rtti0Model, RTTI_3_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Plate Comment
|
||||||
|
if (shouldCreateComment) {
|
||||||
|
// comment created if a label was created, or createLabel option off
|
||||||
|
EHDataTypeUtilities.createPlateCommentIfNeeded(program,
|
||||||
|
RttiUtil.getDescriptorTypeNamespace(rtti0Model) + Namespace.DELIMITER,
|
||||||
|
RTTI_3_NAME, null, getDataAddress(), applyOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -244,22 +244,25 @@ public class CreateRtti4BackgroundCmd extends AbstractCreateDataBackgroundCmd<Rt
|
||||||
Program program = model.getProgram();
|
Program program = model.getProgram();
|
||||||
TypeDescriptorModel rtti0Model = model.getRtti0Model();
|
TypeDescriptorModel rtti0Model = model.getRtti0Model();
|
||||||
|
|
||||||
monitor.checkCanceled();
|
if (rtti0Model == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (rtti0Model != null) {
|
|
||||||
|
|
||||||
// Plate Comment
|
|
||||||
// Plate Comment
|
|
||||||
EHDataTypeUtilities.createPlateCommentIfNeeded(program, RttiUtil.CONST_PREFIX +
|
|
||||||
RttiUtil.getDescriptorTypeNamespace(rtti0Model) + Namespace.DELIMITER, RTTI_4_NAME,
|
|
||||||
null, getDataAddress(), applyOptions);
|
|
||||||
monitor.checkCanceled();
|
monitor.checkCanceled();
|
||||||
|
|
||||||
// Label
|
// Label
|
||||||
|
boolean shouldCreateComment = true;
|
||||||
if (applyOptions.shouldCreateLabel()) {
|
if (applyOptions.shouldCreateLabel()) {
|
||||||
RttiUtil.createSymbolFromDemangledType(program, getDataAddress(), rtti0Model,
|
shouldCreateComment = RttiUtil.createSymbolFromDemangledType(program, getDataAddress(), rtti0Model,
|
||||||
RTTI_4_NAME);
|
RTTI_4_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Plate Comment
|
||||||
|
if (shouldCreateComment) {
|
||||||
|
// comment created if a label was created, or createLabel option off
|
||||||
|
EHDataTypeUtilities.createPlateCommentIfNeeded(program, RttiUtil.CONST_PREFIX +
|
||||||
|
RttiUtil.getDescriptorTypeNamespace(rtti0Model) + Namespace.DELIMITER, RTTI_4_NAME,
|
||||||
|
null, getDataAddress(), applyOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -169,20 +169,23 @@ public class CreateVfTableBackgroundCmd extends AbstractCreateDataBackgroundCmd<
|
||||||
|
|
||||||
TypeDescriptorModel rtti0Model = model.getRtti0Model();
|
TypeDescriptorModel rtti0Model = model.getRtti0Model();
|
||||||
|
|
||||||
if (rtti0Model != null) {
|
if (rtti0Model == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Label
|
||||||
|
boolean shouldCreateComment = true;
|
||||||
|
if (applyOptions.shouldCreateLabel()) {
|
||||||
|
shouldCreateComment = RttiUtil.createSymbolFromDemangledType(program, vfTableAddress, rtti0Model,
|
||||||
|
VF_TABLE_LABEL);
|
||||||
|
}
|
||||||
|
|
||||||
// Plate Comment
|
// Plate Comment
|
||||||
|
if (shouldCreateComment) {
|
||||||
|
// comment created if a label was created, or createLabel option off
|
||||||
EHDataTypeUtilities.createPlateCommentIfNeeded(program, RttiUtil.CONST_PREFIX +
|
EHDataTypeUtilities.createPlateCommentIfNeeded(program, RttiUtil.CONST_PREFIX +
|
||||||
RttiUtil.getDescriptorTypeNamespace(rtti0Model) + Namespace.DELIMITER,
|
RttiUtil.getDescriptorTypeNamespace(rtti0Model) + Namespace.DELIMITER,
|
||||||
VF_TABLE_LABEL, null, vfTableAddress, applyOptions);
|
VF_TABLE_LABEL, null, vfTableAddress, applyOptions);
|
||||||
|
|
||||||
monitor.checkCanceled();
|
|
||||||
|
|
||||||
// Label
|
|
||||||
if (applyOptions.shouldCreateLabel()) {
|
|
||||||
RttiUtil.createSymbolFromDemangledType(program, vfTableAddress, rtti0Model,
|
|
||||||
VF_TABLE_LABEL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create functions that are referred to by the vf table.
|
// Create functions that are referred to by the vf table.
|
||||||
|
@ -209,21 +212,26 @@ public class CreateVfTableBackgroundCmd extends AbstractCreateDataBackgroundCmd<
|
||||||
|
|
||||||
TypeDescriptorModel rtti0Model = model.getRtti0Model();
|
TypeDescriptorModel rtti0Model = model.getRtti0Model();
|
||||||
|
|
||||||
if (rtti0Model != null) {
|
if (rtti0Model == null) {
|
||||||
|
return true;
|
||||||
// Plate Comment
|
}
|
||||||
EHDataTypeUtilities.createPlateCommentIfNeeded(
|
|
||||||
program, META_LABEL + " pointer for " +
|
|
||||||
RttiUtil.getDescriptorTypeNamespace(rtti0Model) + Namespace.DELIMITER,
|
|
||||||
VF_TABLE_LABEL, null, metaAddress, applyOptions);
|
|
||||||
|
|
||||||
monitor.checkCanceled();
|
monitor.checkCanceled();
|
||||||
|
|
||||||
// Label
|
// Label
|
||||||
|
boolean shouldCreateComment = true;
|
||||||
if (applyOptions.shouldCreateLabel()) {
|
if (applyOptions.shouldCreateLabel()) {
|
||||||
RttiUtil.createSymbolFromDemangledType(program, metaAddress, rtti0Model,
|
shouldCreateComment = RttiUtil.createSymbolFromDemangledType(program, metaAddress, rtti0Model,
|
||||||
VF_TABLE_LABEL + NAME_SEPARATOR + META_LABEL + "_ptr");
|
VF_TABLE_LABEL + NAME_SEPARATOR + META_LABEL + "_ptr");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Plate Comment
|
||||||
|
if (shouldCreateComment) {
|
||||||
|
// comment created if a label was created, or createLabel option off
|
||||||
|
EHDataTypeUtilities.createPlateCommentIfNeeded(
|
||||||
|
program, META_LABEL + " pointer for " +
|
||||||
|
RttiUtil.getDescriptorTypeNamespace(rtti0Model) + Namespace.DELIMITER,
|
||||||
|
VF_TABLE_LABEL, null, metaAddress, applyOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -61,9 +61,9 @@ public class RttiUtil {
|
||||||
* @param rttiAddress Address of the RTTI datatype
|
* @param rttiAddress Address of the RTTI datatype
|
||||||
* @param typeDescriptorModel the model for the type descriptor structure
|
* @param typeDescriptorModel the model for the type descriptor structure
|
||||||
* @param rttiSuffix suffix name indicating which type of RTTI structure
|
* @param rttiSuffix suffix name indicating which type of RTTI structure
|
||||||
* @return the symbol or null.
|
* @return true if a symbol was created, false otherwise
|
||||||
*/
|
*/
|
||||||
static Symbol createSymbolFromDemangledType(Program program, Address rttiAddress,
|
static boolean createSymbolFromDemangledType(Program program, Address rttiAddress,
|
||||||
TypeDescriptorModel typeDescriptorModel, String rttiSuffix) {
|
TypeDescriptorModel typeDescriptorModel, String rttiSuffix) {
|
||||||
|
|
||||||
rttiSuffix = SymbolUtilities.replaceInvalidChars(rttiSuffix, true);
|
rttiSuffix = SymbolUtilities.replaceInvalidChars(rttiSuffix, true);
|
||||||
|
@ -94,25 +94,32 @@ public class RttiUtil {
|
||||||
// See if the symbol already exists for the RTTI data.
|
// See if the symbol already exists for the RTTI data.
|
||||||
Symbol matchingSymbol = symbolTable.getSymbol(rttiSuffix, rttiAddress, classNamespace);
|
Symbol matchingSymbol = symbolTable.getSymbol(rttiSuffix, rttiAddress, classNamespace);
|
||||||
if (matchingSymbol != null) {
|
if (matchingSymbol != null) {
|
||||||
return matchingSymbol;
|
return false;
|
||||||
}
|
}
|
||||||
// Don't create it if a similar symbol already exists at the address of the data.
|
// Don't create it if a similar symbol already exists at the address of the data.
|
||||||
Symbol[] symbols = symbolTable.getSymbols(rttiAddress);
|
Symbol[] symbols = symbolTable.getSymbols(rttiAddress);
|
||||||
for (Symbol symbol : symbols) {
|
for (Symbol symbol : symbols) {
|
||||||
String name = symbol.getName();
|
String name = symbol.getName();
|
||||||
if (name.contains(rttiSuffix)) {
|
if (name.contains(rttiSuffix)) {
|
||||||
return symbol; // Similar symbol already exists.
|
return false; // Similar symbol already exists.
|
||||||
|
}
|
||||||
|
// assume any imported symbol is better than what we would put down
|
||||||
|
// if mangled, it will get demangled later
|
||||||
|
SourceType source = symbol.getSource();
|
||||||
|
if (source == SourceType.IMPORTED) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
// Didn't find the symbol, so create it.
|
// Didn't find the symbol, so create it.
|
||||||
return symbolTable.createLabel(rttiAddress, rttiSuffix, classNamespace,
|
symbolTable.createLabel(rttiAddress, rttiSuffix, classNamespace,
|
||||||
SourceType.IMPORTED);
|
SourceType.IMPORTED);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
catch (InvalidInputException e) {
|
catch (InvalidInputException e) {
|
||||||
Msg.error(RttiUtil.class,
|
Msg.error(RttiUtil.class,
|
||||||
"Unable to create label for " + rttiSuffix + " at " + rttiAddress + ".", e);
|
"Unable to create label for " + rttiSuffix + " at " + rttiAddress + ".", e);
|
||||||
return null;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -307,6 +307,7 @@ public class FrontEndTestEnv {
|
||||||
AbstractDockingTest.performAction(terminateCheckoutAction, context, false);
|
AbstractDockingTest.performAction(terminateCheckoutAction, context, false);
|
||||||
OptionDialog optDialog = AbstractDockingTest.waitForDialogComponent(OptionDialog.class);
|
OptionDialog optDialog = AbstractDockingTest.waitForDialogComponent(OptionDialog.class);
|
||||||
AbstractGenericTest.pressButtonByText(optDialog.getComponent(), "Yes", true);
|
AbstractGenericTest.pressButtonByText(optDialog.getComponent(), "Yes", true);
|
||||||
|
waitForTasks();
|
||||||
waitForSwing();
|
waitForSwing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue