Exporting IDA function for IDC Script Usage

Sometimes you want to specify additional options or to call internal function of IDA plugin that you wrote. You can use “set_idc_func” API to achive this. Here’s a sample skeleton code that is showing how to make a custom function that idc script can call.
char *OutputFilename;
static const char SendDiassemblyInfoArgs[]={VT_STR,0 };
static error_t idaapi SendDiassemblyInfo(value_t *argv,value_t *res)
{
msg("%s is called with arg0=%s\n",argv[0].str);
OutputFilename=strdup(argv[0].str);
run(2);
res->num=1;
return eOk;
}

int idaapi init(void)
{
if ( inf.filetype == f_ELF ) return PLUGIN_SKIP;

set_idc_func("SendDiassemblyInfo",SendDiassemblyInfo,SendDiassemblyInfoArgs);
return PLUGIN_KEEP;
}

void idaapi term(void)
{
set_idc_func("SendDiassemblyInfo",NULL,NULL);
}
From idc script, you can call the defined function as if it’s a built-in API like following.
static main()
{
RunPlugin("DarunGrim2",1);
SendDiassemblyInfo("disassembly.info");
Exit(0);
}
Simple!
Advertisements

3 Responses to Exporting IDA function for IDC Script Usage

  1. comzii says:

    Thanks for some other informative blog. The place else may I get that kind of info written in such an ideal manner?
    I have a project that I am just now running on, and I
    have been on the look out for such information.

    Like

  2. Dorie says:

    GE appliances aren't called Generally Expensive for satire. They have the life span of a twinkie.As for Immelt crony catlpaiist, who's proof that in businesses dependent on government largesse and politics to succeed it isn't what you know but who you bl*w.

    Like

  3. I would like to get a suit with both the wear from legs option and the back zipper. How much extra should I add when ordering a suit with both a wear from legs zipper and the standard back zipper?

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: