// vim: sw=2 et /* (C) 2003-2007 Willem Jan Hengeveld * Web: http://www.xs4all.nl/~itsme/ * http://wiki.xda-developers.com/ * * $Id: $ */ #include #include #include #include #include #include #include #include #include "idcextensions.h" //-------------------------------------------------------------------------- // // Initialize. // // IDA will call this function only once. // If this function returns PLGUIN_SKIP, IDA will never load it again. // If this function returns PLUGIN_OK, IDA will unload the plugin but // remember that the plugin agreed to work with the database. // The plugin will be loaded again if the user invokes it by // pressing the hotkey or selecting it from the menu. // After the second load the plugin will stay on memory. // If this function returns PLUGIN_KEEP, IDA will keep the plugin // in the memory. In this case the initialization function can hook // into the processor module and user interface notification points. // See the hook_to_notification_point() function. // // In this example we check the input file format and make the decision. // You may or may not check any other conditions to decide what you do: // whether you agree to work with the database or not. // int idaapi init(void) { // if ( inf.filetype == f_ELF ) return PLUGIN_SKIP; // Please uncomment the following line to see how the notification works // hook_to_notification_point(HT_UI, sample_callback, NULL); // Please uncomment the following line to see how the user-defined prefix works // set_user_defined_prefix(prefix_width, get_user_defined_prefix); msg("idcext - init - %d\n", qerrno); if (!set_idc_func("Beep", idc_Beep, idcargs_Beep) || !set_idc_func("newlist", idc_newlist, idcargs_newlist) || !set_idc_func("dellist", idc_dellist, idcargs_dellist) || !set_idc_func("getlist", idc_getlist, idcargs_getlist) || !set_idc_func("push", idc_push, idcargs_push) || !set_idc_func("pop", idc_pop, idcargs_pop) || !set_idc_func("map", idc_map, idcargs_map) || !set_idc_func("grep", idc_grep, idcargs_grep) || !set_idc_func("foreach", idc_foreach, idcargs_foreach)) { msg("error registering idc extensions\n"); return PLUGIN_SKIP; } return PLUGIN_KEEP; } //-------------------------------------------------------------------------- // Terminate. // Usually this callback is empty. // The plugin should unhook from the notification lists if // hook_to_notification_point() was used. // // IDA will call this function when the user asks to exit. // This function won't be called in the case of emergency exits. void idaapi term(void) { //unhook_from_notification_point(HT_UI, sample_callback); //set_user_defined_prefix(0, NULL); msg("idcext - term\n"); set_idc_func("Beep", NULL, NULL); set_idc_func("newlist", NULL, NULL); set_idc_func("push", NULL, NULL); set_idc_func("pop", NULL, NULL); set_idc_func("map", NULL, NULL); set_idc_func("grep", NULL, NULL); set_idc_func("foreach", NULL, NULL); } //-------------------------------------------------------------------------- // // The plugin method // // This is the main function of plugin. // // It will be called when the user selects the plugin. // // arg - the input argument, it can be specified in // plugins.cfg file. The default is zero. // // void idaapi run(int arg) { msg("idcext - run\n"); } //-------------------------------------------------------------------------- char comment[] = "extends idc scripting language"; char help[] = "\n"; //-------------------------------------------------------------------------- // This is the preferred name of the plugin module in the menu system // The preferred name may be overriden in plugins.cfg file char wanted_name[] = "idcext"; // This is the preferred hotkey for the plugin module // The preferred hotkey may be overriden in plugins.cfg file // Note: IDA won't tell you if the hotkey is not correct // It will just disable the hotkey. char wanted_hotkey[] = ""; //-------------------------------------------------------------------------- // // 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 help, // multiline help about the plugin wanted_name, // the preferred short name of the plugin wanted_hotkey // the preferred hotkey to run the plugin };