【问题标题】:Specify a breakpoint for all a function call in IDA Pro 6.1在 IDA Pro 6.1 中为所有函数调用指定断点
【发布时间】:2013-02-28 10:21:50
【问题描述】:

在 IDA Pro 6.1 中,我有一个 dll,它对“CreateFileA”和“CreateFileW”函数 API 有 20 次调用。

我想自动为所有的 CreateFileA/CreateFileW 指定断点。

我可以为所有外部参照手动完成,但这很乏味。 有没有办法直接为 CreateFileA/CreateFileW 调用指定断点?

非常感谢:)

【问题讨论】:

    标签: debugging reverse-engineering ida


    【解决方案1】:

    您可以在 CreateFile 的第一条指令处设置断点,或者您可以使用 IDAPython 来创建断点。

    遍历所有指令/调用并查找对适当函数的调用。

    add_bpt() 我相信是调用,

    【讨论】:

      【解决方案2】:

      这是我为完成您想要的任务而编写的脚本。它在调用指定函数的位置设置软断点。

      // Script used to set a breakpoint at the callsite
      // of the specified function using cross-references.
      #include <idc.idc>
      
      static SetBreakpoint(location)
      {
        // Sets a breakpoint to be activated when
        // the debugger runs over the address.
        AddBptEx(location, 0, BPT_SOFT);
      }
      
      static CrossReferenceSource(source)
      {
        // Find the linear address of the source
        // location to start xref'ing from.
        auto sourcefn = LocByName(source);
        auto iterfn = DfirstB(sourcefn);
      
        if (sourcefn != BADADDR && iterfn != BADADDR)
        {
      
          do
          {
            Message("Setting breakpoint @ 0x%08x\n", iterfn);
            SetBreakpoint(iterfn);
            iterfn = DnextB(sourcefn, iterfn);
          } while(iterfn != BADADDR);
      }
      }
      
      static main()
      {
        auto source = "FunctionName";
      
        Message("--- Setting breakpoints at cross-reference ---\n");
        CrossReferenceSource(source);
        Message("--- Finished settings breakpoints --\n");
      }
      

      将“FunctionName”替换为您的函数名称并在 IDA 的“执行脚本”窗口中运行它,该窗口可通过File &gt; Script command 获得

      一个已知的限制是它不能识别间接交叉引用(例如使用寄存器的调用)。

      【讨论】:

        【解决方案3】:

        如果 CreateFileA/W 都是导入的(即,在 .idata 部分中定义的外部),你能不能只选择有问题的符号并按 F2(添加断点)?出现的断点设置对话框允许您指定硬件断点模式,在这种情况下,我们希望将其限制为读取(因为解析导入时将在启动时写入符号的值),这应该只发生在 '调用 ds:CreateFileA' 实例。

        IDA 帮助中的一些断点说明:

        • 不可能创建超过 4 个硬件断点
        • 请注意,硬件断点发生在指令执行之后,而软件断点发生在指令之前。

        【讨论】:

          【解决方案4】:

          据我所知并根据 kornman00,“CreateFile”是从 dll 导入的。其实是直接从Kernel32.dll导入的,不知道怎么用的可以看这里。 https://msdn.microsoft.com/en-us/library/windows/desktop/aa363858%28v=vs.85%29.aspx

          因此,为了执行您要查找的操作,最好的方法是直接执行此操作,在 kernel32.CreateFileA 或 kernel32.CreateFileW 中设置断点。区别仅在于应用使用 Ansichar 或 Widechar。

          显然,为了做到这一点,您需要启动调试过程,因为必须先为您的应用加载 kernel32,然后才能在那里设置断点。

          如果您感到困惑,我的建议是“在更简单的调试器中加载二进制文件”并尝试弄清楚我们之前向您解释过的内容

          【讨论】:

            猜你喜欢
            • 2014-09-18
            • 2013-02-21
            • 1970-01-01
            • 2015-06-04
            • 2012-11-09
            • 1970-01-01
            • 2011-05-26
            • 2018-01-05
            • 2021-01-14
            相关资源
            最近更新 更多