//枚举一个函数里的所有调用
//
#include <idc.idc>
static main()
{
auto func,end,target,inst,name,flags,xref;
flags = SEARCH_DOWN | SEARCH_NEXT;
func = GetFunctionAttr(ScreenEA(),FUNCATTR_START);
if(func != -1)
{
name = Name(func);
end = GetFunctionAttr(func,FUNCATTR_END);
for(inst = func; inst < end; inst = FindCode(inst,flags))
{
for(target = Rfirst(inst) ; target != BADADDR; target = Rnext(inst,target)) //Rfirst取得第一个对它的代码的调用
{
xref = XrefType(); //这个程序中只是对调用其它函数的交叉引用感兴趣,所以只关注fl_CN和fl_CF类型的交叉引用
if(xref == fl_CN || xref == fl_CF)
{
Message("%s calls %s from 0x%x\n",name,Name(target),inst);
}
}
}
}
else
{
Warning("No function found at location %x",ScreenEA());
}
}
结果如下:
![](https://i-blog.csdnimg.cn/blog_migrate/7b9ec47755ccef914c44a0d4274feb3f.png)