mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 09:49:23 +02:00
Merge remote-tracking branch
'origin/GP-4459_ghidra007_windows_rtti_null_ptr' into patch (Closes #6348)
This commit is contained in:
commit
10a63ab38f
1 changed files with 13 additions and 45 deletions
|
@ -16,14 +16,7 @@
|
||||||
//DO NOT RUN. THIS IS NOT A SCRIPT! THIS IS A CLASS THAT IS USED BY SCRIPTS.
|
//DO NOT RUN. THIS IS NOT A SCRIPT! THIS IS A CLASS THAT IS USED BY SCRIPTS.
|
||||||
package classrecovery;
|
package classrecovery;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.ListIterator;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import ghidra.app.plugin.core.decompile.actions.FillOutStructureCmd;
|
import ghidra.app.plugin.core.decompile.actions.FillOutStructureCmd;
|
||||||
import ghidra.app.plugin.core.decompile.actions.FillOutStructureCmd.OffsetPcodeOpPair;
|
import ghidra.app.plugin.core.decompile.actions.FillOutStructureCmd.OffsetPcodeOpPair;
|
||||||
|
@ -31,41 +24,17 @@ import ghidra.app.util.opinion.PeLoader;
|
||||||
import ghidra.app.util.opinion.PeLoader.CompilerOpinion.CompilerEnum;
|
import ghidra.app.util.opinion.PeLoader.CompilerOpinion.CompilerEnum;
|
||||||
import ghidra.framework.plugintool.PluginTool;
|
import ghidra.framework.plugintool.PluginTool;
|
||||||
import ghidra.program.flatapi.FlatProgramAPI;
|
import ghidra.program.flatapi.FlatProgramAPI;
|
||||||
import ghidra.program.model.address.Address;
|
import ghidra.program.model.address.*;
|
||||||
import ghidra.program.model.address.AddressOutOfBoundsException;
|
import ghidra.program.model.data.*;
|
||||||
import ghidra.program.model.address.AddressRange;
|
import ghidra.program.model.listing.*;
|
||||||
import ghidra.program.model.address.AddressSet;
|
|
||||||
import ghidra.program.model.address.AddressSetView;
|
|
||||||
import ghidra.program.model.data.ArrayDataType;
|
|
||||||
import ghidra.program.model.data.Category;
|
|
||||||
import ghidra.program.model.data.CategoryPath;
|
|
||||||
import ghidra.program.model.data.DataType;
|
|
||||||
import ghidra.program.model.data.DataTypeConflictHandler;
|
|
||||||
import ghidra.program.model.data.IntegerDataType;
|
|
||||||
import ghidra.program.model.data.PointerDataType;
|
|
||||||
import ghidra.program.model.data.Structure;
|
|
||||||
import ghidra.program.model.data.StructureDataType;
|
|
||||||
import ghidra.program.model.listing.CircularDependencyException;
|
|
||||||
import ghidra.program.model.listing.Data;
|
|
||||||
import ghidra.program.model.listing.FlowOverride;
|
|
||||||
import ghidra.program.model.listing.Function;
|
|
||||||
import ghidra.program.model.listing.Instruction;
|
|
||||||
import ghidra.program.model.listing.Program;
|
|
||||||
import ghidra.program.model.mem.MemoryAccessException;
|
import ghidra.program.model.mem.MemoryAccessException;
|
||||||
import ghidra.program.model.mem.MemoryBlock;
|
import ghidra.program.model.mem.MemoryBlock;
|
||||||
import ghidra.program.model.pcode.HighFunction;
|
import ghidra.program.model.pcode.HighFunction;
|
||||||
import ghidra.program.model.pcode.HighVariable;
|
import ghidra.program.model.pcode.HighVariable;
|
||||||
import ghidra.program.model.symbol.Namespace;
|
import ghidra.program.model.symbol.*;
|
||||||
import ghidra.program.model.symbol.Reference;
|
|
||||||
import ghidra.program.model.symbol.SourceType;
|
|
||||||
import ghidra.program.model.symbol.Symbol;
|
|
||||||
import ghidra.program.model.symbol.SymbolIterator;
|
|
||||||
import ghidra.program.model.symbol.SymbolType;
|
|
||||||
import ghidra.program.util.ProgramLocation;
|
import ghidra.program.util.ProgramLocation;
|
||||||
import ghidra.util.Msg;
|
import ghidra.util.Msg;
|
||||||
import ghidra.util.exception.CancelledException;
|
import ghidra.util.exception.*;
|
||||||
import ghidra.util.exception.DuplicateNameException;
|
|
||||||
import ghidra.util.exception.InvalidInputException;
|
|
||||||
import ghidra.util.task.TaskMonitor;
|
import ghidra.util.task.TaskMonitor;
|
||||||
|
|
||||||
public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
|
public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
|
||||||
|
@ -2405,10 +2374,10 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
|
||||||
recoveredClass.getVftableAddresses().size() > 1 &&
|
recoveredClass.getVftableAddresses().size() > 1 &&
|
||||||
recoveredClass.inheritsVirtualAncestor()) {
|
recoveredClass.inheritsVirtualAncestor()) {
|
||||||
|
|
||||||
int virtParentOffset = getSingleVirtualParentOffset(baseClass);
|
Integer virtParentOffset = getSingleVirtualParentOffset(baseClass);
|
||||||
|
|
||||||
int dataLength;
|
int dataLength;
|
||||||
if (virtParentOffset == NONE) {
|
if (virtParentOffset == null || virtParentOffset == NONE) {
|
||||||
dataLength = baseClassStructure.getLength();
|
dataLength = baseClassStructure.getLength();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -2526,7 +2495,7 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
|
||||||
* @param recoveredClass the given class
|
* @param recoveredClass the given class
|
||||||
* @return the offset in the given class structure of the classes single virtual parent or NONE
|
* @return the offset in the given class structure of the classes single virtual parent or NONE
|
||||||
* if cannot retrieve an offset value or if there is not a single virtual parent for the given
|
* if cannot retrieve an offset value or if there is not a single virtual parent for the given
|
||||||
* class.
|
* class. Return null if cannot retrieve the offset for the single virtual parent.
|
||||||
* @throws CancelledException if cancelled
|
* @throws CancelledException if cancelled
|
||||||
* @throws AddressOutOfBoundsException if trying to access an address that does not exist in program
|
* @throws AddressOutOfBoundsException if trying to access an address that does not exist in program
|
||||||
* @throws MemoryAccessException if trying to access memory that can't be accessed
|
* @throws MemoryAccessException if trying to access memory that can't be accessed
|
||||||
|
@ -2548,7 +2517,7 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
|
||||||
private Map<RecoveredClass, Integer> getBaseClassOffsetMap(RecoveredClass recoveredClass)
|
private Map<RecoveredClass, Integer> getBaseClassOffsetMap(RecoveredClass recoveredClass)
|
||||||
throws CancelledException, MemoryAccessException, AddressOutOfBoundsException {
|
throws CancelledException, MemoryAccessException, AddressOutOfBoundsException {
|
||||||
|
|
||||||
Map<RecoveredClass, Integer> parentOffsetMap = new HashMap<RecoveredClass, Integer>();
|
Map<RecoveredClass, Integer> baseClassOffsetMap = new HashMap<>();
|
||||||
|
|
||||||
Data baseClassArrayData = getBaseClassArray(recoveredClass);
|
Data baseClassArrayData = getBaseClassArray(recoveredClass);
|
||||||
|
|
||||||
|
@ -2574,9 +2543,8 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
|
||||||
baseClassDescriptorAddress.toString());
|
baseClassDescriptorAddress.toString());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Continue if the class has mult inh but base class is not on the parent list
|
// Continue if the class has mult inh but base class is not on the parent list
|
||||||
//TODO: possibly update to include all base classes
|
|
||||||
if (!recoveredClass.getParentList().contains(baseClass)) {
|
if (!recoveredClass.getParentList().contains(baseClass)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -2599,9 +2567,9 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
|
||||||
}
|
}
|
||||||
baseClassOffset = api.getInt(recoveredClass.getVbtableAddress().add(vdisp)) + pdisp;
|
baseClassOffset = api.getInt(recoveredClass.getVbtableAddress().add(vdisp)) + pdisp;
|
||||||
}
|
}
|
||||||
parentOffsetMap.put(baseClass, baseClassOffset);
|
baseClassOffsetMap.put(baseClass, baseClassOffset);
|
||||||
}
|
}
|
||||||
return parentOffsetMap;
|
return baseClassOffsetMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue