mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 18:29:37 +02:00
changes from review
This commit is contained in:
parent
c73f0381d0
commit
0f80eefaa4
2 changed files with 13 additions and 9 deletions
|
@ -688,23 +688,26 @@ public class MemoryBlockDB implements MemoryBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteSourceRangeList getByteSourceRangeList(Address address, long size) {
|
ByteSourceRangeList getByteSourceRangeList(Address address, long size) {
|
||||||
long offset = address.subtract(startAddress);
|
long blockOffset = address.subtract(startAddress);
|
||||||
size = Math.min(size, length - offset);
|
size = Math.min(size, length - blockOffset);
|
||||||
|
|
||||||
SubMemoryBlock subBlock = getSubBlock(offset);
|
SubMemoryBlock subBlock = getSubBlock(blockOffset);
|
||||||
long subSize = Math.min(size, subBlock.subBlockLength - (offset - subBlock.getStartingOffset()));
|
long subBlockOffset = blockOffset - subBlock.getStartingOffset();
|
||||||
|
long available = subBlock.subBlockLength - subBlockOffset;
|
||||||
|
long subSize = Math.min(size, available);
|
||||||
if (subSize == size) {
|
if (subSize == size) {
|
||||||
return subBlock.getByteSourceRangeList(this, address, offset, size);
|
return subBlock.getByteSourceRangeList(this, address, blockOffset, size);
|
||||||
}
|
}
|
||||||
Address start = address;
|
Address start = address;
|
||||||
ByteSourceRangeList set = subBlock.getByteSourceRangeList(this, start, offset, subSize);
|
ByteSourceRangeList set =
|
||||||
|
subBlock.getByteSourceRangeList(this, start, blockOffset, subSize);
|
||||||
|
|
||||||
long total = subSize;
|
long total = subSize;
|
||||||
while (total < size) {
|
while (total < size) {
|
||||||
subBlock = getSubBlock(offset + total);
|
subBlock = getSubBlock(blockOffset + total);
|
||||||
subSize = Math.min(size - total, subBlock.subBlockLength);
|
subSize = Math.min(size - total, subBlock.subBlockLength);
|
||||||
start = address.add(total);
|
start = address.add(total);
|
||||||
set.add(subBlock.getByteSourceRangeList(this, start, offset + total, subSize));
|
set.add(subBlock.getByteSourceRangeList(this, start, blockOffset + total, subSize));
|
||||||
total += subSize;
|
total += subSize;
|
||||||
}
|
}
|
||||||
return set;
|
return set;
|
||||||
|
|
|
@ -80,7 +80,8 @@ abstract class SubMemoryBlock implements Comparable<SubMemoryBlock> {
|
||||||
* @return true if the offset is valid for this block
|
* @return true if the offset is valid for this block
|
||||||
*/
|
*/
|
||||||
public final boolean contains(long memBlockOffset) {
|
public final boolean contains(long memBlockOffset) {
|
||||||
return memBlockOffset >= subBlockOffset && memBlockOffset < subBlockOffset + subBlockLength;
|
return (memBlockOffset >= subBlockOffset) &&
|
||||||
|
(memBlockOffset < subBlockOffset + subBlockLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue