static main()
{
AddHotkey("z", "hello_idc");
}
因为idapython更为强大,所以想改成idapython的
from idaapi import *
from idc import *
def hello_idapython():
print "hello idapython"
def main():
AddHotkey("z", "hello_idapython")
if __name__ == "__main__":
main()
不过使用的时候会报错,
Runtime error:Attempt to call undefined function 'hello_idapython'
是我AddHotkey参数写错了,还是idapython模式下就不可行,请大神指教,先谢了。
// Add hotkey for IDC function
// hotkey - hotkey name ('a', "Alt-A", etc)
// idcfunc - IDC function name
// returns:
#define IDCHK_OK 0 // ok
#define IDCHK_ARG -1 // bad argument(s)
#define IDCHK_KEY -2 // bad hotkey name
#define IDCHK_MAX -3 // too many IDC hotkeys
def registerHotkey(self, shortcut, py_function_pointer):
"""
Can be used by IDAscope widgets to register hotkeys.
Uses a global list HOTKEYS of function pointers that link to the desired functionality.
Right now, linked functions cannot take parameters and should scrape all information they need by themselves.
@param shortcut: A string describing a shortcut, e.g. "ctrl+F3"
@type shortcut: str
@param py_function_pointer: a python function that shall be called when the shortcut is triggered.
@type py_function_pointer: a pointer to a python function
"""
global HOTKEYS
hotkey_index = len(HOTKEYS)
hotkey_name = "idascope_HOTKEY_%d" % hotkey_index
HOTKEYS.append(py_function_pointer)
self.ida_proxy.CompileLine('static %s() { RunPythonStatement("HOTKEYS[%d]()"); }' % (hotkey_name, hotkey_index))
self.ida_proxy.AddHotkey(shortcut, hotkey_name)