def register_for_medium_level_il_instruction(cls, name, description, action, is_valid=None): """ ``register_for_medium_level_il_instruction`` Register a plugin to be called with a medium level IL instruction argument :param str name: name of the plugin :param str description: description of the plugin :param action: function to call with the ``BinaryView`` and a ``MediumLevelILInstruction`` as arguments :param is_valid: optional argument of a function passed a ``BinaryView`` to determine whether the plugin should be enabled for that view :rtype: None .. warning:: Calling ``register_for_medium_level_il_instruction`` with the same function name will replace the existing function but will leak the memory of the original plugin. """ startup._init_plugins() action_obj = ctypes.CFUNCTYPE( None, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.POINTER(core.BNMediumLevelILFunction), ctypes.c_ulonglong)( lambda ctxt, view, func, instr: cls. _medium_level_il_instruction_action(view, func, instr, action)) is_valid_obj = ctypes.CFUNCTYPE( ctypes.c_bool, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.POINTER(core.BNMediumLevelILFunction), ctypes.c_ulonglong)(lambda ctxt, view, func, instr: cls. _medium_level_il_instruction_is_valid( view, func, instr, is_valid)) cls._registered_commands.append((action_obj, is_valid_obj)) core.BNRegisterPluginCommandForMediumLevelILInstruction( name, description, action_obj, is_valid_obj, None)
def __getitem__(self, value): startup._init_plugins() provider = core.BNGetScriptingProviderByName(str(value)) if provider is None: raise KeyError("'%s' is not a valid scripting provider" % str(value)) return ScriptingProvider(provider)
def __iter__(self): startup._init_plugins() count = ctypes.c_ulonglong() types = core.BNGetScriptingProviderList(count) try: for i in xrange(0, count.value): yield ScriptingProvider(types[i]) finally: core.BNFreeScriptingProviderList(types)
def __iter__(self): startup._init_plugins() count = ctypes.c_ulonglong() commands = core.BNGetAllPluginCommands(count) try: for i in xrange(0, count.value): yield PluginCommand(commands[i]) finally: core.BNFreePluginCommandList(commands)
def list(self): startup._init_plugins() count = ctypes.c_ulonglong() commands = core.BNGetAllPluginCommands(count) result = [] for i in xrange(0, count.value): result.append(PluginCommand(commands[i])) core.BNFreePluginCommandList(commands) return result
def __iter__(self): startup._init_plugins() count = ctypes.c_ulonglong() platforms = core.BNGetPlatformList(count) try: for i in xrange(0, count.value): yield Platform(None, core.BNNewPlatformReference(platforms[i])) finally: core.BNFreePlatformList(platforms, count.value)
def list(self): startup._init_plugins() count = ctypes.c_ulonglong() platforms = core.BNGetPlatformList(count) result = [] for i in xrange(0, count.value): result.append(Platform(None, core.BNNewPlatformReference(platforms[i]))) core.BNFreePlatformList(platforms, count.value) return result
def list(self): startup._init_plugins() count = ctypes.c_ulonglong() xforms = core.BNGetTransformTypeList(count) result = [] for i in xrange(0, count.value): result.append(Transform(xforms[i])) core.BNFreeTransformTypeList(xforms) return result
def os_list(self): startup._init_plugins() count = ctypes.c_ulonglong() platforms = core.BNGetPlatformOSList(count) result = [] for i in xrange(0, count.value): result.append(str(platforms[i])) core.BNFreePlatformOSList(platforms, count.value) return result
def __iter__(self): startup._init_plugins() count = ctypes.c_ulonglong() tasks = core.BNGetRunningBackgroundTasks(count) try: for i in xrange(0, count.value): yield BackgroundTask(core.BNNewBackgroundTaskReference(tasks[i])) finally: core.BNFreeBackgroundTaskList(tasks)
def __iter__(self): startup._init_plugins() count = ctypes.c_ulonglong() xforms = core.BNGetTransformTypeList(count) try: for i in xrange(0, count.value): yield Transform(xforms[i]) finally: core.BNFreeTransformTypeList(xforms)
def __iter__(self): startup._init_plugins() count = ctypes.c_ulonglong() tasks = core.BNGetRunningBackgroundTasks(count) try: for i in xrange(0, count.value): yield BackgroundTask( core.BNNewBackgroundTaskReference(tasks[i])) finally: core.BNFreeBackgroundTaskList(tasks)
def register(cls): startup._init_plugins() if cls.name is None: raise ValueError("undo action 'name' not defined") if cls.action_type is None: raise ValueError("undo action 'action_type' not defined") cb_type = ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p, ctypes.c_char_p, ctypes.POINTER(core.BNUndoAction)) cls._registered_cb = cb_type(cls._deserialize) core.BNRegisterUndoActionType(cls.name, 0, cls._registered_cb) cls._registered = True
def list(self): """List all ScriptingProvider types (read-only)""" startup._init_plugins() count = ctypes.c_ulonglong() types = core.BNGetScriptingProviderList(count) result = [] for i in xrange(0, count.value): result.append(ScriptingProvider(types[i])) core.BNFreeScriptingProviderList(types) return result
def register(cls, name, description, action, is_valid=None): startup._init_plugins() action_obj = ctypes.CFUNCTYPE( None, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView))( lambda ctxt, view: cls._default_action(view, action)) is_valid_obj = ctypes.CFUNCTYPE( ctypes.c_bool, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView))( lambda ctxt, view: cls._default_is_valid(view, is_valid)) cls._registered_commands.append((action_obj, is_valid_obj)) core.BNRegisterPluginCommand(name, description, action_obj, is_valid_obj, None)
def register_for_address(cls, name, description, action, is_valid=None): startup._init_plugins() action_obj = ctypes.CFUNCTYPE( None, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.c_ulonglong)(lambda ctxt, view, addr: cls._address_action( view, addr, action)) is_valid_obj = ctypes.CFUNCTYPE( ctypes.c_bool, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.c_ulonglong)(lambda ctxt, view, addr: cls._address_is_valid( view, addr, is_valid)) cls._registered_commands.append((action_obj, is_valid_obj)) core.BNRegisterPluginCommandForAddress(name, description, action_obj, is_valid_obj, None)
def register(cls): startup._init_plugins() if cls.name is None: raise ValueError("transform 'name' is not defined") if cls.long_name is None: cls.long_name = cls.name if cls.transform_type is None: raise ValueError("transform 'transform_type' is not defined") if cls.group is None: cls.group = "" xform = cls(None) cls._registered_cb = xform._cb xform.handle = core.BNRegisterTransformType(cls.transform_type, cls.name, cls.long_name, cls.group, xform._cb)
def __iter__(self): startup._init_plugins() count = ctypes.c_ulonglong() errors = ctypes.c_char_p() channels = core.BNGetUpdateChannels(count, errors) if errors: error_str = errors.value core.BNFreeString(ctypes.cast(errors, ctypes.POINTER(ctypes.c_byte))) raise IOError(error_str) try: for i in xrange(0, count.value): yield UpdateChannel(channels[i].name, channels[i].description, channels[i].latestVersion) finally: core.BNFreeUpdateChannelList(channels, count.value)
def get_list(cls, os = None, arch = None): startup._init_plugins() count = ctypes.c_ulonglong() if os is None: platforms = core.BNGetPlatformList(count) elif arch is None: platforms = core.BNGetPlatformListByOS(os) else: platforms = core.BNGetPlatformListByArchitecture(os, arch.handle) result = [] for i in xrange(0, count.value): result.append(Platform(None, core.BNNewPlatformReference(platforms[i]))) core.BNFreePlatformList(platforms, count.value) return result
def list(self): startup._init_plugins() count = ctypes.c_ulonglong() errors = ctypes.c_char_p() channels = core.BNGetUpdateChannels(count, errors) if errors: error_str = errors.value core.BNFreeString(ctypes.cast(errors, ctypes.POINTER(ctypes.c_byte))) raise IOError(error_str) result = [] for i in xrange(0, count.value): result.append(UpdateChannel(channels[i].name, channels[i].description, channels[i].latestVersion)) core.BNFreeUpdateChannelList(channels, count.value) return result
def __init__(self, filename=None, handle=None): """ Instantiates a new FileMetadata class. :param filename: The string path to the file to be opened. Defaults to None. :param handle: A handle to the underlying C FileMetadata object. Defaults to None. """ if handle is not None: self.handle = core.handle_of_type(handle, core.BNFileMetadata) else: startup._init_plugins() self.handle = core.BNCreateFileMetadata() if filename is not None: core.BNSetFilename(self.handle, str(filename)) self.nav = None
def __init__(self, filename = None, handle = None): """ Instantiates a new FileMetadata class. :param filename: The string path to the file to be opened. Defaults to None. :param handle: A handle to the underlying C FileMetadata object. Defaults to None. """ if handle is not None: self.handle = core.handle_of_type(handle, core.BNFileMetadata) else: startup._init_plugins() self.handle = core.BNCreateFileMetadata() if filename is not None: core.BNSetFilename(self.handle, str(filename)) self.nav = None
def __iter__(self): startup._init_plugins() count = ctypes.c_ulonglong() errors = ctypes.c_char_p() channels = core.BNGetUpdateChannels(count, errors) if errors: error_str = errors.value core.BNFreeString( ctypes.cast(errors, ctypes.POINTER(ctypes.c_byte))) raise IOError(error_str) try: for i in xrange(0, count.value): yield UpdateChannel(channels[i].name, channels[i].description, channels[i].latestVersion) finally: core.BNFreeUpdateChannelList(channels, count.value)
def list(self): startup._init_plugins() count = ctypes.c_ulonglong() errors = ctypes.c_char_p() channels = core.BNGetUpdateChannels(count, errors) if errors: error_str = errors.value core.BNFreeString( ctypes.cast(errors, ctypes.POINTER(ctypes.c_byte))) raise IOError(error_str) result = [] for i in xrange(0, count.value): result.append( UpdateChannel(channels[i].name, channels[i].description, channels[i].latestVersion)) core.BNFreeUpdateChannelList(channels, count.value) return result
def __getitem__(cls, name): startup._init_plugins() count = ctypes.c_ulonglong() errors = ctypes.c_char_p() channels = core.BNGetUpdateChannels(count, errors) if errors: error_str = errors.value core.BNFreeString(ctypes.cast(errors, ctypes.POINTER(ctypes.c_byte))) raise IOError(error_str) result = None for i in xrange(0, count.value): if channels[i].name == str(name): result = UpdateChannel(channels[i].name, channels[i].description, channels[i].latestVersion) break core.BNFreeUpdateChannelList(channels, count.value) if result is None: raise KeyError("'%s' is not a valid channel" % str(name)) return result
def __getitem__(cls, name): startup._init_plugins() count = ctypes.c_ulonglong() errors = ctypes.c_char_p() channels = core.BNGetUpdateChannels(count, errors) if errors: error_str = errors.value core.BNFreeString( ctypes.cast(errors, ctypes.POINTER(ctypes.c_byte))) raise IOError(error_str) result = None for i in xrange(0, count.value): if channels[i].name == str(name): result = UpdateChannel(channels[i].name, channels[i].description, channels[i].latestVersion) break core.BNFreeUpdateChannelList(channels, count.value) if result is None: raise KeyError("'%s' is not a valid channel" % str(name)) return result
def register(cls, name, description, action, is_valid=None): """ ``register`` Register a plugin :param str name: name of the plugin :param str description: description of the plugin :param action: function to call with the ``BinaryView`` as an argument :param is_valid: optional argument of a function passed a ``BinaryView`` to determine whether the plugin should be enabled for that view :rtype: None .. warning:: Calling ``register`` with the same function name will replace the existing function but will leak the memory of the original plugin. """ startup._init_plugins() action_obj = ctypes.CFUNCTYPE( None, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView))( lambda ctxt, view: cls._default_action(view, action)) is_valid_obj = ctypes.CFUNCTYPE( ctypes.c_bool, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView))( lambda ctxt, view: cls._default_is_valid(view, is_valid)) cls._registered_commands.append((action_obj, is_valid_obj)) core.BNRegisterPluginCommand(name, description, action_obj, is_valid_obj, None)
def register_for_function(cls, name, description, action, is_valid = None): startup._init_plugins() action_obj = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.POINTER(core.BNFunction))(lambda ctxt, view, func: cls._function_action(view, func, action)) is_valid_obj = ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.POINTER(core.BNFunction))(lambda ctxt, view, func: cls._function_is_valid(view, func, is_valid)) cls._registered_commands.append((action_obj, is_valid_obj)) core.BNRegisterPluginCommandForFunction(name, description, action_obj, is_valid_obj, None)
def __getitem__(cls, name): startup._init_plugins() xform = core.BNGetTransformByName(name) if xform is None: raise KeyError("'%s' is not a valid transform" % str(name)) return Transform(xform)
def __getitem__(cls, value): startup._init_plugins() platform = core.BNGetPlatformByName(str(value)) if platform is None: raise KeyError("'%s' is not a valid platform" % str(value)) return Platform(None, platform)
def register_for_range(cls, name, description, action, is_valid = None): startup._init_plugins() action_obj = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.c_ulonglong, ctypes.c_ulonglong)(lambda ctxt, view, addr, length: cls._range_action(view, addr, length, action)) is_valid_obj = ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.c_ulonglong, ctypes.c_ulonglong)(lambda ctxt, view, addr, length: cls._range_is_valid(view, addr, length, is_valid)) cls._registered_commands.append((action_obj, is_valid_obj)) core.BNRegisterPluginCommandForRange(name, description, action_obj, is_valid_obj, None)
def default_repository(self): """Gets the default Repository""" startup._init_plugins() return Repository( handle=core.BNRepositoryManagerGetDefaultRepository(self.handle))