Merge remote-tracking branch 'origin/Ghidra_9.2'

Conflicts:
	Ghidra/Features/PDB/src/main/java/pdb/LoadPdbTask.java
This commit is contained in:
ghidra1 2020-11-03 18:41:32 -05:00
commit a721ddc9c7
11 changed files with 159 additions and 84 deletions

View file

@ -22,6 +22,7 @@
<ul> <ul>
<li><I>Analysis</I>. Increased the speed of the Embedded Media Analyzer, which was especially poor for large programs, by doing better checking and reducing the number of passes over the program. (GT-3258)</li> <li><I>Analysis</I>. Increased the speed of the Embedded Media Analyzer, which was especially poor for large programs, by doing better checking and reducing the number of passes over the program. (GT-3258)</li>
<li><I>Analysis</I>. Improved the performance of the RTTI analyzer. (GT-3341, Issue #10)</li> <li><I>Analysis</I>. Improved the performance of the RTTI analyzer. (GT-3341, Issue #10)</li>
<li><I>Analysis</I>. The handling of Exception records found in GCC-compiled binaries has been sped up dramatically. In addition, incorrect code disassembly has been corrected. (GT-3374)</li>
<li><I>Analysis</I>. Updated Auto-analysis to preserve work when encountering recoverable exceptions. (GT-3599)</li> <li><I>Analysis</I>. Updated Auto-analysis to preserve work when encountering recoverable exceptions. (GT-3599)</li>
<li><I>Analysis</I>. Improved efficiency when creating or checking for functions and namespaces which overlap. (GP-21)</li> <li><I>Analysis</I>. Improved efficiency when creating or checking for functions and namespaces which overlap. (GP-21)</li>
<li><I>Analysis</I>. Added partial support of Clang for Windows. (GP-64)</li> <li><I>Analysis</I>. Added partial support of Clang for Windows. (GP-64)</li>
@ -32,6 +33,7 @@
<li><I>Basic Infrastructure</I>. Introduced an extension point <code>priority</code> annotation so users can control extension point ordering. (GT-3350, Issue #1260)</li> <li><I>Basic Infrastructure</I>. Introduced an extension point <code>priority</code> annotation so users can control extension point ordering. (GT-3350, Issue #1260)</li>
<li><I>Basic Infrastructure</I>. Changed file names in <B>launch.bat</B> to always run executables from System32. (GT-3614, Issue #1599)</li> <li><I>Basic Infrastructure</I>. Changed file names in <B>launch.bat</B> to always run executables from System32. (GT-3614, Issue #1599)</li>
<li><I>Basic Infrastructure</I>. Unknown platforms now default to 64-bit. (GT-3615, Issue #1499)</li> <li><I>Basic Infrastructure</I>. Unknown platforms now default to 64-bit. (GT-3615, Issue #1499)</li>
<li><I>Basic Infrastructure</I>. Updated sevenzipjbinding library to version 16.02-2.01. (GP-254)</li>
<li><I>Build</I>. Ghidra's native Windows binaries can now be built using Visual Studio 2019. (GT-3277, Issue #999)</li> <li><I>Build</I>. Ghidra's native Windows binaries can now be built using Visual Studio 2019. (GT-3277, Issue #999)</li>
<li><I>Build</I>. Extension builds now exclude gradlew artifacts from zip file. (GT-3631, Issue #1763)</li> <li><I>Build</I>. Extension builds now exclude gradlew artifacts from zip file. (GT-3631, Issue #1763)</li>
<li><I>Build</I>. Reduced the number of duplicated help files among the build jar files. (GP-57, Issue #2144)</li> <li><I>Build</I>. Reduced the number of duplicated help files among the build jar files. (GP-57, Issue #2144)</li>
@ -81,11 +83,14 @@
<li><I>Importer</I>. Updated the XML Loader to parse symbol names for namespaces. (GT-3293)</li> <li><I>Importer</I>. Updated the XML Loader to parse symbol names for namespaces. (GT-3293)</li>
<li><I>Importer:ELF</I>. Added support for processing Android packed ELF Relocation Tables. (GT-3320, Issue #1192)</li> <li><I>Importer:ELF</I>. Added support for processing Android packed ELF Relocation Tables. (GT-3320, Issue #1192)</li>
<li><I>Importer:ELF</I>. Added ELF import opinion for ARM BE8. (GT-3642, Issue #1187)</li> <li><I>Importer:ELF</I>. Added ELF import opinion for ARM BE8. (GT-3642, Issue #1187)</li>
<li><I>Importer:ELF</I>. Added support for ELF RELR relocations, such as those produced for Android. (GP-348)</li>
<li><I>Importer:MachO</I>. DYLD Loader can now load x86_64 DYLD from macOS. (GT-3611, Issue #1566)</li> <li><I>Importer:MachO</I>. DYLD Loader can now load x86_64 DYLD from macOS. (GT-3611, Issue #1566)</li>
<li><I>Importer:PE</I>. Improved parsing of Microsoft ordinal map files produced with <code>DUMPBIN /EXPORTS</code> (see <B>Ghidra/Features/Base/data/symbols/README.txt</B>). (GT-3235)</li> <li><I>Importer:PE</I>. Improved parsing of Microsoft ordinal map files produced with <code>DUMPBIN /EXPORTS</code> (see <B>Ghidra/Features/Base/data/symbols/README.txt</B>). (GT-3235)</li>
<li><I>Jython</I>. Upgraded Jython to version 2.7.2. (GP-109)</li> <li><I>Jython</I>. Upgraded Jython to version 2.7.2. (GP-109)</li>
<li><I>Listing</I>. In the PCode field of the Listing, accesses of varnodes in the <code>unique</code> space are now always shown with the size of the access. Fixed bug which would cause the PCode emulator to reject valid pcode in rare instances. (GP-196)</li>
<li><I>Listing:Data</I>. Improved handling and display of character sequences embedded in operands or integer values. (GT-3347, Issue #1241)</li> <li><I>Listing:Data</I>. Improved handling and display of character sequences embedded in operands or integer values. (GT-3347, Issue #1241)</li>
<li><I>Multi-User:Ghidra Server</I>. Added ability to specify initial Ghidra Server user password (<code><B>-a0</B></code> mode only) for the svrAdmin <B>add</B> and <B>reset</B> commands. (GT-3640, Issue #321)</li> <li><I>Multi-User:Ghidra Server</I>. Added ability to specify initial Ghidra Server user password (<code><B>-a0</B></code> mode only) for the svrAdmin <B>add</B> and <B>reset</B> commands. (GT-3640, Issue #321)</li>
<li><I>Processors</I>. Updated AVR8 ATmega256 processor model to reflect correct memory layout specification. (GT-933)</li>
<li><I>Processors</I>. Implemented semantics for <code>vstmia/db</code> <code>vldmia/db</code>, added missing instructions, and fixed shift value for several instructions for the ARM/Thumb NEON instruction set. (GT-2567)</li> <li><I>Processors</I>. Implemented semantics for <code>vstmia/db</code> <code>vldmia/db</code>, added missing instructions, and fixed shift value for several instructions for the ARM/Thumb NEON instruction set. (GT-2567)</li>
<li><I>Processors</I>. Added the XMEGA variant of the AVR8 processor with general purpose registers moved to a non-memory-mapped register space. (GT-2909)</li> <li><I>Processors</I>. Added the XMEGA variant of the AVR8 processor with general purpose registers moved to a non-memory-mapped register space. (GT-2909)</li>
<li><I>Processors</I>. Added support for x86 <code>SALC</code> instruction. (GT-3367, Issue #1303)</li> <li><I>Processors</I>. Added support for x86 <code>SALC</code> instruction. (GT-3367, Issue #1303)</li>
@ -97,7 +102,6 @@
<li><I>Processors</I>. Added manual index file for the M6809 processor. (GT-3449, Issue #1414)</li> <li><I>Processors</I>. Added manual index file for the M6809 processor. (GT-3449, Issue #1414)</li>
<li><I>Processors</I>. Corrected issues related to retained instruction context during a language upgrade. In some rare cases this retained context could interfere with the instruction re-disassembly. This context-clearing mechanism is controlled by a new pspec property: <code>resetContextOnUpgrade</code>. (GT-3531)</li> <li><I>Processors</I>. Corrected issues related to retained instruction context during a language upgrade. In some rare cases this retained context could interfere with the instruction re-disassembly. This context-clearing mechanism is controlled by a new pspec property: <code>resetContextOnUpgrade</code>. (GT-3531)</li>
<li><I>Processors</I>. Updated PIC24/PIC30 index file to match latest manual. Added support for dsPIC33C. (GT-3562)</li> <li><I>Processors</I>. Updated PIC24/PIC30 index file to match latest manual. Added support for dsPIC33C. (GT-3562)</li>
<li><I>Processors</I>. Updated AVR8 ATmega256 processor model to reflect correct memory layout specification. (GT-933)</li>
<li><I>Processors</I>. Added missing call-fixup to handle call side-effects for 32 bit gcc programs for <code>get_pc_thunk.ax/si</code>. (GP-10)</li> <li><I>Processors</I>. Added missing call-fixup to handle call side-effects for 32 bit gcc programs for <code>get_pc_thunk.ax/si</code>. (GP-10)</li>
<li><I>Processors</I>. Added <code>ExitProcess</code> to PEFunctionsThatDoNotReturn. (GP-35)</li> <li><I>Processors</I>. Added <code>ExitProcess</code> to PEFunctionsThatDoNotReturn. (GP-35)</li>
<li><I>Processors</I>. <B>External Disassembly</B> field in the Listing now shows Thumb disassembly when appropriate TMode context has been established on a memory location. (GP-49)</li> <li><I>Processors</I>. <B>External Disassembly</B> field in the Listing now shows Thumb disassembly when appropriate TMode context has been established on a memory location. (GP-49)</li>
@ -105,6 +109,7 @@
<li><I>Processors</I>. Updated AARCH64 to v8.5, including new MTE instructions. (GP-124)</li> <li><I>Processors</I>. Updated AARCH64 to v8.5, including new MTE instructions. (GP-124)</li>
<li><I>Processors</I>. Added support for floating point params and return for SH4 processor calling conventions. (GP-183, Issue #2218)</li> <li><I>Processors</I>. Added support for floating point params and return for SH4 processor calling conventions. (GP-183, Issue #2218)</li>
<li><I>Processors</I>. Added semantic support for many AARCH64 neon instructions. Addresses for register lanes are now precalculated, reducing the amount of p-code generated. (GP-343)</li> <li><I>Processors</I>. Added semantic support for many AARCH64 neon instructions. Addresses for register lanes are now precalculated, reducing the amount of p-code generated. (GP-343)</li>
<li><I>Processors</I>. Updated RISCV processor to include reorganization, new instructions, and fixes to several instructions. (GP-358, Issue #2333)</li>
<li><I>Program API</I>. Improved multi-threaded ProgramDB access performance. (GT-3262)</li> <li><I>Program API</I>. Improved multi-threaded ProgramDB access performance. (GT-3262)</li>
<li><I>Scripting</I>. Improved <B>ImportSymbolScript.py</B> to import functions in addition to generic labels. (GT-3249, Issue #946)</li> <li><I>Scripting</I>. Improved <B>ImportSymbolScript.py</B> to import functions in addition to generic labels. (GT-3249, Issue #946)</li>
<li><I>Scripting</I>. Python scripts can now call protected methods from the GhidraScript API. (GT-3334, Issue #1250)</li> <li><I>Scripting</I>. Python scripts can now call protected methods from the GhidraScript API. (GT-3334, Issue #1250)</li>
@ -115,6 +120,7 @@
</blockquote> </blockquote>
<blockquote><p><u>Bugs</u></p> <blockquote><p><u>Bugs</u></p>
<ul> <ul>
<li><I>Analysis</I>. Function start patterns found at 0x0, function signatures applied from the Data Type Manager at 0x0, and DWARF debug symbols applied at 0x0 will no longer cause stack traces. In addition, DWARF symbols with zero length address range no longer stack trace. (GT-2817, Issue #386, #1560)</li>
<li><I>Analysis</I>. Fixed an issue where stored context is initializing the set of registers constantly. (GP-25)</li> <li><I>Analysis</I>. Fixed an issue where stored context is initializing the set of registers constantly. (GP-25)</li>
<li><I>Analysis</I>. Fixed an RTTI Analyzer regression when analyzing RTTI0 structures with no RTTI4 references to them. (GP-62, Issue #2153)</li> <li><I>Analysis</I>. Fixed an RTTI Analyzer regression when analyzing RTTI0 structures with no RTTI4 references to them. (GP-62, Issue #2153)</li>
<li><I>Analysis</I>. Fixed an issue where the RTTI analyzer was not filling out RTTI3 structures in some cases. (GP-111)</li> <li><I>Analysis</I>. Fixed an issue where the RTTI analyzer was not filling out RTTI3 structures in some cases. (GP-111)</li>
@ -145,6 +151,7 @@
<li><I>Decompiler</I>. Fixed a bug causing the Decompiler to lose Equate references to constants passed to functions that were called indirectly. (GP-247)</li> <li><I>Decompiler</I>. Fixed a bug causing the Decompiler to lose Equate references to constants passed to functions that were called indirectly. (GP-247)</li>
<li><I>Decompiler</I>. Addressed various situations where the Decompiler unexpectedly removes active instructions as dead code after renaming or retyping a stack location. If the location was really an array element or structure field, renaming forced the Decompiler to treat the location as a distinct variable. Subsequently, the Decompiler thought that indirect references based before the location could not alias any following stack locations, which could then by considered dead. As of the 9.2 release, the Decompiler's renaming action no longer switches an annotation to <code>forcing</code> if it wasn't already. A retyping action, although it is <code>forcing</code>, won't trigger alias blocking for atomic data-types (this is configurable). (GP-248, Issue #524, #873)</li> <li><I>Decompiler</I>. Addressed various situations where the Decompiler unexpectedly removes active instructions as dead code after renaming or retyping a stack location. If the location was really an array element or structure field, renaming forced the Decompiler to treat the location as a distinct variable. Subsequently, the Decompiler thought that indirect references based before the location could not alias any following stack locations, which could then by considered dead. As of the 9.2 release, the Decompiler's renaming action no longer switches an annotation to <code>forcing</code> if it wasn't already. A retyping action, although it is <code>forcing</code>, won't trigger alias blocking for atomic data-types (this is configurable). (GP-248, Issue #524, #873)</li>
<li><I>Decompiler</I>. Fixed decompiler memory issues reported by a community security researcher. (GP-267)</li> <li><I>Decompiler</I>. Fixed decompiler memory issues reported by a community security researcher. (GP-267)</li>
<li><I>Decompiler</I>. Fix for Decompiler error: <code>Pcode: XML comms: Missing symref attribute in &lt;high&gt; tag</code>. (GP-352, Issue #2360)</li>
<li><I>Demangler</I>. Fixed the GnuDemangler to parse the full namespace for <code>operator</code> symbols. (GT-3474, Issue #1441, #1448)</li> <li><I>Demangler</I>. Fixed the GnuDemangler to parse the full namespace for <code>operator</code> symbols. (GT-3474, Issue #1441, #1448)</li>
<li><I>Demangler</I>. Fixed numerous GNU Demangler parsing issues. Most notable is the added support for C++ Lambda functions. (GT-3545, Issue #1457, #1569)</li> <li><I>Demangler</I>. Fixed numerous GNU Demangler parsing issues. Most notable is the added support for C++ Lambda functions. (GT-3545, Issue #1457, #1569)</li>
<li><I>Demangler</I>. Updated the GNU Demangler to correctly parse and apply C++ strings using the <code>unnamed type</code> syntax. (GT-3645)</li> <li><I>Demangler</I>. Updated the GNU Demangler to correctly parse and apply C++ strings using the <code>unnamed type</code> syntax. (GT-3645)</li>
@ -183,6 +190,7 @@
<li><I>Importer</I>. Fixed RuntimeException occurrence when trying to load NE programs with unknown resources. (GP-182, Issue #1596, #1713, #2012)</li> <li><I>Importer</I>. Fixed RuntimeException occurrence when trying to load NE programs with unknown resources. (GP-182, Issue #1596, #1713, #2012)</li>
<li><I>Importer</I>. Fixed batch import to handle IllegalArgumentExceptions thrown by loaders. (GP-227, Issue #2328)</li> <li><I>Importer</I>. Fixed batch import to handle IllegalArgumentExceptions thrown by loaders. (GP-227, Issue #2328)</li>
<li><I>Importer:ELF</I>. Corrected ELF relocation processing for ARM BE8 (mixed-endian). (GT-3527, Issue #1494)</li> <li><I>Importer:ELF</I>. Corrected ELF relocation processing for ARM BE8 (mixed-endian). (GT-3527, Issue #1494)</li>
<li><I>Importer:ELF</I>. Corrected ELF relocation processing for <code>R_ARM_PC24</code> (Type: 1) that was causing improper flow in ARM disassembly. (GT-3654)</li>
<li><I>Importer:ELF</I>. Corrected ELF import processing of <code>DT_JMPREL</code> relocations and markup of associated PLT entries. (GP-252, Issue #2334)</li> <li><I>Importer:ELF</I>. Corrected ELF import processing of <code>DT_JMPREL</code> relocations and markup of associated PLT entries. (GP-252, Issue #2334)</li>
<li><I>Importer:PE</I>. Fixed an IndexOutOfBoundsException in the PeLoader that occurred when the size of a section extends past the end of the file. (GT-3433, Issue #1371)</li> <li><I>Importer:PE</I>. Fixed an IndexOutOfBoundsException in the PeLoader that occurred when the size of a section extends past the end of the file. (GT-3433, Issue #1371)</li>
<li><I>Listing:Comments</I>. Fixed bug in Comment field that prevented navigation when clicking on an address or symbol where tabs were present in the comment. (GT-3440)</li> <li><I>Listing:Comments</I>. Fixed bug in Comment field that prevented navigation when clicking on an address or symbol where tabs were present in the comment. (GT-3440)</li>

View file

@ -12,47 +12,56 @@
<BODY lang="EN-US"> <BODY lang="EN-US">
<H1><A name="Load_PDB_File"></A>Load PDB File</H1> <H1><A name="Load_PDB_File"></A>Load PDB File</H1>
<P>A program database (PDB) file holds debugging and project state information about programs <P>A program database (PDB) file holds debugging and project state information about a program
compiled using a Microsoft compiler and written in <CODE>C/C++</CODE>, <CODE>C#</CODE>, and and can be created in a number of ways. Historically, it has been created using a Microsoft
<CODE>Visual Basic</CODE>. A user generates a PDB file using the <CODE>/ZI or /Zi</CODE> flag compiler and written in <CODE>C/C++</CODE>, <CODE>C#</CODE>, and <CODE>Visual Basic</CODE>.
(for C/C++ programs) or the <CODE>/debug</CODE> flag (for Visual Basic/C# programs).</P> A user generates a PDB file using the <CODE>/ZI or /Zi</CODE> flag (for C/C++ programs) or the
<CODE>/debug</CODE> flag (for Visual Basic/C# programs).</P>
<P>Ghidra uses the <A href="#dia">DIA SDK</A> to read information from the PDB file.&nbsp; <P>There are two mechanisms for processing a PDB file. First, the platform-independent
Therefore, Ghidra can only load *.PDB files while running on Windows platforms. However, while PDB Universal Reader/Analyzer, which can read a raw PDB file and apply it. Its capabilities
on Windows, the user may create *.PDB.XML files that can be loaded on non-Windows platforms. are expected to be expanded in future releases. Second, the legacy capability that uses the
*.PDB.XML files can be created in three different ways: <A href="#dia">DIA SDK</A> to read information from the PDB file. This mechanism can only run
on a Windows platform, however it creates an XML representation of information gleaned using
the DIA SDK. These XML files can be saved and then used on Windows and non-Windows platforms
hosting Ghidra.</P>
<P>If loading a PDB, this should be done prior to other analysis, except in special cases,
such as when only loading data types.</P>
<P>Restricted loading of data types or public symbols is
supported by PDB Universal.</P>
<H2>To Load a PDB</H2>
<BLOCKQUOTE> <BLOCKQUOTE>
<UL> <OL>
<LI>From the Ghidra GUI in Windows, use the <A href="help/topics/GhidraScriptMgrPlugin/GhidraScriptMgrPlugin.htm">Ghidra Script Manager</A> <LI>From the menu-bar of a tool, select <B>File <IMG src="../../shared/arrow.gif" alt=""
to run the <I>CreatePdbXmlFilesScript.java</I> script. Follow the prompts to choose width="18" height="14"> Load PDB File</B></LI>
the .PDB file (or directory containing .PDB file(s)) to be converted to .PDB.XML form.
When given a directory, the script recursively traverses all subfolders to find .PDB <LI>In the file chooser, select the PDB file (*.PDB or *.PDB.XML)</LI>
files. A created .PDB.XML file is placed in the same location as the corresponding original
.PDB file.</LI> <LI>Click the "Select PDB" button</LI>
<br> </OL>
<LI>From a Windows command line, navigate to the following directory: <I>&lt;ghidra install root&gt;/support</I>
and run the <I>createPdbXmlFiles.bat</I> script. The script takes one argument representing either <BLOCKQUOTE><UL>
one .PDB file or a directory of .PDB files. When given a directory, the script recursively <LI>PDB Universal is automatically used for *.PDB on non-Windows platforms</LI>
traverses all subdirectories to find .PDB files. A created .PDB.XML file is placed in the <LI>PDB MSDIA is used for *.PDB.XML files</LI>
same location as the corresponding original .PDB file. Sample calls to the script are shown below. </UL></BLOCKQUOTE>
<br><br>
<CODE>&nbsp;&nbsp;&nbsp;&nbsp;createPdbXmlFiles.bat C:\Symbols\samplePdb.pdb</CODE> <P>When a user chooses a PDB or XML file to load for a program, Ghidra will verify its
<br> signature to be valid for the program. At this time, the PDB MSDIA loader cannot be used to
<CODE>&nbsp;&nbsp;&nbsp;&nbsp;createPdbXmlFiles.bat C:\Symbols</CODE> force-load a mismatched PDB. To perform a force-load of a PDB file, the user must choose the
<br> PDB Universal loader if given the option. Force-loading an mismatched file can have
</LI> consequences, such as loading incorrect data types and symbols located at the wrong
<br> addresses.</P>
<LI>Run the included <I>pdb.exe</I> executable (found in the <I>&lt;ghidra install root&gt;/Ghidra/Features/PDB/os/win64</I>
directory) and redirect (save) its output to an XML file as shown below: <P>
<br><br> PDB files may also be loaded using the PDB Analyzer, which is available through
<CODE>&nbsp;&nbsp;&nbsp;&nbsp;pdb.exe samplePdb.pdb > samplePdb.pdb.xml</CODE> <A HREF="help/topics/AutoAnalysisPlugin/AutoAnalysis.htm#Auto_Analyze">Auto Analysis</A> or as
</LI> a <A HREF="help/topics/AutoAnalysisPlugin/AutoAnalysis.htm#Analyze_One_Shot">One Shot Analyzer</A>.
</UL>
</BLOCKQUOTE>
</P> </P>
<P><B>NOTE:</B> Execution of <i>pdb.exe</i> has runtime dependencies which must be satisfied. </BLOCKQUOTE>
Please refer to the <a href="docs/README_PDB.html">README_PDB</a> document for details.</P>
<H2>Information Loaded From PDB</H2> <H2>Information Loaded From PDB</H2>
@ -76,24 +85,6 @@
</OL> </OL>
</BLOCKQUOTE> </BLOCKQUOTE>
<H2>To Load a PDB</H2>
<BLOCKQUOTE>
<OL>
<LI>From the menu-bar of a tool, select <B>File <IMG src="../../shared/arrow.gif" alt=""
width="18" height="14"> Load PDB File</B></LI>
<LI>In the file chooser, select the PDB file (*.PDB for Windows and *.PDB.XML for other platforms)</LI>
<LI>Click the "Select PDB" button</LI>
</OL>
<P>
PDB files may also be loaded using the PDB Analyzer, which is available through
<A HREF="help/topics/AutoAnalysisPlugin/AutoAnalysis.htm#Auto_Analyze">Auto Analysis</A> or as
a <A HREF="help/topics/AutoAnalysisPlugin/AutoAnalysis.htm#Analyze_One_Shot">One Shot Analyzer</A>.
</P>
</BLOCKQUOTE>
<H2>Loading Errors</H2> <H2>Loading Errors</H2>
<BLOCKQUOTE> <BLOCKQUOTE>
@ -106,6 +97,44 @@
<P align="center">Figure 1</P> <P align="center">Figure 1</P>
</BLOCKQUOTE> </BLOCKQUOTE>
<H2>The DIA SDK-Based Capability</H2>
<P>*.PDB.XML files can be created in three different ways:
<BLOCKQUOTE><UL>
<LI>From the Ghidra GUI in Windows, use the
<A href="help/topics/GhidraScriptMgrPlugin/GhidraScriptMgrPlugin.htm">Ghidra Script Manager</A>
to run the <I>CreatePdbXmlFilesScript.java</I> script. Follow the prompts to choose
the .PDB file (or directory containing .PDB file(s)) to be converted to .PDB.XML form.
When given a directory, the script recursively traverses all subfolders to find .PDB
files. A created .PDB.XML file is placed in the same location as the corresponding original
.PDB file.</LI>
<br>
<LI>From a Windows command line, navigate to the following directory:
<I>&lt;ghidra install root&gt;/support</I>
and run the <I>createPdbXmlFiles.bat</I> script. The script takes one argument representing
either one .PDB file or a directory of .PDB files. When given a directory, the script
recursively traverses all subdirectories to find .PDB files. A created .PDB.XML file is
placed in the same location as the corresponding original .PDB file. Sample calls to the
script are shown below.
<br><br>
<CODE>&nbsp;&nbsp;&nbsp;&nbsp;createPdbXmlFiles.bat C:\Symbols\samplePdb.pdb</CODE>
<br>
<CODE>&nbsp;&nbsp;&nbsp;&nbsp;createPdbXmlFiles.bat C:\Symbols</CODE>
<br>
</LI>
<br>
<LI>Run the included <I>pdb.exe</I> executable (found in the <I>&lt;ghidra install
root&gt;/Ghidra/Features/PDB/os/win64</I> directory) and redirect (save) its output to an
XML file as shown below:
<br><br>
<CODE>&nbsp;&nbsp;&nbsp;&nbsp;pdb.exe samplePdb.pdb > samplePdb.pdb.xml</CODE>
</LI>
</UL></BLOCKQUOTE>
</P>
<P><B>NOTE:</B> Execution of <i>pdb.exe</i> has runtime dependencies which must be satisfied.
Please refer to the <a href="docs/README_PDB.html">README_PDB</a> document for details.</P>
<H2><A name="dia"></A>Debug Interface Access SDK</H2> <H2><A name="dia"></A>Debug Interface Access SDK</H2>
<BLOCKQUOTE> <BLOCKQUOTE>
@ -122,8 +151,6 @@
you will need to add and register one or more files on your computer. Refer to the you will need to add and register one or more files on your computer. Refer to the
<a href="docs/README_PDB.html">README_PDB</a> document for detailed instructions. <a href="docs/README_PDB.html">README_PDB</a> document for detailed instructions.
</P> </P>
</BLOCKQUOTE> </BLOCKQUOTE>
</BODY> </BODY>
</HTML> </HTML>

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,6 +18,7 @@ package ghidra.app.util.bin.format.pdb;
public class PdbParserConstants { public class PdbParserConstants {
public final static String PDB_LOADED = "PDB Loaded"; public final static String PDB_LOADED = "PDB Loaded";
public final static String PDB_FILE = "PDB File"; public final static String PDB_FILE = "PDB File";
// NOTE: PDB_AGE stored as Hex string value without 0x or other format indicator
public final static String PDB_AGE = "PDB Age"; public final static String PDB_AGE = "PDB Age";
public final static String PDB_SIGNATURE = "PDB Signature"; public final static String PDB_SIGNATURE = "PDB Signature";
public final static String PDB_VERSION = "PDB Version"; public final static String PDB_VERSION = "PDB Version";

View file

@ -14,9 +14,11 @@
<BODY lang="EN-US"> <BODY lang="EN-US">
<H1>PDB</H1> <H1>PDB</H1>
<P>Ghidra offers the ability to download and apply PDB debug information for Microsoft programs. <P>Ghidra offers the ability to download and apply PDB debug information for programs that run
The <I><A href="download_pdb_file.html">Download PDB File</A></I> feature allows users to download on Microsoft Windows operating systems.
a PDB file that matches the user's current program, given an accessible Symbol Server. The <I><A href="download_pdb_file.html">Download PDB File</A></I> feature allows users to
download and optionally load/apply a PDB file that matches the user's current program, given an
accessible Symbol Server.
The <I><A href="help/topics/ImporterPlugin/load_pdb.html">Load PDB File</A></I> feature The <I><A href="help/topics/ImporterPlugin/load_pdb.html">Load PDB File</A></I> feature
allows users to apply a local PDB file to the current program. The <I>PDB Analyzer</I> also allows users to apply a local PDB file to the current program. The <I>PDB Analyzer</I> also
automatically applies PDB symbols (attempting a search for matching PDB files locally) during automatically applies PDB symbols (attempting a search for matching PDB files locally) during

View file

@ -151,10 +151,8 @@
<LI>If the download was successful or an existing PDB file was found, you may be asked <LI>If the download was successful or an existing PDB file was found, you may be asked
whether you want to apply the PDB to the program.</LI> whether you want to apply the PDB to the program.</LI>
<P><IMG src="../../shared/note.png" border="0">You will not be asked if you want to <P><IMG src="../../shared/note.png" border="0">If Yes is chosen, see
apply the found file if the file is of type .PDB and you are not on a Windows system. <A href="help/topics/ImporterPlugin/load_pdb.html">Load PDB File</A> for continued help.</P>
This is because .PDB files can only be parsed when running on Windows, while .PDB.XML
files can be parsed on any Operating System.</P>
</OL> </OL>
</BLOCKQUOTE> </BLOCKQUOTE>

View file

@ -22,8 +22,6 @@ import java.util.Date;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import ghidra.app.services.*; import ghidra.app.services.*;
//import ghidra.app.util.bin.format.pdb.PdbParser;
import ghidra.app.util.bin.format.pdb.PdbParserConstants;
import ghidra.app.util.bin.format.pdb2.pdbreader.*; import ghidra.app.util.bin.format.pdb2.pdbreader.*;
import ghidra.app.util.importer.MessageLog; import ghidra.app.util.importer.MessageLog;
import ghidra.app.util.opinion.PeLoader; import ghidra.app.util.opinion.PeLoader;
@ -310,9 +308,6 @@ public class PdbUniversalAnalyzer extends AbstractAnalyzer {
applicator.applyTo(program, program.getDataTypeManager(), program.getImageBase(), applicator.applyTo(program, program.getDataTypeManager(), program.getImageBase(),
pdbApplicatorOptions, monitor, log); pdbApplicatorOptions, monitor, log);
Options options = program.getOptions(Program.PROGRAM_INFO);
options.setBoolean(PdbParserConstants.PDB_LOADED, true);
} }
catch (PdbException | IOException e) { catch (PdbException | IOException e) {
log.appendMsg(getName(), log.appendMsg(getName(),

View file

@ -372,19 +372,19 @@ public class PdbLocator {
return builder.toString(); return builder.toString();
} }
private StringBuilder formatPdbIdentifiers(PdbProgramAttributes attributes) { public static StringBuilder formatPdbIdentifiers(PdbProgramAttributes attributes) {
Integer signature = (attributes.getPdbSignature() == null) ? null Integer signature = (attributes.getPdbSignature() == null) ? null
: Integer.valueOf(attributes.getPdbSignature()); : Integer.valueOf(attributes.getPdbSignature());
return formatPdbIdentifiers(attributes.getPdbFile(), signature, return formatPdbIdentifiers(attributes.getPdbFile(), signature,
Integer.valueOf(attributes.getPdbAge(), 16), attributes.getPdbGuid()); Integer.valueOf(attributes.getPdbAge(), 16), attributes.getPdbGuid());
} }
private StringBuilder formatPdbIdentifiers(String file, PdbIdentifiers identifiers) { public static StringBuilder formatPdbIdentifiers(String file, PdbIdentifiers identifiers) {
return formatPdbIdentifiers(file, identifiers.getSignature(), identifiers.getAge(), return formatPdbIdentifiers(file, identifiers.getSignature(), identifiers.getAge(),
identifiers.getGuid().toString()); identifiers.getGuid().toString());
} }
private StringBuilder formatPdbIdentifiers(String file, Integer signature, int age, private static StringBuilder formatPdbIdentifiers(String file, Integer signature, int age,
String guidString) { String guidString) {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append(" Location: ").append(file); builder.append(" Location: ").append(file);
@ -648,7 +648,7 @@ public class PdbLocator {
} }
//============================================================================================== //==============================================================================================
private boolean verifyPdbSignature(PdbProgramAttributes programAttributes, public static boolean verifyPdbSignature(PdbProgramAttributes programAttributes,
PdbIdentifiers identifiers) throws PdbException { PdbIdentifiers identifiers) throws PdbException {
String attributesGuidString = programAttributes.getPdbGuid(); String attributesGuidString = programAttributes.getPdbGuid();

View file

@ -21,12 +21,14 @@ import java.util.*;
import ghidra.app.cmd.label.SetLabelPrimaryCmd; import ghidra.app.cmd.label.SetLabelPrimaryCmd;
import ghidra.app.util.NamespaceUtils; import ghidra.app.util.NamespaceUtils;
import ghidra.app.util.SymbolPath; import ghidra.app.util.SymbolPath;
import ghidra.app.util.bin.format.pdb.PdbParserConstants;
import ghidra.app.util.bin.format.pdb2.pdbreader.*; import ghidra.app.util.bin.format.pdb2.pdbreader.*;
import ghidra.app.util.bin.format.pdb2.pdbreader.symbol.*; import ghidra.app.util.bin.format.pdb2.pdbreader.symbol.*;
import ghidra.app.util.bin.format.pdb2.pdbreader.type.AbstractMsType; import ghidra.app.util.bin.format.pdb2.pdbreader.type.AbstractMsType;
import ghidra.app.util.importer.MessageLog; import ghidra.app.util.importer.MessageLog;
import ghidra.app.util.pdb.PdbCategories; import ghidra.app.util.pdb.PdbCategories;
import ghidra.app.util.pdb.pdbapplicator.SymbolGroup.AbstractMsSymbolIterator; import ghidra.app.util.pdb.pdbapplicator.SymbolGroup.AbstractMsSymbolIterator;
import ghidra.framework.options.Options;
import ghidra.graph.*; import ghidra.graph.*;
import ghidra.graph.algo.GraphNavigator; import ghidra.graph.algo.GraphNavigator;
import ghidra.graph.jung.JungDirectedGraph; import ghidra.graph.jung.JungDirectedGraph;
@ -180,6 +182,10 @@ public class PdbApplicator {
Address imageBaseParam, PdbApplicatorOptions applicatorOptionsParam, Address imageBaseParam, PdbApplicatorOptions applicatorOptionsParam,
TaskMonitor monitorParam, MessageLog logParam) throws PdbException, CancelledException { TaskMonitor monitorParam, MessageLog logParam) throws PdbException, CancelledException {
// FIXME: should not support use of DataTypeManager-only since it will not have the correct data
// organization if it corresponds to a data type archive. Need to evaulate archive use case
// and determine if a program must always be used.
initializeApplyTo(programParam, dataTypeManagerParam, imageBaseParam, initializeApplyTo(programParam, dataTypeManagerParam, imageBaseParam,
applicatorOptionsParam, monitorParam, logParam); applicatorOptionsParam, monitorParam, logParam);
@ -198,6 +204,11 @@ public class PdbApplicator {
throw new PdbException("Invalid Restriction"); throw new PdbException("Invalid Restriction");
} }
if (program == null) {
Options options = program.getOptions(Program.PROGRAM_INFO);
options.setBoolean(PdbParserConstants.PDB_LOADED, true);
}
pdbAddressManager.logReport(); pdbAddressManager.logReport();
pdbApplicatorMetrics.logReport(); pdbApplicatorMetrics.logReport();

View file

@ -20,15 +20,17 @@ import java.io.IOException;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import docking.DockingWindowManager; import docking.DockingWindowManager;
import docking.widgets.OptionDialog;
import docking.widgets.dialogs.MultiLineMessageDialog; import docking.widgets.dialogs.MultiLineMessageDialog;
import ghidra.app.plugin.core.analysis.*; import ghidra.app.plugin.core.analysis.*;
import ghidra.app.plugin.core.datamgr.archive.DuplicateIdException; import ghidra.app.plugin.core.datamgr.archive.DuplicateIdException;
import ghidra.app.services.DataTypeManagerService; import ghidra.app.services.DataTypeManagerService;
import ghidra.app.util.bin.format.pdb.PdbException; import ghidra.app.util.bin.format.pdb.PdbException;
import ghidra.app.util.bin.format.pdb.PdbParser; import ghidra.app.util.bin.format.pdb.PdbParser;
import ghidra.app.util.bin.format.pdb2.pdbreader.AbstractPdb; import ghidra.app.util.bin.format.pdb2.pdbreader.*;
import ghidra.app.util.bin.format.pdb2.pdbreader.PdbReaderOptions;
import ghidra.app.util.importer.MessageLog; import ghidra.app.util.importer.MessageLog;
import ghidra.app.util.pdb.PdbLocator;
import ghidra.app.util.pdb.PdbProgramAttributes;
import ghidra.app.util.pdb.pdbapplicator.*; import ghidra.app.util.pdb.pdbapplicator.*;
import ghidra.framework.options.Options; import ghidra.framework.options.Options;
import ghidra.program.model.address.AddressSetView; import ghidra.program.model.address.AddressSetView;
@ -47,7 +49,7 @@ class LoadPdbTask extends Task {
LoadPdbTask(Program program, File pdbFile, boolean useMsDiaParser, LoadPdbTask(Program program, File pdbFile, boolean useMsDiaParser,
PdbApplicatorRestrictions restrictions, DataTypeManagerService service) { PdbApplicatorRestrictions restrictions, DataTypeManagerService service) {
super("Load PDB", true, false, false); super("Load PDB", true, false, true, true);
this.program = program; this.program = program;
this.pdbFile = pdbFile; this.pdbFile = pdbFile;
this.useMsDiaParser = useMsDiaParser; this.useMsDiaParser = useMsDiaParser;
@ -139,6 +141,9 @@ class LoadPdbTask extends Task {
return false; return false;
} }
// NOTE: OptionDialog will not display an empty line
private static final String BLANK_LINE = " \n";
private boolean parseWithNewParser(MessageLog log, TaskMonitor monitor) private boolean parseWithNewParser(MessageLog log, TaskMonitor monitor)
throws IOException, CancelledException { throws IOException, CancelledException {
@ -148,13 +153,38 @@ class LoadPdbTask extends Task {
pdbApplicatorOptions.setRestrictions(restrictions); pdbApplicatorOptions.setRestrictions(restrictions);
PdbProgramAttributes programAttributes = new PdbProgramAttributes(program);
try (AbstractPdb pdb = ghidra.app.util.bin.format.pdb2.pdbreader.PdbParser try (AbstractPdb pdb = ghidra.app.util.bin.format.pdb2.pdbreader.PdbParser
.parse(pdbFile.getAbsolutePath(), pdbReaderOptions, monitor)) { .parse(pdbFile.getAbsolutePath(), pdbReaderOptions, monitor)) {
PdbIdentifiers identifiers = pdb.getIdentifiers();
if (!PdbLocator.verifyPdbSignature(programAttributes, identifiers)) {
StringBuilder builder = new StringBuilder();
builder.append("Selected PDB does not match program's PDB specification!\n");
builder.append(BLANK_LINE);
builder.append("Program's PDB specification:\n");
builder.append(PdbLocator.formatPdbIdentifiers(programAttributes));
builder.append(BLANK_LINE);
builder.append("Selected PDB file specification:\n");
builder.append(
PdbLocator.formatPdbIdentifiers(pdbFile.getAbsolutePath(), identifiers));
builder.append(BLANK_LINE);
builder.append("Do you wish to force load this PDB?");
if (OptionDialog.YES_OPTION != OptionDialog.showYesNoDialog(null,
"Confirm PDB Load", builder.toString())) {
return false;
}
}
monitor.setMessage("PDB: Parsing " + pdbFile + "..."); monitor.setMessage("PDB: Parsing " + pdbFile + "...");
pdb.deserialize(monitor); pdb.deserialize(monitor);
PdbApplicator applicator = new PdbApplicator(pdbFile.getAbsolutePath(), pdb); PdbApplicator applicator = new PdbApplicator(pdbFile.getAbsolutePath(), pdb);
applicator.applyTo(program, program.getDataTypeManager(), program.getImageBase(), applicator.applyTo(program, program.getDataTypeManager(), program.getImageBase(),
pdbApplicatorOptions, monitor, log); pdbApplicatorOptions, monitor, log);
return true; return true;
} }
catch (ghidra.app.util.bin.format.pdb2.pdbreader.PdbException e) { catch (ghidra.app.util.bin.format.pdb2.pdbreader.PdbException e) {

View file

@ -110,6 +110,9 @@ class SleighParsingTest {
@if defined(ENDIAN) @if defined(ENDIAN)
reg = tmp; reg = tmp;
@endif @endif
@if ENDIAN != "big"
reg = N;
@endif
} }
Dest: loc is op=0 [ loc = inst_next; ] { export loc; } Dest: loc is op=0 [ loc = inst_next; ] { export loc; }

View file

@ -49,6 +49,7 @@ IsDefined:
DefineTest: DefineTest:
( '(' test=DefineTest ')' ( '(' test=DefineTest ')'
| symref=DefineSym OP_EQUAL value=(STRING|intvalue|ID) | symref=DefineSym OP_EQUAL value=(STRING|intvalue|ID)
| symref=DefineSym OP_NOTEQUAL value=(STRING|intvalue|ID)
| isdefined=IsDefined ) ( (OP_BOOL_AND andtest=DefineTest) | (OP_BOOL_OR ortest=DefineTest) )? | isdefined=IsDefined ) ( (OP_BOOL_AND andtest=DefineTest) | (OP_BOOL_OR ortest=DefineTest) )?
; ;