Board logo

标题: [讨论]基于Hexrays sdk的插件开发 编译总是出错(附代码) [打印本页]

作者: wlfjck    时间: 2008-7-20 23:26     标题: [讨论]基于Hexrays sdk的插件开发 编译总是出错(附代码)

[讨论]基于Hexrays sdk的插件开发 编译总是出错(附代码)
信息来源:邪恶八进制信息安全团队(www.eviloctal.com
议题作者:BeQuick

我用的是visual studio 2005,安装了IDAPro5.2 + SDK for 5.2 + Hexrays.
Hexrays的安装目录为:C:\program files\IDA\plugins, 并将 hexrays.hpp 拷贝到 C:\program files\IDA\sdk\include, 以上操作都是按照Hexrays网站上的要求和Hexrays的readme的提示作的,其他的未做更改。

出错的情况: 在visual studio 2005下编译IDA SDK的插件可以成功,并能成功运行,但编译Hexrays的插件时(取自Hexrays自带的例子)总是出现几十个错误。错误都是关于visual studio 2005的头文件和hexrays.hpp 的。

下面是Hexrays的插件的代码(取自Hexrays自带的例子)以及编译时的出错信息:

#include <ida.hpp>
#include <idp.hpp>
#include <loader.hpp>
#include <bytes.hpp>
#include <fpro.h>
#include <funcs.hpp>
#include <help.h>
#include <kernwin.hpp>
#include <lines.hpp>
#include <llong.hpp>
#include <nalt.hpp>
#include <name.hpp>
#include <netnode.hpp>
#include <pro.h>
#include <segment.hpp>
#include <typeinf.hpp>
#include <ua.hpp>
#include <xref.hpp>
#include <area.hpp>
#include <hexrays.hpp>

// Hex-Rays API pointer
hexdsp_t *hexdsp = NULL;

static bool inited = false;
//--------------------------------------------------------------------------
int idaapi init(void)
{
  if ( !init_hexrays_plugin() )
    return PLUGIN_SKIP; // no decompiler
  const char *hxver = get_hexrays_version();
  msg("Hex-rays version %s has been detected, %s ready to use\n", hxver, PLUGIN.wanted_name);
  inited = true;
  return PLUGIN_KEEP;
}

//--------------------------------------------------------------------------
void idaapi term(void)
{
  if ( inited )
    term_hexrays_plugin();
}

//--------------------------------------------------------------------------
void idaapi run(int)
{
  func_t *pfn = get_func(get_screen_ea());
  if ( pfn == NULL )
  {
    warning("Please position the cursor within a function");
    return;
  }
  cfunc_t *cfunc = NULL;
  try
  {
    decompile(pfn, &cfunc);
  }
  catch ( vd_failure_t &vf )
  {
    warning("#error \"%a: %s (funcsize=%d)", vf.errea, vf.desc().c_str(), vf.funcsize);
    return;
  }
  msg("%a: successfully decompiled\n", pfn->startEA);
  qstring bodytext;
  qstring_printer_t sp(cfunc, bodytext, false);
  cfunc->print_func(sp);
  msg("%s\n", bodytext.c_str());
  delete cfunc;
}

//--------------------------------------------------------------------------
static char comment[] = "Sample1 plugin for Hex-Rays decompiler";

//--------------------------------------------------------------------------
//
//      PLUGIN DESCRIPTION BLOCK
//
//--------------------------------------------------------------------------
plugin_t PLUGIN =
{
  IDP_INTERFACE_VERSION,
  0,                    // plugin flags
  init,                // initialize
  term,                // terminate. this pointer may be NULL.
  run,                  // invoke plugin
  comment,              // long comment about the plugin
                        // it could appear in the status line
                        // or as a hint
  "",                  // multiline help about the plugin
  "Decompile & Print",  // the preferred short name of the plugin
  ""                    // the preferred hotkey to run the plugin
};


IDA52_Plugin - 49 error(s), 47 warning(s)
都是头文件的出错信息 具体在下一个帖子中
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========


请问各位知道是什么原因吗? 是我的环境配置有问题吗(Hexrays的readme上说编译Hexrays的插件和编译普通的IDA的插件是一样的,只是要把hexrays.hpp拷贝到 IDA\sdk\include里)?
现在关于编写Hexrays插件的资料很少,有没有高手能将自己的经验分享一下? 不胜感激!

编译时的出错信息:

------ Rebuild All started: Project: IDA52_Plugin, Configuration: Debug Win32 ------
Deleting intermediate and output files for project 'IDA52_Plugin', configuration 'Debug|Win32'
Compiling...
cl : Command line warning D9007 : '/Gm' requires '/Zi or /ZI'; option ignored
Hexrays_My_1.cpp
D:\Program Files\IDA5.2\sdk\include\ua.hpp : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
D:\Program Files\IDA5.2\sdk\include\ua.hpp : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
e:\program\microsoft visual studio 8\vc\platformsdk\include\oaidl.h(756) : error C2143: syntax error : missing '}' before 'constant'
e:\program\microsoft visual studio 8\vc\platformsdk\include\oaidl.h(756) : error C2143: syntax error : missing ';' before 'constant'
e:\program\microsoft visual studio 8\vc\platformsdk\include\oaidl.h(756) : error C2059: syntax error : 'constant'
e:\program\microsoft visual studio 8\vc\platformsdk\include\oaidl.h(758) : error C2143: syntax error : missing ';' before '}'
e:\program\microsoft visual studio 8\vc\platformsdk\include\oaidl.h(758) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
e:\program\microsoft visual studio 8\vc\platformsdk\include\oaidl.h(773) : error C2146: syntax error : missing ';' before identifier 'funckind'
e:\program\microsoft visual studio 8\vc\platformsdk\include\oaidl.h(773) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
e:\program\microsoft visual studio 8\vc\platformsdk\include\oaidl.h(773) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
e:\program\microsoft visual studio 8\vc\platformsdk\include\oaidl.h(7008) : error C2059: syntax error : '}'
e:\program\microsoft visual studio 8\vc\platformsdk\include\oaidl.h(7008) : error C2143: syntax error : missing ';' before '}'
e:\program\microsoft visual studio 8\vc\platformsdk\include\oaidl.h(7008) : error C2059: syntax error : '}'
e:\program\microsoft visual studio 8\vc\platformsdk\include\msxml.h(277) : error C2143: syntax error : missing ';' before '{'
e:\program\microsoft visual studio 8\vc\platformsdk\include\msxml.h(277) : error C2447: '{' : missing function header (old-style formal list?)
E:\Program\Microsoft Visual Studio 8\VC\PlatformSDK\include\propidl.h(1433) : error C2732: linkage specification contradicts earlier specification for 'BSTR_UserSize'
        E:\Program\Microsoft Visual Studio 8\VC\PlatformSDK\include\propidl.h(1433) : see declaration of 'BSTR_UserSize'
E:\Program\Microsoft Visual Studio 8\VC\PlatformSDK\include\propidl.h(1434) : error C2732: linkage specification contradicts earlier specification for 'BSTR_UserMarshal'
        E:\Program\Microsoft Visual Studio 8\VC\PlatformSDK\include\propidl.h(1434) : see declaration of 'BSTR_UserMarshal'
E:\Program\Microsoft Visual Studio 8\VC\PlatformSDK\include\propidl.h(1435) : error C2732: linkage specification contradicts earlier specification for 'BSTR_UserUnmarshal'
        E:\Program\Microsoft Visual Studio 8\VC\PlatformSDK\include\propidl.h(1435) : see declaration of 'BSTR_UserUnmarshal'
E:\Program\Microsoft Visual Studio 8\VC\PlatformSDK\include\propidl.h(1436) : error C2732: linkage specification contradicts earlier specification for 'BSTR_UserFree'
        E:\Program\Microsoft Visual Studio 8\VC\PlatformSDK\include\propidl.h(1436) : see declaration of 'BSTR_UserFree'
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(78) : error C2011: 'reg_info_t' : 'struct' type redefinition
        D:\Program Files\IDA5.2\sdk\include\idp.hpp(1469) : see declaration of 'reg_info_t'
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(84) : error C2011: 'funcarg_info_t' : 'struct' type redefinition
        D:\Program Files\IDA5.2\sdk\include\typeinf.hpp(1711) : see declaration of 'funcarg_info_t'
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(90) : error C2011: 'func_type_info_t' : 'struct' type redefinition
        D:\Program Files\IDA5.2\sdk\include\typeinf.hpp(1718) : see declaration of 'func_type_info_t'
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(126) : error C2953: 'qstack' : class template has already been defined
        D:\Program Files\IDA5.2\sdk\include\pro.h(1133) : see declaration of 'qstack'
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(176) : error C2084: function 'bool is_type_signed(til_t *,const type_t *)' already has a body
        D:\Program Files\IDA5.2\sdk\include\typeinf.hpp(1819) : see previous definition of 'is_type_signed'
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(177) : error C2084: function 'bool is_type_unsigned(til_t *,const type_t *)' already has a body
        D:\Program Files\IDA5.2\sdk\include\typeinf.hpp(1820) : see previous definition of 'is_type_unsigned'
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(366) : error C3861: 'vd_skip_type': identifier not found
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(393) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(396) : error C2027: use of undefined type 'func_type_info_t'
        D:\Program Files\IDA5.2\sdk\include\typeinf.hpp(1718) : see declaration of 'func_type_info_t'
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(396) : error C2227: left of '->resize' must point to class/struct/union/generic type
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(400) : error C2027: use of undefined type 'funcarg_info_t'
        D:\Program Files\IDA5.2\sdk\include\typeinf.hpp(1711) : see declaration of 'funcarg_info_t'
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(400) : error C2228: left of '.argloc' must have class/struct/union
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(401) : error C2027: use of undefined type 'funcarg_info_t'
        D:\Program Files\IDA5.2\sdk\include\typeinf.hpp(1711) : see declaration of 'funcarg_info_t'
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(401) : error C2228: left of '.name' must have class/struct/union
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(402) : error C2027: use of undefined type 'funcarg_info_t'
        D:\Program Files\IDA5.2\sdk\include\typeinf.hpp(1711) : see declaration of 'funcarg_info_t'
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(402) : error C2228: left of '.type' must have class/struct/union
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(404) : error C2027: use of undefined type 'func_type_info_t'
        D:\Program Files\IDA5.2\sdk\include\typeinf.hpp(1718) : see declaration of 'func_type_info_t'
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(404) : error C2227: left of '->stkargs' must point to class/struct/union/generic type
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(405) : error C2027: use of undefined type 'func_type_info_t'
        D:\Program Files\IDA5.2\sdk\include\typeinf.hpp(1718) : see declaration of 'func_type_info_t'
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(405) : error C2227: left of '->flags' must point to class/struct/union/generic type
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(406) : error C2027: use of undefined type 'func_type_info_t'
        D:\Program Files\IDA5.2\sdk\include\typeinf.hpp(1718) : see declaration of 'func_type_info_t'
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(406) : error C2227: left of '->basetype' must point to class/struct/union/generic type
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(408) : error C2027: use of undefined type 'func_type_info_t'
        D:\Program Files\IDA5.2\sdk\include\typeinf.hpp(1718) : see declaration of 'func_type_info_t'
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(408) : error C2227: left of '->rettype' must point to class/struct/union/generic type
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(408) : error C2027: use of undefined type 'func_type_info_t'
        D:\Program Files\IDA5.2\sdk\include\typeinf.hpp(1718) : see declaration of 'func_type_info_t'
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(408) : error C2227: left of '->retfields' must point to class/struct/union/generic type
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(408) : error C2027: use of undefined type 'func_type_info_t'
        D:\Program Files\IDA5.2\sdk\include\typeinf.hpp(1718) : see declaration of 'func_type_info_t'
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(408) : error C2227: left of '->retloc' must point to class/struct/union/generic type
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(409) : error C2027: use of undefined type 'func_type_info_t'
        D:\Program Files\IDA5.2\sdk\include\typeinf.hpp(1718) : see declaration of 'func_type_info_t'
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(409) : error C2227: left of '->cc' must point to class/struct/union/generic type
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(782) : error C2011: 'type_visitor_t' : 'struct' type redefinition
        D:\Program Files\IDA5.2\sdk\include\typeinf.hpp(1511) : see declaration of 'type_visitor_t'
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(1767) : error C2264: 'is_type_unsigned' : error in function definition or declaration; function not called
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(1768) : error C2264: 'is_type_signed' : error in function definition or declaration; function not called
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(2513) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(2519) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(2525) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(2537) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(2619) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(2625) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(2667) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(2673) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(2685) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(2773) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(2779) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(2785) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(2833) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(2839) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(2851) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(2893) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(2899) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(2905) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(2911) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(2917) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(2965) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(3015) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(3063) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(3117) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(3123) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(3129) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(3135) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(3141) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(3147) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(3153) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(3159) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(3165) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(3171) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(3183) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(3189) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(3195) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(3201) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(3213) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)

D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(3219) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(3225) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(3231) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(3237) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\Program Files\IDA5.2\sdk\include\hexrays.hpp(3243) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
Build log was saved at "file://e:\program\Microsoft Visual Studio 8\VC\my_project\IDA52_Plugin\IDA52_Plugin\Debug\BuildLog.htm"
帖子15 精华0 积分10 阅读权限40 性别男 来自湖北 武汉 在线时间5 小时




欢迎光临 【3.A.S.T】网络安全爱好者 (http://3ast.com/) Powered by Discuz! 7.2