hexrays_sample7.cpp
/*
* Hex-Rays Decompiler project
* Copyright (c) 2007-2023 by Hex-Rays, support@hex-rays.com
* ALL RIGHTS RESERVED.
*
* Sample plugin for the Hex-Rays Decompiler.
* It demonstrates how to use cblock_t::iterator
*
*/
#include <hexrays.hpp>
//--------------------------------------------------------------------------
struct plugin_ctx_t : public plugmod_t
{
bool inited = true;
plugin_ctx_t()
{
}
~plugin_ctx_t()
{
if ( inited )
{
}
}
virtual bool idaapi run(size_t) override { return false; }
static ssize_t idaapi hr_callback(
void *ud,
hexrays_event_t event,
va_list va);
};
//--------------------------------------------------------------------------
// This callback handles various hexrays events.
ssize_t idaapi plugin_ctx_t::hr_callback(
void *,
hexrays_event_t event,
va_list va)
{
switch ( event )
{
case hxe_maturity:
{
ctree_maturity_t mat = va_argi(va, ctree_maturity_t);
{
{
{
return 0;
}
{
// iterate over all block instructions
msg("dumping block %a\n", ea);
for ( cblock_t::iterator p=b->begin(); p != b->end(); ++p )
{
cinsn_t &i = *p;
}
}
};
cblock_visitor_t cbv;
}
}
break;
default:
break;
}
return 0;
}
//--------------------------------------------------------------------------
// Initialize the plugin.
static plugmod_t *idaapi init()
{
return nullptr; // no decompiler
msg("Hex-rays version %s has been detected, %s ready to use\n",
hxver, PLUGIN.wanted_name);
return new plugin_ctx_t;
}
//--------------------------------------------------------------------------
static char comment[] = "Sample plugin7 for Hex-Rays decompiler";
//--------------------------------------------------------------------------
//
// PLUGIN DESCRIPTION BLOCK
//
//--------------------------------------------------------------------------
plugin_t PLUGIN =
{
IDP_INTERFACE_VERSION,
PLUGIN_HIDE // Plugin should not appear in the Edit, Plugins menu
| PLUGIN_MULTI, // The plugin can work with multiple idbs in parallel
init, // initialize
nullptr,
nullptr,
comment, // long comment about the plugin
nullptr, // multiline help about the plugin
"Hex-Rays block iterator", // the preferred short name of the plugin
nullptr, // the preferred hotkey to run the plugin
};
HexRays SDK header file.
bool init_hexrays_plugin(int flags=0)
Check that your plugin is compatible with hex-rays decompiler.
Definition: hexrays.hpp:8548
bool install_hexrays_callback(hexrays_cb_t *callback, void *ud)
Install handler for decompiler events.
Definition: hexrays.hpp:12298
int remove_hexrays_callback(hexrays_cb_t *callback, void *ud)
Uninstall handler for decompiler events.
Definition: hexrays.hpp:12304