예제 #1
0
def test_load_mem(mem):
    addr2 = 0x200
    data = b'hello'

    other = BufferMemory(ARCH_X86)
    other.map(addr2, 0x100, 'seg2')
    other.segments.seg2.write(data)
    mem.load_memory(other)
    assert mem.read(mem.segments.seg2.address, len(data)) == data
예제 #2
0
def test_alloc_between():
    mem = BufferMemory(ARCH_ARM)
    mem.map(0x0, 0x100, 'seg1')
    mem.map(0x300, 0x100, 'seg2')
    mem.map(0x1400, 0x100, 'seg3')
    mem.map(0x4000, 0x100, 'seg4')
    mem.map(0x5000, 0x100, 'seg5')
    seg = mem.allocate(0x70, 'seg6')
    assert seg.address == 0x2000
예제 #3
0
def test_alloc_after_last():
    mem = BufferMemory(ARCH_ARM)
    mem.map(0x1000, 0x100, 'seg1')
    seg3 = mem.allocate(0x100, 'name')
    assert seg3.address == 0x2000
예제 #4
0
def test_alloc_before_first():
    mem = BufferMemory(ARCH_ARM)
    mem.map(0x2000, 0x1000, 'seg')
    seg2 = mem.allocate(0x1000, 'seg2')
    assert seg2.address == 0x1000
예제 #5
0
def test_from_mem():
    mem = BufferMemory(ARCH_ARM)
    mem.map(0x1000, 0x1000, 'seg')
    emu = Emulator.from_memory(mem)
    assert emu.mem.segments.seg.address == 0x1000