ghidra.program.model.data.StructureDataType Java Examples

The following examples show how to use ghidra.program.model.data.StructureDataType. 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: RuntimeParameterAnnotationsAttribute.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
public DataType toDataType() throws DuplicateNameException, IOException {
	String name = _isVisible
			? "RuntimeVisibleParameterAnnotations_attribute" + "|" + numberOfParameters + "|"
			: "RuntimeInvisibleParameterAnnotations_attribute" + "|" + numberOfParameters + "|";

	StructureDataType structure = getBaseStructure(name);
	structure.add(BYTE, "num_parameters", null);
	for (int i = 0; i < numberOfParameters; ++i) {
		structure.add(WORD, "num_annotations_" + i, null);
		AnnotationJava[] annotations = parameterAnnotations.get(i);
		for (int a = 0; a < annotations.length; ++a) {
			structure.add(annotations[a].toDataType(), "annotations_" + i + "_" + a, null);
		}
	}

	return structure;
}
 
Example #2
Source File: AnnotationElement.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
public DataType toDataType( ) throws DuplicateNameException, IOException {
	DataType encodeValueDataType = value.toDataType( );

	String name = "annotation_element" + "_" + nameIndexLength + "_" + encodeValueDataType.getName( );

	Structure structure = new StructureDataType( name, 0 );

	structure.add( new ArrayDataType( BYTE, nameIndexLength, BYTE.getLength( ) ), "nameIndex", null );

	structure.add( encodeValueDataType, "value", null );

	structure.setCategoryPath( new CategoryPath( "/dex/annotation_element" ) );
	// try {
	// structure.setName( name + "_" + structure.getLength( ) );
	// }
	// catch ( Exception e ) {
	// // ignore
	// }
	return structure;
}
 
Example #3
Source File: Ext4DirEntry2.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
	public DataType toDataType() throws DuplicateNameException, IOException {
		String nameEnd = rec_len + "_" + (extra == null ? "0" : extra.length );
		Structure structure = new StructureDataType("ext4_dir_entry2_" + nameEnd, 0);
		structure.add(DWORD, "inode", null);
		structure.add(WORD, "rec_len", null);
		structure.add(BYTE, "name_len", null);
		structure.add(BYTE, "file_type", null);
		if ( ( name_len & 0xff ) > 0 ) {
			structure.add(STRING, ( name_len & 0xff ), "name", null);
		}
		if( extra != null ) {
			structure.add( new ArrayDataType(BYTE, extra.length, BYTE.getLength()), "extra", null);
		}
//		if ( structure.getLength() != ( rec_len & 0xffff ) ) {
//			System.out.println( "incorrect size!!" );
//		}
		return structure;
	}
 
Example #4
Source File: AnnotationElementValue.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
public DataType toDataType() throws DuplicateNameException, IOException {
	String name = "element_value" + "|" + tag + "|";
	StructureDataType structure = new StructureDataType(name, 0);

	if (tag == DescriptorDecoder.BASE_TYPE_BYTE || tag == DescriptorDecoder.BASE_TYPE_CHAR ||
		tag == DescriptorDecoder.BASE_TYPE_INT || tag == DescriptorDecoder.BASE_TYPE_SHORT ||
		tag == DescriptorDecoder.BASE_TYPE_LONG || tag == DescriptorDecoder.BASE_TYPE_FLOAT ||
		tag == DescriptorDecoder.BASE_TYPE_DOUBLE ||
		tag == DescriptorDecoder.BASE_TYPE_BOOLEAN ||
		tag == DescriptorDecoder.BASE_TYPE_STRING) {
	}
	else if (tag == DescriptorDecoder.BASE_TYPE_ENUM) {
	}
	else if (tag == DescriptorDecoder.BASE_TYPE_CLASS) {
	}
	else if (tag == DescriptorDecoder.BASE_TYPE_ANNOTATION) {
	}
	else if (tag == DescriptorDecoder.BASE_TYPE_ARRAY) {
	}

	return structure;
}
 
