當前位置: 首頁>>代碼示例>>Python>>正文


Python idaapi.execute_sync方法代碼示例

本文整理匯總了Python中idaapi.execute_sync方法的典型用法代碼示例。如果您正苦於以下問題:Python idaapi.execute_sync方法的具體用法?Python idaapi.execute_sync怎麽用?Python idaapi.execute_sync使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在idaapi的用法示例。


在下文中一共展示了idaapi.execute_sync方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: safe_generator

# 需要導入模塊: import idaapi [as 別名]
# 或者: from idaapi import execute_sync [as 別名]
def safe_generator(iterator):

    # Make the sentinel value something that isn't likely to be returned
    # by an API call (and isn't a fixed string that could be inserted into
    # a program to break FIRST maliciously)
    sentinel = '[1st] Sentinel %d' % (random.randint(0, 65535))

    holder = [sentinel] # need a holder, because 'global' sucks

    def trampoline():
        try:
            holder[0] = next(iterator)
        except StopIteration:
            holder[0] = sentinel
        return 1

    while True:
        # See notes above regarding why we use MFF_WRITE here
        idaapi.execute_sync(trampoline, idaapi.MFF_WRITE)
        if holder[0] == sentinel:
            return
        yield holder[0]

#   Main Plug-in Form Class
#------------------------------------------------------------------------------- 
開發者ID:vrtadmin,項目名稱:FIRST-plugin-ida,代碼行數:27,代碼來源:first.py

示例2: __getattribute__

