mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-02-16 07:30:16 +00:00
GP-2045 update COFF section header structure datatypes for binary markup
use.
This commit is contained in:
parent
42f28fd67b
commit
32e75f4f1b
@ -65,8 +65,8 @@ public class CoffSectionHeader implements StructConverter {
|
||||
s_scnptr = reader.readNextInt();
|
||||
s_relptr = reader.readNextInt();
|
||||
s_lnnoptr = reader.readNextInt();
|
||||
s_nreloc = reader.readNextShort() & 0xffff;
|
||||
s_nlnno = reader.readNextShort() & 0xffff;
|
||||
s_nreloc = reader.readNextUnsignedShort();
|
||||
s_nlnno = reader.readNextUnsignedShort();
|
||||
s_flags = reader.readNextInt();
|
||||
s_reserved = 0;
|
||||
s_page = 0;
|
||||
@ -306,14 +306,6 @@ public class CoffSectionHeader implements StructConverter {
|
||||
struct.add(WORD, "s_nreloc", null);
|
||||
struct.add(WORD, "s_nlnno", null);
|
||||
struct.add(DWORD, "s_flags", null);
|
||||
if (_header.getMagic() == CoffMachineType.TICOFF1MAGIC) {
|
||||
struct.add(BYTE, "s_reserved", null);
|
||||
struct.add(BYTE, "s_page", null);
|
||||
}
|
||||
else if (_header.getMagic() == CoffMachineType.TICOFF2MAGIC) {
|
||||
struct.add(WORD, "s_reserved", null);
|
||||
struct.add(WORD, "s_page", null);
|
||||
}
|
||||
return struct;
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,8 @@ package ghidra.app.util.bin.format.coff;
|
||||
import java.io.IOException;
|
||||
|
||||
import ghidra.app.util.bin.BinaryReader;
|
||||
import ghidra.app.util.bin.StructConverterUtil;
|
||||
import ghidra.program.model.data.*;
|
||||
|
||||
/**
|
||||
* A 0x28 byte COFF section header
|
||||
@ -37,11 +39,30 @@ class CoffSectionHeader1 extends CoffSectionHeader {
|
||||
s_scnptr = reader.readNextInt();
|
||||
s_relptr = reader.readNextInt();
|
||||
s_lnnoptr = reader.readNextInt();
|
||||
s_nreloc = reader.readNextShort() & 0xffff;
|
||||
s_nlnno = reader.readNextShort() & 0xffff;
|
||||
s_flags = reader.readNextShort() & 0xffff;
|
||||
s_reserved = reader.readNextByte();
|
||||
s_page = reader.readNextByte();
|
||||
s_nreloc = reader.readNextUnsignedShort();
|
||||
s_nlnno = reader.readNextUnsignedShort();
|
||||
s_flags = reader.readNextUnsignedShort();
|
||||
s_reserved = (short) (reader.readNextByte() & 0xff);
|
||||
s_page = (short) (reader.readNextByte() & 0xff);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataType toDataType() throws IOException {
|
||||
Structure struct = new StructureDataType(StructConverterUtil.parseName(getClass()), 0);
|
||||
struct.add(new ArrayDataType(ASCII, CoffConstants.SECTION_NAME_LENGTH, ASCII.getLength()),
|
||||
"s_name", null);
|
||||
struct.add(DWORD, "s_paddr", null);
|
||||
struct.add(DWORD, "s_vaddr", null);
|
||||
struct.add(DWORD, "s_size", null);
|
||||
struct.add(DWORD, "s_scnptr", null);
|
||||
struct.add(DWORD, "s_relptr", null);
|
||||
struct.add(DWORD, "s_lnnoptr", null);
|
||||
struct.add(WORD, "s_nreloc", null);
|
||||
struct.add(WORD, "s_nlnno", null);
|
||||
struct.add(WORD, "s_flags", null);
|
||||
struct.add(BYTE, "s_reserved", null);
|
||||
struct.add(BYTE, "s_page", null);
|
||||
return struct;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,6 +18,8 @@ package ghidra.app.util.bin.format.coff;
|
||||
import java.io.IOException;
|
||||
|
||||
import ghidra.app.util.bin.BinaryReader;
|
||||
import ghidra.app.util.bin.StructConverterUtil;
|
||||
import ghidra.program.model.data.*;
|
||||
|
||||
/**
|
||||
* A 0x30 byte COFF section header
|
||||
@ -44,4 +46,23 @@ class CoffSectionHeader2 extends CoffSectionHeader {
|
||||
s_page = reader.readNextShort();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataType toDataType() throws IOException {
|
||||
Structure struct = new StructureDataType(StructConverterUtil.parseName(getClass()), 0);
|
||||
struct.add(new ArrayDataType(ASCII, CoffConstants.SECTION_NAME_LENGTH, ASCII.getLength()),
|
||||
"s_name", null);
|
||||
struct.add(DWORD, "s_paddr", null);
|
||||
struct.add(DWORD, "s_vaddr", null);
|
||||
struct.add(DWORD, "s_size", null);
|
||||
struct.add(DWORD, "s_scnptr", null);
|
||||
struct.add(DWORD, "s_relptr", null);
|
||||
struct.add(DWORD, "s_lnnoptr", null);
|
||||
struct.add(DWORD, "s_nreloc", null);
|
||||
struct.add(DWORD, "s_nlnno", null);
|
||||
struct.add(DWORD, "s_flags", null);
|
||||
struct.add(WORD, "s_reserved", null);
|
||||
struct.add(WORD, "s_page", null);
|
||||
return struct;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,6 +18,8 @@ package ghidra.app.util.bin.format.coff;
|
||||
import java.io.IOException;
|
||||
|
||||
import ghidra.app.util.bin.BinaryReader;
|
||||
import ghidra.app.util.bin.StructConverterUtil;
|
||||
import ghidra.program.model.data.*;
|
||||
|
||||
/**
|
||||
* A 0x2c byte COFF section header
|
||||
@ -37,14 +39,32 @@ class CoffSectionHeader3 extends CoffSectionHeader {
|
||||
s_scnptr = reader.readNextInt();
|
||||
s_relptr = reader.readNextInt();
|
||||
s_lnnoptr = reader.readNextInt();
|
||||
s_nreloc = reader.readNextShort() & 0xffff;
|
||||
s_nlnno = reader.readNextShort() & 0xffff;
|
||||
s_nreloc = reader.readNextUnsignedShort();
|
||||
s_nlnno = reader.readNextUnsignedShort();
|
||||
s_flags = reader.readNextInt();
|
||||
|
||||
reader.readNextInt(); // section alignment, currently unused
|
||||
reader.readNextUnsignedInt(); // s_align: section alignment, currently unused
|
||||
|
||||
s_reserved = 0;
|
||||
s_page = 0;
|
||||
s_page = 0; // TODO: (short) (reader.readNextUnsignedByte() & 0xff) ?
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataType toDataType() throws IOException {
|
||||
Structure struct = new StructureDataType(StructConverterUtil.parseName(getClass()), 0);
|
||||
struct.add(new ArrayDataType(ASCII, CoffConstants.SECTION_NAME_LENGTH, ASCII.getLength()),
|
||||
"s_name", null);
|
||||
struct.add(DWORD, "s_paddr", null);
|
||||
struct.add(DWORD, "s_vaddr", null);
|
||||
struct.add(DWORD, "s_size", null);
|
||||
struct.add(DWORD, "s_scnptr", null);
|
||||
struct.add(DWORD, "s_relptr", null);
|
||||
struct.add(DWORD, "s_lnnoptr", null);
|
||||
struct.add(WORD, "s_nreloc", null);
|
||||
struct.add(WORD, "s_nlnno", null);
|
||||
struct.add(DWORD, "s_flags", null);
|
||||
struct.add(DWORD, "s_align", null);
|
||||
return struct;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user