コード例 #1
0
    def term(self):
        self.hooks.unhook()
        self.add_to_search_handler.unregister()
        self.clear_search_handler.unregister()

        for hotkey in self.hotkeys:
            idaapi.del_hotkey(hotkey)
コード例 #2
0
ファイル: ui.py プロジェクト: arizvisa/idascripts
    def map(cls, key, callable):
        '''Map a specific `key` to a python `callable`.'''

        # check to see if the key is stored within our cache and remove it if so
        if key in cls.hotkey:
            idaapi.del_hotkey(cls.hotkey[key])

        # now we can add the hotkey and stash it in our cache
        # XXX: I'm not sure if the key needs to be utf8 encoded or not
        cls.hotkey[key] = res = idaapi.add_hotkey(key, callable)
        return res
コード例 #3
0
ファイル: SyncPlugin.py プロジェクト: IDA-RE-things/qb-sync
    def uninit_hotkeys(self):
        if not self.hotkeys_ctx:
            return

        for ctx in self.hotkeys_ctx:
            if idaapi.del_hotkey(ctx):
                del ctx
コード例 #4
0
    def uninit_hotkeys(self):
        if not self.hotkeys_ctx:
            return

        for ctx in self.hotkeys_ctx:
            if idaapi.del_hotkey(ctx):
                del ctx

        self.hotkeys_ctx = []
コード例 #5
0
    def uninit_hotkeys(self):
        if not self.hotkeys_ctx:
            return

        # delete registered context and restore original action
        for ctx, key, conflict in self.hotkeys_ctx:
            if idaapi.del_hotkey(ctx):
                del ctx
            else:
                print("[sync] failed to delete hotkey %s" % key)

            if conflict:
                ida_kernwin.update_action_shortcut(conflict, key)

        self.hotkeys_ctx = []
コード例 #6
0
def main():
  global hotkey_ctx
  try:
    hotkey_ctx
    if idaapi.del_hotkey(hotkey_ctx):
      print("Hotkey unregistered!")
      del hotkey_ctx
    else:
      print("Failed to delete hotkey!")
  except:
      pass
  hotkey_ctx = idaapi.add_hotkey("F5", show_decompiler)
  if hotkey_ctx is None:
    print("Failed to register hotkey!")
    del hotkey_ctx
  else:
    print("Press F5 to decompile a function.")
コード例 #7
0
ファイル: main.py プロジェクト: Maroc-OS/decompiler
def main():
  global hotkey_ctx
  try:
    hotkey_ctx
    if idaapi.del_hotkey(hotkey_ctx):
      print "Hotkey unregistered!"
      del hotkey_ctx
    else:
      print "Failed to delete hotkey!"
  except:
      pass
  hotkey_ctx = idaapi.add_hotkey("F5", show_decompiler)
  if hotkey_ctx is None:
    print "Failed to register hotkey!"
    del hotkey_ctx
  else:
    print "Press F5 to decompile a function."
コード例 #8
0
    def uninit_hotkeys(self):
        # disable ida_kernwin.UI_Hooks
        if self.cmd_hooks.minver74sp1():
            self.cmd_hooks.unhook()

        if not self.hotkeys_ctx:
            return

        # delete registered context and restore original action
        for ctx, key, conflict in self.hotkeys_ctx:
            if idaapi.del_hotkey(ctx):
                del ctx
            else:
                rs_log("failed to delete hotkey %s" % key)

            if conflict and not self.cmd_hooks.minver74sp1():
                ida_kernwin.update_action_shortcut(conflict, key)

        self.hotkeys_ctx = []
コード例 #9
0
ファイル: quick_copy.py プロジェクト: IoanFilip2/Sark
 def term(self):
     for hotkey in self.hotkeys:
         idaapi.del_hotkey(hotkey)
コード例 #10
0
ファイル: ui.py プロジェクト: heruix/ida-minsc
 def unmap(cls, key):
     '''Unmap the specified `key` from its callable.'''
     idaapi.del_hotkey(cls.hotkey[key])
     del(cls.hotkey[key])
