Java Code Examples for ghidra.app.util.bin.BinaryReader#readNextInt()

The following examples show how to use ghidra.app.util.bin.BinaryReader#readNextInt() . 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: Ext4JournalSuperBlockS.java    From ghidra with Apache License 2.0 6 votes vote down vote up
public Ext4JournalSuperBlockS(BinaryReader reader) throws IOException {
	// Journal is big-endian... opposite of the rest of the file.
	reader.setLittleEndian(false);
	
	s_header = new Ext4JournalHeaderS(reader);
	s_blocksize = reader.readNextInt();
	s_maxlen = reader.readNextInt();
	s_first = reader.readNextInt();
	s_sequence = reader.readNextInt();
	s_start = reader.readNextInt();
	s_errno = reader.readNextInt();
	s_feature_compat = reader.readNextInt();
	s_feature_incompat = reader.readNextInt();
	s_feature_ro_compat = reader.readNextInt();
	s_uuid = reader.readNextByteArray(16); //16 bytes long.
	s_nr_users = reader.readNextInt();
	s_dynsuper = reader.readNextInt();
	s_max_transaction = reader.readNextInt();
	s_max_trans_data = reader.readNextInt();
	s_checksum_type = reader.readNextByte();
	s_padding2 = reader.readNextByteArray(3); //3 bytes long.
	s_padding = reader.readNextIntArray(42); //42 ints long.
	s_checksum = reader.readNextInt();
	s_users = reader.readNextByteArray(768); //768 (16*48) bytes long.
}
 
Example 2
Source File: DyldCacheAccelerateInfo.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * Create a new {@link DyldCacheAccelerateInfo}.
 * 
 * @param reader A {@link BinaryReader} positioned at the start of a DYLD accelerate info
 * @throws IOException if there was an IO-related problem creating the DYLD accelerate info
 */
public DyldCacheAccelerateInfo(BinaryReader reader) throws IOException {
	this.reader = reader;

	version = reader.readNextInt();
	imageExtrasCount = reader.readNextInt();
	imagesExtrasOffset = reader.readNextInt();
	bottomUpListOffset = reader.readNextInt();
	dylibTrieOffset = reader.readNextInt();
	dylibTrieSize = reader.readNextInt();
	initializersOffset = reader.readNextInt();
	initializersCount = reader.readNextInt();
	dofSectionsOffset = reader.readNextInt();
	dofSectionsCount = reader.readNextInt();
	reExportListOffset = reader.readNextInt();
	reExportCount = reader.readNextInt();
	depListOffset = reader.readNextInt();
	depListCount = reader.readNextInt();
	rangeTableOffset = reader.readNextInt();
	rangeTableCount = reader.readNextInt();
	dyldSectionAddr = reader.readNextLong();

	imageInfoExtraList = new ArrayList<>(imageExtrasCount);
	acceleratorInitializerList = new ArrayList<>(initializersCount);
	acceleratorDofList = new ArrayList<>(dofSectionsCount);
	rangeEntryList = new ArrayList<>(rangeTableCount);
}
 
Example 3
Source File: DyldCacheSlideInfo1.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * Create a new {@link DyldCacheSlideInfo1}.
 * 
 * @param reader A {@link BinaryReader} positioned at the start of a DYLD slide info 1
 * @throws IOException if there was an IO-related problem creating the DYLD slide info 1
 */
public DyldCacheSlideInfo1(BinaryReader reader) throws IOException {
	super(reader);
	toc_offset = reader.readNextInt();
	toc_count = reader.readNextInt();
	entries_offset = reader.readNextInt();
	entries_count = reader.readNextInt();
	entries_size = reader.readNextInt();
}
 
Example 4
Source File: GUID.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * Reads a GUID from the given binary reader.
 * @param reader the binary reader to read the GUID
 * @throws IOException if an I/O error occurs while reading the GUID
 */
public GUID(BinaryReader reader) throws IOException {
	data1 = reader.readNextInt();
	data2 = reader.readNextShort();
	data3 = reader.readNextShort();
	data4 = reader.readNextByteArray(8);
}
 
Example 5
Source File: Ext4Mmp.java    From ghidra with Apache License 2.0 5 votes vote down vote up
public Ext4Mmp(BinaryReader reader) throws IOException {
	mmp_magic = reader.readNextInt();
	mmp_seq = reader.readNextInt();
	mmp_time = reader.readNextLong();
	mmp_nodename = reader.readNextByteArray(64);
	mmp_bdevname = reader.readNextByteArray(32);
	mmp_check_interval = reader.readNextShort();
	mmp_pad1 = reader.readNextShort();
	mmp_pad2 = reader.readNextIntArray(226);
	mmp_checksum = reader.readNextInt();
}
 
