Python idaapi.idadir() Examples

The following are 7 code examples of idaapi.idadir(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module idaapi , or try the search function .
Example #1
Source File: ida_batch_decompile.py    From ida-batch_decompile with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self):
        self.is_windows = sys.platform.startswith('win')
        self.is_ida64 = GetIdbPath().endswith(".i64")  # hackhackhack - check if we're ida64 or ida32
        logger.debug("[+] is_windows: %r" % self.is_windows)
        logger.debug("[+] is_ida64: %r" % self.is_ida64)
        self.my_path = os.path.abspath(__file__)
        self.temp_path = None
        self._init_target()
        # settings (form)
        # todo: load from configfile if available.
        self.output_path = None
        self.chk_annotate_stackvar_size = False
        self.chk_annotate_xrefs = False
        self.chk_decompile_imports = False
        self.chk_decompile_imports_recursive = False
        self.chk_decompile_alternative = False
        # self.ida_home = idaapi.idadir(".")
        self.ida_home = GetIdaDirectory()
        # wait for ida analysis to finish
        self.wait_for_analysis_to_finish()
        if not idaapi.init_hexrays_plugin():
            logger.warning("forcing hexrays to load...")
            self.load_plugin_decompiler()
        if not idaapi.init_hexrays_plugin():
            raise Exception("hexrays decompiler is not available :(") 
Example #2
Source File: clrapplier.py    From IDASkins with MIT License 5 votes vote down vote up
def _ida_lib():
    ea_name = 'ida64' if idc.__EA64__ else 'ida'
    if sys.platform == 'win32':
        functype = ctypes.WINFUNCTYPE
        lib = ctypes.WinDLL(ea_name)
    elif sys.platform == 'darwin':
        functype = ctypes.CFUNCTYPE
        lib = ctypes.CDLL(idaapi.idadir("lib" + ea_name + ".dylib"))
    else:
        functype = ctypes.CFUNCTYPE
        lib = ctypes.CDLL('lib' + ea_name + '.so')
    return functype, lib 
Example #3
Source File: config.py    From GhIDA with Apache License 2.0 5 votes vote down vote up
def set_config_path(self):
        """
        Set the JSON configuration file path.
        """
        # Get the path of the config file
        # plugins_path = idaapi.idadir(idaapi.PLG_SUBDIR)
        # ghida_plugin_path = os.path.join(
        #     plugins_path, "ghida_plugin", "config")
        # self.__config_path = os.path.join(ghida_plugin_path, CONFIG_FILENAME)

        self.__config_path = os.path.join(
            tempfile.gettempdir(), CONFIG_FILENAME) 
Example #4
Source File: idascript.py    From idascript with MIT License 5 votes vote down vote up
def loadAllPythonPlugins():
    plugins_dir = idaapi.idadir('plugins')
    print("idascript: loading all .py plugins in %s" % plugins_dir)
    files = [f for f in os.listdir(plugins_dir) if re.match(r'.*\.py', f)]
    for path in files:
        idaapi.load_plugin(path) 
Example #5
Source File: Python_editor.py    From Python_editor with The Unlicense 5 votes vote down vote up
def popeye(self):
        g = globals()
        idahome = idaapi.idadir("plugins\\Code editor")
        IDAPython_ExecScript(idahome +  "\\pyeditor.py", g) 
Example #6
Source File: Python_editor.py    From Python_editor with The Unlicense 5 votes vote down vote up
def popeye(self):
        g = globals()
        idahome = idaapi.idadir("plugins\\Code editor")
        IDAPython_ExecScript(idahome +  "\\pyeditor.py", g) 
Example #7
Source File: env.py    From idapkg with MIT License 5 votes vote down vote up
def __load_ida_native_version():
    sysdir = _os.path.dirname(idaapi.idadir(idaapi.CFG_SUBDIR))
    exe_name = 'ida' if ea == 32 else 'ida64'
    if os == 'win':
        path = _os.path.join(sysdir, exe_name + '.exe')
        with open(path, 'rb') as f:
            data = f.read()
            needle = b'F\0i\0l\0e\0V\0e\0r\0s\0i\0o\0n\0\0\0\0\0'
            offset = data.rfind(needle) + len(needle)
            offset2 = data.find(b'\0\0', offset) + 1
            version_str = data[offset:offset2].decode('utf16')

            version_str = version_str[:version_str.rfind(
                '.')] + version_str[version_str.rfind('.') + 1:]
    elif os == 'mac':
        path = _os.path.join(sysdir, exe_name)
        with open(path, 'rb') as f:
            data = f.read()
            needle = b'<key>CFBundleShortVersionString</key>'
            offset = data.rfind(needle)
            offset = data.find(b'<string>', offset) + 8
            offset2 = data.find(b'</string', offset)
            version_str = data[offset:offset2].decode('utf8')

    result = version_info_cls._make(int(_) for _ in version_str.split('.'))
    return result