mirror of
https://github.com/cemu-project/idapython.git
synced 2024-12-01 05:24:18 +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
49 lines
1.3 KiB
Python
49 lines
1.3 KiB
Python
import idaapi
|
|
import idautils
|
|
|
|
"""
|
|
This is a sample plugin for extending the assemble().
|
|
|
|
We add support for assembling the following pseudo instructions:
|
|
- "zero eax" -> xor eax, eax
|
|
- "nothing" -> nop
|
|
|
|
|
|
(c) Hex-Rays
|
|
"""
|
|
|
|
#--------------------------------------------------------------------------
|
|
class assemble_idp_hook_t(idaapi.IDP_Hooks):
|
|
def __init__(self):
|
|
idaapi.IDP_Hooks.__init__(self)
|
|
|
|
def assemble(self, ea, cs, ip, use32, line):
|
|
line = line.strip()
|
|
if line == "xor eax, eax":
|
|
return "\x33\xC0"
|
|
elif line == "nop":
|
|
# Decode current instruction to figure out its size
|
|
cmd = idautils.DecodeInstruction(ea)
|
|
if cmd:
|
|
# NOP all the instruction bytes
|
|
return "\x90" * cmd.size
|
|
return None
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
# Remove an existing hook on second run
|
|
try:
|
|
idp_hook_stat = "un"
|
|
print("IDP hook: checking for hook...")
|
|
idphook
|
|
print("IDP hook: unhooking....")
|
|
idphook.unhook()
|
|
del idphook
|
|
except:
|
|
print("IDP hook: not installed, installing now....")
|
|
idp_hook_stat = ""
|
|
idphook = assemble_idp_hook_t()
|
|
idphook.hook()
|
|
|
|
print("IDP hook %sinstalled. Run the script again to %sinstall" % (idp_hook_stat, idp_hook_stat))
|