Java Code Examples for ghidra.program.model.mem.MemoryBlock#setExecute()

The following examples show how to use ghidra.program.model.mem.MemoryBlock#setExecute() . 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: DexLoader.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void createMethodByteCodeBlock(Program program, long length, TaskMonitor monitor) throws Exception {
	Address address = toAddr( program, DexUtil.METHOD_ADDRESS );
	MemoryBlock block = program.getMemory( ).createInitializedBlock( "method_bytecode", address, length, (byte) 0xff, monitor, false );
	block.setRead( true );
	block.setWrite( false );
	block.setExecute( true );
}
 
Example 2
Source File: DexLoader.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void createMethodLookupMemoryBlock(Program program, TaskMonitor monitor) throws Exception {
	Address address = toAddr( program, DexUtil.LOOKUP_ADDRESS );
	MemoryBlock block = program.getMemory( ).createInitializedBlock( "method_lookup", address, DexUtil.MAX_METHOD_LENGTH, (byte) 0xff, monitor, false );
	block.setRead( true );
	block.setWrite( false );
	block.setExecute( false );
}
 
Example 3
Source File: DexHeaderFormatAnalyzer.java    From ghidra with Apache License 2.0 4 votes vote down vote up
@Override
public boolean analyze(Program program, AddressSetView set, TaskMonitor monitor, MessageLog log)
		throws Exception {

	Address startAddress = toAddr(program, 0x0);

	if (getDataAt(program, startAddress) != null) {
		log.appendMsg("data already exists.");
		return true;
	}

	Memory memory = program.getMemory();
	MemoryBlock block = memory.getBlock(startAddress);
	block.setRead(true);
	block.setWrite(false);
	block.setExecute(false);

	DexAnalysisState analysisState = DexAnalysisState.getState(program);
	DexHeader header = analysisState.getHeader();
	processHeader(program, header);

	createInitialFragments(program, header, monitor);

	BasicCompilerSpec.enableJavaLanguageDecompilation(program);
	createNamespaces(program, header, monitor, log);
	processMap(program, header, monitor, log);
	processStrings(program, header, monitor, log);
	processTypes(program, header, monitor, log);
	processPrototypes(program, header, monitor, log);
	processFields(program, header, monitor, log);
	processMethods(program, header, monitor, log);
	processClassDefs(program, header, monitor, log);
	createProgramDataTypes(program, header, monitor, log);

	createMethods(program, header, monitor, log);

	monitor.setMessage("DEX: cleaning up tree");
	removeEmptyFragments(program);

	return true;
}
 
Example 4
Source File: OdexHeaderFormatAnalyzer.java    From ghidra with Apache License 2.0 4 votes vote down vote up
@Override
public boolean analyze( Program program, AddressSetView set, TaskMonitor monitor, MessageLog log ) throws Exception {

	Address address = toAddr( program, 0x0 );

	if ( getDataAt( program, address ) != null ) {
		log.appendMsg( "data already exists." );
		return true;
	}

	Memory memory = program.getMemory( );
	MemoryBlock block = memory.getBlock( "ram" );
	block.setRead( true );
	block.setWrite( false );
	block.setExecute( false );

	ByteProvider provider = new MemoryByteProvider( program.getMemory( ), program.getMinAddress( ) );
	BinaryReader reader = new BinaryReader( provider, true );

	OdexHeader header = new OdexHeader( reader );

	DataType headerDataType = header.toDataType();
	createData( program, address, headerDataType);

	createFragment(program, "header", address, address.add(headerDataType.getLength()));

	Address dexAddress = toAddr(program, header.getDexOffset());
	createFragment(program, "dex", dexAddress, dexAddress.add(header.getDexLength()));

	Address depsAddress = toAddr(program, header.getDepsOffset());
	createFragment(program, "deps", depsAddress, depsAddress.add(header.getDepsLength()));
	processDeps( program, header, monitor, log );

	Address auxAddress = toAddr(program, header.getAuxOffset());
	createFragment(program, "aux", auxAddress, auxAddress.add(header.getAuxLength()));

	monitor.setMessage( "ODEX: cleaning up tree" );
	removeEmptyFragments( program );

	return true;
}
 
Example 5
Source File: ProgramBuilder.java    From ghidra with Apache License 2.0 4 votes vote down vote up
public void setExecute(MemoryBlock block, boolean e) {
	startTransaction();
	block.setExecute(e);
}