# stascorp/rdpwrap architecture

> Architecture diagram of the GitHub repository stascorp/rdpwrap, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/stascorp/rdpwrap
- Repository: https://github.com/stascorp/rdpwrap

## Overview

1. This repository is a Windows-only RDP enablement toolkit centered on a wrapper DLL. The wrapper sits between Service Control Manager and Terminal Services so `termsrv.dll` stays untouched while the system behaves like it supports Remote Desktop Host and concurrent sessions.

2. The main runtime component is the wrapper library itself. There are two implementation lines:
   - `src-x86-binarymaster` for the Delphi x86 build
   - `src-x86-x64-Fusix` for the C++ x86/x64 port  
   Both are focused on the low-level hooking/wrapping logic and ship as the core binary used by the rest of the tools.

3. Version-specific behavior is externalized into INI-based configuration, not hardcoded in the DLL. The files under `res/` — especially `rdpwrap.ini` and `rdpwrap-arm-kb.ini` — act as the support matrix and patch/offset database for specific `termsrv.dll` builds. This is the key data boundary in the system.

4. `src-installer` is the packaging and deployment layer. It builds `RDPWInst.exe`, which handles installation, uninstall, updates, and unattended deployment. The repo also includes WiX source in `res/RDPWInst.wxs`, indicating an MSI packaging path in addition to the executable installer.

5. The top-level batch scripts in `bin/` are operational entry points for users and automation:
   - `install.bat`
   - `uninstall.bat`
   - `update.bat`  
   These are thin wrappers around the installer workflow and are meant for admin execution on the target machine.

6. `src-rdpconfig` is the configuration UI. `RDPConf.exe` provides a GUI for checking wrapper status and changing supported settings such as session behavior and related policy values. The presence of `LicenseUnit` and the main form units suggests a classic Delphi desktop app with bundled diagnostics and configuration editing.

7. `src-rdpcheck` is a minimal test client. `RDPCheck.exe` is not a full-featured remote desktop client; it exists to verify that loopback RDP works locally. The README notes it uses `127.0.0.2` and is intentionally limited compared with `mstsc.exe`.

8. The runtime data flow is: installer deploys the wrapper and supporting files, then the wrapper consults the local INI to determine whether the current `termsrv.dll` build is supported and which offsets/settings to use. If the build is unknown, the system shows `[not supported]` until the INI is updated.

9. Update flow is separate from installation. The repo supports an “online mode” where the installer can fetch the latest INI from GitHub, and `update.bat` refreshes support data without rebuilding binaries. This makes the INI repository the main mutable compatibility layer.

10. The config tool and checker are operational consumers of the same underlying wrapper state. `RDPConf` reads status and exposes diagnostics; `RDPCheck` validates local connection behavior; both depend on the wrapper being installed and configured correctly.

11. Build/tooling is split by language and target:
   - Delphi projects (`.dpr`, `.dproj`) for the installer, checker, config tool, and the x86 wrapper
   - Visual Studio C++ solution/project files for the x86/x64 wrapper port
   - WiX source for MSI packaging  
   This repo is therefore a multi-toolchain Windows desktop codebase, not a single unified build system.

12. Architecturally, the important boundaries are:
   - low-level wrapper code vs. version data in INI
   - installer/deployment vs. runtime wrapper
   - diagnostics/configuration UI vs. functional test client
   - local machine state vs. online compatibility updates from GitHub  
   That separation is what makes the project maintainable across many Windows builds without changing the core DLL every time.

