Skip to content
tertit133Public

About

PE32/PE32+ analyzer and byte patcher for Windows. ImGui+DX11 docking UI, Zydis disassembly, imagehlp-compatible CheckSum recomputation.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PEctor

PE analyzer and byte patcher for Windows x86 / x64.

build license C++ platform

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 CheckSum and keeps a .bak safety net.

Features

  • 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 ?? ?? C3 style 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 .bak on 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.

Build

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.exe

First configure pulls ~40 MB of dependencies.

Architecture

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.

PE CheckSum

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.

Pattern syntax

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.

License

MIT. See LICENSE.

About

PE32/PE32+ analyzer and byte patcher for Windows. ImGui+DX11 docking UI, Zydis disassembly, imagehlp-compatible CheckSum recomputation.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages