ghidra.framework.store.LockException Java Examples

The following examples show how to use ghidra.framework.store.LockException. 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: ProgramDB.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
public void setLanguage(Language newLanguage, CompilerSpecID newCompilerSpecID,
		boolean forceRedisassembly, TaskMonitor monitor)
		throws IllegalStateException, IncompatibleLanguageException, LockException {
	if (newLanguage == language) {
		setLanguage((LanguageTranslator) null, newCompilerSpecID, forceRedisassembly, monitor);
		return;
	}
	LanguageTranslator languageTranslator =
		LanguageTranslatorFactory.getLanguageTranslatorFactory().getLanguageTranslator(language,
			newLanguage);
	if (languageTranslator == null) {
		throw new IncompatibleLanguageException("Language translation not supported");
	}
	setLanguage(languageTranslator, newCompilerSpecID, forceRedisassembly, monitor);
}
 
Example #2
Source File: MemoryMapDB.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private void checkPreconditionsForJoining(MemoryBlock block1, MemoryBlock block2)
		throws MemoryBlockException, LockException {

	program.checkExclusiveAccess();
	if (liveMemory != null) {
		throw new MemoryBlockException(
			"Memory join operation not permitted while live memory is active");
	}

	checkBlockForJoining(block1);
	checkBlockForJoining(block2);

	if (block1.isInitialized() != block2.isInitialized()) {
		throw new MemoryBlockException(
			"Both blocks must be either initialized or uninitialized");
	}

	if (!(block1.getEnd().isSuccessor(block2.getStart()))) {
		throw new MemoryBlockException("Blocks are not contiguous");
	}

}
 
Example #3
Source File: MemoryBlockDB.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
public void setName(String name) throws DuplicateNameException, LockException {
	String oldName = getName();
	memMap.lock.acquire();
	try {
		checkValid();
		if (oldName.equals(name)) {
			return;
		}
		memMap.checkBlockName(name, isOverlay());
		try {
			if (isOverlay()) {
				memMap.overlayBlockRenamed(oldName, name);
			}
			record.setString(MemoryMapDBAdapter.NAME_COL, name);
			adapter.updateBlockRecord(record);
		}
		catch (IOException e) {
			memMap.dbError(e);
		}
		memMap.fireBlockChanged(this);
	}
	finally {
		memMap.lock.release();
	}
}
 
Example #4
Source File: ArchiveUtils.java    From ghidra with Apache License 2.0 6 votes vote down vote up
public static boolean lockArchive(FileArchive archive) {
	try {
		archive.acquireWriteLock();
		return true;
	}
	catch (ReadOnlyException e) {
		Msg.showError(log, null, "Unable to Lock File for Writing", e.getMessage());
	}
	catch (LockException exc) {
		Msg.showError(log, null, "Unable to Lock File for Writing",
			"Unable to obtain lock for archive: " + archive.getName() + "\n" +
				exc.getMessage());
	}
	catch (IOException ioe) {
		Msg.showError(log, null, "Unable to Lock File for Writing",
			"Problem attempting to lock archive: " + archive.getName() + "\n" +
				ioe.getMessage());
	}
	return false;
}
 
Example #5
Source File: ProgramDB.java    From ghidra with Apache License 2.0 6 votes vote down vote up
public boolean removeOverlaySpace(AddressSpace overlaySpace) throws LockException {
	lock.acquire();
	try {
		checkExclusiveAccess();
		MemoryBlock[] blocks = memoryManager.getBlocks();
		for (MemoryBlock block : blocks) {
			if (block.getStart().getAddressSpace().equals(overlaySpace)) {
				return false;
			}
		}
		addressFactory.removeOverlaySpace(overlaySpace.getName());
		overlaySpaceAdapter.removeOverlaySpace(overlaySpace.getName());
		addrMap.deleteOverlaySpace(overlaySpace.getName());
		clearCache(true);
		return true;
	}
	catch (IOException e) {
		dbError(e);
	}
	finally {
		lock.release();
	}
	return false;
}
 
Example #6
Source File: ProgramDB.java    From ghidra with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new OverlayAddressSpace with the given name and base AddressSpace
 * @param overlaySpaceName the name of the overlay space to create
 * @param templateSpace the base AddressSpace to overlay	
 * @throws DuplicateNameException if an AddressSpace already exists with the given name.
 * @throws LockException if the program is shared and not checked out exclusively.
 * @throws MemoryConflictException if image base override is active
 */
