首页
社区
课程
招聘
[求助]IDA插件开发中的一个很棘手的问题
发表于: 2008-4-29 23:16 5555

[求助]IDA插件开发中的一个很棘手的问题

2008-4-29 23:16
5555
我正在写一个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;

#include<ida.hpp>
#include<idp.hpp>
#include<ua.hpp>
#include <bytes.hpp>
#include <expr.hpp>
#include <frame.hpp>
#include <kernwin.hpp>
#include <loader.hpp>
#include <name.hpp>

#pragma warning (disable:4273)
#pragma warning (disable:4996)
#pragma warning (disable:4819)

#include "basic_block.h"
#include "proc.h"

////////////////////////////////////////////////////////////////////////////
//_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;
    }

  procPointer=new proc(pid);
  procPointer->CFG_analysis();
  procPointer->CFG_result_print();

  delete procPointer;
}

/////////////////////////////////////////////////////////////////////////////
//_connector_term()
void _connector_term(void)
{
}

// include the data structures that describe the plugin to IDA.
#include "connector_info.h"

connector_info.h文件

#ifndef __CONNECTOR_INFO_H__
#define __CONNECTOR_INFO_H__

//
// These global data items are used by IDA to display information about
// the plugin.
//

char _connector_comment[] = "IDA的连接器";

char _connector_help[] =
    "[ 连接器 ]\n"
    "\n"
    "\n"
    "\n";

// 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.
};

#endif

其中proc是自己定义的类

[EMAIL="xxgc_yinwenjian@126.com"]xxgc_yinwenjian@126.com[/EMAIL]

[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课

收藏
免费 0
支持
分享
最新回复 (1)
雪    币: 79
活跃值: (35)
能力值: ( LV2,RANK:150 )
在线值:
发帖
回帖
粉丝
2
检查_connector_run中的指针使用
2008-5-29 14:42
0
游客
登录 | 注册 方可回帖
返回