Example #5
Source File: EncodedCatchHandlerList.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
	public DataType toDataType( ) throws DuplicateNameException, IOException {
//		int unique = 0;
		String name = "encoded_catch_handler_list" + "_" + sizeLength;
		Structure structure = new StructureDataType( name, 0 );
		structure.add( new ArrayDataType( BYTE, sizeLength, BYTE.getLength( ) ), "size", null );
//		int index = 0;
//		for ( EncodedCatchHandler handler : handlers ) {
//			DataType dataType = handler.toDataType( );
//			structure.add( dataType, "handler_" + index, null );
//			unique += dataType.getLength( );
//		}
		structure.setCategoryPath( new CategoryPath( "/dex/encoded_catch_handler_list" ) );
//		try {
//			structure.setName( name + "_" + Integer.toHexString( unique ) );
//		}
//		catch ( Exception e ) {
//			// ignore
//		}
		return structure;
	}
 
Example #6
Source File: StackMapTableAttribute.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
	public DataType toDataType() throws DuplicateNameException, IOException {
//		String name = "StackMapTable_attribute_" + entries;
//		StructureDataType structure = getBaseStructure( name );
//		structure.add( WORD, "number_of_entries", null );
//		for ( int i = 0 ; i < entries.length ; ++i ) {
//			structure.add( entries[ i ].toDataType(), "entries_" + i, null );
//		}
//		return structure;
		StructureDataType structure = getBaseStructure( "StackMapTable_attribute" );
		if ( infoBytes.length > 0 ) {
			DataType array = new ArrayDataType( BYTE, infoBytes.length, BYTE.getLength() );
			structure.add( array, "info", null );
		}
		return structure;
	}
 
Example #7
Source File: Ext4DxRoot.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
public DataType toDataType() throws DuplicateNameException, IOException {
	Structure structure = new StructureDataType("dx_root", 0);
	structure.add(DWORD, "dot_inode", null);
	structure.add(WORD, "dot_rec_len", null);
	structure.add(BYTE, "dot_name_len", null);
	structure.add(BYTE, "dot_file_type", null);
	structure.add(new ArrayDataType(BYTE, 4, BYTE.getLength()), "dot_name", null);
	structure.add(DWORD, "dotdot_inode", null);
	structure.add(WORD, "dotdot_rec_len", null);
	structure.add(BYTE, "dotdot_name_len", null);
	structure.add(BYTE, "dotdot_file_type", null);
	structure.add(new ArrayDataType(BYTE, 4, BYTE.getLength()), "dotdot_name", null);
	structure.add(DWORD, "dx_root_info_reserved_zero", null);
	structure.add(BYTE, "dx_root_info_hash_version", null);
	structure.add(BYTE, "dx_root_info_info_length", null);
	structure.add(BYTE, "dx_root_info_indirect_levels", null);
	structure.add(BYTE, "dx_root_info_unused_flags", null); 	
	structure.add(WORD, "limit", null);
	structure.add(WORD, "count", null);
	structure.add(DWORD, "block", null);
	structure.add(new ArrayDataType(entries[0].toDataType(), count, entries[0].toDataType().getLength()), "entries", null); 
	return structure;
}
 
Example #8
Source File: CliTableMethodDef.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public StructureDataType getRowDataType() {
	StructureDataType rowDt = new StructureDataType(new CategoryPath(PATH), "MethodDef Row", 0);
	rowDt.add(DWORD, "RVA", null);
	rowDt.add(CliEnumMethodImplAttributes.dataType, "ImplFlags",
		"Bitmask of type MethodImplAttributes");
	rowDt.add(CliEnumMethodAttributes.dataType, "Flags", "Bitmask of type MethodAttribute");
	rowDt.add(metadataStream.getStringIndexDataType(), "Name", "index into String heap");
	rowDt.add(metadataStream.getBlobIndexDataType(), "Signature", "index into Blob heap");
	rowDt.add(metadataStream.getTableIndexDataType(CliTypeTable.Param), "ParamList", "index into Param table");
	return rowDt;
}
 
Example #9
Source File: Ext4Extent.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public DataType toDataType() throws DuplicateNameException, IOException {
	Structure structure = new StructureDataType("ext4_extent", 0);
	structure.add(DWORD, "ee_block", null);
	structure.add(WORD, "ee_len", null);
	structure.add(WORD, "ee_start_hi", null);
	structure.add(DWORD, "ee_start_lo", null);
	return structure;
}
 