public AddressSpace addOverlaySpace(String overlaySpaceName, AddressSpace templateSpace,
		long minOffset, long maxOffset)
		throws DuplicateNameException, LockException, MemoryConflictException {

	checkExclusiveAccess();
	if (imageBaseOverride) {
		throw new MemoryConflictException(
			"Overlay spaces may not be created while an image-base override is active");
	}
	OverlayAddressSpace ovSpace = addressFactory.addOverlayAddressSpace(overlaySpaceName,
		templateSpace, minOffset, maxOffset);
	try {
		overlaySpaceAdapter.addOverlaySpace(ovSpace);
	}
	catch (IOException e) {
		dbError(e);
	}
	return ovSpace;
}
 
Example #7
Source File: JavaLoader.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private void doLoad(ByteProvider provider, Program program, TaskMonitor monitor)
		throws LockException, MemoryConflictException, AddressOverflowException,
		CancelledException, DuplicateNameException, IOException {
	AddressFactory af = program.getAddressFactory();
	AddressSpace space = af.getAddressSpace(CONSTANT_POOL);
	Memory memory = program.getMemory();
	alignmentReg = program.getRegister("alignmentPad");

	BinaryReader reader = new BinaryReader(provider, false);
	ClassFileJava classFile = new ClassFileJava(reader);

	Address address = space.getAddress(0);

	// Create a block of memory with just the right size
	memory.createInitializedBlock("_" + provider.getName() + "_", address,
		provider.getInputStream(0), provider.length(), monitor, false);

	createMethodLookupMemoryBlock(program, monitor);
	createMethodMemoryBlocks(program, provider, classFile, monitor);

}
 
Example #8
Source File: ElfProgramBuilder.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private void pruneDiscardableBlocks() {
	byte[] bytes = new byte[DISCARDABLE_SEGMENT_SIZE];
	try {
		for (MemoryBlock block : memory.getBlocks()) {
			long size = block.getSize();
			if (size > DISCARDABLE_SEGMENT_SIZE ||
				!block.getName().startsWith(SEGMENT_NAME_PREFIX)) {
				continue;
			}
			block.getBytes(block.getStart(), bytes, 0, (int) size);
			if (isZeroedArray(bytes, (int) size)) {
				Msg.debug(this,
					"Removing discardable alignment/filler segment at " + block.getStart());
				memory.removeBlock(block, TaskMonitorAdapter.DUMMY_MONITOR);
			}
		}
	}
	catch (LockException | MemoryAccessException e) {
		throw new AssertException(e); // should never happen
	}
}
 
Example #9
Source File: SymbolLoader.java    From Ghidra-GameCube-Loader with Apache License 2.0 5 votes vote down vote up
private String TryRenameMemoryBlocks(MemoryMapSectionInfo sectionInfo, long sectionAddress) {
	if (sectionInfo.startingAddress >= this.objectAddress &&
		sectionInfo.startingAddress < this.addressSpace.getMaxAddress().getOffset()) {
			sectionAddress = sectionInfo.startingAddress;
	}

	var name = sectionInfo.name;
	var address = this.addressSpace.getAddress(sectionAddress);
	var memoryBlock = this.program.getMemory().getBlock(address);
	if (memoryBlock != null) {
		try {
			var blockName = memoryBlock.getName();
			var originalName = memoryBlock.getName();
			if (blockName.contains("_")) {
				blockName = blockName.substring(0, blockName.lastIndexOf("_"));
			}
			blockName += "_" + name;
			memoryBlock.setName(blockName);
			this.renameFragment(address, blockName);
			
			Msg.info(this, String.format("Symbol Loader: set memory block name of %s to %s!", originalName, memoryBlock.getName()));
			if (name.toLowerCase().contains("rodata")) {
				memoryBlock.setWrite(false);
				memoryBlock.setRead(true);
			}
			
			return memoryBlock.getName();
		} catch (DuplicateNameException | LockException e) {
			e.printStackTrace();
			return memoryBlock.getName();
		}
	}
	
	return name;
}
 