コード例 #11
0
ファイル: ui.py プロジェクト: mmg1/ida-minsc
    def unmap(cls, key):
        '''Unmap the specified `key` from IDA and return the callable that it was assigned to.'''
        frepr = lambda hotkey: internal.utils.string.repr(
            cls.__of_key__(hotkey))

        # First check to see whether we were given a callable or a hotkey. If
        # we were given a callable, then we need to look through our cache for
        # the actual key that it was. Once found, then we normalize it like usual.
        if callable(key):
            try:
                hotkey = cls.__normalize_key__(
                    next(item
                         for item, (_, fcallback) in cls.__cache__.items()
                         if fcallback == key))

            except StopIteration:
                raise internal.exceptions.InvalidParameterError(
                    u"{:s}.unmap({:s}) : Unable to locate the callable {!r} in the current list of keyboard mappings."
                    .format(
                        '.'.join((__name__, cls.__name__)),
                        "{!r}".format(key) if callable(key) else "{!s}".format(
                            internal.utils.string.repr(key)), key))

            else:
                logging.warn(
                    u"{:s}.unmap({:s}) : Discovered the hotkey {!s} being currently mapped to the callable {!r}."
                    .format(
                        '.'.join((__name__, cls.__name__)),
                        "{!r}".format(key) if callable(key) else "{!s}".format(
                            internal.utils.string.repr(key)), frepr(hotkey),
                        key))

        # We need to normalize the hotkey we were given, and convert it back
        # into IDA's format. This way we can locate it in our cache, and prevent
        # sloppy user input from interfering.
        else:
            hotkey = cls.__normalize_key__(key)

        # Check to see if the hotkey is cached and warn the user if it isn't.
        if hotkey not in cls.__cache__:
            logging.warn(
                u"{:s}.unmap({:s}) : Refusing to unmap the hotkey {!s} as it is not currently mapped to anything."
                .format(
                    '.'.join((__name__, cls.__name__)),
                    "{!r}".format(key) if callable(key) else "{!s}".format(
                        internal.utils.string.repr(key)), frepr(hotkey)))
            return

        # Grab the keymapping context from our cache, and then ask IDA to remove
        # it for us. If we weren't successful, then raise an exception so the
        # user knows what's up.
        ctx, _ = cls.__cache__[hotkey]
        ok = idaapi.del_hotkey(ctx)
        if not ok:
            raise internal.exceptions.DisassemblerError(
                u"{:s}.unmap({:s}) : Unable to unmap the specified hotkey ({!s}) from the current list of keyboard mappings."
                .format(
                    '.'.join((__name__, cls.__name__)),
                    "{!r}".format(key) if callable(key) else "{!s}".format(
                        internal.utils.string.repr(key)), frepr(hotkey)))

        # Now we can pop off the callable that was mapped to the hotkey context
        # in order to return it, and remove the hotkey from our cache.
        _, res = cls.__cache__.pop(hotkey)
        return res
コード例 #12
0
ファイル: helper.py プロジェクト: IDA-RE-things/idascripts
 def rm(cls, key):
     """unmap a key"""
     idaapi.del_hotkey(cls.hotkey[key])
     del(cls.hotkey[key])
コード例 #13
0
 def rm(cls, key):
     """unmap a key"""
     idaapi.del_hotkey(cls.hotkey[key])
     del (cls.hotkey[key])
コード例 #14
0
 def add(cls, key, fn):
     """map a key to a python function"""
     if key in cls.hotkey:
         idaapi.del_hotkey(cls.hotkey[key])
     cls.hotkey[key] = res = idaapi.add_hotkey(key, fn)
     return res
コード例 #15
0
ファイル: ui.py プロジェクト: arizvisa/idascripts
 def unmap(cls, key):
     '''Unmap the specified `key` from its callable.'''
     idaapi.del_hotkey(cls.hotkey[key])
     del(cls.hotkey[key])
コード例 #16
0
ファイル: SigMakeAndCheck.py プロジェクト: GigiaJ/Renny
def create_pattern(ea):
	curSig, len = AddInsToSig("", ea)
	ea = ea + len
	while not IsUniquePattern(curSig):
		curSig, len = AddInsToSig(curSig, ea)
		ea = ea + len
	
	return curSig
 
def hotkey_pressed():
	CreatePattern()

try:
	hotkey_ctx
	if idaapi.del_hotkey(hotkey_ctx):
		print("CreateSignature hotkey unregistered!")
		del hotkey_ctx
	else:
		print("Failed to delete CreateSignature hotkey!")
except:
	hotkey_ctx = idaapi.add_hotkey("Ctrl+Shift+Alt+S", hotkey_pressed)
	if hotkey_ctx is None:
		print("Failed to register CreateSignature hotkey!")
		del hotkey_ctx
	else:
		print("CreateSignature hotkey registered to Ctrl+Shift+Alt+S!")
		
try:
	hotkey_scs
	if idaapi.del_hotkey(hotkey_scs):
コード例 #17
0
 def term(self):
     for hotkey in self.hotkeys:
         idaapi.del_hotkey(hotkey)
コード例 #18
0
hotkey_mappings = {
    "Shift-S",
    save_function,
    "Shift-L",
    load_function,
    "Shift-A",
    save_all_functions,
    "Shift-H",
    print_hash,
}

hotkey_contexts = []

