def init(self):
global initialized
if initialized == False:
initialized = True
# menu = idaapi.add_menu_item("Edit/x64dbgida/", "About", "", 0,
# self.about, None)
# if menu is not None:
idaapi.attach_action_to_menu("Edit/x64dbgida/", 'my:exportdb', idaapi.SETMENU_APP)
idaapi.attach_action_to_menu("Edit/x64dbgida/", 'my:importdb', idaapi.SETMENU_APP)
# idaapi.add_menu_item("Edit/x64dbgida/",
# "Import (uncompressed) database", "", 0,
# self.importdb, None)
# elif idaapi.IDA_SDK_VERSION < 680:
# idaapi.add_menu_item("File/Produce file/",
# "Export x64dbg database", "", 0,
# self.exportdb, None)
# idaapi.add_menu_item("File/Load file/",
# "Import x64dbg database", "", 0,
# self.importdb, None)
return idaapi.PLUGIN_OK
python类IDA_SDK_VERSION的实例源码
def OnSelectLine(self, n):
item = self.items[n]
jump_ea = int(item[0], 16)
# Only jump for valid addresses
if idaapi.IDA_SDK_VERSION < 700:
valid_addr = idc.isEnabled(jump_ea)
else:
valid_addr = idc.is_mapped(jump_ea)
if valid_addr:
idc.Jump(jump_ea)
def __getattribute__(self, name):
default = '[1st] default'
if (idaapi.IDA_SDK_VERSION >= 700) and (name in IDAWrapper.mapping):
name = IDAWrapper.mapping[name]
val = getattr(idaapi, name, default)
if val == default:
val = getattr(idc, name, default)
if val == default:
val = getattr(idautils, name, default)
if val == default:
msg = 'Unable to find {}'.format(name)
idaapi.execute_ui_requests((FIRSTUI.Requests.Print(msg),))
return
if hasattr(val, '__call__'):
def call(*args, **kwargs):
holder = [None] # need a holder, because 'global' sucks
def trampoline():
holder[0] = val(*args, **kwargs)
return 1
idaapi.execute_sync(trampoline, idaapi.MFF_FAST)
return holder[0]
return call
else:
return val
def import_qtcore():
"""
This nasty piece of code is here to force the loading of IDA's
Qt bindings.
Without it, Python attempts to load PySide from the site-packages
directory, and failing, as it does not play nicely with IDA.
via: github.com/tmr232/Cute
"""
has_ida = False
try:
# if we're running under IDA,
# then we'll use IDA's Qt bindings
import idaapi
has_ida = True
except ImportError:
# not running under IDA,
# so use default Qt installation
has_ida = False
if has_ida:
old_path = sys.path[:]
try:
ida_python_path = os.path.dirname(idaapi.__file__)
sys.path.insert(0, ida_python_path)
if idaapi.IDA_SDK_VERSION >= 690:
from PyQt5 import QtCore
return QtCore
else:
from PySide import QtCore
return QtCore
finally:
sys.path = old_path
else:
try:
from PyQt5 import QtCore
return QtCore
except ImportError:
pass
try:
from PySide import QtCore
return QtCore
except ImportError:
pass
raise ImportError("No module named PySide or PyQt")