Java Code Examples for ghidra.program.model.mem.Memory#intersect()

The following examples show how to use ghidra.program.model.mem.Memory#intersect() . 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: RegisterMergeManager.java    From ghidra with Apache License 2.0 6 votes vote down vote up
/**
 * 
 * @param monitor
 */
private void determineConflicts(TaskMonitor monitor) throws CancelledException {
	if (conflictSet != null) {
		return; //This method only needs to be called once.
	}
	RegisterConflicts rc =
		new RegisterConflicts(registerName, originalContext, latestContext, myContext,
			resultContext);
	Memory resultMem = resultPgm.getMemory();
	AddressSetView myDiffs =
		rc.getRegisterDifferences(registerName, originalContext, myContext, mySet, monitor);
	AddressSet setToCheck = resultMem.intersect(myDiffs);
	conflictSet = new AddressSet();
	rvrs = rc.getConflicts(setToCheck, monitor);
	if (rvrs.length > 0) {
		for (int j = 0; j < rvrs.length; j++) {
			conflictSet.add(rvrs[j]);
		}
	}
	autoSet = setToCheck.subtract(conflictSet);
}
 
Example 2
Source File: MemorySectionResolver.java    From ghidra with Apache License 2.0 6 votes vote down vote up
/**
 * Determine loaded memory conflict set.  Use physical address of loaded overlay
 * blocks to force reconciliation and avoid duplication.
 * @param rangeMin
 * @param rangeMax
 * @return conflict memory set
 */
private AddressSet getMemoryConflictSet(Address rangeMin, Address rangeMax) {

	// dedicated non-loaded overlay - don't bother with conflict check
	if (rangeMin.isNonLoadedMemoryAddress()) {
		return new AddressSet();
	}

	// Get base memory conflict set
	Memory memory = getMemory();
	AddressSet rangeSet = new AddressSet(rangeMin, rangeMax);
	AddressSet conflictSet = memory.intersect(rangeSet);

	// Add in loaded overlay conflicts (use their physical address)
	for (MemoryBlock block : memory.getBlocks()) {
		Address minAddr = block.getStart();
		Address maxAddr = block.getEnd();
		if (minAddr.isLoadedMemoryAddress() && minAddr.getAddressSpace().isOverlaySpace()) {
			AddressSet intersection = rangeSet.intersectRange(minAddr.getPhysicalAddress(),
				maxAddr.getPhysicalAddress());
			conflictSet.add(intersection);
		}
	}

	return conflictSet;
}