Example #10
Source File: Ext4DirEntryTail.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public DataType toDataType() throws DuplicateNameException, IOException {
	Structure structure = new StructureDataType("ext4_dir_entry_tail", 0);
	structure.add(DWORD, "det_reserved_zero1", null);
	structure.add(WORD, "det_rec_len", null);
	structure.add(BYTE, "det_reserved_zero2", null);
	structure.add(BYTE, "det_reserved_ft", null);
	structure.add(DWORD, "det_checksum", null);
	return structure;
}
 
Example #11
Source File: Ext4DirEntry.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public DataType toDataType() throws DuplicateNameException, IOException {
	Structure structure = new StructureDataType("ext4_dir_entry", 0);
	structure.add(DWORD, "inode", null);
	structure.add(WORD, "rec_len", null);
	structure.add(WORD, "name_len", null);
	structure.add(STRING, name_len, "name", null);
	if( extra != null ) {
		structure.add( new ArrayDataType(BYTE, extra.length, BYTE.getLength()), "extra", null);
	}
	return structure;
}
 
Example #12
Source File: CliTableGenericParamConstraint.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public StructureDataType getRowDataType() {
	StructureDataType rowDt = new StructureDataType(new CategoryPath(PATH), "GenericParamConstraint Row", 0);
	rowDt.add(metadataStream.getTableIndexDataType(CliTypeTable.GenericParam), "Owner", "index into GenericParam table");
	rowDt.add(CliIndexTypeDefOrRef.toDataType(metadataStream), "Constraint", "class/interface this param is constrained to derive/implement");
	return rowDt;
}
 
Example #13
Source File: CliTableEventMap.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public StructureDataType getRowDataType() {
	StructureDataType rowDt = new StructureDataType(new CategoryPath(PATH), "EventMap Row", 0);
	rowDt.add(metadataStream.getTableIndexDataType(CliTypeTable.TypeDef), "Parent", null);
	rowDt.add(metadataStream.getTableIndexDataType(CliTypeTable.Event), "EventList", "First of a contiguous run in Event table, ending with next EventMap reference or end of table.");
	return rowDt;
}
 
Example #14
Source File: CliTableParam.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public StructureDataType getRowDataType() {
	StructureDataType rowDt = new StructureDataType(new CategoryPath(PATH), "ParamRow",0);
	rowDt.add(CliEnumParamAttributes.dataType, "Flags", "bitmask of type ParamAttributes");
	rowDt.add( WORD, "Sequence", "constant");
	rowDt.add(metadataStream.getStringIndexDataType(), "Name", "index into String heap");
	return rowDt;
}
 
Example #15
Source File: CliTableInterfaceImpl.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public StructureDataType getRowDataType() {
	StructureDataType rowDt = new StructureDataType(new CategoryPath(PATH), "InterfaceImpl Row",0);
	rowDt.add(metadataStream.getTableIndexDataType(CliTypeTable.TypeDef), "Class", "index into TypeDef table");
	rowDt.add(CliIndexTypeDefOrRef.toDataType(metadataStream), "Interface", "index into TypeDef/TypeRef/TypeSpec - TypeDefOrRef coded");
	return rowDt;
}
 
Example #16
Source File: CliTablePropertyMap.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public StructureDataType getRowDataType() {
	StructureDataType rowDt = new StructureDataType(new CategoryPath(PATH), "PropertyMap Row", 0);
	rowDt.add(metadataStream.getTableIndexDataType(CliTypeTable.TypeDef), "Parent", null);
	rowDt.add(metadataStream.getTableIndexDataType(CliTypeTable.Property), "options", "Index into Property table. Points to contiguous run of Properties until next ref from PropertyMap or end of table.");
	return rowDt;
}
 
Example #17
Source File: CliTableFile.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public StructureDataType getRowDataType() {
	StructureDataType rowDt = new StructureDataType(new CategoryPath(PATH), "File Row", 0);
	rowDt.add(CliEnumFileAttributes.dataType, "Flags", "Bitmask of type FileAttributes");
	rowDt.add(metadataStream.getStringIndexDataType(), "Name", "index into String heap");
	rowDt.add(metadataStream.getBlobIndexDataType(), "Hash", "index into Blob heap");
	return rowDt;
}
 
Example #18
Source File: CliTableFieldMarshall.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public StructureDataType getRowDataType() {
	StructureDataType rowDt = new StructureDataType(new CategoryPath(PATH), "FieldMarshall Row", 0);
	rowDt.add(CliIndexHasFieldMarshall.toDataType(metadataStream), "Parent", null);
	rowDt.add(metadataStream.getBlobIndexDataType(), "NativeType", null);
	return rowDt;
}
 
Example #19
Source File: CliTableProperty.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public StructureDataType getRowDataType() {
	StructureDataType rowDt = new StructureDataType(new CategoryPath(PATH), "Property Row", 0);
	rowDt.add(CliEnumPropertyAttributes.dataType, "Flags", "Bitmask of type PropertyAttributes");
	rowDt.add(metadataStream.getStringIndexDataType(), "Name", null);
	rowDt.add(metadataStream.getBlobIndexDataType(), "Type", "Blob index to the signature, not a TypeDef/TypeRef");
	return rowDt;
}
 
Example #20
Source File: Ext4JournalHeaderS.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public DataType toDataType() throws DuplicateNameException, IOException {
	Structure structure = new StructureDataType("journal_header_s", 0);
	structure.add(DWORD, "h_magic", null);
	structure.add(DWORD, "h_blocktype", null);
	structure.add(DWORD, "h_sequence", null);
	return structure;
}
 
Example #21
Source File: CliTableImplMap.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public StructureDataType getRowDataType() {
	StructureDataType rowDt = new StructureDataType(new CategoryPath(PATH), "ImplMap Row", 0);
	rowDt.add(CliEnumPInvokeAttributes.dataType, "MappingFlags", "Bitmask of type PInvokeAttributes");
	rowDt.add(CliIndexMemberForwarded.toDataType(metadataStream), "MemberForwarded", "MemberForwarded Coded Index");
	rowDt.add(metadataStream.getStringIndexDataType(), "ImportName", "index into String heap");
	rowDt.add(metadataStream.getTableIndexDataType(CliTypeTable.ModuleRef), "ImportScope", "Index into ModuleRef table");
	return rowDt;
}
 
Example #22
Source File: Ext4DxTail.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public DataType toDataType() throws DuplicateNameException, IOException {
	Structure structure = new StructureDataType("dx_tail", 0);
	structure.add(DWORD, "dt_reserved", null);
	structure.add(DWORD, "dt_checksum", null);
	return structure;
}
 
Example #23
Source File: Ext4ExtentHeader.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public DataType toDataType() throws DuplicateNameException, IOException {
	Structure structure = new StructureDataType("ext4_extent_header", 0);
	structure.add(WORD, "eh_magic", null);
	structure.add(WORD, "eh_entries", null);
	structure.add(WORD, "eh_max", null);
	structure.add(WORD, "eh_depth", null);
	structure.add(DWORD, "eh_generation", null);
	return structure;
}
 
Example #24
Source File: Ext4XattrHeader.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public DataType toDataType() throws DuplicateNameException, IOException {
	Structure structure = new StructureDataType("ext4_xattr_header", 0);
	structure.add(DWORD, "h_magic", null);
	structure.add(DWORD, "h_refcount", null);
	structure.add(DWORD, "h_blocks", null);
	structure.add(DWORD, "h_hash", null);
	structure.add(DWORD, "h_checksum", null);
	structure.add( new ArrayDataType(DWORD, 2, DWORD.getLength()), "h_reserved", null);
	return structure;
}
 
Example #25
Source File: Ext4Mmp.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public DataType toDataType() throws DuplicateNameException, IOException {
	Structure structure = new StructureDataType("mmp_struct", 0);
	structure.add(DWORD, "mmp_magic", null);
	structure.add(DWORD, "mmp_seq", null);
	structure.add(QWORD, "mmp_time", null);
	structure.add( new ArrayDataType( BYTE, 64, BYTE.getLength()), "mmp_nodename", null); //64 bytes long.
	structure.add( new ArrayDataType( BYTE, 32, BYTE.getLength()), "mmp_bdevname", null); //32 bytes long.
	structure.add(WORD, "mmp_check_interval", null);
	structure.add(WORD, "mmp_pad1", null);
	structure.add( new ArrayDataType(DWORD, 226, DWORD.getLength()), "mmp_pad2", null);
	structure.add(DWORD, "mmp_checksum", null);
	return structure;
}
 
