Skip to content

astrosec/pdbgen

 
 

Repository files navigation

PdbGen

Generate a PDB from Ghidra

This project is still very much a WIP, but the basic components should be usable.

Quickstart

  1. download the latest version from github releases
  2. copy assets/PdbGen.java into your ghidra_scripts folder (%USERPROFILE%/ghidra_scripts).
  3. Run the pdbgen script via Ghidra's Script Manager.
  4. Run assets/pdbgen.exe <path/name.exe>
  5. The new pdb will be found at path/name.pdb
  6. Load your binary in windbg and it should automatically find the new pdb.
    1. Note: ensure windbg is not using a cached copy (c:\ProgramData\Dbg\Sym\<name.exe>).

Notes

  1. Currently only global function symbols and data types are currently generated.
    1. dt <module!typename>
    2. x <module!symbolname>
    3. function names should be resolved in the callstack.
  2. You can dump a pdb using llvm's pdbutil tool: llvm-pdbutil.exe dump --all <pdbpath>
  3. We do not need the original binary for Ghidra (it has all the information already)
    1. however I would like to support IDA, which AFAIK discards the pe headers after importing.

How to Build

# You will require a c++17 compliant compiler
git clone --config core.autocrlf=false --branch llvmorg-16.0.0 --single-branch https://github.com/llvm/llvm-project.git
git clone https://github.com/wandel/pdbgen.git --branch develop
git -C llvm-project apply ../pdbgen/llvm-debuginfo.patch  # fix a bug in GSIStreamBuilder
cmake -B llvm-project/build -S llvm-project/llvm -Thost=x64
cmake --build llvm-project/build --target llvm-pdbutil # will take 10mins or so
cmake -B pdbgen/build -S pdbgen/core -DLLVM_DIR=../../llvm-project/build/lib/cmake/llvm -Thost=x64
cmake --build pdbgen/build

To Do

  • Clean this mess up
  • Add symbols for function arguments
  • Add symbols for local variables in functions
  • Support Strings
  • Build with Clang instead of Visual Studio 2019
  • Support building & running on linux
  • Support IDA
  • Avoid requiring the original executable file

Thanks

  1. https://github.com/llvm/llvm-project
  2. https://github.com/Mixaill/FakePDB

About

Generating PDB from Ghidra

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 96.8%
  • Java 2.8%
  • Other 0.4%