def get_jsondoc_basepath(): return os.path.join( Application.getUserCacheDirectory().getAbsolutePath(), 'GhidraAPI_javadoc', Application.getApplicationVersion(), 'api', )
def extract_jsondoc(): zip_location = os.path.join( Application.getInstallationDirectory().getAbsolutePath(), "docs/GhidraAPI_javadoc.zip") extract_dir = os.path.join( Application.getUserCacheDirectory().getAbsolutePath(), 'GhidraAPI_javadoc', Application.getApplicationVersion()) zip_file = zipfile.ZipFile(zip_location) zip_file.extractall(extract_dir)
def readSyscalls(): syscall_token = '#define __NR_' lines = readFile( Application.getModuleDataFile('Femtium', 'headers/bits/syscall.h').getFile(False)) return { int(l[1]): l[0] for l in [ re.split('\\s+', l[len(syscall_token):]) for l in lines if l.startswith(syscall_token) ] }
def get_jsondoc(class_name): jsondoc = None try: root = Application.getApplicationRootDirectory().getFile(False).getParentFile().getAbsolutePath() javadoc_zip_name = "GhidraAPI_javadoc.zip" if SystemUtilities.isInDevelopmentMode(): javadoc_zip = root + "/build/tmp/" + javadoc_zip_name else: javadoc_zip = root + "/docs/" + javadoc_zip_name if os.path.exists(javadoc_zip): json_path = "api/" + class_name.replace('.', '/') + '.json' with zipfile.ZipFile(javadoc_zip, "r").open(json_path) as f: jsondoc = json.load(f) except (IOError, KeyError) as e: pass return jsondoc