【问题标题】:Windbg: Is there a way to Import/Export native breakpoints?Windbg:有没有办法导入/导出本机断点?
【发布时间】:2013-05-08 10:03:43
【问题描述】:

有没有办法导入/导出本机断点?

我现在要做的是有一个有趣的断点记事本,如下所示。

bp foo!bar;bp foo!barbar; bp foo!barbarbar; .................

我每次都手动运行上面的,方法是从记事本复制粘贴到windbg的命令窗口。

附:有没有办法告诉windbg直接运行记事本文件?而不是复制和粘贴?

谢谢,

【问题讨论】:

    标签: windbg breakpoints


    【解决方案1】:

    如果您想保存断点但不想使用工作空间并重新使用断点

    这样做

    .logopen break.txt;.bpcmds;.logclose
    

    然后当你想重新申请时

    只需$<break.txt

    一个样本

    0:000> bl
    0:000> bp calc!WinMain
    0:000> bp calc!atanhrat
    0:000> bu ntdll!ZwCreateIoCompletion ".echo foo"
    0:000> bu ntdll!ZwCreateIoCompletion ".echo foo;gc"
    breakpoint 2 redefined
    0:000> bp calc!xorrat
    0:000> g
    
    Breakpoint 0 hit
    
    calc!WinMain:
    01001f51 b8ee280101      mov     eax,offset calc!terminate+0x6 (010128ee)
    0:000> .logopen break.txt
    Opened log file 'break.txt'
    0:000> .bpcmds
    bp0 0x01001f51 ;
    bp1 0x0101090e ;
    bu2 ntdll!ZwCreateIoCompletion ".echo foo;gc";
    bp3 0x0100c474 ;
    0:000> .logclose
    Closing open log file break.txt
    0:000> .restart
    
    ntdll!DbgBreakPoint:
    7c90120e cc              int     3
    0:000> bl  <<<<<<<<<<<<<<<<<---------------- no breakpoints in new calc.exe 
    0:000> $<break.txt
    0:000> Opened log file 'break.txt'
            ^ Syntax error in 'Opened log file 'break.txt''
    0:000> 0:000> .bpcmds
           ^ Syntax error in '0:000> .bpcmds'
    0:000> bp0 0x01001f51 ;
    0:000> bp1 0x0101090e ;
    0:000> bu2 ntdll!ZwCreateIoCompletion ".echo foo;gc";
    0:000> bp3 0x0100c474 ;
    0:000> 0:000> .logclose
           ^ Syntax error in '0:000> .logclose'
    
    0:000> bl  <<<<<<<<<<<<<<<<<--------------------------- all old bps restored
     0 e 01001f51     0001 (0001)  0:**** calc!WinMain
     1 e 0101090e     0001 (0001)  0:**** calc!atanhrat
     2 e 7c90d0be     0001 (0001)  0:**** ntdll!NtCreateIoCompletion ".echo foo;gc"
     3 e 0100c474     0001 (0001)  0:**** calc!xorrat
    

    【讨论】:

    • 非常漂亮。给了 +1,但您可能想提及 break.txt 文件的保存位置。
    【解决方案2】:

    要执行脚本,请执行以下操作:

    $<"myScript.txt"
    

    以上假设您不需要传递争论(更多选项请参见最后的链接)。

    如果您想保存断点,请注意您可以只保存您的工作区,然后 WinDbg 将重新加载您当前的所有断点并重新应用它们,但出于明显原因的地址断点除外。

    更多信息herehere

    您也可以使用-c 启动 WinDbg 以传递如下命令:

    WinDbg -c "bp foo!bar;bp foo!barbar; bp foo!barbarbar;"
    

    您也可以将它们保存到 .cmdtree 文件中,请参阅 here 以获取示例文件以及 blogpost 中的更多信息

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-18
      • 1970-01-01
      • 2011-08-04
      • 1970-01-01
      • 2019-03-26
      • 2019-09-27
      • 1970-01-01
      相关资源
      最近更新 更多