MCPcopy Create free account
hub / github.com/dobin/SuperMega / DataReuseTest

Class DataReuseTest

tests/test_datareuse.py:14–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12
13
14class DataReuseTest(unittest.TestCase):
15 def test_rangemanager(self):
16 """Test RangeManager for basic functionality"""
17 rm = RangeManager(0, 100)
18 rm.add_range(0, 10)
19 rm.add_range(20, 30)
20 rm.add_range(50, 60)
21
22 hole = rm.find_hole(10)
23 self.assertEqual((11, 19), hole)
24
25 holes = rm.find_holes(20)
26 self.assertEqual([(31, 49), (61, 100)], holes)
27
28 largest = rm.find_largest_gap()
29 self.assertEqual(40, largest)
30
31
32 def test_rangemanager_2(self):
33 rm = RangeManager(0, 100)
34 rm.add_range(0, 90)
35 hole = rm.find_hole(5)
36 self.assertIsNotNone(hole)
37
38 def test_relocation_list(self):
39 superpe = SuperPe(PATH_INJECTABLES + "7z.exe")
40 relocs = superpe.get_relocations_for_section(".rdata")
41 self.assertEqual(836, len(relocs))
42 reloc = relocs[0]
43 self.assertEqual(393216, reloc.base_rva)
44 self.assertEqual(394296, reloc.rva)
45 self.assertEqual(1080, reloc.offset)
46 self.assertEqual("I", reloc.type)
47
48
49 def test_relocmanager(self):
50 """Test reference EXE reloc manager information"""
51 superpe = SuperPe(PATH_INJECTABLES + "procexp64.exe")
52 rm = superpe.get_rdata_rangemanager()
53 self.assertEqual(61, len(rm.intervals))
54 # 0x1ab0 is magic currently (should use find_first_utf16_string_offset()
55 hole = rm.find_hole(20)
56 self.assertEqual(hole, (1174185, 1174591))
57
58
59 def test_largestgap(self):
60 superpe = SuperPe(PATH_INJECTABLES + "7z.exe")
61 rm = superpe.get_rdata_rangemanager()
62 start, stop = rm.find_hole(100)
63 self.assertEqual(394513, start)
64 self.assertEqual(396511, stop)
65
66
67 def test_rdata_overwrite(self):
68 pass
69
70
71 def test_asm_lea_create(self):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected