[TIP] How to define a keyboard shortcut for an IDAPython script
Today, i want to share with you a very useful tip that ive been using for a while, and i particulary like. Gera posted a variation of it in the IDA official forum some time ago but i think that would be useful to share it also here.
Usually, in IDA, we find ourselves needing a way to define a shortcut for that useful IDAPython script to bypass the tedious “alt+9 + [select the wanted IDAPython script] + enter” procedure.
When i finished the FindInFunc script (you can read my previous post about it here), i faced that situation for the Nth time and i finally managed to get an easy hack to get it working.
We know that it is possible to set a shortcut to an IDC script by defining it in the idamain.cfg so after googling for a while i went to the IDAPython source and i’ve found this:
/* Simple Python statement runner function for IDC */
static const char idc_runpythonstatement_args[] = { VT_STR, 0 };
static error_t idaapi idc_runpythonstatement(value_t *argv, value_t *res)
{
res->num = PyRun_SimpleString(argv[0].str);
return eOk;
}
http://code.google.com/p/idapython/source/diff?spec=svn32&r=32&format=side&path=/trunk/python.cpp
This functions alows us to execute a python sentence in the context of an IDC script… Dude! It’s pretty much convenient for our purposes because if we do:
RunPythonStatement("execfile 'c:\pathoffile\script.py'")
Voila! We have our script executed.
So, all we need now is to add something like this to the main() function in ida.idc:
AddHotkey("Alt-F8", "py_findinfunc");
And then, add this handler at the end, in the same file.
static py_findinfunc()
{
RunPythonStatement("execfile('c:\\FindInFunc.py')");
}





Пользовался ранее и буду пользоваться дальше.
Да, лучше бы Вы писали по человечески.
[...] the help of some friends i managed to get a way to reuse the tip I've previously shared with you here. The idea behind this post is to take advantage of the posibilities of using IDC in conditional [...]
IDAPython conditional breakpoints | Reversing.AR said this on June 29, 2010 at 5:06 pm |
[...] help of some friends i managed to get a way to reuse the tip I’ve previously shared with you here. The idea behind this post is to take advantage of the posibilities of using IDC in conditional [...]
Really useful and very cool.. Thanks