Example #10
Source File: MemoryMapDB.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public MemoryBlock createBlock(MemoryBlock block, String name, Address start, long length)
		throws MemoryConflictException, AddressOverflowException, LockException,
		DuplicateNameException {
	checkBlockName(name, false);
	lock.acquire();
	try {
		checkBlockSize(length, block.isInitialized());
		program.checkExclusiveAccess();
		checkRange(start, length);
		try {
			Address mappedAddr = null;
			int mappingScheme = 0;
			if (block.isMapped()) {
				MemoryBlockSourceInfo info = block.getSourceInfos().get(0);
				if (block.getType() == MemoryBlockType.BYTE_MAPPED) {
					mappingScheme = info.getByteMappingScheme().get().getEncodedMappingScheme();
				}
				mappedAddr = info.getMappedRange().get().getMinAddress();
			}
			MemoryBlockDB newBlock = adapter.createBlock(block.getType(), name, start, length,
				mappedAddr, block.isInitialized(), block.getPermissions(), mappingScheme);
			initializeBlocks();
			addBlockAddresses(newBlock, !block.isMapped() && block.isInitialized());
			fireBlockAdded(newBlock);
			return newBlock;
		}
		catch (IOException e) {
			program.dbError(e);
		}
		return null;

	}
	finally {
		lock.release();
	}
}
 
Example #11
Source File: MemoryBlockDefinition.java    From ghidra with Apache License 2.0 5 votes vote down vote up
public void createBlock(Program program) throws LockException, MemoryConflictException,
		AddressOverflowException, DuplicateNameException {
	if (blockName == null || addressString == null || length <= 0) {
		return;
	}

	Memory mem = program.getMemory();
	Address addr = XmlProgramUtilities.parseAddress(program.getAddressFactory(), addressString);

	MemoryBlock block;
	if (bitMappedAddress != null) {
		Address mappedAddr =
			XmlProgramUtilities.parseAddress(program.getAddressFactory(), bitMappedAddress);
		block = mem.createBitMappedBlock(blockName, addr, mappedAddr, length, false);
	}
	else if (initialized) {
		try {
			block =
				mem.createInitializedBlock(blockName, addr, length, (byte) 0,
					TaskMonitor.DUMMY, false);
		}
		catch (CancelledException e) {
			throw new AssertException(e); // unexpected
		}
	}
	else {
		block = mem.createUninitializedBlock(blockName, addr, length, false);
	}
	block.setRead(readPermission);
	block.setWrite(writePermission);
	block.setExecute(executePermission);
	block.setVolatile(volatilePermission);
}
 
Example #12
Source File: MemoryMapDB.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public MemoryBlock join(MemoryBlock blockOne, MemoryBlock blockTwo)
		throws MemoryBlockException, NotFoundException, LockException {
	lock.acquire();
	try {
		// swap if second block is before first block
		if (blockOne.getStart().compareTo(blockTwo.getStart()) > 0) {
			MemoryBlock tmp = blockOne;
			blockOne = blockTwo;
			blockTwo = tmp;
		}

		checkPreconditionsForJoining(blockOne, blockTwo);

		MemoryBlockDB memBlock1 = (MemoryBlockDB) blockOne;
		MemoryBlockDB memBlock2 = (MemoryBlockDB) blockTwo;

		Address block1Addr = blockOne.getStart();
		Address block2Addr = blockTwo.getStart();

		MemoryBlock newBlock = null;
		try {
			memBlock1.join(memBlock2);
			reloadAll();
			newBlock = getBlockDB(block1Addr);
			fireBlocksJoined(newBlock, block2Addr);

		}
		catch (IOException e) {
			program.dbError(e);
		}
		return newBlock;
	}
	finally {
		lock.release();
	}

}
 
Example #13
Source File: AbstractCreateDataTypeModelTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void setImageBase(ProgramBuilder builder, long imageBase)
		throws AddressOverflowException, LockException, IllegalStateException {
	ProgramDB program = builder.getProgram();
	int txID = program.startTransaction("Setting image base.");
	boolean commit = false;
	try {
		program.setImageBase(builder.addr(imageBase), true);
		commit = true;
	}
	finally {
		program.endTransaction(txID, commit);
	}
}
 
Example #14
Source File: MemoryMapDB.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public MemoryBlock createUninitializedBlock(String name, Address start, long size,
		boolean overlay) throws MemoryConflictException, AddressOverflowException,
		LockException, DuplicateNameException {

	checkBlockName(name, overlay);
	lock.acquire();
	try {
		checkBlockSize(size, false);

		program.checkExclusiveAccess();

		if (overlay) {
			start = createOverlaySpace(name, start, size);
		}
		else {
			checkRange(start, size);
		}
		try {
			MemoryBlockDB newBlock = adapter.createBlock(MemoryBlockType.DEFAULT, name, start,
				size, null, false, MemoryBlock.READ, 0);
			initializeBlocks();
			addBlockAddresses(newBlock, false);
			fireBlockAdded(newBlock);
			return newBlock;
		}
		catch (IOException e) {
			program.dbError(e);
		}
	}
	finally {
		lock.release();
	}
	return null;
}
 
Example #15
Source File: ProgramDB.java    From ghidra with Apache License 2.0 5 votes vote down vote up
public void renameOverlaySpace(String oldName, String newName)
		throws DuplicateNameException, LockException {
	checkExclusiveAccess();
	addressFactory.renameOverlaySpace(oldName, newName);
	try {
		overlaySpaceAdapter.renameOverlaySpace(oldName, newName);
		addrMap.renameOverlaySpace(oldName, newName);
	}
	catch (IOException e) {
		dbError(e);
	}
}
 
Example #16
Source File: PinnedSymbolTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Test
public void testMoveMemoryBlock()
		throws AddressOverflowException, LockException, IllegalStateException,
		MemoryBlockException, MemoryConflictException, NotFoundException {

	checkProcessorSymbolsInPlace(EXPECTED_PROCESSOR_SYMBOLS + EXPECTED_USER_SYMBOLS);
	assertNotNull(symbolTable.getPrimarySymbol(addr(4)));

	Memory memory = program.getMemory();
	MemoryBlock block = memory.getBlock(addr(0));
	memory.moveBlock(block, addr(0x200), TaskMonitorAdapter.DUMMY_MONITOR);

	checkProcessorSymbolsInPlace(EXPECTED_PROCESSOR_SYMBOLS + EXPECTED_USER_SYMBOLS + 1);

	// check bob symbol
	assertNotNull(symbolTable.getPrimarySymbol(addr(0x204)));
	assertEquals(0, symbolTable.getLabelHistory(addr(0x4)).length);
	assertEquals(1, symbolTable.getLabelHistory(addr(0x204)).length);

	// check function symbol - function should move, but pinned label should remain.
	Symbol symbol = symbolTable.getPrimarySymbol(addr(0xc));
	assertNotNull(symbol);
	assertEquals(SymbolType.LABEL, symbol.getSymbolType());
	assertEquals("MyFunction", symbol.getName());
	symbol = symbolTable.getPrimarySymbol(addr(0x20c));
	assertNotNull(symbol);
	assertEquals(SymbolType.FUNCTION, symbol.getSymbolType());
	assertEquals(SourceType.DEFAULT, symbol.getSource());

}
 
Example #17
Source File: FileArchive.java    From ghidra with Apache License 2.0 5 votes vote down vote up
public void releaseWriteLock() throws IOException {
	try {
		refreshArchive(false);
	}
	catch (LockException e) {
		// we know this can't happen, since we are already have the write lock
	}
	hasWriteLock = false;
	setChanged(false);
}
 
Example #18
Source File: DomainObjectAdapterDB.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * Synchronize the specified domain object with this domain object
 * using a shared transaction manager.  If either or both is already shared, 
 * a transition to a single shared transaction manager will be 
 * performed.  
 * @param domainObj
 * @throws LockException if lock or open transaction is active on either
 * this or the specified domain object
 */
@Override
public void addSynchronizedDomainObject(DomainObject domainObj) throws LockException {
	if (!(domainObj instanceof DomainObjectAdapterDB)) {
		Msg.debug(this,
			"Attempted to synchronize to a domainObject that is not a domainObjectDB: " +
				domainObj.getClass());
		return;
	}

	DomainObjectAdapterDB other = (DomainObjectAdapterDB) domainObj;
	SynchronizedTransactionManager manager;
	if (transactionMgr instanceof SynchronizedTransactionManager) {
		if (!(other.transactionMgr instanceof DomainObjectTransactionManager)) {
			throw new IllegalStateException();
		}
		manager = (SynchronizedTransactionManager) transactionMgr;
		manager.addDomainObject(other);
	}
	else if (other.transactionMgr instanceof SynchronizedTransactionManager) {
		if (!(transactionMgr instanceof DomainObjectTransactionManager)) {
			throw new IllegalStateException();
		}
		manager = (SynchronizedTransactionManager) other.transactionMgr;
		manager.addDomainObject(this);
	}
	else {
		manager = new SynchronizedTransactionManager();
		manager.addDomainObject(this);
		manager.addDomainObject(other);
	}
}
 
