【问题标题】: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 > Script command 获得
一个已知的限制是它不能识别间接交叉引用(例如使用寄存器的调用)。
【解决方案3】:
如果 CreateFileA/W 都是导入的(即,在 .idata 部分中定义的外部),你能不能只选择有问题的符号并按 F2(添加断点)?出现的断点设置对话框允许您指定硬件断点模式,在这种情况下,我们希望将其限制为读取(因为解析导入时将在启动时写入符号的值),这应该只发生在 '调用 ds:CreateFileA' 实例。
IDA 帮助中的一些断点说明:
- 不可能创建超过 4 个硬件断点
- 请注意,硬件断点发生在指令执行之后,而软件断点发生在指令之前。