Example 6
Source File: Ext4XattrEntry.java    From ghidra with Apache License 2.0 5 votes vote down vote up
public Ext4XattrEntry(BinaryReader reader) throws IOException {
	e_name_len = reader.readNextByte();
	e_name_index = reader.readNextByte();
	e_value_offs = reader.readNextShort();
	e_value_block = reader.readNextInt();
	e_value_size = reader.readNextInt();
	e_hash = reader.readNextInt();
	e_name = reader.readNextByteArray(e_name_len);
}
 
Example 7
Source File: CoffSymbolAuxTagName.java    From ghidra with Apache License 2.0 5 votes vote down vote up
CoffSymbolAuxTagName(BinaryReader reader) throws IOException {
	unused1         = reader.readNextByteArray(6);
	size            = reader.readNextShort();
	unused2         = reader.readNextByteArray(4);
	nextEntryIndex  = reader.readNextInt();
	unused3         = reader.readNextByteArray(2);
}
 
Example 8
Source File: PdbInfoDotNet.java    From ghidra with Apache License 2.0 5 votes vote down vote up
public PdbInfoDotNet(BinaryReader reader, int ptr) throws IOException {
	long origIndex = reader.getPointerIndex();
	reader.setPointerIndex(ptr);
	try {
		magic = reader.readNextByteArray(4);
		guid = new GUID(reader);
		age = reader.readNextInt();
		pdbName = reader.readNextAsciiString();
	}
	finally {
		reader.setPointerIndex(origIndex);
	}
}
 
Example 9
Source File: ExportedSymbol.java    From ghidra with Apache License 2.0 5 votes vote down vote up
ExportedSymbol(BinaryReader reader, LoaderInfoHeader loader, ExportedSymbolKey key) throws IOException {
	classAndName = reader.readNextInt();
	symbolValue  = reader.readNextInt();
	sectionIndex = reader.readNextShort();

	long offset = loader.getSection().getContainerOffset()+loader.getLoaderStringsOffset()+getNameOffset();
	_name = reader.readAsciiString(offset, key.getNameLength()); 
}
 
Example 10
Source File: ObjectiveC2_InstanceVariableList.java    From ghidra with Apache License 2.0 5 votes vote down vote up
public ObjectiveC2_InstanceVariableList(ObjectiveC2_State state, BinaryReader reader) throws IOException {
	this._state = state;
	this._index = reader.getPointerIndex();

	entsize = reader.readNextInt();
	count   = reader.readNextInt();

	for (int i = 0 ; i < count ; ++i) {
		ivars.add( new ObjectiveC2_InstanceVariable(state, reader) );
	}
}
 
Example 11
Source File: GnuVerneed.java    From ghidra with Apache License 2.0 5 votes vote down vote up
GnuVerneed(BinaryReader reader) throws IOException {
    vn_version = reader.readNextShort();
    vn_cnt     = reader.readNextShort();
    vn_file    = reader.readNextInt();
    vn_aux     = reader.readNextInt();
    vn_next    = reader.readNextInt();
}
 
Example 12
Source File: DyldCacheSlideInfo2.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * Create a new {@link DyldCacheSlideInfo2}.
 * 
 * @param reader A {@link BinaryReader} positioned at the start of a DYLD slide info 2
 * @throws IOException if there was an IO-related problem creating the DYLD slide info 2
 */
public DyldCacheSlideInfo2(BinaryReader reader) throws IOException {
	super(reader);
	page_size = reader.readNextInt();
	page_starts_offset = reader.readNextInt();
	page_starts_count = reader.readNextInt();
	page_extras_offset = reader.readNextInt();
	page_extras_count = reader.readNextInt();
	delta_mask = reader.readNextLong();
	value_add = reader.readNextLong();
	page_starts_entries = reader.readNextShortArray(page_starts_count);
	page_extras_entries = reader.readNextShortArray(page_extras_count);
}
 
