PE analyzer and byte patcher for Windows x86 / x64.
ImGui + DX11 UI (docking) * Zydis disassembler
A compact one-window workflow for PE32 / PE32+ analysis: structure tree with click-to-highlight hex view, imports / exports / strings browsers, packer and compiler detection, IDA-style pattern scanner, entry-point disasm, and a byte patcher that recomputes the PE
CheckSumand keeps a.baksafety net.
- PE32 / PE32+ parsing -- DOS + NT headers, data directories,
sections, imports (name / ordinal), exports (with forwarders),
overlay detection. Every field carries its on-disk
Span, so the hex view can highlight it when you click the tree node. - Hex view with structural highlighting -- classic 16-bytes-per-row dump, offset gutter, ASCII column, colored background on whatever the Structure tree has selected.
- String extractor -- ASCII and UTF-16LE runs with a shared offset column; double-click to jump to the hex. Filter inline.
- IDA-style pattern scanner --
48 8B ?? ?? C3style with??wildcards; scans the whole file, click a hit to jump to hex. - Packer / protector / compiler detection -- built-in signature DB covers UPX, Themida, VMProtect, ASPack, MPRESS, Enigma, PECompact, Petite, NsPack, plus MSVC CRT families, MinGW-w64 runtimes, Cygwin, MSYS2, and the CLI data directory for .NET.
- Byte patcher -- queue patches off the hex view, each stores the
original + replacement + an optional label. Save writes an atomic
temp-file replace, creates a
.bakon first save, and recomputes the PE CheckSum so drivers and signed images still load. - Entry-point disasm -- Zydis Intel syntax, double-click an instruction to jump to its bytes in the hex view.
- ImGui docking layout -- drag any pane out, split, float, group;
layout persists in
imgui.ini.
Prerequisites:
- Windows 10/11 x64
- Visual Studio 2022 (MSVC, x64 Native Tools) or CMake + Ninja with MSVC
- CMake 3.20+
- Git (FetchContent pulls Zydis + ImGui)
cmake -S . -B build -G "Visual Studio 17 2022" -A x64
cmake --build build --config Release
build\bin\Release\pector.exeFirst configure pulls ~40 MB of dependencies.
src/
+-- common.h types, windows.h FIRST (lesson from sibling projects)
+-- file_io.{h,cpp} load / atomic save / .bak backup / restore
+-- pe_parser.{h,cpp} DOS + NT headers, sections, imports, exports, overlay
+-- pe_checksum.{h,cpp} imagehlp-compatible CheckSum recomputation
+-- strings_extract.{h,cpp} ASCII + UTF-16LE string scanner
+-- pattern_scan.{h,cpp} IDA-style "48 8B ?? ?? C3" parse + scan
+-- signatures.{h,cpp} section-name + import + EP-pattern detections
+-- disasm.{h,cpp} Zydis wrapper, Intel syntax
+-- patcher.{h,cpp} accumulate byte patches with old/new tracking
+-- engine.{h,cpp} orchestrator; UI thread talks only to this class
+-- main.cpp wWinMain
+-- ui/
+-- theme.{h,cpp} gray ImGui theme
+-- app.{h,cpp} Win32 + DX11 + ImGui docking bootstrap
+-- hex_view.{h,cpp} hex dump with structural highlighting
+-- views.{h,cpp} Control / Structure / Hex / Imports / Exports / Strings
Detect / Patterns / Patches / Disasm / Log
The engine owns the file bytes + parsed PE + patch set. Every read-only
query (strings, detections, pattern search) is a pure function of the
bytes; the UI pulls fresh snapshots each frame instead of maintaining
its own mirror. Save is an in-memory apply patches -> re-parse -> checksum -> atomic temp-file replace -> keep .bak pipeline, so the
on-disk file is never left in a half-written state.
IMAGE_OPTIONAL_HEADER.CheckSum is the one field we have to be careful
with on patch: the Windows loader validates it for drivers and some
signed modules. We implement the standard 16-bit ripple-carry sum with
the checksum field treated as zero, then add the file size -- exactly
what imagehlp!MapFileAndCheckSumW does. On every save PEctor re-parses
the patched buffer, locates the optional-header checksum slot and writes
the new value in place.
48 8B ?? ?? C3 -- MOV with any two bytes between, then RET
48 8B ? ? C3 -- single-'?' also accepted
Whitespace, commas and tabs between tokens are ignored. Everything else is a hex pair.
MIT. See LICENSE.