MCPcopy Create free account
hub / github.com/qilingframework/qiling / ComParser

Class ComParser

qiling/loader/dos.py:16–33  ·  view source on GitHub ↗

Most basic COM file parser.

Source from the content-addressed store, hash-verified

14
15# @see: http://pinvoke.net/default.aspx/Structures.IMAGE_DOS_HEADER
16class ComParser:
17 '''Most basic COM file parser.
18 '''
19
20 def __init__(self, ql: Qiling, data: bytes) -> None:
21 assert data[0:2] == b'MZ'
22
23 nbytes = ql.unpack16(data[2:4]) or 0x200 # number of bytes in last block; 0 means it is fully populated
24 nblocks = ql.unpack16(data[4:6]) # number of blocks used
25 hdrpgs = ql.unpack16(data[8:10]) # number of paragraphs taken up by the header
26
27 self.size = (nblocks - 1) * 0x200 + nbytes
28 self.header_size = hdrpgs * 0x10
29
30 self.init_ss = ql.unpack16(data[14:16])
31 self.init_sp = ql.unpack16(data[16:18])
32 self.init_ip = ql.unpack16(data[20:22])
33 self.init_cs = ql.unpack16(data[22:24])
34
35
36class QlLoaderDOS(QlLoader):

Callers 1

runMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected