Associating IDC Scripts with Hotkeys

Occasionally you may develop a script so amazing in its utility that you must have access to it with a keystroke or two. When this happens, you will want to assign a hotkey sequence that you can use to quickly activate your script. Fortunately IDA provides a simple means to do this. Every time IDA is launched, the script contained in <IDADIR>/idc/ida.idc is executed. The default version of this script contains an empty main function and thus does nothing. To associate a hotkey with one of your scripts, you need to add two lines to ida.idc. The first line you must add is an include directive to include your script file in ida.idc. The second line you must add is a call, within main, to the AddHotkey function to associate a specific hotkey with your amazing IDC function. This might leave ida.idc looking like this:

#include <idc.idc>
#include <my_amazing_script.idc>
static main() {
   AddHotkey("z", "MyAmazingFunc");  //Now 'z' invokes MyAmazingFunc
}

If the hotkey you are attempting to associate with your script has already been assigned to another IDA action (menu hotkey or plug-in activation sequence), AddHotkey silently fails with no way to detect the failure other than the fact that your function fails to execute when your hotkey sequence is activated.

Two important points here are that the standard include directory for IDC scripts is <IDADIR>/idc and that you must not name your script function main. If you want IDA to find your script easily, you can copy it into <IDADIR>/idc. If you intend to leave your script file in another location, then you will need to specify the full path to your script in the include statement. While testing your script, it will be useful to run your script as a standalone program with a main function. Once you are ready to associate your script with a hotkey, however, you cannot use the name main, because it will conflict with the main function in ida.idc. You must rename your main function and use the new name in the call to AddHotkey.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.158.36