forked from Vector35/sample_plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbinaryview.py
More file actions
79 lines (60 loc) · 2.34 KB
/
binaryview.py
File metadata and controls
79 lines (60 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
'''Binary View for the Motorola M6800 Processor'''
import struct
from binaryninja import (BinaryView, Architecture, SegmentFlag, SectionSemantics)
from .instructions import ADDRESS_MASK
class M6800BinaryView(BinaryView):
'''M6800 BinaryView class.'''
name = 'M6800'
long_name = 'Motorola M6800'
def __init__(self, data):
super().__init__(file_metadata=data.file, parent_view=data)
self.raw = data
@classmethod
def is_valid_for_data(self, unused_data):
return True
def init(self):
self.platform = Architecture[M6800BinaryView.name].standalone_platform
self.arch = Architecture[M6800BinaryView.name]
# Create RAM Segment
self.add_auto_segment(
0, 0x200, 0, 0x200,
(SegmentFlag.SegmentContainsData |
SegmentFlag.SegmentReadable |
SegmentFlag.SegmentWritable)
)
# Create Program RAM Section
self.add_auto_section(
'Program Memory', 0, 0x100, SectionSemantics.ReadWriteDataSectionSemantics
)
# Create CMOS RAM Section
self.add_auto_section(
'CMOS Memory', 0x100, 0x100, SectionSemantics.ReadWriteDataSectionSemantics
)
# Create Exectuable Segment
self.add_auto_segment(
0x5800, 0x2800, 0x5800, 0x2800,
(SegmentFlag.SegmentContainsCode |
SegmentFlag.SegmentReadable |
SegmentFlag.SegmentExecutable)
)
# Add Game OS Section
self.add_auto_section(
'Game OS', 0x5800, 0x1000, SectionSemantics.ReadOnlyCodeSectionSemantics
)
# Add Flipper OS Section
self.add_auto_section(
'Flipper OS', 0x6800, 0x1800, SectionSemantics.ReadOnlyCodeSectionSemantics
)
# Find the start address
start_address_pointer = 0xFFFE & ADDRESS_MASK
entry_addr = struct.unpack(
'>H', self.raw.read(start_address_pointer, 2))[0] & ADDRESS_MASK
# Add the start address to the BinaryView
self.add_entry_point(entry_addr)
return False
def perform_get_address_size(self):
return 2
def perform_is_executable(self):
return True
def perform_get_entry_point(self):
return self.entry_point