GP-1519 Changed getComponentAt to getComponentContaining in a breaking EditStructureUtils method and a couple other places. Various refactoring to clean up code.

This commit is contained in:
ghidra007 2021-11-30 01:38:13 +00:00
parent 5c0f06ab8d
commit 2aefe6a15d
8 changed files with 238 additions and 235 deletions

View file

@ -165,8 +165,6 @@ public class RecoverClassesFromRTTIScript extends GhidraScript {
RTTIClassRecoverer recoverClassesFromRTTI; RTTIClassRecoverer recoverClassesFromRTTI;
ExtraScriptUtils extraUtils;
boolean nameVfunctions = false; boolean nameVfunctions = false;
@Override @Override

View file

@ -22,9 +22,9 @@ import ghidra.program.model.data.*;
import ghidra.util.exception.CancelledException; import ghidra.util.exception.CancelledException;
import ghidra.util.task.TaskMonitor; import ghidra.util.task.TaskMonitor;
public class EditStructureUtils { class EditStructureUtils {
EditStructureUtils() { private EditStructureUtils() {
} }
@ -42,7 +42,7 @@ public class EditStructureUtils {
* internal struct, false otherwise * internal struct, false otherwise
* @throws CancelledException if cancelled * @throws CancelledException if cancelled
*/ */
public boolean hasReplaceableComponentsAtOffset(Structure containingStruct, int offset, static boolean hasReplaceableComponentsAtOffset(Structure containingStruct, int offset,
Structure newInternalStruct, TaskMonitor monitor) throws CancelledException { Structure newInternalStruct, TaskMonitor monitor) throws CancelledException {
DataTypeComponent[] newStructComponents = newInternalStruct.getComponents(); DataTypeComponent[] newStructComponents = newInternalStruct.getComponents();
@ -95,7 +95,7 @@ public class EditStructureUtils {
* @return true if there are at least length undefined size 1 components at the given offset in the given structure * @return true if there are at least length undefined size 1 components at the given offset in the given structure
* @throws CancelledException if cancelled * @throws CancelledException if cancelled
*/ */
public boolean hasEnoughUndefined1sAtOffset(Structure structure, int offset, int length, static boolean hasEnoughUndefined1sAtOffset(Structure structure, int offset, int length,
TaskMonitor monitor) throws CancelledException { TaskMonitor monitor) throws CancelledException {
if (structure.getLength() < offset + length) { if (structure.getLength() < offset + length) {
@ -128,7 +128,7 @@ public class EditStructureUtils {
* @return true if successfully cleared from offset to offset+length, false otherwise * @return true if successfully cleared from offset to offset+length, false otherwise
* @throws CancelledException if cancelled * @throws CancelledException if cancelled
*/ */
public boolean clearLengthAtOffset(Structure structure, int offset, int length, static boolean clearLengthAtOffset(Structure structure, int offset, int length,
TaskMonitor monitor) throws CancelledException { TaskMonitor monitor) throws CancelledException {
if (structure.getLength() < offset + length) { if (structure.getLength() < offset + length) {
@ -143,17 +143,10 @@ public class EditStructureUtils {
monitor.checkCanceled(); monitor.checkCanceled();
DataTypeComponent component = structure.getComponentAt(offset); DataTypeComponent component = structure.getComponentContaining(offset);
DataType dataType = component.getDataType();
// return false if it would clear too much offsetsToClear.add(component.getOffset());
if (offset + dataType.getLength() > endOfClear) { offset = component.getOffset() + component.getLength();
return false;
}
offsetsToClear.add(offset);
offset += dataType.getLength();
continue;
} }
@ -178,11 +171,12 @@ public class EditStructureUtils {
* @param dataType the given data type * @param dataType the given data type
* @return true if given data type is undefined size 1, false otherwise * @return true if given data type is undefined size 1, false otherwise
*/ */
public boolean isUndefined1(DataType dataType) { static boolean isUndefined1(DataType dataType) {
if (isUndefined(dataType) && dataType.getLength() == 1) { if (Undefined.isUndefined(dataType) && dataType.getLength() == 1) {
return true; return true;
} }
return false; return false;
} }
@ -191,7 +185,7 @@ public class EditStructureUtils {
* @param dataType the given data type * @param dataType the given data type
* @return true if given data type is undefined of any size, false otherwise * @return true if given data type is undefined of any size, false otherwise
*/ */
public boolean isUndefined(DataType dataType) { static boolean isUndefined(DataType dataType) {
if (dataType.getName().contains("undefined")) { if (dataType.getName().contains("undefined")) {
return true; return true;
} }
@ -199,41 +193,46 @@ public class EditStructureUtils {
} }
/** /**
* Method to determine if there are at least the given length of undefined (any size) components at the given offset in the given structure * Method to determine if there are at least the given length of undefined (any size) components
* at the given offset in the given structure. This is only valid for non-packed structures.
* @param structure the given structure * @param structure the given structure
* @param offset the given offset * @param offset the given offset
* @param length the total length of undefined components to check for starting at given offset * @param length the total length of undefined components to check for starting at given offset
* @param monitor task monitor * @param monitor task monitor
* @return true if there are at least total length of undefined components at the given offset in the given structure * @return true if there are at least total length of undefined components at the given offset in the given structure
* @throws CancelledException if cancelled * @throws CancelledException if cancelled
* @throws IllegalArgumentException if a packed structure is passed in
*/ */
public boolean hasEnoughUndefinedsOfAnyLengthAtOffset(Structure structure, int offset, static boolean hasEnoughUndefinedsOfAnyLengthAtOffset(Structure structure, int offset,
int length, TaskMonitor monitor) throws CancelledException { int length, TaskMonitor monitor) throws CancelledException {
if (structure.getLength() < offset + length) { if (structure.isPackingEnabled()) {
return false; throw new IllegalArgumentException(
"Packed structures are not supported by this method");
} }
int endOfRange = offset + length; int endOfRange = offset + length;
if (offset < 0 || length <= 0 || structure.getLength() < endOfRange) {
return false;
}
while (offset < endOfRange) { while (offset < endOfRange) {
monitor.checkCanceled(); monitor.checkCanceled();
DataTypeComponent component = structure.getComponentAt(offset); DataTypeComponent component = structure.getComponentContaining(offset);
DataType dataType = component.getDataType(); DataType dataType = component.getDataType();
if (isUndefined(dataType)) {
offset += dataType.getLength(); if (!Undefined.isUndefined(dataType)) {
if (offset > endOfRange) {
return false; return false;
} }
continue; offset = component.getOffset() + component.getLength();
} }
return false;
}
return true; return true;
} }
@ -251,7 +250,7 @@ public class EditStructureUtils {
* @throws IllegalArgumentException if issue inserting data type into structure * @throws IllegalArgumentException if issue inserting data type into structure
* @throws CancelledException if cancelled * @throws CancelledException if cancelled
*/ */
public Structure addDataTypeToStructure(Structure structure, int offset, static Structure addDataTypeToStructure(Structure structure, int offset,
DataType dataType, String fieldName, TaskMonitor monitor) DataType dataType, String fieldName, TaskMonitor monitor)
throws CancelledException, IllegalArgumentException { throws CancelledException, IllegalArgumentException {
@ -292,7 +291,7 @@ public class EditStructureUtils {
* @return true if the given structure has room at the given offset to have a component of the given length added to it * @return true if the given structure has room at the given offset to have a component of the given length added to it
* @throws CancelledException if cancelled * @throws CancelledException if cancelled
*/ */
public boolean canAdd(Structure structureDataType, int offset, int lengthToAdd, static boolean canAdd(Structure structureDataType, int offset, int lengthToAdd,
TaskMonitor monitor) TaskMonitor monitor)
throws CancelledException { throws CancelledException {
@ -332,7 +331,7 @@ public class EditStructureUtils {
* @return the number of undefined size 1 components in the given structure before the given offset * @return the number of undefined size 1 components in the given structure before the given offset
* @throws CancelledException if cancelled * @throws CancelledException if cancelled
*/ */
public int getNumberOfUndefinedsBeforeOffset(Structure structure, int offset, static int getNumberOfUndefinedsBeforeOffset(Structure structure, int offset,
TaskMonitor monitor) throws CancelledException { TaskMonitor monitor) throws CancelledException {
if (structure.getNumComponents() == 0) { if (structure.getNumComponents() == 0) {
@ -364,7 +363,7 @@ public class EditStructureUtils {
* @return the number of undefined size 1 components starting at the given offset in the given structure * @return the number of undefined size 1 components starting at the given offset in the given structure
* @throws CancelledException if cancelled * @throws CancelledException if cancelled
*/ */
public int getNumberOfUndefinedsStartingAtOffset(Structure structure, int offset, static int getNumberOfUndefinedsStartingAtOffset(Structure structure, int offset,
TaskMonitor monitor) throws CancelledException { TaskMonitor monitor) throws CancelledException {
int numUndefineds = 0; int numUndefineds = 0;

View file

@ -34,19 +34,13 @@ import ghidra.program.model.symbol.*;
import ghidra.util.exception.*; import ghidra.util.exception.*;
import ghidra.util.task.TaskMonitor; import ghidra.util.task.TaskMonitor;
public class ExtraScriptUtils extends FlatProgramAPI { public class ExtendedFlatProgramAPI extends FlatProgramAPI {
Program program; final int defaultPointerSize;
TaskMonitor taskMonitor;
int defaultPointerSize;
ExtraScriptUtils(Program program, TaskMonitor taskMonitor) { ExtendedFlatProgramAPI(Program program, TaskMonitor taskMonitor) {
this.program = program;
this.taskMonitor = taskMonitor;
currentProgram = program;
monitor = taskMonitor;
super(program, taskMonitor);
defaultPointerSize = program.getDefaultPointerSize(); defaultPointerSize = program.getDefaultPointerSize();
} }
@ -66,7 +60,7 @@ public class ExtraScriptUtils extends FlatProgramAPI {
int numComponents = data.getNumComponents(); int numComponents = data.getNumComponents();
for (int ii = 0; ii < numComponents; ++ii) { for (int ii = 0; ii < numComponents; ++ii) {
taskMonitor.checkCanceled(); monitor.checkCanceled();
Data component = data.getComponent(ii); Data component = data.getComponent(ii);
if (!component.isPointer()) { if (!component.isPointer()) {
@ -125,7 +119,7 @@ public class ExtraScriptUtils extends FlatProgramAPI {
} }
// check for or create function pointer if valid function pointed to // check for or create function pointer if valid function pointed to
Data data = program.getListing().getDefinedDataAt(address); Data data = currentProgram.getListing().getDefinedDataAt(address);
if (data != null) { if (data != null) {
if (data.isPointer() && getPointedToFunction(address) != null) { if (data.isPointer() && getPointedToFunction(address) != null) {
return true; return true;
@ -165,8 +159,8 @@ public class ExtraScriptUtils extends FlatProgramAPI {
return false; return false;
} }
DataType nullPointer = program.getDataTypeManager().getPointer(null); DataType nullPointer = currentProgram.getDataTypeManager().getPointer(null);
Listing listing = program.getListing(); Listing listing = currentProgram.getListing();
Data d = listing.getDefinedDataAt(address); Data d = listing.getDefinedDataAt(address);
if (d == null) { if (d == null) {
try { try {
@ -316,7 +310,7 @@ public class ExtraScriptUtils extends FlatProgramAPI {
*/ */
public Function createFunctionBefore(Address address, Byte expectedFiller) { public Function createFunctionBefore(Address address, Byte expectedFiller) {
PseudoDisassembler pseudoDisassembler = new PseudoDisassembler(program); PseudoDisassembler pseudoDisassembler = new PseudoDisassembler(currentProgram);
Instruction instructionBefore = getInstructionBefore(address); Instruction instructionBefore = getInstructionBefore(address);
@ -419,7 +413,7 @@ public class ExtraScriptUtils extends FlatProgramAPI {
public int getNumberOfSameFillerBytesStartingAtAddress(Address firstAddress) public int getNumberOfSameFillerBytesStartingAtAddress(Address firstAddress)
throws CancelledException, MemoryAccessException { throws CancelledException, MemoryAccessException {
AddressSetView validMemory = program.getMemory().getLoadedAndInitializedAddressSet(); AddressSetView validMemory = currentProgram.getMemory().getLoadedAndInitializedAddressSet();
if (firstAddress == null) { if (firstAddress == null) {
return 0; return 0;
@ -529,7 +523,7 @@ public class ExtraScriptUtils extends FlatProgramAPI {
// Create a new address set to hold the entire selection. // Create a new address set to hold the entire selection.
AddressSet subroutineAddresses = new AddressSet(); AddressSet subroutineAddresses = new AddressSet();
IsolatedEntrySubModel model = new IsolatedEntrySubModel(program); IsolatedEntrySubModel model = new IsolatedEntrySubModel(currentProgram);
CodeBlock[] codeBlocksContaining = model.getCodeBlocksContaining(address, monitor); CodeBlock[] codeBlocksContaining = model.getCodeBlocksContaining(address, monitor);
for (CodeBlock element : codeBlocksContaining) { for (CodeBlock element : codeBlocksContaining) {
@ -607,7 +601,7 @@ public class ExtraScriptUtils extends FlatProgramAPI {
int addressSize = address.getSize(); int addressSize = address.getSize();
if (addressSize == 64 && getIboIf64bit) { if (addressSize == 64 && getIboIf64bit) {
ImageBaseOffset32DataType ibo32 = ImageBaseOffset32DataType ibo32 =
new ImageBaseOffset32DataType(program.getDataTypeManager()); new ImageBaseOffset32DataType(currentProgram.getDataTypeManager());
int length = ibo32.getLength(); int length = ibo32.getLength();
DumbMemBufferImpl compMemBuffer = DumbMemBufferImpl compMemBuffer =
new DumbMemBufferImpl(currentProgram.getMemory(), address); new DumbMemBufferImpl(currentProgram.getMemory(), address);
@ -654,7 +648,7 @@ public class ExtraScriptUtils extends FlatProgramAPI {
List<Symbol> symbolList = new ArrayList<Symbol>(); List<Symbol> symbolList = new ArrayList<Symbol>();
SymbolIterator symbols = program.getSymbolTable().getSymbols(namespace); SymbolIterator symbols = currentProgram.getSymbolTable().getSymbols(namespace);
while (symbols.hasNext()) { while (symbols.hasNext()) {
monitor.checkCanceled(); monitor.checkCanceled();
@ -765,7 +759,7 @@ public class ExtraScriptUtils extends FlatProgramAPI {
List<Address> referenceAddresses = new ArrayList<Address>(); List<Address> referenceAddresses = new ArrayList<Address>();
ReferenceIterator referencesToFunctionBIterator = ReferenceIterator referencesToFunctionBIterator =
program.getReferenceManager().getReferencesTo(bFunction.getEntryPoint()); currentProgram.getReferenceManager().getReferencesTo(bFunction.getEntryPoint());
while (referencesToFunctionBIterator.hasNext()) { while (referencesToFunctionBIterator.hasNext()) {
@ -995,7 +989,7 @@ public class ExtraScriptUtils extends FlatProgramAPI {
*/ */
public void removeAllSymbolsAtAddress(Address address) throws CancelledException { public void removeAllSymbolsAtAddress(Address address) throws CancelledException {
SymbolTable symbolTable = program.getSymbolTable(); SymbolTable symbolTable = currentProgram.getSymbolTable();
Symbol primarySymbol = symbolTable.getPrimarySymbol(address); Symbol primarySymbol = symbolTable.getPrimarySymbol(address);
@ -1031,7 +1025,7 @@ public class ExtraScriptUtils extends FlatProgramAPI {
*/ */
public boolean hasSymbolsInNamespace(Namespace namespace) { public boolean hasSymbolsInNamespace(Namespace namespace) {
SymbolIterator namespaceSymbols = program.getSymbolTable().getSymbols(namespace); SymbolIterator namespaceSymbols = currentProgram.getSymbolTable().getSymbols(namespace);
if (namespaceSymbols.hasNext()) { if (namespaceSymbols.hasNext()) {
return true; return true;

View file

@ -161,7 +161,7 @@ public class RTTIClassRecoverer extends RecoveredClassUtils {
// if class is non-virtual have to search for an existing class datatype // if class is non-virtual have to search for an existing class datatype
if (!recoveredClass.hasVftable()) { if (!recoveredClass.hasVftable()) {
DataType[] possibleExistingClassStructures = DataType[] possibleExistingClassStructures =
extraUtils.getDataTypes(recoveredClass.getName()); extendedFlatAPI.getDataTypes(recoveredClass.getName());
if (possibleExistingClassStructures.length == 0) { if (possibleExistingClassStructures.length == 0) {
continue; continue;
} }

View file

@ -253,7 +253,7 @@ public class RTTIGccClassRecoverer extends RTTIClassRecoverer {
recoveredClasses = recoverClassesFromVftables(vftableSymbols, true, true); recoveredClasses = recoverClassesFromVftables(vftableSymbols, true, true);
// find all typeinfo symbols and get their class namespace and create RecoveredClass object // find all typeinfo symbols and get their class namespace and create RecoveredClass object
List<Symbol> typeinfoSymbols = extraUtils.getListOfSymbolsInAddressSet( List<Symbol> typeinfoSymbols = extendedFlatAPI.getListOfSymbolsInAddressSet(
program.getAddressFactory().getAddressSet(), "typeinfo", true); program.getAddressFactory().getAddressSet(), "typeinfo", true);
// create class objects for each typeinfo struct and make a class to typeinfo mapping for each // create class objects for each typeinfo struct and make a class to typeinfo mapping for each
@ -325,7 +325,7 @@ public class RTTIGccClassRecoverer extends RTTIClassRecoverer {
} }
} }
Address specialTypeinfoRef = extraUtils.getSingleReferencedAddress(typeinfoAddress); Address specialTypeinfoRef = extendedFlatAPI.getSingleReferencedAddress(typeinfoAddress);
if (specialTypeinfoRef == null) { if (specialTypeinfoRef == null) {
if (DEBUG) { if (DEBUG) {
Msg.debug(this, Msg.debug(this,
@ -454,7 +454,7 @@ public class RTTIGccClassRecoverer extends RTTIClassRecoverer {
listOfVtableSymbols = findVtablesUsingTypeinfoRefs(); listOfVtableSymbols = findVtablesUsingTypeinfoRefs();
} }
else { else {
listOfVtableSymbols = extraUtils.getListOfSymbolsInAddressSet( listOfVtableSymbols = extendedFlatAPI.getListOfSymbolsInAddressSet(
program.getAddressFactory().getAddressSet(), VTABLE_LABEL, false); program.getAddressFactory().getAddressSet(), VTABLE_LABEL, false);
} }
@ -496,7 +496,7 @@ public class RTTIGccClassRecoverer extends RTTIClassRecoverer {
for (Address typeinfoRef : typeinfoReferencesNotInTypeinfoStructs) { for (Address typeinfoRef : typeinfoReferencesNotInTypeinfoStructs) {
monitor.checkCanceled(); monitor.checkCanceled();
Address typeinfoAddress = extraUtils.getPointer(typeinfoRef); Address typeinfoAddress = extendedFlatAPI.getPointer(typeinfoRef);
if (typeinfoAddress == null) { if (typeinfoAddress == null) {
continue; continue;
@ -563,7 +563,7 @@ public class RTTIGccClassRecoverer extends RTTIClassRecoverer {
// check for appropriately sized long that is value 0 to make sure the // check for appropriately sized long that is value 0 to make sure the
// vtable the typeinfo ref is in is the main one and skip otherwise since non-zero // vtable the typeinfo ref is in is the main one and skip otherwise since non-zero
// ones are internal vtables that will get processed with the main one // ones are internal vtables that will get processed with the main one
if (!extraUtils.hasNumZeros(longBeforeTypeinfoRef, defaultPointerSize)) { if (!extendedFlatAPI.hasNumZeros(longBeforeTypeinfoRef, defaultPointerSize)) {
return null; return null;
} }
@ -590,7 +590,7 @@ public class RTTIGccClassRecoverer extends RTTIClassRecoverer {
private Address getPointerToDefinedMemory(Address address) { private Address getPointerToDefinedMemory(Address address) {
Address pointer = extraUtils.getPointer(address); Address pointer = extendedFlatAPI.getPointer(address);
if (pointer == null) { if (pointer == null) {
return null; return null;
} }
@ -966,7 +966,7 @@ public class RTTIGccClassRecoverer extends RTTIClassRecoverer {
private Symbol getVTTBefore(Address address) throws CancelledException { private Symbol getVTTBefore(Address address) throws CancelledException {
// get all symbols named VTT and get the one directly before the given address // get all symbols named VTT and get the one directly before the given address
List<Symbol> vttSymbols = extraUtils.getListOfSymbolsInAddressSet( List<Symbol> vttSymbols = extendedFlatAPI.getListOfSymbolsInAddressSet(
program.getAddressFactory().getAddressSet(), "VTT", true); program.getAddressFactory().getAddressSet(), "VTT", true);
return getSymbolOnListBeforeAddress(address, vttSymbols); return getSymbolOnListBeforeAddress(address, vttSymbols);
@ -1210,7 +1210,7 @@ public class RTTIGccClassRecoverer extends RTTIClassRecoverer {
return false; return false;
} }
Reference[] referencesTo = extraUtils.getReferencesTo(address); Reference[] referencesTo = extendedFlatAPI.getReferencesTo(address);
if (referencesTo.length > 0) { if (referencesTo.length > 0) {
return false; return false;
} }
@ -1239,7 +1239,7 @@ public class RTTIGccClassRecoverer extends RTTIClassRecoverer {
return false; return false;
} }
List<Address> referenceFromAddresses = extraUtils.getReferenceFromAddresses(address); List<Address> referenceFromAddresses = extendedFlatAPI.getReferenceFromAddresses(address);
if (referenceFromAddresses.size() > 0) { if (referenceFromAddresses.size() > 0) {
return false; return false;
@ -1304,7 +1304,7 @@ public class RTTIGccClassRecoverer extends RTTIClassRecoverer {
return false; return false;
} }
if (extraUtils.hasNumZeros(vftableAddress, defaultPointerSize)) { if (extendedFlatAPI.hasNumZeros(vftableAddress, defaultPointerSize)) {
return true; return true;
} }
@ -1313,7 +1313,7 @@ public class RTTIGccClassRecoverer extends RTTIClassRecoverer {
if (!data.isPointer()) { if (!data.isPointer()) {
return false; return false;
} }
Address referencedAddress = extraUtils.getSingleReferencedAddress(vftableAddress); Address referencedAddress = extendedFlatAPI.getSingleReferencedAddress(vftableAddress);
if (referencedAddress == null) { if (referencedAddress == null) {
return false; return false;
} }
@ -1407,7 +1407,7 @@ public class RTTIGccClassRecoverer extends RTTIClassRecoverer {
// create a pointer and check to see if it is a reference to a valid memory location // create a pointer and check to see if it is a reference to a valid memory location
try { try {
api.createData(address, pointer); api.createData(address, pointer);
Address referencedAddress = extraUtils.getSingleReferencedAddress(address); Address referencedAddress = extendedFlatAPI.getSingleReferencedAddress(address);
// if it isn't valid, clear what we just created and increment to offset so // if it isn't valid, clear what we just created and increment to offset so
// the next can be checked // the next can be checked
@ -1464,7 +1464,7 @@ public class RTTIGccClassRecoverer extends RTTIClassRecoverer {
for (Address typeinfoAddress : typeinfoAddresses) { for (Address typeinfoAddress : typeinfoAddresses) {
Address specialTypeinfoRef = extraUtils.getSingleReferencedAddress(typeinfoAddress); Address specialTypeinfoRef = extendedFlatAPI.getSingleReferencedAddress(typeinfoAddress);
if (specialTypeinfoRef == null) { if (specialTypeinfoRef == null) {
continue; continue;
} }
@ -1698,7 +1698,7 @@ public class RTTIGccClassRecoverer extends RTTIClassRecoverer {
} }
Address stringReference = Address stringReference =
extraUtils.getSingleReferencedAddress(address.add(typeinfoNameComponent.getOffset())); extendedFlatAPI.getSingleReferencedAddress(address.add(typeinfoNameComponent.getOffset()));
Data stringData = api.getDataAt(stringReference); Data stringData = api.getDataAt(stringReference);
if (stringData == null) { if (stringData == null) {
@ -1728,7 +1728,7 @@ public class RTTIGccClassRecoverer extends RTTIClassRecoverer {
List<Address> typeinfoAddresses = new ArrayList<Address>(); List<Address> typeinfoAddresses = new ArrayList<Address>();
List<Symbol> typeinfoSymbols = extraUtils.getListOfSymbolsInAddressSet( List<Symbol> typeinfoSymbols = extendedFlatAPI.getListOfSymbolsInAddressSet(
program.getAddressFactory().getAddressSet(), "typeinfo", true); program.getAddressFactory().getAddressSet(), "typeinfo", true);
Iterator<Symbol> typeinfoIterator = typeinfoSymbols.iterator(); Iterator<Symbol> typeinfoIterator = typeinfoSymbols.iterator();
@ -2153,8 +2153,8 @@ public class RTTIGccClassRecoverer extends RTTIClassRecoverer {
//virtual base offset for the virtual base referenced (negative). //virtual base offset for the virtual base referenced (negative).
long offset = (publicVirtualOffsetFlag & offsetMask) >> 8; long offset = (publicVirtualOffsetFlag & offsetMask) >> 8;
Msg.debug(this, "typeinfo " + typeinfoAddress + " base [" + i + "] isVirtual = " + // Msg.debug(this, "typeinfo " + typeinfoAddress + " base [" + i + "] isVirtual = " +
isVirtual + " isPublic = " + isPublic + " offset = " + offset); // isVirtual + " isPublic = " + isPublic + " offset = " + offset);
// add order to parent and parent offset // add order to parent and parent offset
orderToParentMap.put(i, parentClass); orderToParentMap.put(i, parentClass);
@ -2207,7 +2207,7 @@ public class RTTIGccClassRecoverer extends RTTIClassRecoverer {
*/ */
private RecoveredClass getParentClassFromParentTypeInfoRef(Address parentTypeinfoRef) { private RecoveredClass getParentClassFromParentTypeInfoRef(Address parentTypeinfoRef) {
Address parentAddress = extraUtils.getSingleReferencedAddress(parentTypeinfoRef); Address parentAddress = extendedFlatAPI.getSingleReferencedAddress(parentTypeinfoRef);
if (parentAddress == null) { if (parentAddress == null) {
return null; return null;
} }
@ -2295,7 +2295,7 @@ public class RTTIGccClassRecoverer extends RTTIClassRecoverer {
int offset = 0; int offset = 0;
Address address = extraUtils.getAddress(startAddress, offset); Address address = extendedFlatAPI.getAddress(startAddress, offset);
MemoryBlock currentMemoryBlock = program.getMemory().getBlock(startAddress); MemoryBlock currentMemoryBlock = program.getMemory().getBlock(startAddress);
@ -2309,10 +2309,10 @@ public class RTTIGccClassRecoverer extends RTTIClassRecoverer {
return null; return null;
} }
Address possibleTypeinfo = extraUtils.getPointer(address); Address possibleTypeinfo = extendedFlatAPI.getPointer(address);
if (possibleTypeinfo == null) { if (possibleTypeinfo == null) {
offset += defaultPointerSize; offset += defaultPointerSize;
address = extraUtils.getAddress(startAddress, offset); address = extendedFlatAPI.getAddress(startAddress, offset);
continue; continue;
} }
@ -2322,7 +2322,7 @@ public class RTTIGccClassRecoverer extends RTTIClassRecoverer {
return address; return address;
} }
offset += defaultPointerSize; offset += defaultPointerSize;
address = extraUtils.getAddress(startAddress, offset); address = extendedFlatAPI.getAddress(startAddress, offset);
} }
@ -2339,7 +2339,7 @@ public class RTTIGccClassRecoverer extends RTTIClassRecoverer {
List<Symbol> vftableSymbols = new ArrayList<Symbol>(); List<Symbol> vftableSymbols = new ArrayList<Symbol>();
// find all vtable symbols // find all vtable symbols
List<Symbol> listOfVtableSymbols = extraUtils.getListOfSymbolsInAddressSet( List<Symbol> listOfVtableSymbols = extendedFlatAPI.getListOfSymbolsInAddressSet(
program.getAddressFactory().getAddressSet(), VTABLE_LABEL, true); program.getAddressFactory().getAddressSet(), VTABLE_LABEL, true);
Iterator<Symbol> vtableIterator = listOfVtableSymbols.iterator(); Iterator<Symbol> vtableIterator = listOfVtableSymbols.iterator();
@ -2373,7 +2373,7 @@ public class RTTIGccClassRecoverer extends RTTIClassRecoverer {
continue; continue;
} }
Address vftableAddress = extraUtils.getAddress(typeinfoAddress, defaultPointerSize); Address vftableAddress = extendedFlatAPI.getAddress(typeinfoAddress, defaultPointerSize);
// no valid address here so continue // no valid address here so continue
if (vftableAddress == null) { if (vftableAddress == null) {
//createNewClass(vtableNamespace, false); //createNewClass(vtableNamespace, false);
@ -2454,7 +2454,7 @@ public class RTTIGccClassRecoverer extends RTTIClassRecoverer {
recoveredClasses.add(recoveredClass); recoveredClasses.add(recoveredClass);
} }
Address specialTypeinfoRef = extraUtils.getSingleReferencedAddress(typeinfoAddress); Address specialTypeinfoRef = extendedFlatAPI.getSingleReferencedAddress(typeinfoAddress);
if (specialTypeinfoRef == null) { if (specialTypeinfoRef == null) {
if (DEBUG) { if (DEBUG) {
Msg.debug(this, Msg.debug(this,
@ -2759,7 +2759,7 @@ public class RTTIGccClassRecoverer extends RTTIClassRecoverer {
* @return true if the given address could be a valid null pointer, false if not * @return true if the given address could be a valid null pointer, false if not
*/ */
private boolean isPossibleNullPointer(Address address) throws CancelledException { private boolean isPossibleNullPointer(Address address) throws CancelledException {
if (!extraUtils.hasNumZeros(address, defaultPointerSize)) { if (!extendedFlatAPI.hasNumZeros(address, defaultPointerSize)) {
return false; return false;
} }
return true; return true;
@ -2772,7 +2772,7 @@ public class RTTIGccClassRecoverer extends RTTIClassRecoverer {
*/ */
private boolean isPossibleFunctionPointer(Address address) { private boolean isPossibleFunctionPointer(Address address) {
Address possibleFunctionPointer = extraUtils.getPointer(address); Address possibleFunctionPointer = extendedFlatAPI.getPointer(address);
if (possibleFunctionPointer == null) { if (possibleFunctionPointer == null) {
return false; return false;
} }
@ -2967,9 +2967,11 @@ public class RTTIGccClassRecoverer extends RTTIClassRecoverer {
DataType classVftablePointer = vfPointerDataTypes.get(vftableAddress); DataType classVftablePointer = vfPointerDataTypes.get(vftableAddress);
// simple case the offset for vftablePtr is 0 // simple case the offset for vftablePtr is 0
if (structUtils.canAdd(classStructureDataType, 0, classVftablePointer.getLength(), if (EditStructureUtils.canAdd(classStructureDataType, 0,
classVftablePointer.getLength(),
monitor)) { monitor)) {
classStructureDataType = structUtils.addDataTypeToStructure(classStructureDataType, classStructureDataType =
EditStructureUtils.addDataTypeToStructure(classStructureDataType,
0, classVftablePointer, CLASS_VTABLE_PTR_FIELD_EXT, monitor); 0, classVftablePointer, CLASS_VTABLE_PTR_FIELD_EXT, monitor);
} }
@ -3013,10 +3015,11 @@ public class RTTIGccClassRecoverer extends RTTIClassRecoverer {
" : structure should exist but doesn't."); " : structure should exist but doesn't.");
} }
if (structUtils.canAdd(classStructureDataType, parentOffset, if (EditStructureUtils.canAdd(classStructureDataType, parentOffset,
baseClassStructure.getLength(), monitor)) { baseClassStructure.getLength(), monitor)) {
classStructureDataType = classStructureDataType =
structUtils.addDataTypeToStructure(classStructureDataType, parentOffset, EditStructureUtils.addDataTypeToStructure(classStructureDataType,
parentOffset,
baseClassStructure, baseClassStructure.getName(), monitor); baseClassStructure, baseClassStructure.getName(), monitor);
} }
} }
@ -3027,7 +3030,8 @@ public class RTTIGccClassRecoverer extends RTTIClassRecoverer {
int dataOffset = getDataOffset(recoveredClass, classStructureDataType); int dataOffset = getDataOffset(recoveredClass, classStructureDataType);
int dataLen = UNKNOWN; int dataLen = UNKNOWN;
if (dataOffset != NONE) { if (dataOffset != NONE) {
dataLen = structUtils.getNumberOfUndefinedsStartingAtOffset(classStructureDataType, dataLen =
EditStructureUtils.getNumberOfUndefinedsStartingAtOffset(classStructureDataType,
dataOffset, monitor); dataOffset, monitor);
} }
@ -3037,7 +3041,8 @@ public class RTTIGccClassRecoverer extends RTTIClassRecoverer {
classStructureDataType, dataLen, dataOffset); classStructureDataType, dataLen, dataOffset);
if (recoveredClassDataStruct != null) { if (recoveredClassDataStruct != null) {
classStructureDataType = structUtils.addDataTypeToStructure(classStructureDataType, classStructureDataType = EditStructureUtils.addDataTypeToStructure(
classStructureDataType,
dataOffset, recoveredClassDataStruct, "data", monitor); dataOffset, recoveredClassDataStruct, "data", monitor);
} }

View file

@ -190,7 +190,7 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
figureOutClassDataMembers(recoveredClasses); figureOutClassDataMembers(recoveredClasses);
if (USE_SHORT_TEMPLATE_NAMES_IN_STRUCTURE_FIELDS) { if (USE_SHORT_TEMPLATE_NAMES_IN_STRUCTURE_FIELDS) {
extraUtils.createShortenedTemplateNamesForClasses(recoveredClasses); extendedFlatAPI.createShortenedTemplateNamesForClasses(recoveredClasses);
} }
createAndApplyClassStructures(recoveredClasses); createAndApplyClassStructures(recoveredClasses);
@ -336,7 +336,7 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
continue; continue;
} }
Data data = extraUtils.getDataAt(symbol.getAddress()); Data data = extendedFlatAPI.getDataAt(symbol.getAddress());
if (data != null && if (data != null &&
data.getDataType().getName().contains(RTTI_BASE_COMPLETE_OBJECT_LOADER_DATA_NAME)) { data.getDataType().getName().contains(RTTI_BASE_COMPLETE_OBJECT_LOADER_DATA_NAME)) {
completeObjectLocatorSymbols.add(symbol); completeObjectLocatorSymbols.add(symbol);
@ -375,7 +375,7 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
int sizeOfDt = completeObjLocatorDataType.getLength(); int sizeOfDt = completeObjLocatorDataType.getLength();
api.clearListing(address, address.add(sizeOfDt)); api.clearListing(address, address.add(sizeOfDt));
Data completeObjectLocator = extraUtils.createData(address, completeObjLocatorDataType); Data completeObjectLocator = extendedFlatAPI.createData(address, completeObjLocatorDataType);
if (completeObjectLocator == null) { if (completeObjectLocator == null) {
return null; return null;
} }
@ -402,7 +402,7 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
continue; continue;
} }
Data data = extraUtils.getDataAt(symbol.getAddress()); Data data = extendedFlatAPI.getDataAt(symbol.getAddress());
if (data != null && if (data != null &&
data.getDataType().getName().contains(RTTI_BASE_CLASS_DESCRIPTOR_DATA_NAME)) { data.getDataType().getName().contains(RTTI_BASE_CLASS_DESCRIPTOR_DATA_NAME)) {
baseClassDescriptorSymbols.add(symbol); baseClassDescriptorSymbols.add(symbol);
@ -440,7 +440,7 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
api.clearListing(baseClassDescriptorAddress, baseClassDescriptorAddress.add(sizeOfDt)); api.clearListing(baseClassDescriptorAddress, baseClassDescriptorAddress.add(sizeOfDt));
Data baseClassDescArray = Data baseClassDescArray =
extraUtils.createData(baseClassDescriptorAddress, baseClassDescriptor); extendedFlatAPI.createData(baseClassDescriptorAddress, baseClassDescriptor);
if (baseClassDescArray == null) { if (baseClassDescArray == null) {
return null; return null;
} }
@ -467,16 +467,16 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
//TODO: extraUtils.getReferencedAddress(address, getIboIf64bit); //TODO: extraUtils.getReferencedAddress(address, getIboIf64bit);
Address baseClassDescriptorAddress = getReferencedAddress(address.add(i * 4)); Address baseClassDescriptorAddress = getReferencedAddress(address.add(i * 4));
Data baseClassDescriptor = extraUtils.getDataAt(baseClassDescriptorAddress); Data baseClassDescriptor = extendedFlatAPI.getDataAt(baseClassDescriptorAddress);
if (baseClassDescriptor == null || !baseClassDescriptor.getDataType() if (baseClassDescriptor == null || !baseClassDescriptor.getDataType()
.getName() .getName()
.equals( .equals(
RTTI_BASE_CLASS_DESCRIPTOR_DATA_NAME)) { RTTI_BASE_CLASS_DESCRIPTOR_DATA_NAME)) {
int num1 = extraUtils.getInt(baseClassDescriptorAddress.add(8)); int num1 = extendedFlatAPI.getInt(baseClassDescriptorAddress.add(8));
int num2 = extraUtils.getInt(baseClassDescriptorAddress.add(12)); int num2 = extendedFlatAPI.getInt(baseClassDescriptorAddress.add(12));
int num3 = extraUtils.getInt(baseClassDescriptorAddress.add(16)); int num3 = extendedFlatAPI.getInt(baseClassDescriptorAddress.add(16));
int num4 = extraUtils.getInt(baseClassDescriptorAddress.add(20)); int num4 = extendedFlatAPI.getInt(baseClassDescriptorAddress.add(20));
baseClassDescriptor = createBaseClassDescriptor(baseClassDescriptorAddress); baseClassDescriptor = createBaseClassDescriptor(baseClassDescriptorAddress);
if (baseClassDescriptor != null) { if (baseClassDescriptor != null) {
@ -556,7 +556,7 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
//TODO: extraUtils.getReferencedAddress(address, getIboIf64bit); //TODO: extraUtils.getReferencedAddress(address, getIboIf64bit);
Address classHierarchyDescriptorAddress = getReferencedAddress(address); Address classHierarchyDescriptorAddress = getReferencedAddress(address);
Data classHierarchyStructure = extraUtils.getDataAt(classHierarchyDescriptorAddress); Data classHierarchyStructure = extendedFlatAPI.getDataAt(classHierarchyDescriptorAddress);
if (classHierarchyStructure != null && if (classHierarchyStructure != null &&
classHierarchyStructure.getDataType() classHierarchyStructure.getDataType()
@ -601,7 +601,7 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
classHierarchyDescriptorAddress.add(sizeOfDt)); classHierarchyDescriptorAddress.add(sizeOfDt));
Data classHierarchyStructure = Data classHierarchyStructure =
extraUtils.createData(classHierarchyDescriptorAddress, classHDatatype); extendedFlatAPI.createData(classHierarchyDescriptorAddress, classHDatatype);
if (classHierarchyStructure == null) { if (classHierarchyStructure == null) {
return null; return null;
} }
@ -634,13 +634,13 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
symbolTable.getPrimarySymbol(classHierarchyDescriptorAddress); symbolTable.getPrimarySymbol(classHierarchyDescriptorAddress);
Namespace classNamespace = classHierarchyDescriptorSymbol.getParentNamespace(); Namespace classNamespace = classHierarchyDescriptorSymbol.getParentNamespace();
int numBaseClasses = extraUtils.getInt(classHierarchyDescriptorAddress.add(8)); int numBaseClasses = extendedFlatAPI.getInt(classHierarchyDescriptorAddress.add(8));
//TODO: extraUtils.getReferencedAddress(address, getIboIf64bit); //TODO: extraUtils.getReferencedAddress(address, getIboIf64bit);
Address baseClassArrayAddress = Address baseClassArrayAddress =
getReferencedAddress(classHierarchyDescriptorAddress.add(12)); getReferencedAddress(classHierarchyDescriptorAddress.add(12));
Data baseClassDescArray = extraUtils.getDataAt(baseClassArrayAddress); Data baseClassDescArray = extendedFlatAPI.getDataAt(baseClassArrayAddress);
if (baseClassDescArray != null && baseClassDescArray.isArray()) { if (baseClassDescArray != null && baseClassDescArray.isArray()) {
baseClassArrayAddresses.add(baseClassArrayAddress); baseClassArrayAddresses.add(baseClassArrayAddress);
@ -704,7 +704,7 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
api.clearListing(baseClassArrayAddress, api.clearListing(baseClassArrayAddress,
baseClassArrayAddress.add(numBaseClasses * sizeOfDt)); baseClassArrayAddress.add(numBaseClasses * sizeOfDt));
Data baseClassDescArray = Data baseClassDescArray =
extraUtils.createData(baseClassArrayAddress, baseClassDescArrayDT); extendedFlatAPI.createData(baseClassArrayAddress, baseClassDescArrayDT);
if (baseClassDescArray == null) { if (baseClassDescArray == null) {
return null; return null;
@ -740,7 +740,7 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
continue; continue;
} }
Reference[] referencesTo = extraUtils.getReferencesTo(completeObjectLocatorAddress); Reference[] referencesTo = extendedFlatAPI.getReferencesTo(completeObjectLocatorAddress);
if (referencesTo.length == 0) { if (referencesTo.length == 0) {
//println("no refs to " + completeObjectLocatorAddress.toString()); //println("no refs to " + completeObjectLocatorAddress.toString());
continue; continue;
@ -824,7 +824,7 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
// this will work whether there is a created reference or not // this will work whether there is a created reference or not
int addressSize = address.getSize(); int addressSize = address.getSize();
if (addressSize == 32) { if (addressSize == 32) {
long offset = extraUtils.getInt(address); long offset = extendedFlatAPI.getInt(address);
return address.getNewAddress(offset); return address.getNewAddress(offset);
} }
@ -832,7 +832,7 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
// this currently will workn only if there is a created reference // this currently will workn only if there is a created reference
// TODO: get ibo bytes and figure out what the ibo ref address would be // TODO: get ibo bytes and figure out what the ibo ref address would be
if (addressSize == 64) { if (addressSize == 64) {
Reference refs[] = extraUtils.getReferencesFrom(address); Reference refs[] = extendedFlatAPI.getReferencesFrom(address);
if (refs.length == 0) { if (refs.length == 0) {
return null; return null;
} }
@ -875,7 +875,7 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
findVftableReferencesNotInFunction(vftableSymbols); findVftableReferencesNotInFunction(vftableSymbols);
if (unusedVftableReferences.size() > 0) { if (unusedVftableReferences.size() > 0) {
extraUtils.createUndefinedFunctions(unusedVftableReferences); extendedFlatAPI.createUndefinedFunctions(unusedVftableReferences);
} }
// create these automatically if found // create these automatically if found
@ -937,7 +937,7 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
// Create Data Type Manager Category for given class // Create Data Type Manager Category for given class
// TODO: make this global and check it for null // TODO: make this global and check it for null
CategoryPath classPath = CategoryPath classPath =
extraUtils.createDataTypeCategoryPath(classDataTypesCategoryPath, extendedFlatAPI.createDataTypeCategoryPath(classDataTypesCategoryPath,
classNameWithNamespace); classNameWithNamespace);
RecoveredClass nonVftableClass = RecoveredClass nonVftableClass =
@ -982,7 +982,7 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
*/ */
private List<Symbol> getListOfClassHierarchyDescriptors() throws CancelledException { private List<Symbol> getListOfClassHierarchyDescriptors() throws CancelledException {
List<Symbol> classHierarchyDescriptorList = extraUtils.getListOfSymbolsInAddressSet( List<Symbol> classHierarchyDescriptorList = extendedFlatAPI.getListOfSymbolsInAddressSet(
getInitializedMemory(), RTTI_CLASS_HIERARCHY_DESCRIPTOR_LABEL, false); getInitializedMemory(), RTTI_CLASS_HIERARCHY_DESCRIPTOR_LABEL, false);
return classHierarchyDescriptorList; return classHierarchyDescriptorList;
@ -1011,13 +1011,13 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
Address vftableAddress = vftableIterator.next(); Address vftableAddress = vftableIterator.next();
Address ptrToColAddress = vftableAddress.subtract(defaultPointerSize); Address ptrToColAddress = vftableAddress.subtract(defaultPointerSize);
Data pointerToCompleteObjLocator = extraUtils.getDataAt(vftableAddress); Data pointerToCompleteObjLocator = extendedFlatAPI.getDataAt(vftableAddress);
if (pointerToCompleteObjLocator == null) { if (pointerToCompleteObjLocator == null) {
pointerToCompleteObjLocator = pointerToCompleteObjLocator =
extraUtils.createData(ptrToColAddress, pointerDataType); extendedFlatAPI.createData(ptrToColAddress, pointerDataType);
} }
Address colAddress = extraUtils.getReferencedAddress(ptrToColAddress, false); Address colAddress = extendedFlatAPI.getReferencedAddress(ptrToColAddress, false);
if (colAddress == null) { if (colAddress == null) {
// println(recoveredClass.getName() + " couldn't get referenced col from " + // println(recoveredClass.getName() + " couldn't get referenced col from " +
@ -1028,7 +1028,7 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
try { try {
Address addressOfOffset = colAddress.add(4); Address addressOfOffset = colAddress.add(4);
int offset = extraUtils.getInt(addressOfOffset); int offset = extendedFlatAPI.getInt(addressOfOffset);
recoveredClass.addClassOffsetToVftableMapping(offset, vftableAddress); recoveredClass.addClassOffsetToVftableMapping(offset, vftableAddress);
} }
@ -1178,7 +1178,7 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
List<RecoveredClass> classHierarchy = new ArrayList<RecoveredClass>(); List<RecoveredClass> classHierarchy = new ArrayList<RecoveredClass>();
List<Symbol> symbols = extraUtils.getListOfSymbolsByNameInNamespace( List<Symbol> symbols = extendedFlatAPI.getListOfSymbolsByNameInNamespace(
RTTI_BASE_CLASS_ARRAY_LABEL, RTTI_BASE_CLASS_ARRAY_LABEL,
recoveredClass.getClassNamespace(), false); recoveredClass.getClassNamespace(), false);
@ -1195,7 +1195,7 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
Address pointerAddress = rttiBaseClassDescriptorArray.getComponent(i).getAddress(); Address pointerAddress = rttiBaseClassDescriptorArray.getComponent(i).getAddress();
Address baseClassDescriptorAddress = Address baseClassDescriptorAddress =
extraUtils.getSingleReferencedAddress(pointerAddress); extendedFlatAPI.getSingleReferencedAddress(pointerAddress);
if (baseClassDescriptorAddress == null) { if (baseClassDescriptorAddress == null) {
return classHierarchy; return classHierarchy;
@ -1246,13 +1246,13 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
private int getClassInheritanceFlag(Namespace classNamespace) private int getClassInheritanceFlag(Namespace classNamespace)
throws CancelledException, MemoryAccessException, AddressOutOfBoundsException { throws CancelledException, MemoryAccessException, AddressOutOfBoundsException {
List<Symbol> symbols = extraUtils.getListOfSymbolsByNameInNamespace( List<Symbol> symbols = extendedFlatAPI.getListOfSymbolsByNameInNamespace(
RTTI_CLASS_HIERARCHY_DESCRIPTOR_LABEL, classNamespace, false); RTTI_CLASS_HIERARCHY_DESCRIPTOR_LABEL, classNamespace, false);
if (symbols.size() >= 1) { if (symbols.size() >= 1) {
try { try {
return (extraUtils.getInt(symbols.get(0).getAddress().add(4))); return (extendedFlatAPI.getInt(symbols.get(0).getAddress().add(4)));
} }
catch (MemoryAccessException e) { catch (MemoryAccessException e) {
// println("Could not get class inheritance flag at address " + // println("Could not get class inheritance flag at address " +
@ -1393,7 +1393,7 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
// iterate over base class array and for each parent class of the given recovered class // iterate over base class array and for each parent class of the given recovered class
// get the mdisp, pdisp, vdisp info // get the mdisp, pdisp, vdisp info
List<Symbol> baseClassArray = extraUtils.getListOfSymbolsByNameInNamespace( List<Symbol> baseClassArray = extendedFlatAPI.getListOfSymbolsByNameInNamespace(
RTTI_BASE_CLASS_ARRAY_LABEL, recoveredClass.getClassNamespace(), false); RTTI_BASE_CLASS_ARRAY_LABEL, recoveredClass.getClassNamespace(), false);
// this should never happen // this should never happen
@ -1425,7 +1425,7 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
Address pointerAddress = baseClassArrayData.getComponent(i).getAddress(); Address pointerAddress = baseClassArrayData.getComponent(i).getAddress();
Address baseClassDescriptorAddress = Address baseClassDescriptorAddress =
extraUtils.getReferencedAddress(pointerAddress, true); extendedFlatAPI.getReferencedAddress(pointerAddress, true);
if (baseClassArrayAddress == null) { if (baseClassArrayAddress == null) {
continue; continue;
} }
@ -1630,7 +1630,7 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
getTargetAddressFromPcodeOp(offsetPcodeOpPair.getPcodeOp()); getTargetAddressFromPcodeOp(offsetPcodeOpPair.getPcodeOp());
Address vbtableAddress = Address vbtableAddress =
extraUtils.getSingleReferencedAddress(listingAddress); extendedFlatAPI.getSingleReferencedAddress(listingAddress);
if (vbtableAddress == null) { if (vbtableAddress == null) {
continue; continue;
@ -1989,7 +1989,7 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
if (possibleVftable == null) { if (possibleVftable == null) {
Function referencedFunction = Function referencedFunction =
extraUtils.getReferencedFunction(classReferenceAddress, true); extendedFlatAPI.getReferencedFunction(classReferenceAddress, true);
if (referencedFunction == null) { if (referencedFunction == null) {
continue; continue;
} }
@ -2337,7 +2337,7 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
Address pointerAddress = baseClassArrayData.getComponent(i).getAddress(); Address pointerAddress = baseClassArrayData.getComponent(i).getAddress();
Address baseClassDescriptorAddress = Address baseClassDescriptorAddress =
extraUtils.getReferencedAddress(pointerAddress, true); extendedFlatAPI.getReferencedAddress(pointerAddress, true);
if (baseClassDescriptorAddress == null) { if (baseClassDescriptorAddress == null) {
continue; continue;
} }
@ -2400,7 +2400,8 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
dataLength = baseClassStructure.getLength() - lengthOfVirtualParent; dataLength = baseClassStructure.getLength() - lengthOfVirtualParent;
} }
if (structUtils.canAdd(classStructureDataType, baseClassOffset, dataLength, if (EditStructureUtils.canAdd(classStructureDataType, baseClassOffset,
dataLength,
monitor)) { monitor)) {
classStructureDataType = classStructureDataType =
addIndividualComponentsToStructure(classStructureDataType, addIndividualComponentsToStructure(classStructureDataType,
@ -2410,10 +2411,11 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
} }
// else copy whole baseClass structure to the class Structure // else copy whole baseClass structure to the class Structure
if (structUtils.canAdd(classStructureDataType, baseClassOffset, if (EditStructureUtils.canAdd(classStructureDataType, baseClassOffset,
baseClassStructure.getLength(), monitor)) { baseClassStructure.getLength(), monitor)) {
classStructureDataType = classStructureDataType =
structUtils.addDataTypeToStructure(classStructureDataType, baseClassOffset, EditStructureUtils.addDataTypeToStructure(classStructureDataType,
baseClassOffset,
baseClassStructure, baseClassStructure.getName(), monitor); baseClassStructure, baseClassStructure.getName(), monitor);
} }
@ -2429,11 +2431,12 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
baseClassOffset = api.getInt(recoveredClass.getVbtableAddress().add(vdisp)) + pdisp; baseClassOffset = api.getInt(recoveredClass.getVbtableAddress().add(vdisp)) + pdisp;
if (structUtils.canAdd(classStructureDataType, baseClassOffset, if (EditStructureUtils.canAdd(classStructureDataType, baseClassOffset,
baseClassStructure.getLength(), monitor)) { baseClassStructure.getLength(), monitor)) {
classStructureDataType = classStructureDataType =
structUtils.addDataTypeToStructure(classStructureDataType, baseClassOffset, EditStructureUtils.addDataTypeToStructure(classStructureDataType,
baseClassOffset,
baseClassStructure, baseClassStructure.getName(), monitor); baseClassStructure, baseClassStructure.getName(), monitor);
} }
@ -2461,9 +2464,10 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
DataType classVftablePointer = vfPointerDataTypes.get(vftableAddress); DataType classVftablePointer = vfPointerDataTypes.get(vftableAddress);
if (structUtils.canAdd(classStructureDataType, offset.intValue(), if (EditStructureUtils.canAdd(classStructureDataType, offset.intValue(),
classVftablePointer.getLength(), monitor)) { classVftablePointer.getLength(), monitor)) {
classStructureDataType = structUtils.addDataTypeToStructure(classStructureDataType, classStructureDataType = EditStructureUtils.addDataTypeToStructure(
classStructureDataType,
offset.intValue(), classVftablePointer, CLASS_VTABLE_PTR_FIELD_EXT, monitor); offset.intValue(), classVftablePointer, CLASS_VTABLE_PTR_FIELD_EXT, monitor);
} }
@ -2479,7 +2483,8 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
int dataOffset = getDataOffset(recoveredClass, classStructureDataType); int dataOffset = getDataOffset(recoveredClass, classStructureDataType);
int dataLen = UNKNOWN; int dataLen = UNKNOWN;
if (dataOffset != NONE) { if (dataOffset != NONE) {
dataLen = structUtils.getNumberOfUndefinedsStartingAtOffset(classStructureDataType, dataLen =
EditStructureUtils.getNumberOfUndefinedsStartingAtOffset(classStructureDataType,
dataOffset, monitor); dataOffset, monitor);
} }
@ -2489,7 +2494,8 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
classStructureDataType, dataLen, dataOffset); classStructureDataType, dataLen, dataOffset);
if (recoveredClassDataStruct != null) { if (recoveredClassDataStruct != null) {
classStructureDataType = structUtils.addDataTypeToStructure(classStructureDataType, classStructureDataType =
EditStructureUtils.addDataTypeToStructure(classStructureDataType,
dataOffset, recoveredClassDataStruct, dataOffset, recoveredClassDataStruct,
classStructureDataType.getName() + "_data", monitor); classStructureDataType.getName() + "_data", monitor);
} }
@ -2556,11 +2562,12 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
monitor.checkCanceled(); monitor.checkCanceled();
// if enough empty bytes - add class vftable pointer // if enough empty bytes - add class vftable pointer
if (structUtils.canAdd(classStructureDataType, vftableOffset, if (EditStructureUtils.canAdd(classStructureDataType, vftableOffset,
classVftablePointer.getLength(), monitor)) { classVftablePointer.getLength(), monitor)) {
classStructureDataType = classStructureDataType =
structUtils.addDataTypeToStructure(classStructureDataType, vftableOffset, EditStructureUtils.addDataTypeToStructure(classStructureDataType,
vftableOffset,
classVftablePointer, CLASS_VTABLE_PTR_FIELD_EXT, monitor); classVftablePointer, CLASS_VTABLE_PTR_FIELD_EXT, monitor);
addedVftablePointer = true; addedVftablePointer = true;
@ -2677,7 +2684,7 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
return false; return false;
} }
int numUndefined1s = int numUndefined1s =
structUtils.getNumberOfUndefinedsStartingAtOffset(structure, 0, monitor); EditStructureUtils.getNumberOfUndefinedsStartingAtOffset(structure, 0, monitor);
if (structure.getLength() == numUndefined1s) { if (structure.getLength() == numUndefined1s) {
return true; return true;
} }
@ -2722,7 +2729,7 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
Address pointerAddress = baseClassArrayData.getComponent(i).getAddress(); Address pointerAddress = baseClassArrayData.getComponent(i).getAddress();
Address baseClassDescriptorAddress = Address baseClassDescriptorAddress =
extraUtils.getReferencedAddress(pointerAddress, true); extendedFlatAPI.getReferencedAddress(pointerAddress, true);
if (baseClassDescriptorAddress == null) { if (baseClassDescriptorAddress == null) {
continue; continue;
} }
@ -2785,7 +2792,7 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
*/ */
private Data getBaseClassArray(RecoveredClass recoveredClass) throws CancelledException { private Data getBaseClassArray(RecoveredClass recoveredClass) throws CancelledException {
List<Symbol> baseClassArray = extraUtils.getListOfSymbolsByNameInNamespace( List<Symbol> baseClassArray = extendedFlatAPI.getListOfSymbolsByNameInNamespace(
RTTI_BASE_CLASS_ARRAY_LABEL, recoveredClass.getClassNamespace(), false); RTTI_BASE_CLASS_ARRAY_LABEL, recoveredClass.getClassNamespace(), false);
if (baseClassArray.size() != 1) { if (baseClassArray.size() != 1) {
@ -2842,9 +2849,11 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
DataType vbaseStructPointer = dataTypeManager.getPointer(vbtableStructure); DataType vbaseStructPointer = dataTypeManager.getPointer(vbtableStructure);
int dataLength = vbaseStructPointer.getLength(); int dataLength = vbaseStructPointer.getLength();
if (structUtils.canAdd(classStructureDataType, vbtableOffset, dataLength, monitor)) { if (EditStructureUtils.canAdd(classStructureDataType, vbtableOffset, dataLength,
monitor)) {
classStructureDataType = structUtils.addDataTypeToStructure(classStructureDataType, classStructureDataType =
EditStructureUtils.addDataTypeToStructure(classStructureDataType,
vbtableOffset, vbaseStructPointer, "vbtablePtr", monitor); vbtableOffset, vbaseStructPointer, "vbtablePtr", monitor);
} }

View file

@ -95,7 +95,6 @@ public class RecoveredClass {
private static final int NONE = -1; private static final int NONE = -1;
TaskMonitor monitor = TaskMonitor.DUMMY; TaskMonitor monitor = TaskMonitor.DUMMY;
EditStructureUtils structUtils;
RecoveredClass(String name, CategoryPath classPath, Namespace classNamespace, RecoveredClass(String name, CategoryPath classPath, Namespace classNamespace,
@ -105,7 +104,6 @@ public class RecoveredClass {
this.classNamespace = classNamespace; this.classNamespace = classNamespace;
this.dataTypeManager = dataTypeManager; this.dataTypeManager = dataTypeManager;
this.structUtils = new EditStructureUtils();
} }
public String getName() { public String getName() {
@ -531,11 +529,11 @@ public class RecoveredClass {
// if the new component is a non-empty structure, check to see if the current // if the new component is a non-empty structure, check to see if the current
// structure has undefined or equivalent components and replace with new struct if so // structure has undefined or equivalent components and replace with new struct if so
if (newComponentDataType instanceof Structure) { if (newComponentDataType instanceof Structure) {
if (structUtils.hasReplaceableComponentsAtOffset(computedClassStructure, if (EditStructureUtils.hasReplaceableComponentsAtOffset(computedClassStructure,
offset, (Structure) newComponentDataType, monitor)) { offset, (Structure) newComponentDataType, monitor)) {
boolean successfulClear = boolean successfulClear =
structUtils.clearLengthAtOffset(computedClassStructure, offset, EditStructureUtils.clearLengthAtOffset(computedClassStructure, offset,
length, monitor); length, monitor);
if (successfulClear) { if (successfulClear) {
@ -547,13 +545,14 @@ public class RecoveredClass {
} }
// if current component is undefined size 1 and new component is not undefined size 1 // if current component is undefined size 1 and new component is not undefined size 1
// then replace it // and there are enough undefineds for it to fit, then replace it
if (structUtils.isUndefined1(currentComponentDataType) && if (EditStructureUtils.isUndefined1(currentComponentDataType) &&
!structUtils.isUndefined1(newComponentDataType)) { !EditStructureUtils.isUndefined1(newComponentDataType)) {
if (structUtils.hasEnoughUndefinedsOfAnyLengthAtOffset(computedClassStructure, if (EditStructureUtils.hasEnoughUndefinedsOfAnyLengthAtOffset(
computedClassStructure,
offset, length, monitor)) { offset, length, monitor)) {
boolean successfulClear = boolean successfulClear =
structUtils.clearLengthAtOffset(computedClassStructure, offset, EditStructureUtils.clearLengthAtOffset(computedClassStructure, offset,
length, monitor); length, monitor);
if (successfulClear) { if (successfulClear) {
@ -567,13 +566,14 @@ public class RecoveredClass {
// if new component is not an undefined data type and the current componenent(s) // if new component is not an undefined data type and the current componenent(s)
// that make up new component length are all undefineds then clear and replace // that make up new component length are all undefineds then clear and replace
// the current component(s) with the new one // the current component(s) with the new one
if (structUtils.isUndefined(currentComponentDataType) && if (Undefined.isUndefined(currentComponentDataType) &&
!structUtils.isUndefined(newComponentDataType)) { !Undefined.isUndefined(newComponentDataType)) {
if (structUtils.hasEnoughUndefinedsOfAnyLengthAtOffset(computedClassStructure, if (EditStructureUtils.hasEnoughUndefinedsOfAnyLengthAtOffset(
computedClassStructure,
offset, length, monitor)) { offset, length, monitor)) {
boolean successfulClear = boolean successfulClear =
structUtils.clearLengthAtOffset(computedClassStructure, offset, EditStructureUtils.clearLengthAtOffset(computedClassStructure, offset,
length, monitor); length, monitor);
if (successfulClear) { if (successfulClear) {
@ -601,7 +601,7 @@ public class RecoveredClass {
continue; continue;
} }
if (structUtils.isUndefined1(dataType)) { if (EditStructureUtils.isUndefined1(dataType)) {
dataType = new Undefined1DataType(); dataType = new Undefined1DataType();
DataTypeComponent component = DataTypeComponent component =
computedClassStructure.getComponentAt(offset.intValue()); computedClassStructure.getComponentAt(offset.intValue());

View file

@ -130,8 +130,7 @@ public class RecoveredClassUtils {
int defaultPointerSize; int defaultPointerSize;
SymbolTable symbolTable; SymbolTable symbolTable;
ExtraScriptUtils extraUtils; ExtendedFlatProgramAPI extendedFlatAPI;
EditStructureUtils structUtils;
DecompilerScriptUtils decompilerUtils; DecompilerScriptUtils decompilerUtils;
CategoryPath classDataTypesCategoryPath; CategoryPath classDataTypesCategoryPath;
@ -156,10 +155,10 @@ public class RecoveredClassUtils {
this.tool = tool; this.tool = tool;
this.api = api; this.api = api;
extraUtils = new ExtraScriptUtils(program, monitor); extendedFlatAPI = new ExtendedFlatProgramAPI(program, monitor);
this.classDataTypesCategoryPath = this.classDataTypesCategoryPath =
extraUtils.createDataTypeCategoryPath(CategoryPath.ROOT, DTM_CLASS_DATA_FOLDER_NAME); extendedFlatAPI.createDataTypeCategoryPath(CategoryPath.ROOT, DTM_CLASS_DATA_FOLDER_NAME);
this.createBookmarks = createBookmarks; this.createBookmarks = createBookmarks;
this.useShortTemplates = useShortTemplates; this.useShortTemplates = useShortTemplates;
@ -169,7 +168,6 @@ public class RecoveredClassUtils {
globalNamespace = (GlobalNamespace) program.getGlobalNamespace(); globalNamespace = (GlobalNamespace) program.getGlobalNamespace();
decompilerUtils = new DecompilerScriptUtils(program, tool, monitor); decompilerUtils = new DecompilerScriptUtils(program, tool, monitor);
structUtils = new EditStructureUtils();
dataTypeManager = program.getDataTypeManager(); dataTypeManager = program.getDataTypeManager();
symbolTable = program.getSymbolTable(); symbolTable = program.getSymbolTable();
@ -416,7 +414,7 @@ public class RecoveredClassUtils {
if (allConstructorsAndDestructors.contains(calledFunction)) { if (allConstructorsAndDestructors.contains(calledFunction)) {
// get list of refs to this function from the calling function // get list of refs to this function from the calling function
List<Address> referencesToFunctionBFromFunctionA = List<Address> referencesToFunctionBFromFunctionA =
extraUtils.getReferencesToFunctionBFromFunctionA(function, extendedFlatAPI.getReferencesToFunctionBFromFunctionA(function,
referencedFunction); referencedFunction);
// add them to list of ref address pairs // add them to list of ref address pairs
Iterator<Address> iterator = referencesToFunctionBFromFunctionA.iterator(); Iterator<Address> iterator = referencesToFunctionBFromFunctionA.iterator();
@ -684,7 +682,7 @@ public class RecoveredClassUtils {
monitor.checkCanceled(); monitor.checkCanceled();
Address vftableRef = vftableRefIterator.next(); Address vftableRef = vftableRefIterator.next();
Address vftableAddress = extraUtils.getSingleReferencedAddress(vftableRef); Address vftableAddress = extendedFlatAPI.getSingleReferencedAddress(vftableRef);
if (vftableAddress == null) { if (vftableAddress == null) {
continue; continue;
@ -1264,11 +1262,11 @@ public class RecoveredClassUtils {
DataType dataType = function.getParameter(i).getDataType(); DataType dataType = function.getParameter(i).getDataType();
if (!extraUtils.isPointerToEmptyStructure(dataType)) { if (!extendedFlatAPI.isPointerToEmptyStructure(dataType)) {
continue; continue;
} }
PointerDataType ptrUndefined = extraUtils.createPointerToUndefinedDataType(dataType); PointerDataType ptrUndefined = extendedFlatAPI.createPointerToUndefinedDataType(dataType);
if (ptrUndefined != null) { if (ptrUndefined != null) {
function.getParameter(i).setDataType(ptrUndefined, SourceType.ANALYSIS); function.getParameter(i).setDataType(ptrUndefined, SourceType.ANALYSIS);
} }
@ -1277,9 +1275,9 @@ public class RecoveredClassUtils {
// Next check the return type to see if it is the empty structure // Next check the return type to see if it is the empty structure
DataType returnType = function.getReturnType(); DataType returnType = function.getReturnType();
if (extraUtils.isPointerToEmptyStructure(returnType)) { if (extendedFlatAPI.isPointerToEmptyStructure(returnType)) {
PointerDataType ptrUndefined = PointerDataType ptrUndefined =
extraUtils.createPointerToUndefinedDataType(returnType); extendedFlatAPI.createPointerToUndefinedDataType(returnType);
if (ptrUndefined != null) { if (ptrUndefined != null) {
function.setReturnType(ptrUndefined, SourceType.ANALYSIS); function.setReturnType(ptrUndefined, SourceType.ANALYSIS);
} }
@ -1694,7 +1692,7 @@ public class RecoveredClassUtils {
return possibleParentConstructors; return possibleParentConstructors;
} }
Address minVftableReference = extraUtils.getMinimumAddressOnList(vftableReferenceList); Address minVftableReference = extendedFlatAPI.getMinimumAddressOnList(vftableReferenceList);
Iterator<ReferenceAddressPair> iterator = refAddrPairList.iterator(); Iterator<ReferenceAddressPair> iterator = refAddrPairList.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
@ -1768,7 +1766,7 @@ public class RecoveredClassUtils {
return possibleParentDestructors; return possibleParentDestructors;
} }
Address maxVftableReference = extraUtils.getMaximumAddressOnList(vftableReferenceList); Address maxVftableReference = extendedFlatAPI.getMaximumAddressOnList(vftableReferenceList);
Iterator<ReferenceAddressPair> iterator = refAddrPairList.iterator(); Iterator<ReferenceAddressPair> iterator = refAddrPairList.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
@ -1776,7 +1774,7 @@ public class RecoveredClassUtils {
ReferenceAddressPair refAddrPair = iterator.next(); ReferenceAddressPair refAddrPair = iterator.next();
Address sourceAddr = refAddrPair.getSource(); Address sourceAddr = refAddrPair.getSource();
if (sourceAddr.compareTo(maxVftableReference) > 0) { if (sourceAddr.compareTo(maxVftableReference) > 0) {
Function calledFunction = extraUtils.getFunctionAt(refAddrPair.getDestination()); Function calledFunction = extendedFlatAPI.getFunctionAt(refAddrPair.getDestination());
if (calledFunction != null) { if (calledFunction != null) {
possibleParentDestructors.add(calledFunction); possibleParentDestructors.add(calledFunction);
} }
@ -1960,7 +1958,7 @@ public class RecoveredClassUtils {
} }
// If not already, make function a thiscall // If not already, make function a thiscall
extraUtils.makeFunctionThiscall(constructorFunction); extendedFlatAPI.makeFunctionThiscall(constructorFunction);
recoveredClass.addConstructor(constructorFunction); recoveredClass.addConstructor(constructorFunction);
addToAllConstructors(constructorFunction); addToAllConstructors(constructorFunction);
@ -1978,7 +1976,7 @@ public class RecoveredClassUtils {
throws InvalidInputException, DuplicateNameException { throws InvalidInputException, DuplicateNameException {
//If not already, make function a thiscall //If not already, make function a thiscall
extraUtils.makeFunctionThiscall(inlinedConstructorFunction); extendedFlatAPI.makeFunctionThiscall(inlinedConstructorFunction);
recoveredClass.addInlinedConstructor(inlinedConstructorFunction); recoveredClass.addInlinedConstructor(inlinedConstructorFunction);
addToAllInlinedConstructors(inlinedConstructorFunction); addToAllInlinedConstructors(inlinedConstructorFunction);
@ -1995,7 +1993,7 @@ public class RecoveredClassUtils {
throws InvalidInputException, DuplicateNameException { throws InvalidInputException, DuplicateNameException {
//If not already, make function a thiscall //If not already, make function a thiscall
extraUtils.makeFunctionThiscall(destructorFunction); extendedFlatAPI.makeFunctionThiscall(destructorFunction);
recoveredClass.addDestructor(destructorFunction); recoveredClass.addDestructor(destructorFunction);
addToAllDestructors(destructorFunction); addToAllDestructors(destructorFunction);
@ -2013,7 +2011,7 @@ public class RecoveredClassUtils {
throws InvalidInputException, DuplicateNameException { throws InvalidInputException, DuplicateNameException {
//If not already, make function a thiscall //If not already, make function a thiscall
extraUtils.makeFunctionThiscall(inlinedDestructorFunction); extendedFlatAPI.makeFunctionThiscall(inlinedDestructorFunction);
recoveredClass.addInlinedDestructor(inlinedDestructorFunction); recoveredClass.addInlinedDestructor(inlinedDestructorFunction);
addToAllInlinedDestructors(inlinedDestructorFunction); addToAllInlinedDestructors(inlinedDestructorFunction);
@ -2098,7 +2096,7 @@ public class RecoveredClassUtils {
Address constructorReference = constructorIterator.next(); Address constructorReference = constructorIterator.next();
RecoveredClass recoveredClass = referenceToClassMap.get(constructorReference); RecoveredClass recoveredClass = referenceToClassMap.get(constructorReference);
Function constructor = extraUtils.getReferencedFunction(constructorReference, true); Function constructor = extendedFlatAPI.getReferencedFunction(constructorReference, true);
if (recoveredClass.getIndeterminateList().contains(constructor)) { if (recoveredClass.getIndeterminateList().contains(constructor)) {
addConstructorToClass(recoveredClass, constructor); addConstructorToClass(recoveredClass, constructor);
@ -2295,7 +2293,7 @@ public class RecoveredClassUtils {
ReferenceAddressPair referenceAddressPair = calledFunctionIterator.next(); ReferenceAddressPair referenceAddressPair = calledFunctionIterator.next();
Address calledFunctionAddress = referenceAddressPair.getDestination(); Address calledFunctionAddress = referenceAddressPair.getDestination();
Function calledFunction = extraUtils.getFunctionAt(calledFunctionAddress); Function calledFunction = extendedFlatAPI.getFunctionAt(calledFunctionAddress);
if (calledFunction.isThunk()) { if (calledFunction.isThunk()) {
calledFunction = calledFunction.getThunkedFunction(true); calledFunction = calledFunction.getThunkedFunction(true);
@ -2329,7 +2327,7 @@ public class RecoveredClassUtils {
ReferenceAddressPair referenceAddressPair = calledFunctionIterator.next(); ReferenceAddressPair referenceAddressPair = calledFunctionIterator.next();
Address calledFunctionAddress = referenceAddressPair.getDestination(); Address calledFunctionAddress = referenceAddressPair.getDestination();
Function calledFunction = extraUtils.getFunctionAt(calledFunctionAddress); Function calledFunction = extendedFlatAPI.getFunctionAt(calledFunctionAddress);
if (calledFunction.isThunk()) { if (calledFunction.isThunk()) {
calledFunction = calledFunction.getThunkedFunction(true); calledFunction = calledFunction.getThunkedFunction(true);
@ -2542,7 +2540,7 @@ public class RecoveredClassUtils {
Address destructorReference = destructorIterator.next(); Address destructorReference = destructorIterator.next();
RecoveredClass recoveredClass = referenceToClassMap.get(destructorReference); RecoveredClass recoveredClass = referenceToClassMap.get(destructorReference);
Function destructor = extraUtils.getReferencedFunction(destructorReference, true); Function destructor = extendedFlatAPI.getReferencedFunction(destructorReference, true);
if (recoveredClass.getIndeterminateList().contains(destructor)) { if (recoveredClass.getIndeterminateList().contains(destructor)) {
addDestructorToClass(recoveredClass, destructor); addDestructorToClass(recoveredClass, destructor);
@ -2668,7 +2666,7 @@ public class RecoveredClassUtils {
String className = namespace.getName(); String className = namespace.getName();
String classNameWithNamespace = namespace.getName(true); String classNameWithNamespace = namespace.getName(true);
CategoryPath classPath = extraUtils.createDataTypeCategoryPath(classDataTypesCategoryPath, CategoryPath classPath = extendedFlatAPI.createDataTypeCategoryPath(classDataTypesCategoryPath,
classNameWithNamespace); classNameWithNamespace);
RecoveredClass newClass = RecoveredClass newClass =
@ -2873,7 +2871,7 @@ public class RecoveredClassUtils {
while (referencesIterator.hasNext()) { while (referencesIterator.hasNext()) {
monitor.checkCanceled(); monitor.checkCanceled();
Address vftableReference = referencesIterator.next(); Address vftableReference = referencesIterator.next();
Function functionContaining = extraUtils.getFunctionContaining(vftableReference); Function functionContaining = extendedFlatAPI.getFunctionContaining(vftableReference);
if (functionContaining != null) { if (functionContaining != null) {
vftableRefToFunctionMapping.put(vftableReference, functionContaining); vftableRefToFunctionMapping.put(vftableReference, functionContaining);
} }
@ -2923,7 +2921,7 @@ public class RecoveredClassUtils {
Data vftableData = program.getListing().getDefinedDataAt(vftableAddress); Data vftableData = program.getListing().getDefinedDataAt(vftableAddress);
// now make sure the array or the structure is all pointers // now make sure the array or the structure is all pointers
if (!extraUtils.isArrayOrStructureOfAllPointers(vftableData)) { if (!extendedFlatAPI.isArrayOrStructureOfAllPointers(vftableData)) {
// if it isn't an array of pointers then we don't know the size of the vftable // if it isn't an array of pointers then we don't know the size of the vftable
// If undefined or pointers not in array or struct then see if what they are // If undefined or pointers not in array or struct then see if what they are
// pointing to are in the class already to determine size of array // pointing to are in the class already to determine size of array
@ -2957,12 +2955,12 @@ public class RecoveredClassUtils {
monitor.checkCanceled(); monitor.checkCanceled();
Address functionPointerAddress = vftableData.getComponent(i).getAddress(); Address functionPointerAddress = vftableData.getComponent(i).getAddress();
if (allowNullFunctionPtrs && extraUtils.isNullPointer(functionPointerAddress)) { if (allowNullFunctionPtrs && extendedFlatAPI.isNullPointer(functionPointerAddress)) {
virtualFunctionList.add(null); virtualFunctionList.add(null);
continue; continue;
} }
Function function = extraUtils.getPointedToFunction(functionPointerAddress); Function function = extendedFlatAPI.getPointedToFunction(functionPointerAddress);
if (function != null) { if (function != null) {
virtualFunctionList.add(function); virtualFunctionList.add(function);
@ -3009,7 +3007,7 @@ public class RecoveredClassUtils {
boolean stillInCurrentTable = true; boolean stillInCurrentTable = true;
while (address != null && currentBlock.contains(address) && stillInCurrentTable && while (address != null && currentBlock.contains(address) && stillInCurrentTable &&
extraUtils.isFunctionPointer(address, allowNullFunctionPtrs)) { extendedFlatAPI.isFunctionPointer(address, allowNullFunctionPtrs)) {
numFunctionPointers++; numFunctionPointers++;
address = address.add(defaultPointerSize); address = address.add(defaultPointerSize);
Symbol symbol = program.getSymbolTable().getPrimarySymbol(address); Symbol symbol = program.getSymbolTable().getPrimarySymbol(address);
@ -3098,7 +3096,7 @@ public class RecoveredClassUtils {
program.getListing().getInstructionContaining(vftableReference); program.getListing().getInstructionContaining(vftableReference);
if (instructionContaining != null) { if (instructionContaining != null) {
boolean functionCreated = boolean functionCreated =
extraUtils.createFunction(program, vftableReference); extendedFlatAPI.createFunction(program, vftableReference);
if (!functionCreated) { if (!functionCreated) {
notInFunctionVftableRefs.add(vftableReference); notInFunctionVftableRefs.add(vftableReference);
@ -3154,7 +3152,7 @@ public class RecoveredClassUtils {
} }
else { else {
boolean functionCreated = boolean functionCreated =
extraUtils.createFunction(prog, addr); extendedFlatAPI.createFunction(prog, addr);
if (!functionCreated) { if (!functionCreated) {
notInFunctionVftableRefs.add(addr); notInFunctionVftableRefs.add(addr);
} }
@ -3819,7 +3817,7 @@ public class RecoveredClassUtils {
if (!badFIDNamespaces.contains(symbol.getParentNamespace())) { if (!badFIDNamespaces.contains(symbol.getParentNamespace())) {
badFIDNamespaces.add(symbol.getParentNamespace()); badFIDNamespaces.add(symbol.getParentNamespace());
} }
extraUtils.addUniqueStringToPlateComment(functionAddress, extendedFlatAPI.addUniqueStringToPlateComment(functionAddress,
"***** Removed Bad FID Symbol *****"); "***** Removed Bad FID Symbol *****");
if (!badFIDFunctions.contains(function)) { if (!badFIDFunctions.contains(function)) {
@ -3827,7 +3825,7 @@ public class RecoveredClassUtils {
} }
findAndRemoveBadStructuresFromFunction(function, namespace); findAndRemoveBadStructuresFromFunction(function, namespace);
extraUtils.removeAllSymbolsAtAddress(functionAddress); extendedFlatAPI.removeAllSymbolsAtAddress(functionAddress);
} }
return; return;
@ -3838,7 +3836,7 @@ public class RecoveredClassUtils {
if (bookmarkComment.contains("Multiple Matches")) { if (bookmarkComment.contains("Multiple Matches")) {
// See if any contain the class name and if so add "resolved" and if not // See if any contain the class name and if so add "resolved" and if not
if (doAnySymbolsHaveMatchingName(functionAddress, name)) { if (doAnySymbolsHaveMatchingName(functionAddress, name)) {
extraUtils.addUniqueStringToPlateComment(functionAddress, extendedFlatAPI.addUniqueStringToPlateComment(functionAddress,
"***** Resolved FID Conflict *****"); "***** Resolved FID Conflict *****");
if (!resolvedFIDFunctions.contains(function)) { if (!resolvedFIDFunctions.contains(function)) {
@ -3848,7 +3846,7 @@ public class RecoveredClassUtils {
findAndRemoveBadStructuresFromFunction(function, namespace); findAndRemoveBadStructuresFromFunction(function, namespace);
} }
else { else {
extraUtils.addUniqueStringToPlateComment(functionAddress, extendedFlatAPI.addUniqueStringToPlateComment(functionAddress,
"***** Removed Bad FID Symbol(s) *****"); "***** Removed Bad FID Symbol(s) *****");
if (!badFIDFunctions.contains(function)) { if (!badFIDFunctions.contains(function)) {
@ -3858,7 +3856,7 @@ public class RecoveredClassUtils {
findAndRemoveBadStructuresFromFunction(function, namespace); findAndRemoveBadStructuresFromFunction(function, namespace);
} }
extraUtils.removeAllSymbolsAtAddress(functionAddress); extendedFlatAPI.removeAllSymbolsAtAddress(functionAddress);
return; return;
} }
} }
@ -3971,7 +3969,7 @@ public class RecoveredClassUtils {
monitor.checkCanceled(); monitor.checkCanceled();
DataType dataType = function.getParameter(i).getDataType(); DataType dataType = function.getParameter(i).getDataType();
if (!dataType.getName().equals(namespace.getName()) && if (!dataType.getName().equals(namespace.getName()) &&
extraUtils.isPointerToEmptyStructure(dataType)) { extendedFlatAPI.isPointerToEmptyStructure(dataType)) {
Pointer ptr = (Pointer) dataType; Pointer ptr = (Pointer) dataType;
Structure structure = (Structure) ptr.getDataType(); Structure structure = (Structure) ptr.getDataType();
@ -4001,7 +3999,7 @@ public class RecoveredClassUtils {
for (int i = 0; i < parameterCount; i++) { for (int i = 0; i < parameterCount; i++) {
monitor.checkCanceled(); monitor.checkCanceled();
DataType paramDataType = function.getParameter(i).getDataType(); DataType paramDataType = function.getParameter(i).getDataType();
Structure baseDataType = extraUtils.getBaseStructureDataType(paramDataType); Structure baseDataType = extendedFlatAPI.getBaseStructureDataType(paramDataType);
if (baseDataType != null && badStructureDataTypes.contains(baseDataType)) { if (baseDataType != null && badStructureDataTypes.contains(baseDataType)) {
// To remove from this param we have to remove the function from its namespace // To remove from this param we have to remove the function from its namespace
@ -4011,7 +4009,7 @@ public class RecoveredClassUtils {
} }
else { else {
PointerDataType ptrUndefined = PointerDataType ptrUndefined =
extraUtils.createPointerToUndefinedDataType(paramDataType); extendedFlatAPI.createPointerToUndefinedDataType(paramDataType);
if (ptrUndefined != null) { if (ptrUndefined != null) {
function.getParameter(i).setDataType(ptrUndefined, SourceType.ANALYSIS); function.getParameter(i).setDataType(ptrUndefined, SourceType.ANALYSIS);
} }
@ -4036,7 +4034,7 @@ public class RecoveredClassUtils {
DataType returnType = function.getReturnType(); DataType returnType = function.getReturnType();
if (!returnType.getName().equals(namespace.getName()) && if (!returnType.getName().equals(namespace.getName()) &&
extraUtils.isPointerToEmptyStructure(returnType)) { extendedFlatAPI.isPointerToEmptyStructure(returnType)) {
Pointer ptr = (Pointer) returnType; Pointer ptr = (Pointer) returnType;
Structure structure = (Structure) ptr.getDataType(); Structure structure = (Structure) ptr.getDataType();
@ -4058,10 +4056,10 @@ public class RecoveredClassUtils {
throws InvalidInputException { throws InvalidInputException {
DataType returnType = function.getReturnType(); DataType returnType = function.getReturnType();
Structure baseDataType = extraUtils.getBaseStructureDataType(returnType); Structure baseDataType = extendedFlatAPI.getBaseStructureDataType(returnType);
if (baseDataType != null && badStructureDataTypes.contains(baseDataType)) { if (baseDataType != null && badStructureDataTypes.contains(baseDataType)) {
PointerDataType ptrUndefined = PointerDataType ptrUndefined =
extraUtils.createPointerToUndefinedDataType(returnType); extendedFlatAPI.createPointerToUndefinedDataType(returnType);
if (ptrUndefined != null) { if (ptrUndefined != null) {
function.setReturnType(ptrUndefined, SourceType.ANALYSIS); function.setReturnType(ptrUndefined, SourceType.ANALYSIS);
} }
@ -4080,13 +4078,13 @@ public class RecoveredClassUtils {
private boolean doAnySymbolsHaveMatchingName(Address address, String name) private boolean doAnySymbolsHaveMatchingName(Address address, String name)
throws CancelledException { throws CancelledException {
String simpleName = extraUtils.removeTemplate(name); String simpleName = extendedFlatAPI.removeTemplate(name);
SymbolIterator it = symbolTable.getSymbolsAsIterator(address); SymbolIterator it = symbolTable.getSymbolsAsIterator(address);
for (Symbol symbol : it) { for (Symbol symbol : it) {
monitor.checkCanceled(); monitor.checkCanceled();
String simpleSymbolName = extraUtils.removeTemplate(symbol.getName()); String simpleSymbolName = extendedFlatAPI.removeTemplate(symbol.getName());
simpleSymbolName = removeSingleQuotes(simpleSymbolName); simpleSymbolName = removeSingleQuotes(simpleSymbolName);
simpleSymbolName = removeFIDConflict(simpleSymbolName); simpleSymbolName = removeFIDConflict(simpleSymbolName);
simpleSymbolName = removeSingleQuotes(simpleSymbolName); simpleSymbolName = removeSingleQuotes(simpleSymbolName);
@ -4178,7 +4176,7 @@ public class RecoveredClassUtils {
throws CancelledException { throws CancelledException {
List<ReferenceAddressPair> orderedReferenceAddressPairsFromCallingFunction = List<ReferenceAddressPair> orderedReferenceAddressPairsFromCallingFunction =
extraUtils.getOrderedReferenceAddressPairsFromCallingFunction(constructor); extendedFlatAPI.getOrderedReferenceAddressPairsFromCallingFunction(constructor);
// if there are no calls from the function then return false // if there are no calls from the function then return false
if (orderedReferenceAddressPairsFromCallingFunction.size() == 0) { if (orderedReferenceAddressPairsFromCallingFunction.size() == 0) {
@ -4252,9 +4250,9 @@ public class RecoveredClassUtils {
monitor.checkCanceled(); monitor.checkCanceled();
Function vfunction = vfunctionIterator.next(); Function vfunction = vfunctionIterator.next();
if (extraUtils.doesFunctionACallAnyListedFunction(vfunction, if (extendedFlatAPI.doesFunctionACallAnyListedFunction(vfunction,
recoveredClass.getConstructorList()) && recoveredClass.getConstructorList()) &&
!extraUtils.doesFunctionACallAnyListedFunction(vfunction, !extendedFlatAPI.doesFunctionACallAnyListedFunction(vfunction,
allOtherConstructors)) { allOtherConstructors)) {
cloneToClassMap.put(vfunction, recoveredClass); cloneToClassMap.put(vfunction, recoveredClass);
} }
@ -4297,13 +4295,13 @@ public class RecoveredClassUtils {
if (calledFunctions.size() != 2 && calledFunctions.size() != 3) { if (calledFunctions.size() != 2 && calledFunctions.size() != 3) {
return false; return false;
} }
if (!extraUtils.getCalledFunctionByCallOrder(caller, 1).equals(firstCalled)) { if (!extendedFlatAPI.getCalledFunctionByCallOrder(caller, 1).equals(firstCalled)) {
return false; return false;
} }
RecoveredClass recoveredClass = cloneFunctionToClassMap.get(caller); RecoveredClass recoveredClass = cloneFunctionToClassMap.get(caller);
List<Function> constructorList = recoveredClass.getConstructorList(); List<Function> constructorList = recoveredClass.getConstructorList();
Function secondFunction = extraUtils.getCalledFunctionByCallOrder(caller, 2); Function secondFunction = extendedFlatAPI.getCalledFunctionByCallOrder(caller, 2);
if (secondFunction.isThunk()) { if (secondFunction.isThunk()) {
secondFunction = secondFunction.getThunkedFunction(true); secondFunction = secondFunction.getThunkedFunction(true);
} }
@ -4342,7 +4340,7 @@ public class RecoveredClassUtils {
// The second call is a class constructor and we know it is called // The second call is a class constructor and we know it is called
// from the cloneFunction or it wouldn't be a cloneFunction // from the cloneFunction or it wouldn't be a cloneFunction
Function firstCalledFunction = Function firstCalledFunction =
extraUtils.getCalledFunctionByCallOrder(cloneFunction, 1); extendedFlatAPI.getCalledFunctionByCallOrder(cloneFunction, 1);
if (firstCalledFunction == null) { if (firstCalledFunction == null) {
continue; continue;
} }
@ -4434,7 +4432,7 @@ public class RecoveredClassUtils {
Namespace badNamespace = badNamespaceIterator.next(); Namespace badNamespace = badNamespaceIterator.next();
// delete empty namespace and parent namespaces // delete empty namespace and parent namespaces
if (!extraUtils.hasSymbolsInNamespace(badNamespace)) { if (!extendedFlatAPI.hasSymbolsInNamespace(badNamespace)) {
removeEmptyNamespaces(badNamespace); removeEmptyNamespaces(badNamespace);
} }
} }
@ -4455,7 +4453,7 @@ public class RecoveredClassUtils {
Namespace parentNamespace = namespace.getParentNamespace(); Namespace parentNamespace = namespace.getParentNamespace();
namespace.getSymbol().delete(); namespace.getSymbol().delete();
while (parentNamespace != null && !extraUtils.hasSymbolsInNamespace(parentNamespace)) { while (parentNamespace != null && !extendedFlatAPI.hasSymbolsInNamespace(parentNamespace)) {
monitor.checkCanceled(); monitor.checkCanceled();
namespace = parentNamespace; namespace = parentNamespace;
@ -4500,7 +4498,7 @@ public class RecoveredClassUtils {
throws CancelledException { throws CancelledException {
DataType dataType = dataTypeManager.getDataType(folderPath, structureName); DataType dataType = dataTypeManager.getDataType(folderPath, structureName);
if (extraUtils.isEmptyStructure(dataType)) { if (extendedFlatAPI.isEmptyStructure(dataType)) {
dataTypeManager.remove(dataType, monitor); dataTypeManager.remove(dataType, monitor);
Category classCategory = dataTypeManager.getCategory(folderPath); Category classCategory = dataTypeManager.getCategory(folderPath);
@ -5335,7 +5333,7 @@ public class RecoveredClassUtils {
} }
// get first called function and verify it is on cd list // get first called function and verify it is on cd list
Function firstCalledFunction = Function firstCalledFunction =
extraUtils.getCalledFunctionByCallOrder(deletingDestructor, 1); extendedFlatAPI.getCalledFunctionByCallOrder(deletingDestructor, 1);
if (firstCalledFunction == null || if (firstCalledFunction == null ||
!recoveredClass.getConstructorOrDestructorFunctions() !recoveredClass.getConstructorOrDestructorFunctions()
.contains( .contains(
@ -5345,7 +5343,7 @@ public class RecoveredClassUtils {
// get second one and if operator_delete has not been assigned yet, assign it // get second one and if operator_delete has not been assigned yet, assign it
Function secondCalledFunction = Function secondCalledFunction =
extraUtils.getCalledFunctionByCallOrder(deletingDestructor, 2); extendedFlatAPI.getCalledFunctionByCallOrder(deletingDestructor, 2);
if (secondCalledFunction == null) { if (secondCalledFunction == null) {
return null; return null;
} }
@ -5392,7 +5390,7 @@ public class RecoveredClassUtils {
throws CancelledException, InvalidInputException, DuplicateNameException { throws CancelledException, InvalidInputException, DuplicateNameException {
// don't continue checking if it doesn't call operator_delete // don't continue checking if it doesn't call operator_delete
if (!extraUtils.doesFunctionACallFunctionB(virtualFunction, operatorDeleteFunction)) { if (!extendedFlatAPI.doesFunctionACallFunctionB(virtualFunction, operatorDeleteFunction)) {
return; return;
} }
@ -5408,7 +5406,7 @@ public class RecoveredClassUtils {
Function function = functionIterator.next(); Function function = functionIterator.next();
//Type 4 - class c/d called from other than first vfunction //Type 4 - class c/d called from other than first vfunction
if (extraUtils.doesFunctionACallFunctionB(virtualFunction, function)) { if (extendedFlatAPI.doesFunctionACallFunctionB(virtualFunction, function)) {
recoveredClass.addDeletingDestructor(virtualFunction); recoveredClass.addDeletingDestructor(virtualFunction);
addDestructorToClass(recoveredClass, function); addDestructorToClass(recoveredClass, function);
recoveredClass.removeIndeterminateConstructorOrDestructor(function); recoveredClass.removeIndeterminateConstructorOrDestructor(function);
@ -5454,7 +5452,7 @@ public class RecoveredClassUtils {
continue; continue;
} }
Function referencedFunction = extraUtils.getReferencedFunction(codeUnitAddress, true); Function referencedFunction = extendedFlatAPI.getReferencedFunction(codeUnitAddress, true);
if (referencedFunction == null) { if (referencedFunction == null) {
continue; continue;
} }
@ -5580,7 +5578,7 @@ public class RecoveredClassUtils {
String fieldname = dataTypeComponent.getFieldName(); String fieldname = dataTypeComponent.getFieldName();
structureDataType = structUtils.addDataTypeToStructure(structureDataType, structureDataType = EditStructureUtils.addDataTypeToStructure(structureDataType,
startOffset + dataComponentOffset, dataTypeComponent.getDataType(), fieldname, startOffset + dataComponentOffset, dataTypeComponent.getDataType(), fieldname,
monitor); monitor);
} }
@ -5609,7 +5607,7 @@ public class RecoveredClassUtils {
String fieldname = dataTypeComponent.getFieldName(); String fieldname = dataTypeComponent.getFieldName();
structureDataType = structUtils.addDataTypeToStructure(structureDataType, structureDataType = EditStructureUtils.addDataTypeToStructure(structureDataType,
startOffset + dataComponentOffset, dataTypeComponent.getDataType(), fieldname, startOffset + dataComponentOffset, dataTypeComponent.getDataType(), fieldname,
monitor); monitor);
} }
@ -5913,9 +5911,9 @@ public class RecoveredClassUtils {
// get first called function and verify is not a c/d function in current class or // get first called function and verify is not a c/d function in current class or
// any class get second called function and verify it is operator delete // any class get second called function and verify it is operator delete
Function firstCalledFunction = Function firstCalledFunction =
extraUtils.getCalledFunctionByCallOrder(vFunction, 1); extendedFlatAPI.getCalledFunctionByCallOrder(vFunction, 1);
Function secondCalledFunction = Function secondCalledFunction =
extraUtils.getCalledFunctionByCallOrder(vFunction, 2); extendedFlatAPI.getCalledFunctionByCallOrder(vFunction, 2);
if (firstCalledFunction != null && secondCalledFunction != null && if (firstCalledFunction != null && secondCalledFunction != null &&
!recoveredClass.getConstructorOrDestructorFunctions() !recoveredClass.getConstructorOrDestructorFunctions()
.contains( .contains(
@ -6197,7 +6195,7 @@ public class RecoveredClassUtils {
Map<Address, RecoveredClass> referenceToClassMap = Map<Address, RecoveredClass> referenceToClassMap =
getReferenceToClassMap(recoveredClass, inlineFunction); getReferenceToClassMap(recoveredClass, inlineFunction);
List<Address> referencesToFunctions = List<Address> referencesToFunctions =
extraUtils.getReferencesToFunctions(referenceToClassMap); extendedFlatAPI.getReferencesToFunctions(referenceToClassMap);
// if some of the references are to functions figure out if they are // if some of the references are to functions figure out if they are
// constructors destructors or add them to list of indetermined // constructors destructors or add them to list of indetermined
@ -6212,7 +6210,7 @@ public class RecoveredClassUtils {
monitor.checkCanceled(); monitor.checkCanceled();
Address functionReference = functionReferenceIterator.next(); Address functionReference = functionReferenceIterator.next();
Function function = Function function =
extraUtils.getReferencedFunction(functionReference, true); extendedFlatAPI.getReferencedFunction(functionReference, true);
if (function == null) { if (function == null) {
continue; continue;
} }
@ -6342,7 +6340,7 @@ public class RecoveredClassUtils {
} }
int dataLength = int dataLength =
structUtils.getNumberOfUndefinedsBeforeOffset(structure, endOfData, monitor); EditStructureUtils.getNumberOfUndefinedsBeforeOffset(structure, endOfData, monitor);
if (dataLength < 0) { if (dataLength < 0) {
return NONE; return NONE;
} }
@ -6378,7 +6376,7 @@ public class RecoveredClassUtils {
boolean callsKnownConstructor = callsKnownConstructor(indeterminateFunction); boolean callsKnownConstructor = callsKnownConstructor(indeterminateFunction);
boolean callsKnownDestrutor = callsKnownDestructor(indeterminateFunction); boolean callsKnownDestrutor = callsKnownDestructor(indeterminateFunction);
boolean callsAtexit = boolean callsAtexit =
extraUtils.doesFunctionACallFunctionB(indeterminateFunction, atexit); extendedFlatAPI.doesFunctionACallFunctionB(indeterminateFunction, atexit);
if (callsKnownConstructor && !callsKnownDestrutor) { if (callsKnownConstructor && !callsKnownDestrutor) {
addConstructorToClass(recoveredClass, indeterminateFunction); addConstructorToClass(recoveredClass, indeterminateFunction);
@ -6486,7 +6484,7 @@ public class RecoveredClassUtils {
public void findFunctionsUsingAtexit() throws CancelledException, InvalidInputException { public void findFunctionsUsingAtexit() throws CancelledException, InvalidInputException {
Function atexitFunction = null; Function atexitFunction = null;
List<Function> atexitFunctions = extraUtils.getGlobalFunctions("_atexit"); List<Function> atexitFunctions = extendedFlatAPI.getGlobalFunctions("_atexit");
if (atexitFunctions.size() != 1) { if (atexitFunctions.size() != 1) {
return; return;
} }
@ -6501,13 +6499,13 @@ public class RecoveredClassUtils {
Reference ref = referenceIterator.next(); Reference ref = referenceIterator.next();
Address fromAddress = ref.getFromAddress(); Address fromAddress = ref.getFromAddress();
Function function = extraUtils.getFunctionContaining(fromAddress); Function function = extendedFlatAPI.getFunctionContaining(fromAddress);
if (function == null) { if (function == null) {
AddressSet subroutineAddresses = AddressSet subroutineAddresses =
extraUtils.getSubroutineAddresses(program, fromAddress); extendedFlatAPI.getSubroutineAddresses(program, fromAddress);
Address minAddress = subroutineAddresses.getMinAddress(); Address minAddress = subroutineAddresses.getMinAddress();
function = extraUtils.createFunction(minAddress, null); function = extendedFlatAPI.createFunction(minAddress, null);
if (function == null) { if (function == null) {
continue; continue;
} }
@ -6542,9 +6540,9 @@ public class RecoveredClassUtils {
continue; continue;
} }
Function calledFunction = extraUtils.getFunctionAt(calledAddress); Function calledFunction = extendedFlatAPI.getFunctionAt(calledAddress);
if (calledFunction == null) { if (calledFunction == null) {
calledFunction = extraUtils.createFunction(calledAddress, null); calledFunction = extendedFlatAPI.createFunction(calledAddress, null);
if (calledFunction == null) { if (calledFunction == null) {
continue; continue;
} }
@ -6595,7 +6593,7 @@ public class RecoveredClassUtils {
Address vftableAddress = vftableIterator.next(); Address vftableAddress = vftableIterator.next();
// this gets the first function pointer in the vftable // this gets the first function pointer in the vftable
Function firstVirtualFunction = extraUtils.getPointedToFunction(vftableAddress); Function firstVirtualFunction = extendedFlatAPI.getPointedToFunction(vftableAddress);
processDeletingDestructor(recoveredClass, firstVirtualFunction); processDeletingDestructor(recoveredClass, firstVirtualFunction);
} }
} }
@ -6641,7 +6639,7 @@ public class RecoveredClassUtils {
monitor.checkCanceled(); monitor.checkCanceled();
Address vftableAddress = vftableAddressIterator.next(); Address vftableAddress = vftableAddressIterator.next();
Function firstVirtualFunction = extraUtils.getPointedToFunction(vftableAddress); Function firstVirtualFunction = extendedFlatAPI.getPointedToFunction(vftableAddress);
List<Function> virtualFunctions = List<Function> virtualFunctions =
recoveredClass.getVirtualFunctions(vftableAddress); recoveredClass.getVirtualFunctions(vftableAddress);
@ -6748,7 +6746,7 @@ public class RecoveredClassUtils {
Function function = functionIterator.next(); Function function = functionIterator.next();
if (extraUtils.doesFunctionACallFunctionB(firstVirtualFunction, function)) { if (extendedFlatAPI.doesFunctionACallFunctionB(firstVirtualFunction, function)) {
recoveredClass.addDeletingDestructor(firstVirtualFunction); recoveredClass.addDeletingDestructor(firstVirtualFunction);
addDestructorToClass(recoveredClass, function); addDestructorToClass(recoveredClass, function);
recoveredClass.removeIndeterminateConstructorOrDestructor(function); recoveredClass.removeIndeterminateConstructorOrDestructor(function);
@ -7113,7 +7111,7 @@ public class RecoveredClassUtils {
// if the computed class struct has field name (ie from pdb) use it otherwise create one // if the computed class struct has field name (ie from pdb) use it otherwise create one
if (definedComponent.getFieldName() == null) { if (definedComponent.getFieldName() == null) {
fieldName = "offset_" + extraUtils.toHexString(offset, false, true); fieldName = "offset_" + extendedFlatAPI.toHexString(offset, false, true);
} }
else { else {
fieldName = definedComponent.getFieldName(); fieldName = definedComponent.getFieldName();
@ -7149,7 +7147,7 @@ public class RecoveredClassUtils {
for (DataTypeComponent component : definedComponents) { for (DataTypeComponent component : definedComponents) {
monitor.checkCanceled(); monitor.checkCanceled();
classStructureDataType = structUtils.addDataTypeToStructure( classStructureDataType = EditStructureUtils.addDataTypeToStructure(
classStructureDataType, component.getOffset(), component.getDataType(), classStructureDataType, component.getOffset(), component.getDataType(),
component.getFieldName(), monitor); component.getFieldName(), monitor);
} }
@ -7302,7 +7300,7 @@ public class RecoveredClassUtils {
} }
String classNameWithNamespace = classNamespace.getName(true); String classNameWithNamespace = classNamespace.getName(true);
CategoryPath classPath = extraUtils.createDataTypeCategoryPath( CategoryPath classPath = extendedFlatAPI.createDataTypeCategoryPath(
classDataTypesCategoryPath, classNameWithNamespace); classDataTypesCategoryPath, classNameWithNamespace);
// check that the given vftable data type is in the right ClassDataTypes/<class_folder> // check that the given vftable data type is in the right ClassDataTypes/<class_folder>