Java Code Examples for generic.continues.GenericFactory#create()

The following examples show how to use generic.continues.GenericFactory#create() . 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: ElfRelocation.java    From ghidra with Apache License 2.0 6 votes vote down vote up
/**
 * GenericFactory construction and initialization method for a ELF representative 
 * relocation entry 
 * @param reader binary reader positioned at start of relocation entry.
 * @param elfHeader ELF header
 * @param relocationIndex index of entry in relocation table
 * @param withAddend true if if RELA entry with addend, else false
 * @param r_offset The offset for the entry
 * @param r_info The info value for the entry
 * @param r_addend The addend for the entry
 * @return ELF relocation object
 */
static ElfRelocation createElfRelocation(GenericFactory factory, ElfHeader elfHeader,
		int relocationIndex, boolean withAddend, long r_offset, long r_info, long r_addend) {

	Class<? extends ElfRelocation> elfRelocationClass = getElfRelocationClass(elfHeader);
	ElfRelocation elfRelocation = (ElfRelocation) factory.create(elfRelocationClass);
	try {
		elfRelocation.initElfRelocation(elfHeader, relocationIndex, withAddend, r_offset,
			r_info, r_addend);
	}
	catch (IOException e) {
		// absence of reader should prevent any IOException from occurring
		throw new AssertException("unexpected IO error", e);
	}
	return elfRelocation;
}
 
Example 2
Source File: ElfHeader.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a new ELF header using the specified byte provider.
 * @param provider the byte provider to supply the bytes
 * @throws ElfException if the underlying bytes in the byte provider 
 * do not constitute a valid ELF.
 */
public static ElfHeader createElfHeader(GenericFactory factory, ByteProvider provider)
		throws ElfException {
	ElfHeader elfHeader = (ElfHeader) factory.create(ElfHeader.class);
	elfHeader.initElfHeader(factory, provider);
	return elfHeader;
}
 
Example 3
Source File: PortableExecutable.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a new Portable Executable using the specified byte provider and layout.
 * @param factory generic factory instance
 * @param bp the byte provider
 * @param layout specifies the layout of the underlying provider and governs RVA resolution
 * @param advancedProcess if true, the data directories are also processed
 * @param parseCliHeaders if true, CLI headers are parsed (if present)
 * @throws IOException if an I/O error occurs.
 */
public static PortableExecutable createPortableExecutable(GenericFactory factory,
		ByteProvider bp, SectionLayout layout, boolean advancedProcess, boolean parseCliHeaders)
		throws IOException {
	PortableExecutable portableExecutable =
		(PortableExecutable) factory.create(PortableExecutable.class);
	portableExecutable.initPortableExecutable(factory, bp, layout, advancedProcess,
		parseCliHeaders);
	return portableExecutable;
}
 
Example 4
Source File: FatHeader.java    From ghidra with Apache License 2.0 4 votes vote down vote up
public static FatHeader createFatHeader(GenericFactory factory, ByteProvider provider)
        throws IOException, UbiException, MachException {
    FatHeader fatHeader = (FatHeader) factory.create(FatHeader.class);
    fatHeader.initFatHeader(factory, provider);
    return fatHeader;
}
 
Example 5
Source File: RplHeader.java    From GhidraRPXLoader with GNU General Public License v3.0 4 votes vote down vote up
public static RplHeader createRplHeader(GenericFactory factory, ByteProvider provider)
		throws ElfException {
	RplHeader elfHeader = (RplHeader) factory.create(RplHeader.class);
	elfHeader.initElfHeader(factory, provider);
	return elfHeader;
}
 
Example 6
Source File: MachHeader.java    From ghidra with Apache License 2.0 3 votes vote down vote up
/**
 * Assumes the MachHeader starts at index <i>machHeaderStartIndexInProvider</i> in the ByteProvider.
 * @param provider the ByteProvider
 * @param machHeaderStartIndexInProvider the index into the ByteProvider where the MachHeader begins.
 * @throws IOException if an I/O error occurs while reading from the ByteProvider
 * @throws MachException if an invalid MachHeader is detected
 */
public static MachHeader createMachHeader(GenericFactory factory, ByteProvider provider,
		long machHeaderStartIndexInProvider) throws IOException, MachException {
	MachHeader machHeader = (MachHeader) factory.create(MachHeader.class);
	machHeader.initMachHeader(factory, provider, machHeaderStartIndexInProvider, true);
	return machHeader;
}
 
Example 7
Source File: MachHeader.java    From ghidra with Apache License 2.0 3 votes vote down vote up
/**
 * Assumes the MachHeader starts at index <i>machHeaderStartIndexInProvider</i> in the ByteProvider.
 * @param provider the ByteProvider
 * @param machHeaderStartIndexInProvider the index into the ByteProvider where the MachHeader begins.
 * @param isRemainingMachoRelativeToStartIndex TRUE if the rest of the macho uses relative indexing. This is common in UBI and kernel cache files.
 *                                             FALSE if the rest of the file uses absolute indexing from 0. This is common in DYLD cache files.
 * @throws IOException if an I/O error occurs while reading from the ByteProvider
 * @throws MachException if an invalid MachHeader is detected
 */
public static MachHeader createMachHeader(GenericFactory factory, ByteProvider provider,
		long machHeaderStartIndexInProvider, boolean isRemainingMachoRelativeToStartIndex)
		throws IOException, MachException {
	MachHeader machHeader = (MachHeader) factory.create(MachHeader.class);
	machHeader.initMachHeader(factory, provider, machHeaderStartIndexInProvider,
		isRemainingMachoRelativeToStartIndex);
	return machHeader;
}