当前位置: 首页>>代码示例>>Python>>正文


Python pykd.dbgCommand方法代码示例

本文整理汇总了Python中pykd.dbgCommand方法的典型用法代码示例。如果您正苦于以下问题:Python pykd.dbgCommand方法的具体用法?Python pykd.dbgCommand怎么用?Python pykd.dbgCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pykd的用法示例。


在下文中一共展示了pykd.dbgCommand方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_addr_list

# 需要导入模块: import pykd [as 别名]
# 或者: from pykd import dbgCommand [as 别名]
def get_addr_list():
    addr_list = []
    addr_list.append(pykd.getContext().ip())
    for line in pykd.dbgCommand("k").splitlines()[1:]:
        skip = False
        try:
            _, ret_addr, sym = line.split()
            ret_addr = int(ret_addr, 16)
        except ValueError:
            continue
        for noise in BLACKLIST_LIBS:
            if sym.startswith(noise):
                skip = True
                break
        if skip:
            continue
        addr_list.append(ret_addr)
    addr_list.pop() # remove 0 from the list
    return addr_list 
开发者ID:blackberry,项目名称:ALF,代码行数:21,代码来源:WinDBGTrace.py

示例2: get_proc_run_time

# 需要导入模块: import pykd [as 别名]
# 或者: from pykd import dbgCommand [as 别名]
def get_proc_run_time():
    #Debug session time: Tue Aug 21 16:27:31.971 2012 (UTC - 4:00)
    #System Uptime: 5 days 13:06:34.062
    #Process Uptime: 0 days 0:00:02.718
      #Kernel time: 0 days 0:00:00.000
      #User time: 0 days 0:00:00.000
    duration = 0
    for line in pykd.dbgCommand(".time").splitlines()[-2:]:
        line = line.strip().split()
        duration += int(line[2]) * 86400 # days
        line = line[-1].split('.')
        duration += float("0.%s" % line[-1])
        line = line[0].split(':')
        duration += int(line[0]) * 3600 # hours
        duration += int(line[1]) * 60 # minutes
        duration += int(line[2]) # seconds
    return duration 
开发者ID:blackberry,项目名称:ALF,代码行数:19,代码来源:WinDBGTrace.py

示例3: requested_mem_size

# 需要导入模块: import pykd [as 别名]
# 或者: from pykd import dbgCommand [as 别名]
def requested_mem_size():
    possible_bp_syms = ["calloc", "malloc", "realloc"]
    sym = None
    for line in pykd.dbgCommand("kb").splitlines()[1:]:
        try:
            _, _, arg0, arg1, _, sym = line.split()
            arg0 = int(arg0, 16)
            arg1 = int(arg1, 16)
            sym = sym.split("!")[1].strip()
        except (ValueError, IndexError):
            continue
        if sym in possible_bp_syms:
            break
        sym = None

    if sym == "calloc":
        ret_val = arg0 * arg1
    elif sym == "malloc":
        ret_val = arg0
    elif sym == "realloc":
        ret_val = arg1
    else:
        ret_val = 0
    return ret_val 
开发者ID:blackberry,项目名称:ALF,代码行数:26,代码来源:WinDBGMemoryLimit.py

示例4: disasmBackward

# 需要导入模块: import pykd [as 别名]
# 或者: from pykd import dbgCommand [as 别名]
def disasmBackward(self, address, depth):
        while True:
            cmd2run = "ub 0x%08x L%d" % (address, depth)
            try:
                disasmlist = pykd.dbgCommand(cmd2run)
                disasmLinesTmp = disasmlist.split("\n")
                disasmLines = []
                for line in disasmLinesTmp:
                    if line.replace(" ", "") != "":
                        disasmLines.append(line)
                lineindex = len(disasmLines) - depth
                if lineindex > -1:
                    asmline = disasmLines[lineindex]
                    pointer = asmline[0:8]
                    return self.getOpcode(hexStrToInt(pointer))
                else:
                    return self.getOpcode(address)
            except:
                # probably invalid instruction, so fake by returning itself
                # caller should check if address is different than what was provided
                if depth == 1:
                    return self.getOpcode(address)
            depth -= 1 
开发者ID:x64dbg,项目名称:x64dbgpylib,代码行数:25,代码来源:x64dbgpylib.py

示例5: setMemBreakpoint

# 需要导入模块: import pykd [as 别名]
# 或者: from pykd import dbgCommand [as 别名]
def setMemBreakpoint(self, address, memType):
        validtype = False
        bpcommand = ""
        if memType.upper() == "S":
            bpcommand = "ba e 1 0x%08x" % address
            validtype = True
        if memType.upper() == "R":
            bpcommand = "ba r 4 0x%08x" % address
            validtype = True
        if memType.upper() == "W":
            bpcommand = "ba w 4 0x%08x" % address
            validtype = True
        if validtype:
            output = ""
            try:
                output = pykd.dbgCommand(bpcommand)
            except:
                if memType.upper() == "S":
                    bpcommand = "bp 0x%08x" % address
                    output = pykd.dbgCommand(bpcommand)
                else:
                    self.log("** Unable to set memory breakpoint. Check alignment,")
                    self.log("   and try to run the following command to get more information:")
                    self.log("   %s" % bpcommand) 
开发者ID:x64dbg,项目名称:x64dbgpylib,代码行数:26,代码来源:x64dbgpylib.py

示例6: find_symbol

