-
Notifications
You must be signed in to change notification settings - Fork 0
/
memorywriter_exec.py
82 lines (62 loc) · 2.76 KB
/
memorywriter_exec.py
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
# This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
import kaitaistruct
from kaitaistruct import KaitaiStruct, KaitaiStream, BytesIO
if getattr(kaitaistruct, 'API_VERSION', (0, 9)) < (0, 9):
raise Exception("Incompatible Kaitai Struct Python API: 0.9 or later is required, but you have %s" % (kaitaistruct.__version__))
class MemorywriterExec(KaitaiStruct):
def __init__(self, _io, _parent=None, _root=None):
self._io = _io
self._parent = _parent
self._root = _root if _root else self
self._read()
def _read(self):
self.chunks = []
i = 0
while not self._io.is_eof():
self.chunks.append(MemorywriterExec.ChunkT(self._io, self, self._root))
i += 1
class ChunkHeaderT(KaitaiStruct):
def __init__(self, _io, _parent=None, _root=None):
self._io = _io
self._parent = _parent
self._root = _root if _root else self
self._read()
def _read(self):
self.chunktype = self._io.read_u1()
self.chunksize = self._io.read_u2le()
class ChunkT(KaitaiStruct):
def __init__(self, _io, _parent=None, _root=None):
self._io = _io
self._parent = _parent
self._root = _root if _root else self
self._read()
def _read(self):
self.header = MemorywriterExec.ChunkHeaderT(self._io, self, self._root)
_on = self.header.chunktype
if _on == 6:
self._raw_body = self._io.read_bytes((self.header.chunksize - 1))
_io__raw_body = KaitaiStream(BytesIO(self._raw_body))
self.body = MemorywriterExec.LoadChunk(_io__raw_body, self, self._root)
else:
self._raw_body = self._io.read_bytes((self.header.chunksize - 1))
_io__raw_body = KaitaiStream(BytesIO(self._raw_body))
self.body = MemorywriterExec.UnknownChunk(_io__raw_body, self, self._root)
self.checksum = self._io.read_u1()
class LoadChunk(KaitaiStruct):
def __init__(self, _io, _parent=None, _root=None):
self._io = _io
self._parent = _parent
self._root = _root if _root else self
self._read()
def _read(self):
self.unknown = self._io.read_u1()
self.loadaddress = self._io.read_u2le()
self.data = self._io.read_bytes_full()
class UnknownChunk(KaitaiStruct):
def __init__(self, _io, _parent=None, _root=None):
self._io = _io
self._parent = _parent
self._root = _root if _root else self
self._read()
def _read(self):
self.data = self._io.read_bytes_full()