pkeyconfig-gui rewrite in modern C++ - architecture proposal

Discussion in 'Mixed Languages' started by wesmar, Nov 28, 2025.

  1. wesmar

    wesmar MDL Member

    Apr 1, 2012
    173
    597
    10
    #1 wesmar, Nov 28, 2025
    Last edited: Feb 25, 2026
    Hi everyone,

    Since Dark Vador got banned and I've seen people trying to reach him, I wanted to step in. I've spent some time studying his pkeyconfig_gui.ps1 and I have to say - I'm genuinely impressed. The amount of knowledge packed into this script is remarkable: Windows licensing internals, native API calls, key encoding algorithms, all the edge cases... it's a treasure trove of tribal knowledge built over years.

    That said, the project has grown to 26,000 lines in a single PowerShell file - globals everywhere, data mixed with logic, P/Invoke through Reflection.Emit. It works, but maintaining or extending it is a challenge.

    I'd be willing to rewrite it in modern C++ (C++20/23) with a clean architecture. Here's my proposal:

    Code:
    pkeyconfig-cpp/
    │
    ├── include/pkeyconfig/
    │   │
    │   ├── core/                        # Fundamental types & algorithms
    │   │   ├── types.hpp                # UINT128, Guid, base types
    │   │   ├── product_key.hpp          # Key encode/decode (base24, CRC)
    │   │   └── error_codes.hpp          # HRESULT/NTSTATUS parsing
    │   │
    │   ├── data/                        # Static data & parsers
    │   │   ├── sku_database.hpp         # SKU lookup table (~200 entries)
    │   │   ├── error_database.hpp       # WU/CBS error tables
    │   │   └── pkeyconfig_parser.hpp    # XRM-MS XML/base64 parser
    │   │
    │   ├── native/                      # Windows API wrappers
    │   │   ├── ntdll.hpp                # NtQuerySystemInformation, PEB access
    │   │   ├── sppc.hpp                 # SLOpen, SLGetLicense, SLInstall*
    │   │   └── pkhelper.hpp             # pkeyhelper.dll bindings
    │   │
    │   └── license/                     # High-level license operations
    │       ├── license_info.hpp         # Query license status
    │       ├── license_manager.hpp      # Install/uninstall licenses
    │       └── activation.hpp           # Activation helpers
    │
    ├── src/                             # Implementation files
    │   └── [mirrors include structure]
    │
    ├── data/                            # Static data files (optional)
    │   ├── sku_table.json               # Or embedded as constexpr
    │   └── error_codes.json
    │
    └── gui/                             # Optional GUI (ImGui/Qt/WinUI)
    
    The goal is to preserve all that hard-won knowledge while making the codebase maintainable: proper separation of concerns, RAII for handles, constexpr lookup tables, modern error handling.

    Anyone interested in collaborating? Would especially appreciate input from those who understand the deeper licensing internals.

    Credits to Dark Vador for the original work, abbodi1406 for SKU tables, and all researchers referenced in the script.

    One important thing: This is Dark Vador's work and I fully respect that. Before I start any serious rewrite, I'd like to ask the community - does anyone have contact with him to get his blessing? Or if any of the original contributors (abbodi1406, WindowsAddict, others) have thoughts on this, I'd appreciate your input.

    I don't want to step on anyone's toes here. Just want to help keep this valuable project alive.
     

    Attached Files:

  2. haber123

    haber123 MDL Member

    Nov 5, 2009
    137
    50
    10
    Thank you, I look forward to seeing this continued.
     
  3. Sajjo

    Sajjo MDL Member

    Feb 6, 2018
    3,255
    4,407
    120
    @wesmar
    Me too ;)
    He would appreciate it :)
     
  4. Tito

    Tito Admin / Adviser
    Staff Member

    Nov 30, 2009
    19,079
    19,893
    340
  5. wesmar

    wesmar MDL Member

    Apr 1, 2012
    173
    597
    10
    #5 wesmar, Dec 2, 2025
    Last edited: Dec 6, 2025
    (OP)
    I am still working on rewriting Dark Vadora's PowerShell-based Windows product key configuration tool to modern C++, and wanted to share some early progress. The project has been an interesting challenge in porting functionality while taking advantage of C++'s performance and type safety.
    I will provide the source codes in the evening once I have created a complete repeatable compilation with the "BREPRO" flag.
    =============
    Test compilation 12/6/2025
     

    Attached Files:

  6. haber123

    haber123 MDL Member

    Nov 5, 2009
    137
    50
    10
    I am impressed, and it is fast.
     
  7. wesmar

    wesmar MDL Member

    Apr 1, 2012
    173
    597
    10
    PKeyConfigGUI - Native C++ Windows Licensing Tool
    PowerShell → Modern C++20: Complete Rewrite
    What is this?
    A native C++ implementation of Windows product key management tools, replacing slow PowerShell scripts with a lightning-fast standalone executable. Zero dependencies, direct API access, dual GUI/CLI interface.
    Why Rewrite?
    PowerShell/VBS Problems:
    • Slow (~500ms startup overhead)
    • Requires .NET Framework + WMI service
    • Flagged by antivirus heuristics
    • Unreliable WMI queries (especially firmware access)
    • ~80MB memory footprint
    Native C++ Solution:
    • <50ms cold start, <10ms warm
    • Zero dependencies (static binary, ~280KB)
    • Direct ACPI/firmware table access
    • ~4MB memory footprint
    • 29-266x faster operations
    Feature Comparison
    Feature PowerShell This Tool Status
    PKeyConfig Parser XML DOM/Regex Native parser ✓ Complete
    Key Encode/Decode Array loops Bitwise UINT128 ✓ Complete
    BIOS Key Read WMI (150ms) ACPI Direct (1ms) ✓ Complete
    System Keys Extract Registry queries Registry + Firmware ✓ Complete
    Key Generation Manual parameters Smart Edition mapping ✓ Complete
    Remote Operations PSRemoting WMI + Remote Registry ✓ Complete
    Offline Activation (IID/CID) slmgr /dti, /atp Not implemented ⚠ Planned
    License Rearm slmgr /rearm Not implemented ⚠ Planned
    KMS Configuration slmgr /skms Not implemented ⚠ Planned
    Current Implementation Status
    ✓ PHASE 1 COMPLETE (95% of key management)
    Core Components:
    • Full pkeyconfig.xrm-ms parser (Windows/Office/Visual Studio)
    • Base-24 codec with checksum validation
    • System key extraction (DigitalProductId, DigitalProductId4, OA3x, MSDM)
    • Direct ACPI firmware table access (bypasses WMI)
    • Intelligent key generation with Edition→GroupID mapping
    • CLI mode: /dump, /gen, /decode, /remote
    • GUI with ListView manager and HTML export
    • Remote WMI + Registry connector
    ⚠ PHASE 2 IN PROGRESS (Activation features)
    What's Missing:
    • Offline Activation: IID generation (Installation ID) and CID input (Confirmation ID) - requires SLGenerateOfflineInstallationId() and SLDepositOfflineConfirmationId()
    • License Rearm: Reset activation counters - requires SLReArm() API
    • KMS Client Setup: Configure KMS server address/port - requires WMI SetKeyManagementServiceMachine() or registry manipulation
    • Full SLC API Wrapper: Complete activation trigger, license status queries
    ⏳ PHASE 3 RESEARCH (Advanced methods)
    • Token store manipulation (native C++ approach)
    • Advanced activation methods
    • Network licensing server integration
    Performance Benchmarks
    Operation PowerShell C++ Native Speedup
    Parse 2MB config file 350ms 12ms 29x
    Decode 1000 keys 800ms 3ms 266x
    Read BIOS key 150ms 1ms 150x
    Cold start 500ms 45ms 11x
    Technical Architecture
    Key Innovations:
    • KeyOrchestrator: Intelligent Edition ID → RefGroupID mapping with automatic key range selection
    • Direct Firmware Access: Raw ACPI table parsing instead of flaky WMI queries
    • UINT128 Bitwise Operations: Optimized Base-24 encoding/decoding using union structures
    • Zero External Dependencies: Static CRT, no .NET/WMI runtime requirements
    • Dual Interface: Full GUI for interactive use + CLI arguments for batch automation
    What You Can Do Now
    Code:
    ✓ Parse any pkeyconfig.xrm-ms file (system or custom)
    ✓ Decode/validate any Windows product key
    ✓ Generate valid keys for any edition (with proper GroupID/KeyID/Secret)
    ✓ Extract all system keys (registry + BIOS/UEFI)
    ✓ Query remote computers for licensing info
    ✓ Export detailed HTML reports
    ✓ Automate via CLI in batch scripts
    
    What You Cannot Do Yet
    Code:
    ✗ Perform offline activation (IID/CID workflow)
    ✗ Reset activation state (rearm)
    ✗ Configure KMS client settings
    ✗ Trigger online activation (partially available via SlcApi)
    
    Bottom Line
    Current state: Complete product key management tool (95% feature parity with PowerShell scripts)
    Target v2.0: Full slmgr.vbs replacement with activation capabilities
    This is a production-ready key manager, not yet a full activator. The architecture is in place for Phase 2 activation features.
    Binary Info
    Code:
    Platform: x64 Windows
    Compiler: MSVC 2026 (C++20/C++23/StdLatestCpp)
    Size: ~280KB
    Dependencies: None
    Tested: Windows 10/11
    
    Download
    For now, downloads with source codes, which after compilation produce an identical binary file for transparency (BREPRO flag), are available on our forum. Once everything is ready, I will rewrite the first post.
     
  8. wesmar

    wesmar MDL Member

    Apr 1, 2012
    173
    597
    10
    PKeyConfigGUI v2.0 - Ultimate Windows Licensing Tool
    Native C++20 Replacement for PowerShell/VBS Scripts




    Project Status: GOLD / COMPLETE (theoretically, because I only tested it at home)

    The project has reached functionality parity with standard Windows administration tools (`slmgr.vbs`), but runs significantly faster and natively without external dependencies.

    What's New in v2.0:
    • Added full Activation / SLC API integration.
    • Implemented Offline Activation (IID generation / CID deposit).
    • Added KMS Client Configuration (/skms, /ckms).
    • Added License Rearm capability.
    • Complete CLI Manager fully compatible with `slmgr` commands.




    Feature Matrix & Completion Status

    Category Feature Status C++ Implementation
    Core Logic PKeyConfig Parsing ✓ 100% Native XML Parser (No MSXML)
    Key Gen / Decode ✓ 100% UINT128 Bitwise Math
    System BIOS/UEFI Key ✓ 100% Direct ACPI Table Access
    Registry Keys ✓ 100% DPID4 + OA3x Extraction
    Activation Online Activation (/ato) ✓ 100% SLC API Wrapper
    Install/Uninstall Key ✓ 100% Syncs with Windows Licensing
    Offline Activation ✓ 100% IID Gen + CID Deposit
    KMS Management ✓ 100% Set Host/Port/Clear
    Rearm ✓ 100% Timer Reset Implementation
    Performance Benchmarks (Final)

    Code:
    Operation              | PowerShell (slmgr) | PKeyConfigGUI (C++) | Improvement
    -----------------------|--------------------|---------------------|------------
    Startup Time           | ~500 ms            | ~15 ms              | 33x Faster
    Parse Config (2MB)     | ~350 ms            | ~12 ms              | 29x Faster
    Read BIOS Key          | ~150 ms (WMI)      | ~1 ms (ACPI)        | 150x Faster
    Activation Check       | ~1200 ms           | ~40 ms              | 30x Faster
    Binary Size            | Script (Requires VM)| ~290 KB (Static)   | Portable
    
    How to Use

    GUI Mode: Just run the executable.
    • New "Active/Upgrade" button: Install keys and trigger online activation.
    • New "Add License" button: Install offline license files (`.xrm-ms`).

    CLI Mode (slmgr replacement - "PKeyConfigGUI /?" from command line):
    Code:
    PKeyConfigGUI.exe /ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX   (Install Key)
    PKeyConfigGUI.exe /ato                                 (Activate Online)
    PKeyConfigGUI.exe /dti                                 (Get Offline ID)
    PKeyConfigGUI.exe /atp <ConfirmationID>                (Deposit Offline ID)
    PKeyConfigGUI.exe /skms kms.server.com:1688            (Set KMS)
    PKeyConfigGUI.exe /rearm                               (Reset Licensing)
    
     
  9. pm67310

    pm67310 MDL Guru

    Sep 6, 2011
    3,863
    3,133
    120
    #9 pm67310, Dec 5, 2025
    Last edited by a moderator: Dec 5, 2025
    @wesmar

    Missing features to create generated key for all pkeyconfig ( you need to create manual key ) and features to extract key embedded in exe or xml or dll

    And link to download latest project ?.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  10. wesmar

    wesmar MDL Member

    Apr 1, 2012
    173
    597
    10
    Current Focus: Code Quality & Foundation
    Right now, I'm focused on improving the core code quality before adding new features. I'm implementing RAII (Resource Acquisition Is Initialization) patterns throughout the project to eliminate memory leaks and ensure resource safety, especially in Windows API interactions. The internal architecture is becoming much more robust and maintainable.
    Regarding Missing Features:
    You're right about the missing automated key generation and extraction features. These are definitely on the roadmap! Currently, manual key input is required, but automated extraction from executables, XML, DLLs, and other binary formats is planned for future releases.
    Why It's Taking Time???
    This project has complex mathematical foundations that Dark Vador worked on for a long time, and I need to fully understand these implementations before extending them safely. There's still significant "dirty math" to clean up and properly document.
    Current State:
    - Solid internals: The core engine is becoming quite robust
    - Parallel development: Both GUI and CLI interfaces are being developed simultaneously
    - Code refinement: Major refactoring in progress (RAII, smart pointers, error handling)
    - Feature backlog: Automated key gen/extraction coming after code stabilization
     
  11. Sajjo

    Sajjo MDL Member

    Feb 6, 2018
    3,255
    4,407
    120
    @wesmar
    You can update #5 all day long and combined with same filename, no members are sure what they are testing anymore.
    (unless they check date/checksum stamp)

    You can get feedback on wrong release.
    ;)
     
  12. wesmar

    wesmar MDL Member

    Apr 1, 2012
    173
    597
    10
    I'm almost done with the non-binary blobs and logic from massgrave. By the end of this week, I'll put it up for testing, replace the binary, and describe it. Best regards
     
  13. haber123

    haber123 MDL Member

    Nov 5, 2009
    137
    50
    10
    I am looking forward to this.
     
  14. ceo54

    ceo54 MDL Addicted

    Aug 13, 2015
    969
    465
    30
    Thank you @wesmar, looking for ward to it.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  15. wesmar

    wesmar MDL Member

    Apr 1, 2012
    173
    597
    10
    Updated the tool (attached in the first post), but I don't have a way to test it myself. Let me know when it's confirmed working and I'll write up a proper description and drop the source code. Also, the activation functions currently rely on LibTSforge.dll and TSforge.exe — they need to be in the same directory as when you unzip it, but that's just temporary while we're confirming stuff, since I've basically rewritten all of that into a single file "PKeyConfigGUI.exe" anyway.
     
  16. haber123

    haber123 MDL Member

    Nov 5, 2009
    137
    50
    10
    Thank you. I will test it this and get back to you.