# 需要导入模块: import pykd [as 别名]
# 或者: from pykd import dbgCommand [as 别名]
def find_symbol(self, address):
        name = ''
        if not address in self.address_to_symbols:
            self.load_address_symbol(address)

        if address in self.address_to_symbols:
            name = self.address_to_symbols[address]
        else:
            if self.use_command_mode:
                try:
                    output = pykd.dbgCommand("u %x L1" % address)
                except:
                    output = ''

                if output:
                    output_lines = output.splitlines()
                    if len(output_lines) >= 0 and output_lines[0].endswith(':'):
                        name = output_lines[0]
            else:
                name = pykd.findSymbol(address)

        return name 
开发者ID:ohjeongwook,项目名称:windbgtool,代码行数:24,代码来源:debugger.py

示例7: get_current_stack

# 需要导入模块: import pykd [as 别名]
# 或者: from pykd import dbgCommand [as 别名]
def get_current_stack():
    call_stack = []
    for line in pykd.dbgCommand("k").splitlines()[1:]:
        try:
            _, ret_addr, sym = line.split()
            _ = int(ret_addr, 16)
        except ValueError:
            continue
        call_stack.append(sym)
    return call_stack 
开发者ID:blackberry,项目名称:ALF,代码行数:12,代码来源:WinDBGTrace.py

示例8: get_thread_list

# 需要导入模块: import pykd [as 别名]
# 或者: from pykd import dbgCommand [as 别名]
def get_thread_list():
    return pykd.dbgCommand("!runaway").splitlines()[2:] 
开发者ID:blackberry,项目名称:ALF,代码行数:4,代码来源:WinDBGTrace.py

示例9: set_thread

# 需要导入模块: import pykd [as 别名]
# 或者: from pykd import dbgCommand [as 别名]
def set_thread(t_id):
    pykd.dbgCommand("~%d s" % t_id) 
开发者ID:blackberry,项目名称:ALF,代码行数:4,代码来源:WinDBGTrace.py

示例10: is_complete

# 需要导入模块: import pykd [as 别名]
# 或者: from pykd import dbgCommand [as 别名]
def is_complete():
    return pykd.dbgCommand(".lastevent").find("Exit process") != -1 
开发者ID:blackberry,项目名称:ALF,代码行数:4,代码来源:WinDBGTrace.py

示例11: get_bp_hit

# 需要导入模块: import pykd [as 别名]
# 或者: from pykd import dbgCommand [as 别名]
def get_bp_hit():
    tmp_bp = pykd.dbgCommand(".lastevent")
    if tmp_bp.find("Hit breakpoint") != -1:
        return int(tmp_bp.splitlines()[0].split()[-1])
    return None 
开发者ID:blackberry,项目名称:ALF,代码行数:7,代码来源:WinDBGTrace.py

示例12: find_next_sym

# 需要导入模块: import pykd [as 别名]
# 或者: from pykd import dbgCommand [as 别名]
def find_next_sym(next_bp, prev_bp, timeout):
    iters = 100
    found_sym = False
    sample_time = 0

    set_bp(next_bp, 0, 1)
    set_bp(prev_bp, 1, iters)
    while not is_complete():
        pykd.go()
        curr_bp = get_bp_hit()
        target_time = get_proc_run_time()
        log.debug("target time %0.2f", target_time)
        if curr_bp == 1:
            if target_time >= timeout:
                break
            iter_duration = target_time - sample_time
            if iter_duration < 0.5: # optimization
                if iters < 25600:
                    iters *= 2
                    log.debug("iter duration: %0.2f, (x2) prev_bp iters: %d", iter_duration, iters)
            elif iter_duration >= 0.5 and iter_duration < 0.85: # optimization
                iters += 100
                log.debug("iter duration: %0.2f, (+100) prev_bp iters: %d", iter_duration, iters)
            set_bp(prev_bp, 1, iters)
        elif curr_bp == 0:
            found_sym = True
            break
        else:
            log.debug("break not triggered by breakpoint")
            if pykd.dbgCommand(".lastevent").find("(!!! second chance !!!)") != -1:
                raise RuntimeError("Expected Timeout found Access violation!")
        sample_time = target_time

    pykd.removeBp(1)
    pykd.removeBp(0)
    return found_sym 
开发者ID:blackberry,项目名称:ALF,代码行数:38,代码来源:WinDBGTrace.py

示例13: get_page_size

# 需要导入模块: import pykd [as 别名]
# 或者: from pykd import dbgCommand [as 别名]
def get_page_size():
    return int(pykd.dbgCommand("r $pagesize").split("=")[-1], 16) 
开发者ID:blackberry,项目名称:ALF,代码行数:4,代码来源:WinDBGMemoryLimit.py

示例14: get_pid

# 需要导入模块: import pykd [as 别名]
# 或者: from pykd import dbgCommand [as 别名]
def get_pid():
    return int(pykd.dbgCommand("|").split()[3], 16) 
开发者ID:blackberry,项目名称:ALF,代码行数:4,代码来源:WinDBGMemoryLimit.py

示例15: disasm_around

# 需要导入模块: import pykd [as 别名]
# 或者: from pykd import dbgCommand [as 别名]
def disasm_around(self):
    try:
      lines = pykd.dbgCommand("u %s-c L12" % self.pc_register)
      for line in lines.split("\n"):
        tmp = re.findall("([a-f0-9]{1,}) ([a-f0-9]{2,}) (.*)", line)
        if len(tmp) > 0:
          line = tmp[0]

          addr = line[0]
          dis = line[2]
          self.crash_data.add_data("disassembly", int(addr, 16), dis)
    except:
      log("Error in disasm_around: %s" % str(sys.exc_info()[1])) 
开发者ID:joxeankoret,项目名称:nightmare,代码行数:15,代码来源:pykd_iface.py


注:本文中的pykd.dbgCommand方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。