# 需要導入模塊: import idaapi [as 別名]
# 或者: from idaapi import execute_sync [as 別名]
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(idautils, name, default)

        if val == default:
            val = getattr(idc, 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

                # Execute the request using MFF_WRITE, which should be safe for
                # any possible request at the expense of speed.  In my testing,
                # though, it wasn't noticably slower than MFF_FAST.  If this
                # is observed to impact performance, consider creating a list
                # that maps API calls to the most appropriate flag.
                idaapi.execute_sync(trampoline, idaapi.MFF_WRITE)
                return holder[0]
            return call

        else:
            return val 
開發者ID:vrtadmin,項目名稱:FIRST-plugin-ida,代碼行數:39,代碼來源:first.py

示例3: idawrite

# 需要導入模塊: import idaapi [as 別名]
# 或者: from idaapi import execute_sync [as 別名]
def idawrite(f):
    @functools.wraps(f)
    def wrapper(*args, **kwargs):
        ff = functools.partial(f, *args, **kwargs)
        return idaapi.execute_sync(ff, idaapi.MFF_WRITE)
    return wrapper 
開發者ID:andreafioraldi,項目名稱:IDAngr,代碼行數:8,代碼來源:ida_debugger.py

示例4: sync_wrapper

# 需要導入模塊: import idaapi [as 別名]
# 或者: from idaapi import execute_sync [as 別名]
def sync_wrapper(ff,safety_mode):
    """
    Call a function ff with a specific IDA safety_mode.
    """
    logger.debug('sync_wrapper: {}, {}'.format(ff.__name__,safety_mode))

    if safety_mode not in [IDASafety.SAFE_READ,IDASafety.SAFE_WRITE]:
        error_str = 'Invalid safety mode {} over function {}'\
                .format(safety_mode,ff.__name__)
        logger.error(error_str)
        raise IDASyncError(error_str)

    # No safety level is set up:
    res_container = Queue.Queue()

    def runned():
        logger.debug('Inside runned')

        # Make sure that we are not already inside a sync_wrapper:
        if not call_stack.empty():
            last_func_name = call_stack.get()
            error_str = ('Call stack is not empty while calling the '
                'function {} from {}').format(ff.__name__,last_func_name)
            logger.error(error_str)
            raise IDASyncError(error_str)

        call_stack.put((ff.__name__))
        try:
            res_container.put(ff())
        finally:
            call_stack.get()
            logger.debug('Finished runned')

    ret_val = idaapi.execute_sync(runned,safety_mode)
    res = res_container.get()
    return res 
開發者ID:xorpd,項目名稱:fcatalog_client,代碼行數:38,代碼來源:idasync.py

示例5: execute_sync

# 需要導入模塊: import idaapi [as 別名]
# 或者: from idaapi import execute_sync [as 別名]
def execute_sync(function, sync_type):
    """
    Synchronize with the disassembler for safe database access.

    Modified from https://github.com/vrtadmin/FIRST-plugin-ida
    """

    @functools.wraps(function)
    def wrapper(*args, **kwargs):
        output = [None]

        #
        # this inline function definition is technically what will execute
        # in the context of the main thread. we use this thunk to capture
        # any output the function may want to return to the user.
        #

        def thunk():
            output[0] = function(*args, **kwargs)
            return 1

        if is_mainthread():
            thunk()
        else:
            idaapi.execute_sync(thunk, sync_type)

        # return the output of the synchronized execution
        return output[0]
    return wrapper

#------------------------------------------------------------------------------
# Disassembler Core API (universal)
#------------------------------------------------------------------------------ 
開發者ID:gaasedelen,項目名稱:lighthouse,代碼行數:35,代碼來源:ida_api.py

示例6: execute_read

# 需要導入模塊: import idaapi [as 別名]
# 或者: from idaapi import execute_sync [as 別名]
def execute_read(function):
        return execute_sync(function, idaapi.MFF_READ) 
開發者ID:gaasedelen,項目名稱:lighthouse,代碼行數:4,代碼來源:ida_api.py

示例7: execute_write

# 需要導入模塊: import idaapi [as 別名]
# 或者: from idaapi import execute_sync [as 別名]
def execute_write(function):
        return execute_sync(function, idaapi.MFF_WRITE) 
開發者ID:gaasedelen,項目名稱:lighthouse,代碼行數:4,代碼來源:ida_api.py

示例8: execute_ui

# 需要導入模塊: import idaapi [as 別名]
# 或者: from idaapi import execute_sync [as 別名]
def execute_ui(function):
        return execute_sync(function, idaapi.MFF_FAST)

    #--------------------------------------------------------------------------
    # API Shims
    #-------------------------------------------------------------------------- 
開發者ID:gaasedelen,項目名稱:lighthouse,代碼行數:8,代碼來源:ida_api.py

示例9: __getattribute__

# 需要導入模塊: import idaapi [as 別名]
# 或者: from idaapi import execute_sync [as 別名]
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(idautils, name, default)

        if val == default:
            val = getattr(idc, 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 
開發者ID:Cisco-Talos,項目名稱:CASC,代碼行數:34,代碼來源:casc_plugin.py

示例10: onmsg_safe

# 需要導入模塊: import idaapi [as 別名]
# 或者: from idaapi import execute_sync [as 別名]
def onmsg_safe(key, data, replay=False):
    def tmp():
        try:
            onmsg(key, data, replay=replay)
        except Exception as e:
            print('error during callback for %s: %s' % (data.get('cmd'), e))
            traceback.print_exc()
    idaapi.execute_sync(tmp, MFF_WRITE) 
開發者ID:lunixbochs,項目名稱:revsync,代碼行數:10,代碼來源:ida_frontend.py

示例11: warning_msgbox

# 需要導入模塊: import idaapi [as 別名]
# 或者: from idaapi import execute_sync [as 別名]
def warning_msgbox(warning_str):
    def fun(warning_str):
        idc.Warning(warning_str)
    idaapi.execute_sync(partial(fun, warning_str), idaapi.MFF_FAST)


# TODO: not sure if this should always work (race condition? or not with GIL?) 
開發者ID:Riscure,項目名稱:DROP-IDA-plugin,代碼行數:9,代碼來源:helpers.py

示例12: asklong

# 需要導入模塊: import idaapi [as 別名]
# 或者: from idaapi import execute_sync [as 別名]
def asklong(defval, prompt):
    res = [None]  # Python 2 way to assign outside of a nested function
    def fun(defval, prompt):
        res[0] = idc.AskLong(defval, prompt)
    idaapi.execute_sync(partial(fun, defval, prompt), idaapi.MFF_FAST)
    return res[0]


# TODO: Put these global functions somewhere in a scope? 
開發者ID:Riscure,項目名稱:DROP-IDA-plugin,代碼行數:11,代碼來源:helpers.py

示例13: get_func_codeblocks

# 需要導入模塊: import idaapi [as 別名]
# 或者: from idaapi import execute_sync [as 別名]
def get_func_codeblocks(f):
    cbs = [None]
    def fun():
        cbs[0] = list(sark.codeblocks(start=f.startEA, end=f.endEA))
    idaapi.execute_sync(fun, idaapi.MFF_READ)
    return cbs[0] 
開發者ID:Riscure,項目名稱:DROP-IDA-plugin,代碼行數:8,代碼來源:helpers.py

示例14: get_current_codeblock

# 需要導入模塊: import idaapi [as 別名]
# 或者: from idaapi import execute_sync [as 別名]
def get_current_codeblock():
    cb = [None]
    def fun():
        cb[0] = sark.CodeBlock()
    idaapi.execute_sync(fun, idaapi.MFF_READ)
    return cb[0] 
開發者ID:Riscure,項目名稱:DROP-IDA-plugin,代碼行數:8,代碼來源:helpers.py

示例15: reset_block_colors

# 需要導入模塊: import idaapi [as 別名]
# 或者: from idaapi import execute_sync [as 別名]
def reset_block_colors(f):
    def fun():
        cbs = sark.codeblocks(start=f.startEA, end=f.endEA)
        for cb in cbs:
            cb.color = 0xFFFFFF
    idaapi.execute_sync(fun, idaapi.MFF_WRITE) 
開發者ID:Riscure,項目名稱:DROP-IDA-plugin,代碼行數:8,代碼來源:helpers.py


注:本文中的idaapi.execute_sync方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。