Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring of menu handler for IDA 7.0 #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 93 additions & 13 deletions plugins/fluorescence/fluorescence.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,58 @@
import idaapi
import idautils

VERSION = "0.1"

try:
class Kp_Menu_Context(idaapi.action_handler_t):
def __init__(self):
idaapi.action_handler_t.__init__(self)

@classmethod
def get_name(self):
return self.__name__

@classmethod
def get_label(self):
return self.label

@classmethod
def register(self, plugin, label):
self.plugin = plugin
self.label = label
instance = self()
return idaapi.register_action(idaapi.action_desc_t(
self.get_name(), # Name. Acts as an ID. Must be unique.
instance.get_label(), # Label. That's what users see.
instance # Handler. Called when activated, and for updating
))

@classmethod
def unregister(self):
"""Unregister the action.
After unregistering the class cannot be used.
"""
idaapi.unregister_action(self.get_name())

@classmethod
def activate(self, ctx):
# dummy method
return 1

# This action is always available.
@classmethod
def update(self, ctx):
return idaapi.AST_ENABLE_ALWAYS

class Fluorescence(Kp_Menu_Context):
def activate(self, ctx):
self.plugin.run()
return 1

except:
pass


class CallHighlighter(object):

COLOR = 0xFF99FF #BBGGRR
Expand All @@ -16,26 +68,54 @@ def highlight(self, color=COLOR):
elif current_color == idc.DEFCOLOR:
idaapi.set_item_color(ea, self.COLOR)

class fluorescence_blower_t(idaapi.plugin_t):

flags = 0
#--------------------------------------------------------------------------
# Plugin
#--------------------------------------------------------------------------

p_initialized = False

class Fluorescence_Plugin_t(idaapi.plugin_t):
comment = "Highlights function calls"
help = ''
wanted_name = 'fluorescence'
wanted_hotkey = ''
help = ""
wanted_name = "Fluorescence"
wanted_hotkey = ""
flags = idaapi.PLUGIN_KEEP

def init(self):
global p_initialized

# register popup menu handlers
try:
Fluorescence.register(self, "Un/highlight call instructions")
except:
pass

self.highlighted = False
self.context_menu = idaapi.add_menu_item("Options/", "Un/highlight call instructions", "", 0, self.run, (None,))
return idaapi.PLUGIN_KEEP

if p_initialized is False:
p_initialized = True
idaapi.register_action(idaapi.action_desc_t(
"Fluorescence",
"Highlights function calls",
self.run,
None,
None,
0))
idaapi.attach_action_to_menu("Options/General...", "Fluorescence", idaapi.SETMENU_APP)
print("=" * 80)
print("Fluorescence v{0} by devttys0, 2017".format(VERSION))
print("=" * 80)

def term(self):
idaapi.del_menu_item(self.context_menu)
return None
return idaapi.PLUGIN_KEEP

def run(self, arg):
def run(self):
CallHighlighter().highlight()
return 1

def PLUGIN_ENTRY():
return fluorescence_blower_t()
def term(self):
pass

# register IDA plugin
def PLUGIN_ENTRY():
return Fluorescence_Plugin_t()