mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-02-16 07:30:16 +00:00
Merge remote-tracking branch 'origin/GP-789_emteere_RTTIOrderFix' into patch
This commit is contained in:
commit
acf78878ce
@ -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();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
if (rtti0Model != null) {
|
||||
// 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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
@ -112,20 +112,27 @@ 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;
|
||||
}
|
||||
|
||||
|
@ -98,23 +98,27 @@ public class CreateRtti3BackgroundCmd extends AbstractCreateDataBackgroundCmd<Rt
|
||||
Program program = model.getProgram();
|
||||
TypeDescriptorModel rtti0Model = model.getRtti0Model();
|
||||
|
||||
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);
|
||||
}
|
||||
if (rtti0Model == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
monitor.checkCanceled();
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -169,20 +169,23 @@ public class CreateVfTableBackgroundCmd extends AbstractCreateDataBackgroundCmd<
|
||||
|
||||
TypeDescriptorModel rtti0Model = model.getRtti0Model();
|
||||
|
||||
if (rtti0Model != null) {
|
||||
|
||||
// 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,
|
||||
if (rtti0Model == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
monitor.checkCanceled();
|
||||
|
||||
// Plate Comment
|
||||
EHDataTypeUtilities.createPlateCommentIfNeeded(
|
||||
program, META_LABEL + " pointer for " +
|
||||
RttiUtil.getDescriptorTypeNamespace(rtti0Model) + Namespace.DELIMITER,
|
||||
VF_TABLE_LABEL, null, metaAddress, applyOptions);
|
||||
|
||||
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;
|
||||
|
@ -61,11 +61,11 @@ 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);
|
||||
|
||||
// Get or create the namespace for this RTTI's type descriptor.
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user