How rajendra1185/processhacker works
Project type and purpose
• This is a native Windows desktop application with two main facets:
– A kernel-mode driver component (KSystemInformer) that hooks into low-level system APIs to capture events (process/thread creation, file I/O, registry, networking, etc.).
– A user-mode GUI client (SystemInformer) that presents that data in real time, plus a plugin framework and a wealth of command-line utilities and libraries.
• The README confirms: “A free, powerful, multi-purpose tool to monitor system resources… includes kernel-mode, WOW64 and .NET support.”
File structure
Top-level components:
• build/ – build scripts (cmd files), SDK, driver packaging (DDf).
• KSystemInformer/ – kernel driver solution, .sys, .inf and driver source (alloc.c, back_trace.c, alpc.c, comms.c, etc.).
• SystemInformer/ – user-mode GUI solution, .exe and resource files, main UI code, phsvc (service), plugins loader support.
• plugins/ – multiple plugin projects (.vcxproj), each a DLL loaded by the GUI.
• kphlib/, phlib/, phnt/ – shared libraries: kernel/user helper libs, NT API definitions and wrappers used by both driver and GUI.
• tools/ – standalone CLI utilities (.exe) and helper tools (custom build, code generators).
• tools/thirdparty/ – vendor libraries (Capstone, Detours, JSON-C, etc.).
README for additional insights
• Describes the two solutions: SystemInformer.sln (GUI + service) and Plugins.sln (all plugins).
• Build instructions point you to build_release.cmd in build/, implying a unified build pipeline.
• Mentions plugin configuration via Options > Plugins.
Main components & interactions
a. Kernel Driver (KSystemInformer.sys)
– Hooks low-level APIs via kernel callbacks, ETW, detours-like techniques.
– Writes events to shared channels (ALPC ports or dynamic memory buffers).
– Exposes IOCTL interfaces and ALPC endpoints for control and data retrieval.
b. User-Mode Service/Client (SystemInformer.exe + phsvc)
– phsvc runs as a Windows service for elevated operations (if required).
– GUI (SystemInformer.exe) connects via ALPC/IOCTL to the driver, requests snapshots or real-time streams.
– Uses kphlib and phlib wrappers to talk to the driver and parse NT structures.
c. Plugin Framework
– DLLs placed in plugins/ folder conform to plugin interface headers in plugins/include.
– GUI loads each plugin, calls its exported entry points to gather additional data (disk I/O, network stats, etc.).
d. Supporting Libraries
– phnt: pure header definitions of native NT APIs.
– kphlib: kernel-mode helpers and user-mode stubs for driver communication.
– phlib: UI support, data structures, utility functions shared by GUI and tools.
e. Standalone Tools
– Each under tools/ (CustomBuildTool, CustomSetupTool, CustomSignTool, CustomStartTool, peview, etc.).
– They consume phlib/phnt/capstone/etc. to perform discrete tasks (PE inspection, driver signing, code-gen).
f. Third-party Dependencies
– Compiled into static libs or built as part of the “thirdparty.sln.”
– Capstone (disassembler), Detours (instrumentation), JSON-C, Miniz, PCRE, etc.
Architectural patterns & principles
• Layered architecture:
– Kernel layer (driver) <–> communication layer (ALPC/IOCTL) <–> user-mode core <–> plugin modules <–> GUI presentation.
• Plugin pattern: loose coupling, plugins implement exported hooks and rely on core plugin manager.
• Shared library modules (phlib, kphlib) centralize common code.
• Build pipeline (build/*.cmd) orchestrates compilation of driver, GUI, plugins, tools, and third-party.