コード例 #1
0
ファイル: test_memory_manager.py プロジェクト: nylon7/zelos
    def test_memory_manager_map_anywhere(self):
        mm = Memory(Uc(UC_ARCH_X86, UC_MODE_32), None, 32)
        address1 = mm.map_anywhere(0x1000, "name1", "size1")

        self.assertEqual(
            mm.memory_info[address1],
            Section(mm.emu, address1, 0x1000, "name1", "size1", ""),
        )

        address2 = mm.map_anywhere(0x2000, "name2", "size2")

        self.assertEqual(
            mm.memory_info[address1],
            Section(mm.emu, address1, 0x1000, "name1", "size1", ""),
        )
        self.assertEqual(
            mm.memory_info[address2],
            Section(mm.emu, address2, 0x2000, "name2", "size2", ""),
        )

        mm.unmap(address1, 0x1000)
        self.assertNotIn(address1, mm.memory_info)
        self.assertEqual(
            mm.memory_info[address2],
            Section(mm.emu, address2, 0x2000, "name2", "size2", ""),
        )
コード例 #2
0
    def test_memory_manager_map_anywhere(self):
        state = State(None, None, None)
        mm = Memory(create_emulator(UC_ARCH_X86, UC_MODE_32, state), state)
        address1 = mm.map_anywhere(0x1000, name="name1", kind="size1")

        self.assertEqual(mm.get_region(address1).name, "name1")

        address2 = mm.map_anywhere(0x2000, name="name2", kind="size2")

        self.assertEqual(mm.get_region(address1).name, "name1")
        self.assertEqual(mm.get_region(address2).name, "name2")

        mm.unmap(address1, 0x1000)
        self.assertEqual(mm.get_region(address1), None)
        self.assertEqual(mm.get_region(address2).name, "name2")
コード例 #3
0
    def test_memory_manager_map_anywhere(self):
        state = State(None, None, None)
        attrs = {"_get_hooks.return_value": []}
        hook_manager = Mock(**attrs)
        m = Memory(
            create_emulator(UC_ARCH_X86, UC_MODE_32, state),
            hook_manager,
            state,
        )
        address1 = m.map_anywhere(0x1000, name="name1", kind="size1")

        self.assertEqual(m.get_region(address1).name, "name1")

        address2 = m.map_anywhere(0x2000, name="name2", kind="size2")

        self.assertEqual(m.get_region(address1).name, "name1")
        self.assertEqual(m.get_region(address2).name, "name2")

        m.unmap(address1, 0x1000)
        self.assertEqual(m.get_region(address1), None)
        self.assertEqual(m.get_region(address2).name, "name2")