GP-6502: Removing DVRT references

This commit is contained in:
Ryan Kurtz
2026-03-03 06:10:27 -05:00
parent 0a37382eb9
commit ded7b845a6
6 changed files with 44 additions and 49 deletions
@@ -23,8 +23,7 @@ import ghidra.app.util.bin.*;
import ghidra.app.util.importer.MessageLog;
import ghidra.program.model.address.Address;
import ghidra.program.model.data.*;
import ghidra.program.model.listing.*;
import ghidra.program.model.symbol.*;
import ghidra.program.model.listing.Program;
import ghidra.util.DataConverter;
import ghidra.util.exception.DuplicateNameException;
import ghidra.util.task.TaskMonitor;
@@ -192,9 +191,9 @@ public class BaseRelocation implements StructConverter, ByteArrayConverter {
public void markup(Program program, Address addr, boolean isBinary, TaskMonitor monitor,
MessageLog log, NTHeader ntHeader) throws DuplicateNameException, IOException {
ReferenceManager refMgr = program.getReferenceManager();
Listing listing = program.getListing();
Address imageBase = program.getImageBase();
// ReferenceManager refMgr = program.getReferenceManager();
// Listing listing = program.getListing();
// Address imageBase = program.getImageBase();
DataType dt = toDataType();
PeUtils.createData(program, addr, dt, log);
addr = addr.add(dt.getLength());
@@ -206,14 +205,14 @@ public class BaseRelocation implements StructConverter, ByteArrayConverter {
DataType typeOffsetDt = typeOffset.toDataType();
PeUtils.createData(program, addr, typeOffsetDt, log);
if (typeOffset.typeOffset != 0) {
refMgr.addMemoryReference(addr, imageBase.add(virtualAddress + typeOffset.offset),
RefType.DATA, SourceType.IMPORTED, 0);
listing.setComment(addr, CommentType.EOL, getName(typeOffset.type));
}
else {
listing.setComment(addr, CommentType.EOL, "padding");
}
// if (typeOffset.typeOffset != 0) {
// refMgr.addMemoryReference(addr, imageBase.add(virtualAddress + typeOffset.offset),
// RefType.DATA, SourceType.IMPORTED, 0);
// listing.setComment(addr, CommentType.EOL, getName(typeOffset.type));
// }
// else {
// listing.setComment(addr, CommentType.EOL, "padding");
// }
addr = addr.add(typeOffsetDt.getLength());
}
@@ -223,7 +222,7 @@ public class BaseRelocation implements StructConverter, ByteArrayConverter {
public DataType toDataType() throws DuplicateNameException {
StructureDataType struct = new StructureDataType(NAME, 0);
struct.add(IBO32, "VirtualAddress", null);
struct.add(DWORD, "VirtualAddress", null);
struct.add(DWORD,"SizeOfBlock",null);
struct.setCategoryPath(new CategoryPath("/PE"));
@@ -27,7 +27,6 @@ import ghidra.program.model.address.Address;
import ghidra.program.model.data.*;
import ghidra.program.model.listing.Program;
import ghidra.program.model.mem.MemoryAccessException;
import ghidra.program.model.symbol.*;
import ghidra.program.model.util.CodeUnitInsertionException;
import ghidra.util.exception.DuplicateNameException;
import ghidra.util.task.TaskMonitor;
@@ -86,7 +85,7 @@ public class ImageArm64X extends AbstractImageDynamicRelocationHeader {
public void markup(Program program, boolean isBinary, TaskMonitor monitor, MessageLog log,
NTHeader ntHeader) throws DuplicateNameException, CodeUnitInsertionException,
IOException, MemoryAccessException {
ReferenceManager refMgr = program.getReferenceManager();
// ReferenceManager refMgr = program.getReferenceManager();
Address imageBase = program.getImageBase();
DataType dt = toDataType();
Address addr = imageBase.add(rva);
@@ -94,11 +93,11 @@ public class ImageArm64X extends AbstractImageDynamicRelocationHeader {
addr = addr.add(dt.getLength());
for (ImageArm64XDynamicRelocation reloc : relocs) {
reloc.markup(program, isBinary, monitor, log, ntHeader);
int pageRelativeOffset = reloc.getPageRelativeOffset();
if (pageRelativeOffset != 0) {
refMgr.addMemoryReference(addr, imageBase.add(virtualAddress + pageRelativeOffset),
RefType.DATA, SourceType.IMPORTED, 0);
}
// int pageRelativeOffset = reloc.getPageRelativeOffset();
// if (pageRelativeOffset != 0) {
// refMgr.addMemoryReference(addr, imageBase.add(virtualAddress + pageRelativeOffset),
// RefType.DATA, SourceType.IMPORTED, 0);
// }
addr = addr.add(reloc.toDataType().getLength() + reloc.getData().length);
}
}
@@ -106,7 +105,7 @@ public class ImageArm64X extends AbstractImageDynamicRelocationHeader {
@Override
public DataType toDataType() throws DuplicateNameException, IOException {
StructureDataType struct = new StructureDataType("IMAGE_ARM64X", 0);
struct.add(IBO32, "VirtualAddress", null);
struct.add(DWORD, "VirtualAddress", null);
struct.add(DWORD, "SizeOfBlock", null);
struct.setCategoryPath(new CategoryPath("/PE"));
return struct;
@@ -114,8 +114,8 @@ public class ImageFunctionOverrideDynamicRelocation implements StructConverter,
PeUtils.createData(program, addr, dt, log);
addr = addr.add(dt.getLength());
for (int i = 0; i < rvas.length; i++) {
PeUtils.createData(program, addr, IBO32, log);
addr = addr.add(IBO32.getLength());
PeUtils.createData(program, addr, DWORD, log);
addr = addr.add(DWORD.getLength());
}
for (BaseRelocation baseReloc : baseRelocs) {
baseReloc.markup(program, addr, isBinary, monitor, log, ntHeader);
@@ -127,7 +127,7 @@ public class ImageFunctionOverrideDynamicRelocation implements StructConverter,
public DataType toDataType() throws DuplicateNameException, IOException {
StructureDataType struct =
new StructureDataType("IMAGE_FUNCTION_OVERRIDE_DYNAMIC_RELOCATION", 0);
struct.add(IBO32, "OriginalRva", "RVA of original function");
struct.add(DWORD, "OriginalRva", "RVA of original function");
struct.add(DWORD, "BDDOffset", "Offset into the BDD region");
struct.add(DWORD, "RvaSize",
"Size in bytes taken by RVAs. Must be multiple of sizeof(DWORD).");
@@ -27,7 +27,6 @@ import ghidra.program.model.address.Address;
import ghidra.program.model.data.*;
import ghidra.program.model.listing.Program;
import ghidra.program.model.mem.MemoryAccessException;
import ghidra.program.model.symbol.*;
import ghidra.program.model.util.CodeUnitInsertionException;
import ghidra.util.exception.DuplicateNameException;
import ghidra.util.task.TaskMonitor;
@@ -87,7 +86,7 @@ public class ImageImportControlTransfer extends AbstractImageDynamicRelocationHe
public void markup(Program program, boolean isBinary, TaskMonitor monitor, MessageLog log,
NTHeader ntHeader) throws DuplicateNameException, CodeUnitInsertionException,
IOException, MemoryAccessException {
ReferenceManager refMgr = program.getReferenceManager();
// ReferenceManager refMgr = program.getReferenceManager();
Address imageBase = program.getImageBase();
DataType dt = toDataType();
Address addr = imageBase.add(rva);
@@ -95,11 +94,11 @@ public class ImageImportControlTransfer extends AbstractImageDynamicRelocationHe
addr = addr.add(dt.getLength());
for (ImageImportControlTransferDynamicRelocation reloc : relocs) {
reloc.markup(program, isBinary, monitor, log, ntHeader);
int pageRelativeOffset = reloc.getPageRelativeOffset();
if (pageRelativeOffset != 0) {
refMgr.addMemoryReference(addr, imageBase.add(virtualAddress + pageRelativeOffset),
RefType.DATA, SourceType.IMPORTED, 0);
}
// int pageRelativeOffset = reloc.getPageRelativeOffset();
// if (pageRelativeOffset != 0) {
// refMgr.addMemoryReference(addr, imageBase.add(virtualAddress + pageRelativeOffset),
// RefType.DATA, SourceType.IMPORTED, 0);
// }
addr = addr.add(reloc.toDataType().getLength());
}
}
@@ -107,7 +106,7 @@ public class ImageImportControlTransfer extends AbstractImageDynamicRelocationHe
@Override
public DataType toDataType() throws DuplicateNameException, IOException {
StructureDataType struct = new StructureDataType("IMAGE_IMPORT_CONTROL_TRANSFER", 0);
struct.add(IBO32, "VirtualAddress", null);
struct.add(DWORD, "VirtualAddress", null);
struct.add(DWORD, "SizeOfBlock", null);
struct.setCategoryPath(new CategoryPath("/PE"));
return struct;
@@ -27,7 +27,6 @@ import ghidra.program.model.address.Address;
import ghidra.program.model.data.*;
import ghidra.program.model.listing.Program;
import ghidra.program.model.mem.MemoryAccessException;
import ghidra.program.model.symbol.*;
import ghidra.program.model.util.CodeUnitInsertionException;
import ghidra.util.exception.DuplicateNameException;
import ghidra.util.task.TaskMonitor;
@@ -87,7 +86,7 @@ public class ImageIndirControlTransfer extends AbstractImageDynamicRelocationHea
public void markup(Program program, boolean isBinary, TaskMonitor monitor, MessageLog log,
NTHeader ntHeader) throws DuplicateNameException, CodeUnitInsertionException,
IOException, MemoryAccessException {
ReferenceManager refMgr = program.getReferenceManager();
// ReferenceManager refMgr = program.getReferenceManager();
Address imageBase = program.getImageBase();
DataType dt = toDataType();
Address addr = imageBase.add(rva);
@@ -95,11 +94,11 @@ public class ImageIndirControlTransfer extends AbstractImageDynamicRelocationHea
addr = addr.add(dt.getLength());
for (ImageIndirControlTransferDynamicRelocation reloc : relocs) {
reloc.markup(program, isBinary, monitor, log, ntHeader);
int pageRelativeOffset = reloc.getPageRelativeOffset();
if (pageRelativeOffset != 0) {
refMgr.addMemoryReference(addr, imageBase.add(virtualAddress + pageRelativeOffset),
RefType.DATA, SourceType.IMPORTED, 0);
}
// int pageRelativeOffset = reloc.getPageRelativeOffset();
// if (pageRelativeOffset != 0) {
// refMgr.addMemoryReference(addr, imageBase.add(virtualAddress + pageRelativeOffset),
// RefType.DATA, SourceType.IMPORTED, 0);
// }
addr = addr.add(reloc.toDataType().getLength());
}
}
@@ -107,7 +106,7 @@ public class ImageIndirControlTransfer extends AbstractImageDynamicRelocationHea
@Override
public DataType toDataType() throws DuplicateNameException, IOException {
StructureDataType struct = new StructureDataType("IMAGE_INDIR_CONTROL_TRANSFER", 0);
struct.add(IBO32, "VirtualAddress", null);
struct.add(DWORD, "VirtualAddress", null);
struct.add(DWORD, "SizeOfBlock", null);
struct.setCategoryPath(new CategoryPath("/PE"));
return struct;
@@ -27,7 +27,6 @@ import ghidra.program.model.address.Address;
import ghidra.program.model.data.*;
import ghidra.program.model.listing.Program;
import ghidra.program.model.mem.MemoryAccessException;
import ghidra.program.model.symbol.*;
import ghidra.program.model.util.CodeUnitInsertionException;
import ghidra.util.exception.DuplicateNameException;
import ghidra.util.task.TaskMonitor;
@@ -86,7 +85,7 @@ public class ImageSwitchtableBranch extends AbstractImageDynamicRelocationHeader
public void markup(Program program, boolean isBinary, TaskMonitor monitor, MessageLog log,
NTHeader ntHeader) throws DuplicateNameException, CodeUnitInsertionException,
IOException, MemoryAccessException {
ReferenceManager refMgr = program.getReferenceManager();
// ReferenceManager refMgr = program.getReferenceManager();
Address imageBase = program.getImageBase();
DataType dt = toDataType();
Address addr = imageBase.add(rva);
@@ -94,11 +93,11 @@ public class ImageSwitchtableBranch extends AbstractImageDynamicRelocationHeader
addr = addr.add(dt.getLength());
for (ImageSwitchtableBranchDynamicRelocation reloc : relocs) {
reloc.markup(program, isBinary, monitor, log, ntHeader);
int pageRelativeOffset = reloc.getPageRelativeOffset();
if (pageRelativeOffset != 0) {
refMgr.addMemoryReference(addr, imageBase.add(virtualAddress + pageRelativeOffset),
RefType.DATA, SourceType.IMPORTED, 0);
}
// int pageRelativeOffset = reloc.getPageRelativeOffset();
// if (pageRelativeOffset != 0) {
// refMgr.addMemoryReference(addr, imageBase.add(virtualAddress + pageRelativeOffset),
// RefType.DATA, SourceType.IMPORTED, 0);
// }
addr = addr.add(reloc.toDataType().getLength());
}
}
@@ -106,7 +105,7 @@ public class ImageSwitchtableBranch extends AbstractImageDynamicRelocationHeader
@Override
public DataType toDataType() throws DuplicateNameException, IOException {
StructureDataType struct = new StructureDataType("IMAGE_SWITCHTABLE_BRANCH", 0);
struct.add(IBO32, "VirtualAddress", null);
struct.add(DWORD, "VirtualAddress", null);
struct.add(DWORD, "SizeOfBlock", null);
struct.setCategoryPath(new CategoryPath("/PE"));
return struct;