public static void copyBytesInRanges(Program toProgram, Program fromProgram,
			AddressSetView addrSet, TaskMonitor monitor)
			throws MemoryAccessException, CancelledException {
		Memory toMem = toProgram.getMemory();
		Memory fromMem = fromProgram.getMemory();
		// Copy each range.
		AddressRangeIterator iter = addrSet.getAddressRanges();
		while (iter.hasNext()) {
			monitor.checkCancelled();
			AddressRange range = iter.next();
			copyByteRange(toMem, fromMem, range);
		}
	}
Copies the bytes to one program from another for the specified set of
address ranges.
@param toProgram program that the bytes are copied to.
@param fromProgram program the bytes are copied from.
@param addrSet the set of address ranges to be copied.
The addresses in this set are derived from the "to program".

@throws MemoryAccessException if bytes can't be copied.
@throws CancelledException if user cancels copy bytes via the monitor.
Ghidra/Features/Base/src/main/java/ghidra/program/util/ProgramMemoryUtil.java