Main entry points: [`src-installer/RDPWInst.dpr`](https://github.com/stascorp/rdpwrap/blob/master/src-installer/RDPWInst.dpr) (Installer), [`src-x86-binarymaster/rdpwrap.dpr`](https://github.com/stascorp/rdpwrap/blob/master/src-x86-binarymaster/rdpwrap.dpr) (RDPWrap DLL), [`src-x86-x64-Fusix/RDPWrap.cpp`](https://github.com/stascorp/rdpwrap/blob/master/src-x86-x64-Fusix/RDPWrap.cpp) (RDPWrap C++), [`res/rdpwrap.ini`](https://github.com/stascorp/rdpwrap/blob/master/res/rdpwrap.ini) (RDP INI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Core runtime"]
  node_rdpwrap_dll_x86["RDPWrap DLL<br/>wrapper dll<br/>[rdpwrap.dpr]"]
  node_rdpwrap_cpp["RDPWrap C++<br/>wrapper dll<br/>[RDPWrap.cpp]"]
end

subgraph group_tools["Tools"]
  node_installer_exe["Installer<br/>deployment exe<br/>[RDPWInst.dpr]"]
  node_config_ui["RDPConf<br/>config gui<br/>[RDPConf.dpr]"]
  node_check_client["RDPCheck<br/>test client<br/>[RDPCheck.dpr]"]
end

subgraph group_packaging["Packaging"]
  node_install_bat["install.bat<br/>admin script<br/>[install.bat]"]
  node_uninstall_bat["uninstall.bat<br/>admin script<br/>[uninstall.bat]"]
  node_update_bat["update.bat<br/>admin script<br/>[update.bat]"]
  node_rdpwinst_wxs["RDPWInst.wxs<br/>wix source<br/>[RDPWInst.wxs]"]
end

subgraph group_data["Compatibility data"]
  node_ini_support["RDP INI<br/>compat data<br/>[rdpwrap.ini]"]
  node_arm_kb_ini["ARM KB INI<br/>compat data<br/>[rdpwrap-arm-kb.ini]"]
end

subgraph group_build["Build systems"]
  node_installer_proj["Installer proj<br/>delphi project<br/>[RDPWInst.dproj]"]
  node_config_proj["Config proj<br/>delphi project<br/>[RDPConf.dproj]"]
  node_check_proj["Check proj<br/>delphi project<br/>[RDPCheck.dproj]"]
  node_x86_proj["x86 wrapper proj<br/>delphi project<br/>[rdpwrap.dproj]"]
  node_cpp_solution["C++ solution<br/>[RDPWrap.sln]"]
  node_cpp_project["C++ project<br/>[RDPWrap.vcxproj]"]
end

node_rdpwrap_dll_x86 -->|"reads support data"| node_ini_support
node_rdpwrap_dll_x86 -->|"reads variants"| node_arm_kb_ini
node_rdpwrap_cpp -->|"reads support data"| node_ini_support
node_rdpwrap_cpp -->|"reads variants"| node_arm_kb_ini
node_installer_exe -->|"deploys"| node_rdpwrap_dll_x86
node_installer_exe -->|"deploys"| node_rdpwrap_cpp
node_installer_exe -->|"installs"| node_ini_support
node_installer_exe -->|"installs"| node_arm_kb_ini
node_installer_exe -->|"packages"| node_rdpwinst_wxs
node_install_bat -->|"invokes"| node_installer_exe
node_uninstall_bat -->|"invokes"| node_installer_exe
node_update_bat -->|"invokes"| node_installer_exe
node_update_bat -->|"refreshes"| node_ini_support
node_config_ui -->|"checks status"| node_rdpwrap_dll_x86
node_config_ui -->|"checks status"| node_rdpwrap_cpp
node_check_client -->|"validates"| node_rdpwrap_dll_x86
node_check_client -->|"validates"| node_rdpwrap_cpp
node_installer_proj -->|"builds"| node_installer_exe
node_config_proj -->|"builds"| node_config_ui
node_check_proj -->|"builds"| node_check_client
node_x86_proj -->|"builds"| node_rdpwrap_dll_x86
node_cpp_solution -->|"contains"| node_cpp_project

click node_rdpwrap_dll_x86 "https://github.com/stascorp/rdpwrap/blob/master/src-x86-binarymaster/rdpwrap.dpr"
click node_rdpwrap_cpp "https://github.com/stascorp/rdpwrap/blob/master/src-x86-x64-Fusix/RDPWrap.cpp"
click node_ini_support "https://github.com/stascorp/rdpwrap/blob/master/res/rdpwrap.ini"
click node_arm_kb_ini "https://github.com/stascorp/rdpwrap/blob/master/res/rdpwrap-arm-kb.ini"
click node_installer_exe "https://github.com/stascorp/rdpwrap/blob/master/src-installer/RDPWInst.dpr"
click node_config_ui "https://github.com/stascorp/rdpwrap/blob/master/src-rdpconfig/RDPConf.dpr"
click node_check_client "https://github.com/stascorp/rdpwrap/blob/master/src-rdpcheck/RDPCheck.dpr"
click node_install_bat "https://github.com/stascorp/rdpwrap/blob/master/bin/install.bat"
click node_uninstall_bat "https://github.com/stascorp/rdpwrap/blob/master/bin/uninstall.bat"
click node_update_bat "https://github.com/stascorp/rdpwrap/blob/master/bin/update.bat"
click node_rdpwinst_wxs "https://github.com/stascorp/rdpwrap/blob/master/res/RDPWInst.wxs"
click node_installer_proj "https://github.com/stascorp/rdpwrap/blob/master/src-installer/RDPWInst.dproj"
click node_config_proj "https://github.com/stascorp/rdpwrap/blob/master/src-rdpconfig/RDPConf.dproj"
click node_check_proj "https://github.com/stascorp/rdpwrap/blob/master/src-rdpcheck/RDPCheck.dproj"
click node_x86_proj "https://github.com/stascorp/rdpwrap/blob/master/src-x86-binarymaster/rdpwrap.dproj"
click node_cpp_solution "https://github.com/stascorp/rdpwrap/blob/master/src-x86-x64-Fusix/RDPWrap.sln"
click node_cpp_project "https://github.com/stascorp/rdpwrap/blob/master/src-x86-x64-Fusix/RDPWrap.vcxproj"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_rdpwrap_dll_x86,node_rdpwrap_cpp toneBlue
class node_installer_exe,node_config_ui,node_check_client toneAmber
class node_install_bat,node_uninstall_bat,node_update_bat,node_rdpwinst_wxs toneMint
class node_ini_support,node_arm_kb_ini toneRose
class node_installer_proj,node_config_proj,node_check_proj,node_x86_proj,node_cpp_solution,node_cpp_project toneIndigo
```

## Components

### Core runtime

Wrapper DLL implementations and their support-data boundary.

- [RDPWrap DLL](https://github.com/stascorp/rdpwrap/blob/master/src-x86-binarymaster/rdpwrap.dpr): wrapper dll · Delphi x86 wrapper implementation that mediates between SCM and Terminal Services. · `src-x86-binarymaster/rdpwrap.dpr`
- [RDPWrap C++](https://github.com/stascorp/rdpwrap/blob/master/src-x86-x64-Fusix/RDPWrap.cpp): wrapper dll · C++ x86/x64 wrapper port with low-level hooking and export surface. · `src-x86-x64-Fusix/RDPWrap.cpp`

### Tools

Installer, configuration UI, and test client.

- [Installer](https://github.com/stascorp/rdpwrap/blob/master/src-installer/RDPWInst.dpr): deployment exe · RDPWInst.exe installs, uninstalls, updates, and supports unattended deployment. · `src-installer/RDPWInst.dpr`
- [RDPConf](https://github.com/stascorp/rdpwrap/blob/master/src-rdpconfig/RDPConf.dpr): config gui · Desktop UI for wrapper status, diagnostics, and supported settings. · `src-rdpconfig/RDPConf.dpr`
- [RDPCheck](https://github.com/stascorp/rdpwrap/blob/master/src-rdpcheck/RDPCheck.dpr): test client · Minimal loopback RDP validation client using local host behavior. · `src-rdpcheck/RDPCheck.dpr`

### Packaging

Batch entry points and MSI/WiX packaging assets.

- [install.bat](https://github.com/stascorp/rdpwrap/blob/master/bin/install.bat): admin script · Thin entry point for installation workflow. · `bin/install.bat`
- [uninstall.bat](https://github.com/stascorp/rdpwrap/blob/master/bin/uninstall.bat): admin script · Thin entry point for removal workflow. · `bin/uninstall.bat`
- [update.bat](https://github.com/stascorp/rdpwrap/blob/master/bin/update.bat): admin script · Thin entry point for refreshing support data. · `bin/update.bat`
- [RDPWInst.wxs](https://github.com/stascorp/rdpwrap/blob/master/res/RDPWInst.wxs): wix source · MSI packaging definition for the installer path. · `res/RDPWInst.wxs`

### Compatibility data

INI support matrix and build-specific metadata.

- [RDP INI](https://github.com/stascorp/rdpwrap/blob/master/res/rdpwrap.ini): compat data · Build matrix and patch/offset database for supported termsrv.dll versions. · `res/rdpwrap.ini`
- [ARM KB INI](https://github.com/stascorp/rdpwrap/blob/master/res/rdpwrap-arm-kb.ini): compat data · Supplemental compatibility entries for ARM and KB-specific cases. · `res/rdpwrap-arm-kb.ini`

### Build systems

Language- and target-specific project files.

- [Installer proj](https://github.com/stascorp/rdpwrap/blob/master/src-installer/RDPWInst.dproj): delphi project · Delphi project files for the installer executable. · `src-installer/RDPWInst.dproj`
- [Config proj](https://github.com/stascorp/rdpwrap/blob/master/src-rdpconfig/RDPConf.dproj): delphi project · Delphi project files for the configuration UI. · `src-rdpconfig/RDPConf.dproj`
- [Check proj](https://github.com/stascorp/rdpwrap/blob/master/src-rdpcheck/RDPCheck.dproj): delphi project · Delphi project files for the validation client. · `src-rdpcheck/RDPCheck.dproj`
- [x86 wrapper proj](https://github.com/stascorp/rdpwrap/blob/master/src-x86-binarymaster/rdpwrap.dproj): delphi project · Delphi project files for the x86 wrapper build. · `src-x86-binarymaster/rdpwrap.dproj`
- [C++ solution](https://github.com/stascorp/rdpwrap/blob/master/src-x86-x64-Fusix/RDPWrap.sln): vc++ solution · Visual Studio solution for the x86/x64 wrapper port. · `src-x86-x64-Fusix/RDPWrap.sln`
- [C++ project](https://github.com/stascorp/rdpwrap/blob/master/src-x86-x64-Fusix/RDPWrap.vcxproj): vc++ project · Visual C++ project and filters for the wrapper port. · `src-x86-x64-Fusix/RDPWrap.vcxproj`

## Connections

- RDPWrap DLL → RDP INI: reads support data · Uses the INI matrix to map termsrv.dll versions and offsets.
- RDPWrap DLL → ARM KB INI: reads variants · Consults supplemental compatibility entries where needed.
- RDPWrap C++ → RDP INI: reads support data · Uses the same version/offset database for build-specific behavior.
- RDPWrap C++ → ARM KB INI: reads variants · Consumes supplemental compatibility entries.
- Installer → RDPWrap DLL: deploys · Packages and installs the wrapper runtime.
- Installer → RDPWrap C++: deploys · Can deploy the wrapper port artifacts.
- Installer → RDP INI: installs · Places compatibility data on the target machine.
- Installer → ARM KB INI: installs · Places supplemental compatibility data on the target machine.
- Installer → RDPWInst.wxs: packages · Uses WiX source for MSI packaging.
- install.bat → Installer: invokes · Admin wrapper for installation workflow.
- uninstall.bat → Installer: invokes · Admin wrapper for uninstall workflow.
- update.bat → Installer: invokes · Admin wrapper for update workflow.
- update.bat → RDP INI: refreshes · Updates support data without rebuilding binaries.
- RDPConf → RDPWrap DLL: checks status · Reads wrapper state and exposed configuration.
- RDPConf → RDPWrap C++: checks status · Reads wrapper state for the selected runtime.
- RDPCheck → RDPWrap DLL: validates · Exercises local loopback RDP behavior through the installed wrapper.
- RDPCheck → RDPWrap C++: validates · Exercises local loopback RDP behavior through the installed wrapper.
- Installer proj → Installer: builds · Delphi project produces the installer executable.
- Config proj → RDPConf: builds · Delphi project produces the configuration UI.
- Check proj → RDPCheck: builds · Delphi project produces the loopback test client.
- x86 wrapper proj → RDPWrap DLL: builds · Delphi project produces the x86 wrapper binary.
- C++ solution → C++ project: contains · Visual Studio solution contains the C++ wrapper project.