Example #19
Source File: MemoryMapDB.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public void removeBlock(MemoryBlock block, TaskMonitor monitor) throws LockException {
	lock.acquire();
	try {
		program.checkExclusiveAccess();
		checkBlock(block);
		MemoryBlockDB memBlock = (MemoryBlockDB) block;

		Address startAddress = block.getStart();

		program.setEventsEnabled(false);// ensure that no domain object change
		// events go out that would cause screen updates;
		// the code manager will be locked until the remove is done

		try {
			program.deleteAddressRange(startAddress, memBlock.getEnd(), monitor);
			memBlock.delete();
			reloadAll();
		}
		catch (IOException e) {
			program.dbError(e);
		}
		finally {
			program.setEventsEnabled(true);
		}

		fireBlockRemoved(startAddress);
		if (startAddress.getAddressSpace().isOverlaySpace()) {
			checkRemoveAddressSpace(startAddress.getAddressSpace());
		}
	}
	finally {
		lock.release();
	}
}
 
Example #20
Source File: MemoryMapDB.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * Tests if the given addressSpace (overlay space) is used by any blocks.  If not, it
 * removes the space.
 * @param addressSpace overlay address space to be removed
 */
private void checkRemoveAddressSpace(AddressSpace addressSpace) {
	lock.acquire();
	try {
		program.removeOverlaySpace(addressSpace);
	}
	catch (LockException e) {
		throw new AssertException();
	}
	finally {
		lock.release();
	}

}
 
Example #21
Source File: ProgramUserDataDB.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
	 * Translate language
	 * @param translator language translator, if null only re-disassembly will occur.
	 * @param monitor
	 * @throws LockException
	 */
	private void setLanguage(LanguageTranslator translator, TaskMonitor monitor)
			throws LockException {
		lock.acquire();
		try {
			//setEventsEnabled(false);
			try {

				language = translator.getNewLanguage();
				languageID = language.getLanguageID();
				languageVersion = language.getVersion();

				addressFactory = language.getAddressFactory();
				addressMap.setLanguage(language, addressFactory, translator);

				clearCache(true);

				Record record = SCHEMA.createRecord(new StringField(LANGUAGE_ID));
				record.setString(VALUE_COL, languageID.getIdAsString());
				table.putRecord(record);

				setChanged(true);
				clearCache(true);

				//invalidate();

			}
			catch (Throwable t) {
				throw new IllegalStateException(
					"Set language aborted - program user data is now in an unusable state!", t);
			}
//			finally {
//				setEventsEnabled(true);
//			}
		}
		finally {
			lock.release();
		}
	}
 
Example #22
Source File: DefaultProjectManager.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public Project createProject(ProjectLocator projectLocator, RepositoryAdapter repAdapter,
		boolean remember) throws IOException {

	if (currentProject != null) {
		Msg.error(this,
			"Current project must be closed before establishing a new active project");
		return null;
	}

	if (!projectLocator.getMarkerFile().getParentFile().isDirectory()) {
		throw new FileNotFoundException(
			"Directory not found: " + projectLocator.getMarkerFile().getParentFile());
	}

	try {
		currentProject = new DefaultProject(this, projectLocator, repAdapter);
	}
	catch (LockException e) {
		throw new IOException(e.getMessage());
	}

	if (remember) {
		addProjectToList(recentlyOpenedProjectsList, projectLocator);
		lastOpenedProject = projectLocator;
		updatePreferences();
	}
	return currentProject;
}
 
Example #23
Source File: DefaultProject.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor for opening a project.
 * 
 * @param projectManager the manager of this project
 * @param projectLocator location and name of project
 * @param resetOwner if true, set the owner to the current user
 * @throws FileNotFoundException project directory not found
 * @throws IOException if I/O error occurs.
 * @throws NotOwnerException if userName is not the owner of the project.
 * @throws LockException if unable to establish project lock
 */
protected DefaultProject(DefaultProjectManager projectManager, ProjectLocator projectLocator,
		boolean resetOwner) throws IOException, NotOwnerException, LockException {

	this.projectManager = projectManager;
	this.projectLocator = projectLocator;
	this.projectLock = getProjectLock(projectLocator, true);
	if (projectLock == null) {
		throw new LockException("Unable to lock project! " + projectLocator);
	}

	boolean success = false;
	try {
		Msg.info(this, "Opening project: " + projectLocator.toString());
		fileMgr = new ProjectFileManager(projectLocator, true, resetOwner);
		if (!SystemUtilities.isInHeadlessMode()) {
			toolManager = new ToolManagerImpl(this);
		}
		success = true;
	}
	finally {
		if (!success) {
			if (fileMgr != null) {
				fileMgr.dispose();
			}
			projectLock.release();
		}
	}
}
 
