Last active
November 13, 2022 17:35
Revisions
-
Informatic revised this gist
Nov 13, 2022 . 1 changed file with 6 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,13 +1,15 @@ # Looks for matching libraries in current project and automatically assigns to current program. # "Link existing project libraries" doesn't seem to fully work when using bulk import, and this # pretty much reimplements this. # # After running this script you will probably want to use FixupELFExternalSymbolsScript.java too. # #@author infowski #@category Symbol #@keybinding F11 #@menupath #@toolbar projdata = ghidra.framework.main.AppInfo().getActiveProject().getProjectData() def findLibrary(name, base=None): -
Informatic created this gist
Nov 12, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,40 @@ # Looks for matching libraries in current project and automatically assigns to current program #@author infowski #@category Symbol #@keybinding F11 #@menupath #@toolbar #TODO Add User Code Here projdata = ghidra.framework.main.AppInfo().getActiveProject().getProjectData() def findLibrary(name, base=None): if base is None: base = projdata.getRootFolder() for f in base.getFiles(): if f.getName().startswith(name): return f for f in base.getFolders(): tgt = findLibrary(name, f) if tgt: return tgt return None exm = getState().currentProgram.getExternalManager() for lib in exm.getExternalLibraryNames(): if lib == '<EXTERNAL>': continue #print(lib, '->', exm.getExternalLibraryPath(lib)) path = exm.getExternalLibraryPath(lib) if path is None: found = findLibrary(lib) if found: print('Setting %s to %s' % (lib, found.getPathname())) exm.setExternalPath(lib, found.getPathname(), True)