def WindbgGetRegBase(tid): ok, s = ida_dbg.send_dbg_command("dg %x" % idautils.cpu.fs) if not ok: return 0 m = re.compile("[0-9a-f]{4} ([0-9a-f]{8})") t = m.match(s.split('\n')[-2]) if not t: return 0 return int(t.group(1), 16)
def DumpPTE(ea1, ea2): items = [] PG = 0x1000 npages = (ea2 - ea1) / PG for i in range(npages): ok, r = ida_dbg.send_dbg_command("!pte %x" % ea1) if not ok: return False r = parse_pte(r) if r: print("VA: %08X PTE: %s PDE: %s" % (ea1, r['ptepfns'], r['pdepfns'])) ea1 += PG
def Refresh(self): items = [] PG = 0x1000 ea1 = self.ea1 npages = (self.ea2 - ea1) / PG for i in range(npages): ok, r = ida_dbg.send_dbg_command("!pte %x" % ea1) if not ok: return False r = parse_pte(r) if r: items.append([hex(ea1), r['ptepfns']]) ea1 += PG self.items = items print(self.items) return True
def IssueCommand(self): s = ida_kernwin.ask_str(self.last_cmd, 0, "Please enter a debugger command") if not s: return # Save last command self.last_cmd = s # Add it using a different color self.AddLine("debugger>" + ida_lines.COLSTR(s, ida_lines.SCOLOR_VOIDOP)) ok, out = ida_dbg.send_dbg_command(s) if ok: for line in out.split("\n"): self.AddLine(ida_lines.COLSTR(line, ida_lines.SCOLOR_LIBNAME)) else: self.AddLine( ida_lines.COLSTR( "Debugger is not active or does not export ida_dbg.send_dbg_command() (%s)" % out, ida_lines.SCOLOR_ERROR)) self.Refresh()
def WinDbg_command(cmd): ok, s = ida_dbg.send_dbg_command(cmd) return s if ok else False