Example #26
Source File: CliTableMethodSemantics.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public StructureDataType getRowDataType() {
	StructureDataType rowDt = new StructureDataType(new CategoryPath(PATH), "MethodSemantics Row", 0);
	rowDt.add(CliEnumMethodSemanticsAttributes.dataType, "Semantics", "Bitmask of type MethodSemanticsAttributes");
	rowDt.add(metadataStream.getTableIndexDataType(CliTypeTable.MethodDef), "Method", "index into MethodDef table");
	rowDt.add(CliIndexHasSemantics.toDataType(metadataStream), "Association", "HasSemantics coded index into Event or Property");
	return rowDt;
}
 
Example #27
Source File: Ext4DxEntry.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public DataType toDataType() throws DuplicateNameException, IOException {
	Structure structure = new StructureDataType("dx_entry", 0);
	structure.add(DWORD, "hash", null);
	structure.add(DWORD, "block", null);
	return structure;
}
 
Example #28
Source File: Ext4XattrEntry.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public DataType toDataType() throws DuplicateNameException, IOException {
	Structure structure = new StructureDataType("ext4_xattr_entry", 0);
	structure.add(BYTE, "e_name_len", null);
	structure.add(BYTE, "e_name_index", null);
	structure.add(WORD, "e_value_offs", null);
	structure.add(DWORD, "e_value_block", null);
	structure.add(DWORD, "e_value_size", null);
	structure.add(DWORD, "e_hash", null);
	structure.add( new ArrayDataType(BYTE, e_name_len, BYTE.getLength()), "e_name", null);
	return structure;
}
 
Example #29
Source File: Ext4Inode.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public DataType toDataType() throws DuplicateNameException, IOException {
	DataType iBlockDataType = i_block.toDataType();
	Structure structure = new StructureDataType("ext4_inode_"+iBlockDataType.getName( ), 0);
	structure.add(WORD, "i_mode", null);
	structure.add(WORD, "i_uid", null);
	structure.add(DWORD, "i_size_lo", null);
	structure.add(DWORD, "i_atime", null);
	structure.add(DWORD, "i_ctime", null);
	structure.add(DWORD, "i_mtime", null);
	structure.add(DWORD, "i_dtime", null);
	structure.add(WORD, "i_gid", null);
	structure.add(WORD, "i_links_count", null);
	structure.add(DWORD, "i_blocks_lo", null);
	structure.add(DWORD, "i_flags", null);
	structure.add(DWORD, "i_osd1", null);
	structure.add(iBlockDataType, "i_block", null);
	structure.add(DWORD, "i_generation", null);
	structure.add(DWORD, "i_file_acl_lo", null);
	structure.add(DWORD, "i_size_high", null);
	structure.add(DWORD, "i_obso_faddr", null);
	structure.add(new ArrayDataType(BYTE, 12, BYTE.getLength()), "i_osd2", null); //12 bytes long
	structure.add(WORD, "i_extra_isize", null);
	structure.add(WORD, "i_checksum_hi", null);
	structure.add(DWORD, "i_ctime_extra", null);
	structure.add(DWORD, "i_mtime_extra", null);
	structure.add(DWORD, "i_atime_extra", null);
	structure.add(DWORD, "i_crtime", null);
	structure.add(DWORD, "i_crtime_extra", null);
	structure.add(DWORD, "i_version_hi", null);
	structure.add(DWORD, "i_projid", null);
	return structure;
}
 
Example #30
Source File: OdexHeader.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public DataType toDataType() throws DuplicateNameException, IOException {
	Structure structure = new StructureDataType( "odex_header_item", 0 );
	structure.add( UTF8, OdexConstants.ODEX_MAGIC_LENGTH, "magic", null );
	structure.add( DWORD, "dex_offset", null );
	structure.add( DWORD, "dex_length", null );
	structure.add( DWORD, "deps_offset", null );
	structure.add( DWORD, "deps_length", null );
	structure.add( DWORD, "aux_offset", null );
	structure.add( DWORD, "aux_length", null );
	structure.add( DWORD, "flags", null );
	structure.add( DWORD, "padding", null );
	return structure;
}