mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-01-09 14:08:03 -05:00
GP-0: Adding plate comment OMF DEPLST (Closes #8751)
This commit is contained in:
@@ -26,14 +26,21 @@ import ghidra.util.exception.DuplicateNameException;
|
||||
|
||||
public class Omf166DepList extends OmfRecord {
|
||||
|
||||
private record Info(byte type, Byte mark, Integer time, OmfString name, OmfString bigName) {}
|
||||
public record InfoEntry(byte type, Byte mark, Integer time, OmfString name) {}
|
||||
|
||||
private List<Info> infoList = new ArrayList<>();
|
||||
private List<InfoEntry> info = new ArrayList<>();
|
||||
|
||||
public Omf166DepList(BinaryReader reader) throws IOException {
|
||||
super(reader);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the {@link Omf166DepList} "info"}
|
||||
*/
|
||||
public List<InfoEntry> getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseData() throws IOException, OmfException {
|
||||
while (dataReader.getPointerIndex() < dataEnd) {
|
||||
@@ -47,16 +54,15 @@ public class Omf166DepList extends OmfRecord {
|
||||
byte mark = dataReader.readNextByte();
|
||||
int time = dataReader.readNextInt();
|
||||
OmfString name = OmfUtils.readString(dataReader);
|
||||
infoList.add(new Info(iTyp, mark, time, name, null));
|
||||
info.add(new InfoEntry(iTyp, mark, time, name));
|
||||
break;
|
||||
case (byte) 0xff:
|
||||
OmfString invocation = OmfUtils.readString(dataReader);
|
||||
OmfString bigName = null;
|
||||
if (invocation.length() == 0) {
|
||||
// We assume that a "big string" follows
|
||||
bigName = OmfUtils.readBigString(dataReader);
|
||||
invocation = OmfUtils.readBigString(dataReader);
|
||||
}
|
||||
infoList.add(new Info(iTyp, null, null, invocation, bigName));
|
||||
info.add(new InfoEntry(iTyp, null, null, invocation));
|
||||
break;
|
||||
default:
|
||||
throw new OmfException("Unexpected DEPLST iTyp: 0x%x".formatted(iTyp));
|
||||
@@ -69,19 +75,19 @@ public class Omf166DepList extends OmfRecord {
|
||||
StructureDataType struct = new StructureDataType(Omf166RecordTypes.getName(recordType), 0);
|
||||
struct.add(BYTE, "type", null);
|
||||
struct.add(WORD, "length", null);
|
||||
for (Info info : infoList) {
|
||||
for (InfoEntry entry : info) {
|
||||
struct.add(BYTE, "iTyp", null);
|
||||
if (info.mark != null) {
|
||||
if (entry.mark != null) {
|
||||
struct.add(BYTE, "mark8", null);
|
||||
}
|
||||
if (info.time != null) {
|
||||
if (entry.time != null) {
|
||||
struct.add(DWORD, "time32", null);
|
||||
}
|
||||
struct.add(info.name.toDataType(), info.name.getDataTypeSize(), "name", null);
|
||||
if (info.bigName != null) {
|
||||
struct.add(info.bigName.toDataType(), info.bigName.getDataTypeSize(), "bigName",
|
||||
null);
|
||||
if (entry.name().isBig()) {
|
||||
OmfString empty = new OmfString(0, "", false);
|
||||
struct.add(empty.toDataType(), empty.getDataTypeSize(), "empty", null);
|
||||
}
|
||||
struct.add(entry.name.toDataType(), entry.name.getDataTypeSize(), "name", null);
|
||||
}
|
||||
struct.add(BYTE, "checksum", null);
|
||||
struct.setCategoryPath(new CategoryPath(OmfUtils.CATEGORY_PATH));
|
||||
|
||||
@@ -23,6 +23,7 @@ import ghidra.app.util.MemoryBlockUtils;
|
||||
import ghidra.app.util.bin.ByteProvider;
|
||||
import ghidra.app.util.bin.StructConverter;
|
||||
import ghidra.app.util.bin.format.omf.*;
|
||||
import ghidra.app.util.bin.format.omf.omf166.Omf166DepList;
|
||||
import ghidra.app.util.bin.format.omf.omf51.*;
|
||||
import ghidra.app.util.importer.MessageLog;
|
||||
import ghidra.program.database.mem.FileBytes;
|
||||
@@ -381,9 +382,21 @@ public class Omf51Loader extends AbstractProgramWrapperLoader {
|
||||
|
||||
for (OmfRecord record : records) {
|
||||
try {
|
||||
Data d = DataUtilities.createData(program, start.add(record.getRecordOffset()),
|
||||
record.toDataType(), -1, DataUtilities.ClearDataMode.CHECK_FOR_SPACE);
|
||||
Address addr = start.add(record.getRecordOffset());
|
||||
Data d = DataUtilities.createData(program, addr, record.toDataType(), -1,
|
||||
DataUtilities.ClearDataMode.CHECK_FOR_SPACE);
|
||||
StructConverter.setEndian(d, false);
|
||||
|
||||
if (record instanceof Omf166DepList depList) {
|
||||
String comment = depList.getInfo()
|
||||
.stream()
|
||||
.map(Omf166DepList.InfoEntry::name)
|
||||
.map(OmfString::str)
|
||||
.collect(Collectors.joining(System.lineSeparator()));
|
||||
if (!comment.isEmpty()) {
|
||||
program.getListing().setComment(addr, CommentType.PLATE, comment);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.appendMsg("Failed to markup record type 0x%x at offset 0x%x. %s."
|
||||
|
||||
Reference in New Issue
Block a user