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

Method run

qiling/loader/dos.py:50–119  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

48 self.old_excepthook(tp, value, tb)
49
50 def run(self):
51 path = self.ql.path
52 profile = self.ql.profile
53
54 # bare com file
55 if path.endswith(".DOS_COM"):
56 with open(path, "rb") as f:
57 content = f.read()
58
59 cs = profile.getint("COM", "start_cs")
60 ip = profile.getint("COM", "start_ip")
61 sp = profile.getint("COM", "start_sp")
62 ss = cs
63
64 base_address = (cs << 4) + ip
65
66 # com file with a dos header
67 elif path.endswith(".DOS_EXE"):
68 with open(path, "rb") as f:
69 content = f.read()
70
71 com = ComParser(self.ql, content)
72
73 cs = com.init_cs
74 ip = com.init_ip
75 sp = com.init_sp
76 ss = com.init_ss
77
78 base_address = 0
79 content = content[com.header_size:]
80
81 elif path.endswith(".DOS_MBR"):
82 with open(path, "rb") as f:
83 content = f.read()
84
85 cs = 0x0000
86 ip = 0x7c00
87 sp = 0xfff0
88 ss = cs
89
90 base_address = (cs << 4) + ip
91
92 # https://en.wikipedia.org/wiki/Master_boot_record#BIOS_to_MBR_interface
93 if not self.ql.os.fs_mapper.has_mapping(0x80):
94 self.ql.os.fs_mapper.add_mapping(0x80, QlDisk(path, 0x80))
95
96 # 0x80 -> first drive
97 self.ql.arch.regs.dx = 0x80
98 else:
99 raise NotImplementedError()
100
101 self.ql.arch.regs.cs = cs
102 self.ql.arch.regs.ds = cs
103 self.ql.arch.regs.es = cs
104 self.ql.arch.regs.ss = ss
105 self.ql.arch.regs.ip = ip
106 self.ql.arch.regs.sp = sp
107

Callers

nothing calls this directly

Calls 7

QlDiskClass · 0.90
ComParserClass · 0.85
has_mappingMethod · 0.80
add_mappingMethod · 0.80
mapMethod · 0.80
readMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected