Merge remote-tracking branch 'origin/patch'

This commit is contained in:
ghidra1 2021-03-22 15:48:07 -04:00
commit fe0f67cd5e
8 changed files with 131 additions and 102 deletions

View file

@ -302,15 +302,12 @@ public class DisassemblerPlugin extends Plugin {
}
public void setDefaultContext(ListingActionContext context) {
Program contextProgram = context.getProgram();
Register baseContextReg = contextProgram.getLanguage().getContextBaseRegister();
if (baseContextReg != null && baseContextReg.hasChildren()) {
return;
tool.showDialog(new ProcessorStateDialog(contextProgram.getProgramContext()),
context.getComponentProvider());
}
tool.showDialog(new ProcessorStateDialog(contextProgram.getProgramContext()),
context.getComponentProvider());
}
public boolean hasContextRegisters(Program currentProgram) {

View file

@ -100,36 +100,38 @@ public class CreateRtti1BackgroundCmd extends AbstractCreateDataBackgroundCmd<Rt
Program program = model.getProgram();
TypeDescriptorModel rtti0Model = model.getRtti0Model();
if (rtti0Model == null) {
return true;
}
monitor.checkCanceled();
if (rtti0Model != null) {
String suffix = "";
try {
suffix = " at " + getPMDAttrList(program);
}
catch (InvalidDataTypeException e) {
// Couldn't get pmd and attributes so leave it off and simply log the error.
String message =
"Unable to get PMD and attributes for RTTI1 at " + getDataAddress() + ".";
handleError(message);
}
String suffix = "";
try {
suffix = " at " + getPMDAttrList(program);
}
catch (InvalidDataTypeException e) {
// Couldn't get pmd and attributes so leave it off and simply log the error.
String message =
"Unable to get PMD and attributes for RTTI1 at " + getDataAddress() + ".";
handleError(message);
}
// Label
boolean shouldCreateComment = true;
if (applyOptions.shouldCreateLabel()) {
String rtti1Suffix = RTTI_1_NAME + suffix;
rtti1Suffix = SymbolUtilities.replaceInvalidChars(rtti1Suffix, true);
shouldCreateComment = RttiUtil.createSymbolFromDemangledType(program, getDataAddress(), rtti0Model,
rtti1Suffix);
}
// Plate Comment
// 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);
monitor.checkCanceled();
// Label
if (applyOptions.shouldCreateLabel()) {
String rtti1Suffix = RTTI_1_NAME + suffix;
rtti1Suffix = SymbolUtilities.replaceInvalidChars(rtti1Suffix, true);
RttiUtil.createSymbolFromDemangledType(program, getDataAddress(), rtti0Model,
rtti1Suffix);
}
RttiUtil.getDescriptorTypeNamespace(rtti0Model) + Namespace.DELIMITER, RTTI_1_NAME,
suffix, getDataAddress(), applyOptions);
}
return true;

View file

@ -113,19 +113,26 @@ public class CreateRtti2BackgroundCmd extends AbstractCreateDataBackgroundCmd<Rt
Program program = model.getProgram();
TypeDescriptorModel rtti0Model = model.getRtti0Model();
monitor.checkCanceled();
// Plate Comment
EHDataTypeUtilities.createPlateCommentIfNeeded(program,
RttiUtil.getDescriptorTypeNamespace(rtti0Model) + Namespace.DELIMITER,
RTTI_2_NAME, null, getDataAddress(), applyOptions);
if (rtti0Model == null) {
return true;
}
monitor.checkCanceled();
// Label
boolean shouldCreateComment = true;
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;
}

View file

