diff --git a/Ghidra/Features/Base/certification.manifest b/Ghidra/Features/Base/certification.manifest index 55fb461fc3..b541792880 100644 --- a/Ghidra/Features/Base/certification.manifest +++ b/Ghidra/Features/Base/certification.manifest @@ -35,6 +35,7 @@ data/parserprofiles/objc_mac_carbon.prf||GHIDRA||reviewed||END| data/parserprofiles/vs12Local.prf||GHIDRA||||END| data/pcodetest/EmuTesting.gdt||GHIDRA||||END| data/stringngrams/StringModel.sng||GHIDRA||reviewed||END| +data/symbols/README.txt||GHIDRA||||END| data/symbols/win32/kernel32.hints||GHIDRA||||END| data/symbols/win32/mfc100.exports||GHIDRA||||END| data/symbols/win32/mfc100u.exports||GHIDRA||||END| @@ -1186,3 +1187,4 @@ src/test.slow/resources/filterTestDirList.txt||GHIDRA||||END| src/test.slow/resources/ghidra/app/plugin/core/datamgr/TestDataType.txt||GHIDRA||||END| src/test.slow/resources/ghidra/app/script/GhidraScriptAsk.properties||GHIDRA||||END| src/test/resources/defaultTools/TestCodeBrowser.tool||GHIDRA||||END| +src/test/resources/ghidra/app/util/opinion/test.ord||GHIDRA||||END| diff --git a/Ghidra/Features/Base/data/symbols/README.txt b/Ghidra/Features/Base/data/symbols/README.txt new file mode 100644 index 0000000000..2d98c6f1dd --- /dev/null +++ b/Ghidra/Features/Base/data/symbols/README.txt @@ -0,0 +1,26 @@ +The use of library symbol table information is currently limited to Windows +x86 (32-bit and 64-bit). Currently, the use of these library symbol files are +best suited for library names which incorporate an API version (e.g., mfc100.dll) +since the .exports and .ord files will utilize this same name for identification. + +When the PE loader detects a library dependency (i.e., DLL) and the library is +not loaded, the subdirectories win32 or win64 will be searched for a corresponding +.exports or .ord file to provide ordinal-to-symbol name mappings. User generated +.exports and .ord files may also be stored/read from the user's 'symbols' resource +directory contained within the user's version-specific .ghidra directory (e.g., +%HOMEPATH%/.ghidra/.ghidra-9.0/symbols/win64). + +The .exports files can be generated from a loaded library program and can also +provide function stack purge and function comment information. The Ghidra script +'CreateExportFileForDLL' may be used to generate a .exports file for the current +program which will be stored within the user's 'symbols' resource directory +mentioned above. + +Many library functions are referenced through the use of ordinals and may be +missing real symbol names. In such cases it may be desirable to rely on ordinal +to symbol name map .ord files which may be generated with the following command: + + DUMPBIN /EXPORTS + +The DUMPBIN utility is provided with Microsoft Visual Studio. The resulting output +should be stored within a .ord file using the DLL name (e.g., mfc100.ord). diff --git a/Ghidra/Features/Decompiler/ghidra_scripts/CreateExportFileForDLL.java b/Ghidra/Features/Base/ghidra_scripts/CreateExportFileForDLL.java similarity index 87% rename from Ghidra/Features/Decompiler/ghidra_scripts/CreateExportFileForDLL.java rename to Ghidra/Features/Base/ghidra_scripts/CreateExportFileForDLL.java index b9354b14aa..4805d3df71 100644 --- a/Ghidra/Features/Decompiler/ghidra_scripts/CreateExportFileForDLL.java +++ b/Ghidra/Features/Base/ghidra_scripts/CreateExportFileForDLL.java @@ -29,14 +29,22 @@ import generic.jar.ResourceFile; import ghidra.app.script.GhidraScript; import ghidra.app.util.opinion.LibraryLookupTable; +import ghidra.util.Msg; +import ghidra.util.SystemUtilities; public class CreateExportFileForDLL extends GhidraScript { @Override public void run() throws Exception { + + if (currentProgram == null) { + Msg.error(this, "Script requires active program"); + } + // push this .dll into the location of the system .exports files. // must have write permissions. - ResourceFile file = LibraryLookupTable.createFile(currentProgram, false, true, monitor); + ResourceFile file = LibraryLookupTable.createFile(currentProgram, false, + SystemUtilities.isInDevelopmentMode(), monitor); println("Created .exports file : " + file.getAbsolutePath()); } diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/AbstractLibrarySupportLoader.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/AbstractLibrarySupportLoader.java index 7a62948957..0e86417a82 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/AbstractLibrarySupportLoader.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/AbstractLibrarySupportLoader.java @@ -139,7 +139,8 @@ public abstract class AbstractLibrarySupportLoader extends AbstractProgramLoader } @Override - public String validateOptions(ByteProvider provider, LoadSpec loadSpec, List