Java Code Examples for ghidra.app.util.bin.BinaryReader#SIZEOF_INT

The following examples show how to use ghidra.app.util.bin.BinaryReader#SIZEOF_INT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TLSDirectory.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private void initTLSDirectory(FactoryBundledWithBinaryReader reader, int index, boolean is64bit) throws IOException {
    this.is64bit = is64bit;
    if (is64bit) {
     startAddressOfRawData = reader.readLong(index); index += BinaryReader.SIZEOF_LONG;
     endAddressOfRawData   = reader.readLong(index); index += BinaryReader.SIZEOF_LONG;
     addressOfIndex        = reader.readLong(index); index += BinaryReader.SIZEOF_LONG;
     addressOfCallBacks    = reader.readLong(index); index += BinaryReader.SIZEOF_LONG;
    }
    else {
     startAddressOfRawData = reader.readInt(index) & Conv.INT_MASK; index += BinaryReader.SIZEOF_INT;
     endAddressOfRawData   = reader.readInt(index) & Conv.INT_MASK; index += BinaryReader.SIZEOF_INT;
     addressOfIndex        = reader.readInt(index) & Conv.INT_MASK; index += BinaryReader.SIZEOF_INT;
     addressOfCallBacks    = reader.readInt(index) & Conv.INT_MASK; index += BinaryReader.SIZEOF_INT;
    }
    Msg.info(this, "TLS callbacks at "+Long.toHexString(addressOfCallBacks));
    sizeOfZeroFill        = reader.readInt(index); index += BinaryReader.SIZEOF_INT;
    characteristics       = reader.readInt(index); index += BinaryReader.SIZEOF_INT;
}
 
Example 2
Source File: DelayImportDescriptor.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private void readFields(FactoryBundledWithBinaryReader reader, int index) throws IOException {
	grAttrs = reader.readInt(index);
	index += BinaryReader.SIZEOF_INT;
	szName = reader.readInt(index) & Conv.INT_MASK;
	index += BinaryReader.SIZEOF_INT;
	phmod = reader.readInt(index) & Conv.INT_MASK;
	index += BinaryReader.SIZEOF_INT;
	pIAT = reader.readInt(index) & Conv.INT_MASK;
	index += BinaryReader.SIZEOF_INT;
	pINT = reader.readInt(index) & Conv.INT_MASK;
	index += BinaryReader.SIZEOF_INT;
	pBoundIAT = reader.readInt(index) & Conv.INT_MASK;
	index += BinaryReader.SIZEOF_INT;
	pUnloadIAT = reader.readInt(index) & Conv.INT_MASK;
	index += BinaryReader.SIZEOF_INT;
	dwTimeStamp = reader.readInt(index);
	index += BinaryReader.SIZEOF_INT;
}
 
Example 3
Source File: DebugCOFFSymbolsHeader.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void initDebugCOFFSymbolsHeader(FactoryBundledWithBinaryReader reader,
		DebugDirectory debugDir, OffsetValidator validator) throws IOException {
	int ptr = debugDir.getPointerToRawData();
	if (!validator.checkPointer(ptr)) {
		Msg.error(this, "Invalid pointer " + Long.toHexString(ptr));
		return;
	}

	numberOfSymbols = reader.readInt(ptr);
	ptr += BinaryReader.SIZEOF_INT;
	lvaToFirstSymbol = reader.readInt(ptr);
	ptr += BinaryReader.SIZEOF_INT;
	numberOfLinenumbers = reader.readInt(ptr);
	ptr += BinaryReader.SIZEOF_INT;
	lvaToFirstLinenumber = reader.readInt(ptr);
	ptr += BinaryReader.SIZEOF_INT;
	rvaToFirstByteOfCode = reader.readInt(ptr);
	ptr += BinaryReader.SIZEOF_INT;
	rvaToLastByteOfCode = reader.readInt(ptr);
	ptr += BinaryReader.SIZEOF_INT;
	rvaToFirstByteOfData = reader.readInt(ptr);
	ptr += BinaryReader.SIZEOF_INT;
	rvaToLastByteOfData = reader.readInt(ptr);
	ptr += BinaryReader.SIZEOF_INT;

	if (numberOfLinenumbers > 0 && numberOfLinenumbers < NTHeader.MAX_SANE_COUNT) {
		lineNumbers = new DebugCOFFLineNumber[numberOfLinenumbers];
		for (int i = 0; i < numberOfLinenumbers; ++i) {
			lineNumbers[i] = DebugCOFFLineNumber.createDebugCOFFLineNumber(reader, ptr);
			ptr += DebugCOFFLineNumber.IMAGE_SIZEOF_LINENUMBER;
		}
	}

	symbolTable =
		DebugCOFFSymbolTable.createDebugCOFFSymbolTable(reader, this,
			debugDir.getPointerToRawData());
}
 
Example 4
Source File: SecurityCertificate.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void initSecurityCertificate(FactoryBundledWithBinaryReader reader, int index) throws IOException {
      int i = index;

int maxDwLength = (int) ClampPropertiesLookup.getClampValue("ghidra.app.util.bin.format.pe.SecurityCertificate.dwLength.max", 30000);
      dwLength         = reader.readInt  (i, 8, maxDwLength); i += BinaryReader.SIZEOF_INT;
if (dwLength < 0)  return;
wRevision        = reader.readShort(i); i += BinaryReader.SIZEOF_SHORT;
wCertificateType = reader.readShort(i); i += BinaryReader.SIZEOF_SHORT;
bCertificate     = reader.readByteArray(i, dwLength-4-2-2);
  }
 
Example 5
Source File: DebugFixupElement.java    From ghidra with Apache License 2.0 4 votes vote down vote up
private void initDebugFixupElement(FactoryBundledWithBinaryReader reader, int index) throws IOException {
    type  = reader.readInt(index); index += BinaryReader.SIZEOF_INT;
    addr1 = reader.readInt(index); index += BinaryReader.SIZEOF_INT;
    addr2 = reader.readInt(index); index += BinaryReader.SIZEOF_INT;
}
 
Example 6
Source File: DebugCOFFLineNumber.java    From ghidra with Apache License 2.0 4 votes vote down vote up
private void initDebugCOFFLineNumber(FactoryBundledWithBinaryReader reader, int index) throws IOException {
      symbolTableIndex = reader.readInt(index);
      virtualAddress   = reader.readInt(index);
      index += BinaryReader.SIZEOF_INT;
lineNumber = Conv.shortToInt(reader.readShort(index));
  }
 
Example 7
Source File: SecurityCertificate.java    From ghidra with Apache License 2.0 4 votes vote down vote up
int getNumberOfBytesConsumed() {
    return dwLength + BinaryReader.SIZEOF_INT +
                2 * BinaryReader.SIZEOF_SHORT;
}