枚举光标当前所在位置的函数包含的指令的数量

//枚举光标当前所在位置的函数包含的指令的数量
//
#include <idc.idc>
static main()
{
	auto func,end,count,inst;
	func = GetFunctionAttr(ScreenEA(),FUNCATTR_START);	//获取包含光标位置的起始地址
	if(func != -1)
	{
		end = GetFunctionAttr(func,FUNCATTR_END);	//获取函数的结束地址
		count = 0;
		inst = func;
		while(inst < end)	//获取的地址小于函数结束地址
		{
			count++;	//函数指令计数
			inst = FindCode(inst,SEARCH_DOWN | SEARCH_NEXT);	//查找指令
		}
		Warning("%s contains %d instructions\n",Name(func),count);
	}
	else
	{
		waring("No function found at location %x",ScreenEA());
	}
}

结果如下:


  

posted @ 2014-08-20 17:52  M-先生  阅读(321)  评论(0编辑  收藏  举报