mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
fixing issues in memory sub-blocks
This commit is contained in:
parent
083b5f61cc
commit
c73f0381d0
10 changed files with 137 additions and 89 deletions
|
@ -18,6 +18,7 @@ package ghidra.program.database.mem;
|
|||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.*;
|
||||
|
@ -315,6 +316,27 @@ public class MemBlockDBTest extends AbstractGenericTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWriteBytesAcrossSubBlocks() throws Exception {
|
||||
FileBytes fileBytes = createFileBytes();
|
||||
MemoryBlock block1 = createFileBytesBlock(fileBytes, addr(10), 25, 10);
|
||||
MemoryBlock block2 = createFileBytesBlock(fileBytes, addr(20), 50, 10);
|
||||
mem.join(block1, block2);
|
||||
byte[] bytes = createBytes(20);
|
||||
mem.setBytes(addr(10), bytes);
|
||||
byte[] readBytes = new byte[20];
|
||||
mem.getBytes(addr(10), readBytes);
|
||||
assertTrue(Arrays.equals(bytes, readBytes));
|
||||
}
|
||||
|
||||
private byte[] createBytes(int size) {
|
||||
byte[] bytes = new byte[size];
|
||||
for (int i = 0; i < size; i++) {
|
||||
bytes[i] = (byte) i;
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJoinFileBytes() throws Exception {
|
||||
FileBytes fileBytes = createFileBytes();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue