mirror of
https://github.com/cemu-project/idapython.git
synced 2024-11-24 10:09:20 +01:00
1258fab948
- IDA Pro 6.2 support - added set_idc_func_ex(): it is now possible to add new IDC functions using Python - added visit_patched_bytes() (see ex_patch.py) - added support for the multiline text input control in the Form class - added support for the editable/readonly dropdown list control in the Form class - added execute_sync() to register a function call into the UI message queue - added execute_ui_requests() / check ex_uirequests.py - added add_hotkey() / del_hotkey() to bind Python methods to hotkeys - added register_timer()/unregister_timer(). Check ex_timer.py - added the IDC (Arrays) netnode manipulation layer into idc.py - added idautils.Structs() and StructMembers() generator functions - removed the "Run Python Statement" menu item. IDA now has a unified dialog. Use RunPlugin("python", 0) to invoke it manually. - better error messages for script plugins, loaders and processor modules - bugfix: Dbg_Hooks.dbg_run_to() was receiving wrong input - bugfix: A few Enum related functions were not properly working in idc.py - bugfix: GetIdaDirectory() and GetProcessName() were broken in idc.py - bugfix: idaapi.get_item_head() / idc.ItemHead() were not working
76 lines
2.3 KiB
Python
76 lines
2.3 KiB
Python
# -----------------------------------------------------------------------
|
|
# This is an example illustrating how to use the execute_ui_requests()
|
|
# and the idautils.ProcessUiActions()
|
|
# (c) Hex-Rays
|
|
#
|
|
import idaapi
|
|
import idautils
|
|
import idc
|
|
|
|
# --------------------------------------------------------------------------
|
|
class __process_ui_actions_helper(object):
|
|
def __init__(self, actions, flags = 0):
|
|
"""Expect a list or a string with a list of actions"""
|
|
if isinstance(actions, str):
|
|
lst = actions.split(";")
|
|
elif isinstance(actions, (list, tuple)):
|
|
lst = actions
|
|
else:
|
|
raise ValueError, "Must pass a string, list or a tuple"
|
|
|
|
# Remember the action list and the flags
|
|
self.__action_list = lst
|
|
self.__flags = flags
|
|
|
|
# Reset action index
|
|
self.__idx = 0
|
|
|
|
def __len__(self):
|
|
return len(self.__action_list)
|
|
|
|
def __call__(self):
|
|
if self.__idx >= len(self.__action_list):
|
|
return False
|
|
|
|
# Execute one action
|
|
idaapi.process_ui_action(
|
|
self.__action_list[self.__idx],
|
|
self.__flags)
|
|
|
|
# Move to next action
|
|
self.__idx += 1
|
|
print "index=%d" % self.__idx
|
|
|
|
# Reschedule
|
|
return True
|
|
|
|
# --------------------------------------------------------------------------
|
|
def ProcessUiActions(actions, flags=0):
|
|
"""
|
|
@param actions: A string containing a list of actions separated by semicolon, a list or a tuple
|
|
@param flags: flags to be passed to process_ui_action()
|
|
@return: Boolean. Returns False if the action list was empty or execute_ui_requests() failed.
|
|
"""
|
|
|
|
# Instantiate a helper
|
|
helper = __process_ui_actions_helper(actions, flags)
|
|
return False if len(helper) < 1 else idaapi.execute_ui_requests((helper,))
|
|
|
|
|
|
# --------------------------------------------------------------------------
|
|
class print_req_t(object):
|
|
def __init__(self, s):
|
|
self.s = s
|
|
def __call__(self):
|
|
idaapi.msg("%s" % self.s)
|
|
return False # Don't reschedule
|
|
|
|
|
|
|
|
if idc.AskYN(1,("HIDECANCEL\nDo you want to run execute_ui_requests() example?\n"
|
|
"Press NO to execute ProcessUiActions() example\n")):
|
|
idaapi.execute_ui_requests(
|
|
(print_req_t("Hello"), print_req_t(" world\n")) )
|
|
else:
|
|
ProcessUiActions("JumpQ;JumpName")
|