Example 13
Source File: NRO0Header.java    From Ghidra-Switch-Loader with ISC License 5 votes vote down vote up
private void readHeader(BinaryReader reader)
{
    try 
    {
        reader.readNextInt(); // Reserved
        this.mod0Offset = reader.readNextInt();
        reader.readNextLong(); // Padding
        this.magic = reader.readNextAsciiString(4);
        
        if (!this.magic.equals("NRO0"))
            throw new InvalidMagicException("NRO0");
        
        this.version = reader.readNextInt();
        this.size = reader.readNextInt();
        this.flags = reader.readNextInt();
        this.textHeader = new NRO0SectionHeader(reader);
        this.rodataHeader = new NRO0SectionHeader(reader);
        this.dataHeader = new NRO0SectionHeader(reader);
        this.bssSize = reader.readNextInt();
        reader.readNextInt(); // Reserved
        this.buildId = reader.readNextByteArray(0x20);
        reader.readNextInt(); // Reserved
        this.apiInfo = new NRO0SectionHeader(reader);
        this.dynstr = new NRO0SectionHeader(reader);
        this.dynsym = new NRO0SectionHeader(reader);
    } 
    catch (IOException e) 
    {
        Msg.error(this, "Failed to read NRO0 header");
    }
}
 
Example 14
Source File: AnnotationsDirectoryItem.java    From ghidra with Apache License 2.0 5 votes vote down vote up
public AnnotationsDirectoryItem( BinaryReader reader ) throws IOException {

		classAnnotationsOffset = reader.readNextInt( );
		fieldsSize = reader.readNextInt( );
		annotatedMethodsSize = reader.readNextInt( );
		annotatedParametersSize = reader.readNextInt( );

		for ( int i = 0 ; i < fieldsSize ; ++i ) {
			fieldAnnotations.add( new FieldAnnotation( reader ) );
		}
		for ( int i = 0 ; i < annotatedMethodsSize ; ++i ) {
			methodAnnotations.add( new MethodAnnotation( reader ) );
		}
		for ( int i = 0 ; i < annotatedParametersSize ; ++i ) {
			parameterAnnotations.add( new ParameterAnnotation( reader ) );
		}

		if ( classAnnotationsOffset > 0 ){
			long oldIndex = reader.getPointerIndex( );
			try {
				reader.setPointerIndex( classAnnotationsOffset );
				_classAnnotations = new AnnotationSetItem( reader );
			}
			finally {
				reader.setPointerIndex( oldIndex );
			}
		}
	}
 
Example 15
Source File: CliTableManifestResource.java    From ghidra with Apache License 2.0 5 votes vote down vote up
public CliTableManifestResource(BinaryReader reader, CliStreamMetadata stream, CliTypeTable tableId) throws IOException {
	super(reader, stream, tableId);
	for (int i = 0; i < this.numRows; i++) {
		CliManifestResourceRow row = new CliManifestResourceRow(reader.readNextInt(), reader.readNextInt(), readStringIndex(reader), 
			CliIndexImplementation.readCodedIndex(reader, stream));
		rows.add(row);
		strings.add(row.nameIndex);
	}
	reader.setPointerIndex(this.readerOffset);

}
 
Example 16
Source File: AbstractAttributeInfo.java    From ghidra with Apache License 2.0 4 votes vote down vote up
protected AbstractAttributeInfo(BinaryReader reader) throws IOException {
	_offset = reader.getPointerIndex();

	attributeNameIndex = reader.readNextShort();
	attributeLength = reader.readNextInt();
}
 
Example 17
Source File: ConstantPoolIntegerInfo.java    From ghidra with Apache License 2.0 4 votes vote down vote up
public ConstantPoolIntegerInfo( BinaryReader reader ) throws IOException {
	super( reader );
	bytes = reader.readNextInt();
}
 
Example 18
Source File: LoadConfigDirectory.java    From ghidra with Apache License 2.0 4 votes vote down vote up
private long readPointer(BinaryReader reader) throws IOException {
	if (is64bit) {
		return reader.readNextLong();
	}
	return reader.readNextInt() & Conv.INT_MASK;
}
 
Example 19
Source File: VersionTag.java    From ghidra with Apache License 2.0 4 votes vote down vote up
VersionTag(BinaryReader reader) throws IOException {
	super(reader);

	_length = reader.readNextInt();
	_versionString = reader.readNextByteArray( _length );
}
 
Example 20
Source File: DyldCacheLocalSymbolsEntry.java    From ghidra with Apache License 2.0 2 votes vote down vote up
/**
 * Create a new {@link DyldCacheLocalSymbolsEntry}.
 * 
 * @param reader A {@link BinaryReader} positioned at the start of a DYLD local symbols entry
 * @throws IOException if there was an IO-related problem creating the DYLD local symbols entry
 */
public DyldCacheLocalSymbolsEntry(BinaryReader reader) throws IOException {
	dylibOffset = reader.readNextInt();
	nlistStartIndex = reader.readNextInt();
	nlistCount = reader.readNextInt();
}