Example #24
Source File: DefaultProject.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor for creating a New project
 * 
 * @param projectManager the manager of this project
 * @param projectLocator location and name of project
 * @param repository shared repository associated with the new project. Can
 *            be null for non-shared projects
 * @throws IOException if I/O error occurs.
 * @throws LockException if unable to establish project lock
 */
protected DefaultProject(DefaultProjectManager projectManager, ProjectLocator projectLocator,
		RepositoryAdapter repository) throws IOException, LockException {
	this.projectManager = projectManager;
	this.projectLocator = projectLocator;
	this.projectLock = getProjectLock(projectLocator, false);
	if (projectLock == null) {
		throw new LockException("Unable to lock project! " + projectLocator);
	}

	boolean success = false;
	try {
		Msg.info(this, "Creating project: " + projectLocator.toString());
		fileMgr = new ProjectFileManager(projectLocator, repository, true);
		if (!SystemUtilities.isInHeadlessMode()) {
			toolManager = new ToolManagerImpl(this);
		}
		success = true;
	}
	finally {
		if (!success) {
			if (fileMgr != null) {
				fileMgr.dispose();
			}
			projectLock.release();
		}
	}
	initializeNewProject();
}
 
Example #25
Source File: AbstractSymbolTreePluginExternalsTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
protected void addOverlayBlock(String name, String startAddress, long length)
		throws LockException, DuplicateNameException, MemoryConflictException,
		AddressOverflowException, CancelledException {
	int transactionID = program.startTransaction("Add Overlay Block to test");
	Address address = program.getAddressFactory().getAddress(startAddress);
	Memory memory = program.getMemory();
	memory.createInitializedBlock(name, address, length, (byte) 0,
		TaskMonitorAdapter.DUMMY_MONITOR, true);
	program.endTransaction(transactionID, true);
}
 
Example #26
Source File: AddByteMappedMemoryBlockCmd.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
protected MemoryBlock createMemoryBlock(Memory memory)
		throws LockException, MemoryConflictException, AddressOverflowException,
		IllegalArgumentException, DuplicateNameException {
	return memory.createByteMappedBlock(name, start, mappedAddress, length,
		byteMappingScheme,
		isOverlay);
}
 
Example #27
Source File: MemoryStub.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public MemoryBlock createInitializedBlock(String name, Address start, InputStream is,
		long length, TaskMonitor monitor, boolean overlay)
		throws LockException, MemoryConflictException, AddressOverflowException,
		CancelledException, DuplicateNameException {
	throw new UnsupportedOperationException();
}
 
Example #28
Source File: MemoryStub.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public MemoryBlock createInitializedBlock(String name, Address start, long size,
		byte initialValue, TaskMonitor monitor, boolean overlay)
		throws LockException, DuplicateNameException, MemoryConflictException,
		AddressOverflowException, CancelledException {
	throw new UnsupportedOperationException();
}
 
Example #29
Source File: MemoryTestDummy.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public MemoryBlock createInitializedBlock(String name, Address start, long size,
		byte initialValue, TaskMonitor monitor, boolean overlay)
		throws LockException, DuplicateNameException, MemoryConflictException,
		AddressOverflowException, CancelledException {
	return null;
}
 
Example #30
Source File: DeleteBlockCmd.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public boolean applyTo(DomainObject obj, TaskMonitor monitor) {
	Program program = (Program) obj;
	Memory mem = program.getMemory();

	if (!program.hasExclusiveAccess()) {
		setStatusMsg("Exclusive access required");
		return false;
	}

	monitor.initialize(blockAddresses.length);
	for (Address blockAddresse : blockAddresses) {
		if (monitor.isCancelled()) {
			break;
		}

		MemoryBlock block = mem.getBlock(blockAddresse);
		monitor.setMessage("Deleting block '" + block.getName() + "'...");

		try {
			mem.removeBlock(block, monitor);
		}
		catch (LockException e) {
			Msg.debug(this,
				"Unable to delete block--do not have lock: '" + block.getName() + "'", e);
		}
		monitor.initialize(block.getSize());
	}
	status = true;
	return status;
}