def run(self, brk): bid = brk.GetId() logger.debug("Breakpoint run %s %d", str(brk), bid) if bid in self.callbacks: dosbox.Dosbox().addCallback(self.callbacks[bid], self.brk2hash(brk)) if brk.GetOnce(): del self.callbacks[bid]
def readEnv(psp, progName=False): d = dosbox.Dosbox() ret = {} envs = struct.unpack('<H', d.mem((psp << 4) + 0x2C, 2))[0] if envs == 0: return None mcb = struct.unpack('<BHH', d.mem((envs - 1) << 4, 5)) env = d.mem(envs << 4, mcb[2] * 16) last = 0 for x in env.split('\x00'): if last == 2: if progName: return x ret['programName'] = x break if last > 0: last += 1 continue if len(x) == 0: last = 1 continue if not progName: s = x.split('=') ret[s[0]] = s[1] return ret
def _onExec(self, **kwargs): psp = kwargs.get('value') nm = dosbox.readEnv(psp, True) logger.debug("check exec %s", nm) if nm.lower().endswith(self.fname): self.psp = psp breaks.Breaks().delExec() self._prepare() else: dosbox.Dosbox().cont()
def __init__(self, fname, symbols=None): self.fname = fname.lower() self.symbols = symbols self.psp = self._checkLoaded() self.base = None self.dseg = None if self.psp: if self._prepare(): dosbox.Dosbox().cont() else: breaks.Breaks().addExec(callback=self._onExec)
def _checkLoaded(self): try: # check dosbox loaded/we are not plugin dosbox.Dosbox().cs except: return None prg = dosbox.loadedProgs() for x in prg: if not prg[x]: continue if prg[x].lower().endswith(self.fname): return x return None
def _prepare(self): self.base = self.psp + 0x10 if self.symbols: logger.debug("loading symbols from %s at %04X", self.symbols, self.base) self.ctx = context.Context() self.ctx.loadSymbols(self.symbols, self.base) try: self.dseg = self.ctx.var("__SEG__DATA0") except Exception: self.dseg = None self.dbox = dosbox.Dosbox() self.loaded()
def loadedProgs(): psps = [0, 8] ret = {} d = dosbox.Dosbox() mcb = d.firstMCB() i = 0 while True: m = struct.unpack('<BHH', d.mem(mcb << 4, 5)) if m[1] not in psps: psps += [m[1]] ret[m[1]] = readEnv(m[1], True) if m[0] == 0x5A: break i += 1 mcb += m[2] + 1 return ret
def __init__(self): dosbox.Dosbox().server = self self.start(dosbox.Dosbox().host, dosbox.Dosbox().port)
def __init__(self): dosbox.Dosbox().dasm = self
def __init__(self): dosbox.Dosbox().ui = self
def readString(addr="ds:dx", end='\x00', maxsize=256): data = dosbox.Dosbox().mem(addr, maxsize) idx = data.find(end) if idx >= 0: data = data[:idx] return data