Skip to content

Latest commit

 

History

History
85 lines (60 loc) · 3.83 KB

building.md

File metadata and controls

85 lines (60 loc) · 3.83 KB

Building from Source

Prerequisites

  • Visual Studio 2026 with the C++ desktop workload (toolset v145). The code is C++20.
  • vcpkg in classic mode, triplet x64-windows-static
  • Git, with submodules

Steps

  1. Clone the repository and its submodule (WTLHelper):

    git clone --recurse-submodules https://github.com/zodiacon/TotalPE2.git
    

    In an existing clone, run git submodule update --init.

  2. Install the dependencies:

    vcpkg install lief capstone scintilla lexilla wil nlohmann-json catch2 webview2 yara[dotnet] --triplet x64-windows-static
    
  3. Download the Win32 metadata (see below):

    powershell -ExecutionPolicy Bypass -File TotalPE\GetWin32Metadata.ps1
    
  4. Open TotalPE2.sln and build the x64 configuration (Debug or Release).

  5. Put msdia140.dll and symsrv.dll next to TotalPE.exe to load PDB symbols. They are not part of the build, but every release zip includes them.

The build output (x64\Debug or x64\Release) contains these files:

File What it is
TotalPE.exe The application
tpe.exe The command-line tool
Win32ApiExp.exe The standalone Windows API Explorer
Decompiler\languages\ The decompiler's processor specifications
Signatures\*.sig Library signatures
Windows.Win32.winmd, Windows.Wdk.winmd The Win32 and WDK metadata, when downloaded

Win32 metadata

The prototypes of Windows functions, the Windows API window and the names of constants and GUIDs come from Microsoft's Win32 metadata (Windows.Win32.winmd) and the WDK's (Windows.Wdk.winmd). These files are licensed under the Windows SDK license and are not part of the sources. TotalPE\GetWin32Metadata.ps1 downloads both into Win32Metadata, and the build copies them next to TotalPE.exe. Without them, imports are decompiled without prototypes.

Library signatures

Tools\BuildSignatures.ps1 makes the signatures of static libraries (TotalPE\Signatures\*.sig). It uses the libraries of the toolsets, Windows SDKs and WDKs installed. The build copies the signatures next to TotalPE.exe. Run the script again when a new toolset comes out.

File Libraries
msvc.sig The C runtime, vcruntime, the STL, ConcRT, the UCRT, delay loading, COM support
msvcd.sig The same, from debug builds
atl.sig ATL's static library
wdk.sig Kernel drivers: the kernel's C runtime, the stack cookie and GsDriverEntry, ntstrsafe, wdmsec, KMDF's stub

Signatures made by users (Tools > Add Library Signatures) go to %LOCALAPPDATA%\TotalPE\Signatures.

The solution

Project What it contains
PECore Everything that is not UI: parsers (PE, COFF, libraries, ELF, CodeView, DWARF, resources) and analyses (disassembly, flow graphs, anomalies, signatures, comparison, reports, YARA, capabilities, fuzzy hashes)
Decompiler Ghidra's decompiler as a static library, behind GhidraDecompiler.h. See Decompiler/README.md.
DiaHelper PDB access through DIA
HexControl The hex editor control
Win32MetaCore Reading the Win32 metadata
Win32ApiUI The Windows API browser, shared by TotalPE and Win32ApiExplorer
TotalPE The UI (WTL)
TotalPE.Cli tpe.exe
Win32ApiExplorer The standalone Windows API browser
WTLHelper Submodule: WTL helpers and dark mode

Tests

PECore.Tests has the unit tests (Catch2). Some use files of the system (kernel32.dll and the like). Tests that need the Windows SDK or WSL skip themselves when those are not installed. Decompiler.Tests tests the decompiler on small pieces of x86, x64 and ARM64 code.

x64\Release\PECore.Tests.exe
x64\Release\Decompiler.Tests.exe