我正在写一个IDA的插件,也用SDK,基本思想是定义两个类,在run()函数中调用这两个类的公有接口来实现我所需要的功能,现在写好了,插件也在vs2005下编译,连接通过,生成了plw文件,将生成的plw文件导入IDA中后,运行此插件,报错如下:
acdess violation at address 04114106 in module 'connector.plw' ;read of address 000000
我的源文件如下:
plugin.cpp文件
#include<windows.h>
#include<string>
#include<vector>
using std::string;
using std::vector;
////////////////////////////////////////////////////////////////////////////
//_connector_init()
int _connector_init(void)
{
// this connector now only works with metapc (x86) CPU types.
if(strcmp(inf.procName, "metapc") != 0)
{
msg("[!] Detected an incompatible non-metapc CPU type: %s\n", inf.procName);
return PLUGIN_SKIP;
}
return PLUGIN_KEEP;
}
/////////////////////////////////////////////////////////////////////////////
//_connector_run(int arg)
void _connector_run(int arg)
{
proc *procPointer;
int pid;
// ensure we are within the confines of a known function.
//get_screen_ea()返回光标处的地址
if ((pid = get_func_num(get_screen_ea())) == -1)
{
warning("Current screen effective address:\n\n"
" 0x%08x\n\n" //0x%08x是输出内存地址的格式标识
"does not lie within a known function.",
get_screen_ea());
return;
}
// This is the preferred name of the plugin module in the menu system.
// The preferred name may be overridden in the plugins.cfg file.
char _connector_wanted_name[] = "pCONNECTOR";
// This is the preferred hot key for the plugin module.
// The preferred hot key may be overridden in the plugins.cfg file.
// Note: IDA won't tell you if the hot key is not correct.
// It will just disable the hot key.
char _connector_wanted_hotkey[] = "Alt-3";
//
// PLUGIN DESCRIPTION BLOCK
//
extern "C" plugin_t PLUGIN =
{
IDP_INTERFACE_VERSION,
0, // plugin flags.
_connector_init, // initialize callback.
_connector_term, // terminate callback. this pointer may be NULL.
_connector_run, // invoke plugin routine.
_connector_comment, // long comment about the plugin.
// it could appear in the status line
// or as a hint.
_connector_help, // multiline help about the plugin.
_connector_wanted_name, // the preferred short name of the plugin.
_connector_wanted_hotkey // the preferred hot key to run the plugin.
};