@ -98,23 +98,27 @@ public class CreateRtti3BackgroundCmd extends AbstractCreateDataBackgroundCmd<Rt
Program program = model.getProgram();
TypeDescriptorModel rtti0Model = model.getRtti0Model();
if (rtti0Model == null) {
return true;
}
monitor.checkCanceled();
if (rtti0Model != null) {
// Plate Comment
EHDataTypeUtilities.createPlateCommentIfNeeded(program,
RttiUtil.getDescriptorTypeNamespace(rtti0Model) + Namespace.DELIMITER,
RTTI_3_NAME, null, getDataAddress(), applyOptions);
monitor.checkCanceled();
// Label
if (applyOptions.shouldCreateLabel()) {
RttiUtil.createSymbolFromDemangledType(program, getDataAddress(), rtti0Model, RTTI_3_NAME);
}
// Label
boolean shouldCreateComment = true;
if (applyOptions.shouldCreateLabel()) {
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;
}

View file

@ -244,22 +244,25 @@ public class CreateRtti4BackgroundCmd extends AbstractCreateDataBackgroundCmd<Rt
Program program = model.getProgram();
TypeDescriptorModel rtti0Model = model.getRtti0Model();
if (rtti0Model == null) {
return true;
}
monitor.checkCanceled();
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();
// Label
if (applyOptions.shouldCreateLabel()) {
RttiUtil.createSymbolFromDemangledType(program, getDataAddress(), rtti0Model,
// Label
boolean shouldCreateComment = true;
if (applyOptions.shouldCreateLabel()) {
shouldCreateComment = RttiUtil.createSymbolFromDemangledType(program, getDataAddress(), rtti0Model,
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;

View file

@ -169,20 +169,23 @@ public class CreateVfTableBackgroundCmd extends AbstractCreateDataBackgroundCmd<
TypeDescriptorModel rtti0Model = model.getRtti0Model();
if (rtti0Model != null) {
if (rtti0Model == null) {
return true;
}
// Plate Comment
EHDataTypeUtilities.createPlateCommentIfNeeded(program, RttiUtil.CONST_PREFIX +
RttiUtil.getDescriptorTypeNamespace(rtti0Model) + Namespace.DELIMITER,
VF_TABLE_LABEL, null, vfTableAddress, applyOptions);
monitor.checkCanceled();
// Label
if (applyOptions.shouldCreateLabel()) {
RttiUtil.createSymbolFromDemangledType(program, vfTableAddress, rtti0Model,
// Label
boolean shouldCreateComment = true;
if (applyOptions.shouldCreateLabel()) {
shouldCreateComment = RttiUtil.createSymbolFromDemangledType(program, vfTableAddress, rtti0Model,
VF_TABLE_LABEL);
}
}
// 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,
VF_TABLE_LABEL, null, vfTableAddress, applyOptions);
}
// Create functions that are referred to by the vf table.
@ -209,21 +212,26 @@ public class CreateVfTableBackgroundCmd extends AbstractCreateDataBackgroundCmd<
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
if (applyOptions.shouldCreateLabel()) {
RttiUtil.createSymbolFromDemangledType(program, metaAddress, rtti0Model,
// Label
boolean shouldCreateComment = true;
if (applyOptions.shouldCreateLabel()) {
shouldCreateComment = RttiUtil.createSymbolFromDemangledType(program, metaAddress, rtti0Model,
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;

View file

@ -61,9 +61,9 @@ public class RttiUtil {
* @param rttiAddress Address of the RTTI datatype
* @param typeDescriptorModel the model for the type descriptor 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) {
rttiSuffix = SymbolUtilities.replaceInvalidChars(rttiSuffix, true);
@ -94,25 +94,32 @@ public class RttiUtil {
// See if the symbol already exists for the RTTI data.
Symbol matchingSymbol = symbolTable.getSymbol(rttiSuffix, rttiAddress, classNamespace);
if (matchingSymbol != null) {
return matchingSymbol;
return false;
}
// Don't create it if a similar symbol already exists at the address of the data.
Symbol[] symbols = symbolTable.getSymbols(rttiAddress);
for (Symbol symbol : symbols) {
String name = symbol.getName();
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 {
// Didn't find the symbol, so create it.
return symbolTable.createLabel(rttiAddress, rttiSuffix, classNamespace,
symbolTable.createLabel(rttiAddress, rttiSuffix, classNamespace,
SourceType.IMPORTED);
return true;
}
catch (InvalidInputException e) {
Msg.error(RttiUtil.class,
"Unable to create label for " + rttiSuffix + " at " + rttiAddress + ".", e);
return null;
return false;
}
}

View file

@ -307,6 +307,7 @@ public class FrontEndTestEnv {
AbstractDockingTest.performAction(terminateCheckoutAction, context, false);
OptionDialog optDialog = AbstractDockingTest.waitForDialogComponent(OptionDialog.class);
AbstractGenericTest.pressButtonByText(optDialog.getComponent(), "Yes", true);
waitForTasks();
waitForSwing();
}