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类SETMENU_APP的实例源码
def hxe_callback(self, event, *args):
if event == idaapi.hxe_populating_popup:
form, popup, vu = args
if get_cursor_func_ref() == idaapi.BADADDR:
return 0
idaapi.attach_action_to_popup(
form,
popup,
funcref_t.ACTION_COPY,
"Rename global item",
idaapi.SETMENU_APP
)
return 0
def _install_load_file(self):
"""
Install the 'File->Load->Code coverage file...' menu entry.
"""
# create a custom IDA icon
icon_path = plugin_resource(os.path.join("icons", "load.png"))
icon_data = str(open(icon_path, "rb").read())
self._icon_id_file = idaapi.load_custom_icon(data=icon_data)
# describe a custom IDA UI action
action_desc = idaapi.action_desc_t(
self.ACTION_LOAD_FILE, # The action name.
"~C~ode coverage file...", # The action text.
IDACtxEntry(self.interactive_load_file), # The action handler.
None, # Optional: action shortcut
"Load individual code coverage file(s)", # Optional: tooltip
self._icon_id_file # Optional: the action icon
)
# register the action with IDA
result = idaapi.register_action(action_desc)
if not result:
RuntimeError("Failed to register load_file action with IDA")
# attach the action to the File-> dropdown menu
result = idaapi.attach_action_to_menu(
"File/Load file/", # Relative path of where to add the action
self.ACTION_LOAD_FILE, # The action ID (see above)
idaapi.SETMENU_APP # We want to append the action after ^
)
if not result:
RuntimeError("Failed action attach load_file")
logger.info("Installed the 'Code coverage file' menu entry")
def _install_load_batch(self):
"""
Install the 'File->Load->Code coverage batch...' menu entry.
"""
# create a custom IDA icon
icon_path = plugin_resource(os.path.join("icons", "batch.png"))
icon_data = str(open(icon_path, "rb").read())
self._icon_id_batch = idaapi.load_custom_icon(data=icon_data)
# describe a custom IDA UI action
action_desc = idaapi.action_desc_t(
self.ACTION_LOAD_BATCH, # The action name.
"~C~ode coverage batch...", # The action text.
IDACtxEntry(self.interactive_load_batch), # The action handler.
None, # Optional: action shortcut
"Load and aggregate code coverage files", # Optional: tooltip
self._icon_id_batch # Optional: the action icon
)
# register the action with IDA
result = idaapi.register_action(action_desc)
if not result:
RuntimeError("Failed to register load_batch action with IDA")
# attach the action to the File-> dropdown menu
result = idaapi.attach_action_to_menu(
"File/Load file/", # Relative path of where to add the action
self.ACTION_LOAD_BATCH, # The action ID (see above)
idaapi.SETMENU_APP # We want to append the action after ^
)
if not result:
RuntimeError("Failed action attach load_batch")
logger.info("Installed the 'Code coverage batch' menu entry")
def init():
if not idaapi.init_hexrays_plugin():
print "[ERROR] Failed to initialize Hex-Rays SDK"
return idaapi.PLUGIN_SKIP
Helper.temporary_structure = TemporaryStructureModel()
# Actions.register(Actions.CreateVtable)
Actions.register(Actions.ShowGraph)
Actions.register(Actions.ShowClasses)
Actions.register(Actions.GetStructureBySize)
Actions.register(Actions.RemoveArgument)
Actions.register(Actions.AddRemoveReturn)
Actions.register(Actions.ConvertToUsercall)
Actions.register(Actions.ShallowScanVariable, Helper.temporary_structure)
Actions.register(Actions.DeepScanVariable, Helper.temporary_structure)
Actions.register(Actions.DeepScanReturn, Helper.temporary_structure)
Actions.register(Actions.DeepScanFunctions, Helper.temporary_structure)
Actions.register(Actions.RecognizeShape)
Actions.register(Actions.CreateNewField)
Actions.register(Actions.SelectContainingStructure, potential_negatives)
Actions.register(Actions.ResetContainingStructure)
Actions.register(Actions.RecastItemRight)
Actions.register(Actions.RecastItemLeft)
Actions.register(Actions.RenameOther)
Actions.register(Actions.RenameInside)
Actions.register(Actions.RenameOutside)
Actions.register(Actions.SwapThenElse)
idaapi.attach_action_to_menu('View/Open subviews/Local types', Actions.ShowClasses.name, idaapi.SETMENU_APP)
idaapi.install_hexrays_callback(hexrays_events_callback)
Helper.touched_functions.clear()
Const.init()
return idaapi.PLUGIN_KEEP
def init(self):
self.lines = set()
self.settings = IDASettings('HighlightCalls')
try:
self.set_color(self.settings['color'])
except KeyError:
self.settings.user['color'] = HIGHLIGHT_COLOR
self.set_color(HIGHLIGHT_COLOR)
self.ui_hooks = UiHooks(self.lines)
self.toggle_action_desc = idaapi.action_desc_t('HighlightCalls:Toggle',
'Toggle call highlighting',
ToggleHighlightHandler(self.enable_highlights,
self.disable_highlights),
'',
'Toggle call highlighting',
-1)
idaapi.register_action(self.toggle_action_desc)
self.color_selector = idaapi.action_desc_t('HighlightCalls:SelectColor',
'Select highlight color',
SelectColorHandler(set_color=self.set_color),
'',
'Select highlight color',
-1)
idaapi.register_action(self.color_selector)
idaapi.attach_action_to_menu('Edit/', self.toggle_action_desc.name, idaapi.SETMENU_APP)
idaapi.attach_action_to_menu('Edit/', self.color_selector.name, idaapi.SETMENU_APP)
return idaapi.PLUGIN_KEEP
def hxe_callback(self, event, *args):
"""
HexRays event callback.
We lump this under the (UI) Hooks class for organizational reasons.
"""
#
# if the event callback indicates that this is a popup menu event
# (in the hexrays window), we may want to install our prefix menu
# actions depending on what the cursor right clicked.
#
if event == idaapi.hxe_populating_popup:
form, popup, vu = args
#
# if the user cursor isn't hovering over a function ref, there
# is nothing for us to do
#
if get_cursor_func_ref() == idaapi.BADADDR:
return 0
#
# the user cursor is hovering over a valid target for a recursive
# function prefix. insert the prefix action entry into the menu
#
idaapi.attach_action_to_popup(
form,
popup,
prefix_t.ACTION_RECURSIVE,
"Rename global item",
idaapi.SETMENU_APP
)
# done
return 0
#------------------------------------------------------------------------------
# Prefix Wrappers
#------------------------------------------------------------------------------
def register_actions():
AncestorGraphHandler = OpenGraphHandler()
def type_of_current_var(vdui):
var = vdui.item.get_lvar()
if var is None:
return None
return get_type_by_tinfo(var.type())
def graph_callback(event, *args):
if event == idaapi.hxe_curpos:
vdui = args[0]
type = type_of_current_var(vdui)
AncestorGraphHandler.target_type = type
elif event == idaapi.hxe_populating_popup:
form, popup, vdui = args
if AncestorGraphHandler.target_type is None:
return 0
action_desc = idaapi.action_desc_t(
None,
'Open Ancestor Type Graph',
AncestorGraphHandler)
idaapi.attach_dynamic_action_to_popup(form, popup, action_desc, None)
return 0
action_desc = idaapi.action_desc_t(
'devirtualize:open_ancestor_type_graph',
'Open Ancestor Type Graph',
AncestorGraphHandler,
None,
'Open Ancestor Type Graph',
199)
idaapi.register_action(action_desc)
idaapi.attach_action_to_menu(
'View/Graphs/User xrefs char...',
'devirtualize:open_ancestor_type_graph',
idaapi.SETMENU_APP)
idaapi.install_hexrays_callback(graph_callback)
#TODO: Show diamond inheritance as a diamond