try:
    hotkey_context_S
    if idaapi.del_hotkey(hotkey_context_S):
        print("FunctionSimSearch: Hotkey S unregistered.")
        del hotkey_context_S
    else:
        print("FunctionSimSearch: Failed to unregister hotkey S.")
    hotkey_context_L
    if idaapi.del_hotkey(hotkey_context_L):
        print("FunctionSimSearch: Hotkey L unregistered.")
        del hotkey_context_L
    else:
        print("FunctionSimSearch: Failed to unregister hotkey L.")
    hotkey_context_H
    if idaapi.del_hotkey(hotkey_context_H):
        print("FunctionSimSearch: Hotkey H unregistered.")
        del hotkey_context_H
    else:
コード例 #19
0
ファイル: helper.py プロジェクト: IDA-RE-things/idascripts
 def add(cls, key, fn):
     """map a key to a python function"""
     if key in cls.hotkey:
         idaapi.del_hotkey(cls.hotkey[key])
     cls.hotkey[key] = res = idaapi.add_hotkey(key, fn)
     return res
コード例 #20
0
ファイル: ui.py プロジェクト: heruix/ida-minsc
 def map(cls, key, callable):
     '''Map a specific `key` to a python `callable`.'''
     if key in cls.hotkey:
         idaapi.del_hotkey(cls.hotkey[key])
     cls.hotkey[key] = res = idaapi.add_hotkey(key, callable)
     return res
コード例 #21
0
ファイル: ex_hotkey.py プロジェクト: xcode2010/XMicro
from __future__ import print_function
#---------------------------------------------------------------------
# This script demonstrates the usage of hotkeys.
#
#
# Author: IDAPython team
#---------------------------------------------------------------------
import idaapi

def hotkey_pressed():
    print("hotkey pressed!")

try:
    hotkey_ctx
    if idaapi.del_hotkey(hotkey_ctx):
        print("Hotkey unregistered!")
        del hotkey_ctx
    else:
        print("Failed to delete hotkey!")
except:
    hotkey_ctx = idaapi.add_hotkey("Shift-A", hotkey_pressed)
    if hotkey_ctx is None:
        print("Failed to register hotkey!")
        del hotkey_ctx
    else:
        print("Hotkey registered!")
コード例 #22
0
ファイル: ui.py プロジェクト: mmg1/ida-minsc
    def map(cls, key, callable):
        """Map the specified `key` combination to a python `callable` in IDA.

        If the provided `key` is being re-mapped due to the mapping already existing, then return the previous callable that it was assigned to.
        """

        # First we'll normalize the hotkey that we were given, and convert it
        # back into a format that IDA can understand. This way we can prevent
        # users from giving us a sloppy hotkey combination that we won't be
        # able to search for in our cache.
        hotkey = cls.__normalize_key__(key)
        keystring = cls.__of_key__(hotkey)

        # The hotkey we normalized is now a tuple, so check to see if it's
        # already within our cache. If it is, then we need to unmap it prior to
        # re-creating the mapping.
        if hotkey in cls.__cache__:
            logging.warn(
                u"{:s}.map({!s}, {!r}) : Remapping the hotkey combination {!s} with the callable {!r}."
                .format('.'.join((__name__, cls.__name__)),
                        internal.utils.string.repr(key), callable,
                        internal.utils.string.repr(keystring), callable))
            ctx, _ = cls.__cache__[hotkey]

            ok = idaapi.del_hotkey(ctx)
            if not ok:
                raise internal.exceptions.DisassemblerError(
                    u"{:s}.map({!s}, {!r}) : Unable to remove the hotkey combination {!s} from the list of current keyboard mappings."
                    .format('.'.join((__name__, cls.__name__)),
                            internal.utils.string.repr(key), callable,
                            internal.utils.string.repr(keystring)))

            # Pop the callable that was mapped out of the cache so that we can
            # return it to the user.
            _, res = cls.__cache__.pop(hotkey)

        # If the user is mapping a new key, then there's no callable to return.
        else:
            res = None

        # Define a closure that calls the user's callable as it seems that IDA's
        # hotkey functionality doesn't deal too well when the same callable is
        # mapped to different hotkeys.

        def closure(*args, **kwargs):
            return callable(*args, **kwargs)

        # Now we can add the hotkey to IDA using the closure that we generated.
        # XXX: I'm not sure if the key needs to be utf8 encoded or not
        ctx = idaapi.add_hotkey(keystring, closure)
        if not ctx:
            raise internal.exceptions.DisassemblerError(
                u"{:s}.map({!s}, {!r}) : Unable to map the callable {!r} to the hotkey combination {!s}."
                .format('.'.join((__name__, cls.__name__)),
                        internal.utils.string.repr(key), callable, callable,
                        internal.utils.string.repr(keystring)))

        # Last thing to do is to stash it in our cache with the user's callable
        # in order to keep track of it for removal.
        cls.__cache__[hotkey] = ctx, callable
        return res