# thexappy/remotenet architecture

> Architecture diagram of the GitHub repository thexappy/remotenet, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/thexappy/remotenet
- Repository: https://github.com/thexappy/remotenet

## Overview

- Client Interface/API Layer – This is the public API (i.e. RemoteNET, RemoteNET.Common, ScubaDiver.API) that users of the library interact with. It exposes methods such as Connect, QueryInstances, Activator.CreateInstance, and so on.
- Remote Process Connector – Represented by components like RemoteApp, RemoteAppFactory, and the underlying injection modules. This component is responsible for attaching to target processes, whether .NET or native, and establishing communication.
- Injection & Hooking Mechanism – Includes the Injector project (Injector, InjectableDummy, and related C++ projects like UnmanagedAdapterDLL) and components that use Detours/net and Harmony wrappers. Their job is to install hooks, inject code, and set up remote execution.
- Remote Object and Reflection Engine – Components that manage/proxy remote objects (RemoteObject, Dynamify mechanism, Reflection classes under RemoteNET/Internal) and that allow dynamic field/property access and method invocation.
- Demangling and Symbol Processing – The ScubaDiver.Demangle module is clearly a standalone component that processes C++ names and other low-level artifact decoding.
- Utilities, Testing, and Diagnostic Components – Include the various test projects (RemoteNET.Tester, RemoteNET.Tests, ScubaDiver.API.Tests, DebuggableDummy) and extra helper libraries (e.g., MsvcOffensiveGcHelper, auxiliary/dissector).

##### Out Relationships and Data Flow
- The RemoteApp then interacts with the underlying Connector, which handles the code injection into the target process.
- From the injected code, control transfers through the Injection/Hooking Mechanisms. This portion bridges with both managed and unmanaged targets – nicely differentiating between .NET hook setups (using Harmony wrappers in projects like Lifeboat and LifeboatProxy) and C++ native interception (via Injector, UnmanagedAdapterDLL, Detours.net).
- Once connected, the Remote Object and Reflection Engine enables the inspection of remote objects (querying, dynamifying, object creation via Activator, and remote method invocations).
- Optionally, the Demangling component receives native symbols to properly transform C++ names into human-readable identifiers; indicate a dependency from the Injector/Hooking layer to the Demangle module.
- Testing and Diagnostic components are layered around these core modules to validate correct behavior.

##### Architectural Patterns and Technologies
- That the library uses a layered architecture where the high-level API (RemoteNET and ScubaDiver.API) abstracts low-level details such as DLL injection and hooking.
- The system exhibits a proxy design pattern – “Dynamify” is used to create dynamic proxies for remote objects, simulating local object method calls.
- There is a separation of concerns: communication with the target process is isolated (handled by the RemoteApp/Injector layer) from the reflection/proxy-handling that the client sees.
- That the mix of managed (.NET C# projects) and native (C++ projects with VC++ projects and Detours/net) is a crucial part of the design, as well as the reliance on external frameworks like Harmony for method hooking and Detours for native interception.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Interface/API Layer
    subgraph "Client Interface/API Layer"
        RN["RemoteNET"]:::managed
        RNC["RemoteNET.Common"]:::managed
        SDA["ScubaDiver.API"]:::managed
    end

    %% Remote Process Connector
    subgraph "Remote Process Connector"
        RAF["RemoteAppFactory"]:::managed
        RA["RemoteApp"]:::managed
        ITK["InjectionToolKit"]:::managed
    end

    %% Injection & Hooking Mechanism
    subgraph "Injection & Hooking Mechanism"
        Inj["Injector"]:::native
        ID["InjectableDummy"]:::native
        UAD["UnmanagedAdapterDLL"]:::native
        LB["Lifeboat"]:::native
        LBP["LifeboatProxy"]:::native
        GMC["MsvcOffensiveGcHelper"]:::native
    end

    %% Remote Object and Reflection Engine
    subgraph "Remote Object and Reflection Engine"
        MRA["ManagedRemoteActivator"]:::managed
        MRO["ManagedRemoteObject"]:::managed
        RDP["Reflection & Dynamic Proxy"]:::managed
        ROR["RemoteObjectRef"]:::managed
    end

    %% Demangling and Symbol Processing
    subgraph "Demangling and Symbol Processing"
        SDD["ScubaDiver.Demangle"]:::utility
    end

    %% Testing, Utilities, and Diagnostics
    subgraph "Testing, Utilities, and Diagnostics"
        RT["RemoteNET.Tester"]:::utility
        RTs["RemoteNET.Tests"]:::utility
        SDA_T["ScubaDiver.API.Tests"]:::utility
        DD["DebuggableDummy"]:::utility
        ADS["auxiliary/dissector"]:::utility
    end

    %% External Components
    TP("Target Process (External)"):::external
    Detours("Detours.net"):::external
    Harmony("Harmony"):::external

    %% Connections between components
    RN -->|"Connect"| RAF
    RNC -->|"UsesAPI"| RAF
    SDA -->|"UsesAPI"| RAF
    RAF -->|"Creates"| RA
    RA -->|"Utilizes"| ITK
    ITK -->|"TriggersInjection"| Inj
    Inj -->|"InjectsTo"| TP

    %% Injection & Hooking internal interactions
    Inj -->|"Invokes"| ID
    Inj -->|"DelegatesTo"| UAD
    LB -->|"HooksManaged"| TP
    LBP -->|"HooksManaged"| TP
    GMC -->|"NativeHook"| TP

    %% External libraries integration
    Detours -->|"UsedBy"| Inj
    Detours -->|"UsedBy"| UAD
    Harmony -->|"UsedBy"| LB
    Harmony -->|"UsedBy"| LBP

    %% Flow to Remote Object and Reflection Engine
    Inj -->|"Enables"| MRA
    Inj -->|"Enables"| MRO
    Inj -->|"Enables"| RDP
    Inj -->|"Enables"| ROR
    RN -->|"DynamicInvoke"| MRA
    RNC -->|"ReflectAccess"| MRO
    RAF -->|"InitiatesReflection"| MRA
    RA -->|"InitiatesReflection"| MRO

    %% Injection & Hooking to Demangling
    Inj -->|"ProvidesSymbolInfo"| SDD

    %% Testing components interactions
    RT -->|"Tests"| RN
    RTs -->|"Tests"| RNC
    SDA_T -->|"Tests"| SDA
    DD -->|"Tests"| TP
    ADS -->|"Analyzes"| TP

    %% External linkage from Reflection back to Client API
    MRA -->|"DynamicInvocation"| RN
    MRO -->|"ReflectionAccess"| RNC

    %% Styling classes
    classDef managed fill:#add8e6,stroke:#000,stroke-width:1px;
    classDef native fill:#90ee90,stroke:#000,stroke-width:1px;
    classDef utility fill:#ffa500,stroke:#000,stroke-width:1px;
    classDef external fill:#ffffff,stroke:#000,stroke-dasharray: 5,5,stroke-width:1px;
    
    %% Click Events
    click RN "https://github.com/thexappy/remotenet/tree/main/src/RemoteNET"
    click RNC "https://github.com/thexappy/remotenet/blob/main/src/RemoteNET.Common"
    click SDA "https://github.com/thexappy/remotenet/blob/main/src/ScubaDiver.API"
    click RAF "https://github.com/thexappy/remotenet/blob/main/src/RemoteNET/Access/RemoteAppFactory.cs"
    click RA "https://github.com/thexappy/remotenet/blob/main/src/RemoteNET/RemoteApp.cs"
    click ITK "https://github.com/thexappy/remotenet/blob/main/src/RemoteNET/Access/InjectionToolKit.cs"
    click Inj "https://github.com/thexappy/remotenet/tree/main/src/Injector"
    click ID "https://github.com/thexappy/remotenet/tree/main/src/InjectableDummy"
    click UAD "https://github.com/thexappy/remotenet/tree/main/src/UnmanagedAdapterDLL"
    click LB "https://github.com/thexappy/remotenet/tree/main/src/Lifeboat"
    click LBP "https://github.com/thexappy/remotenet/tree/main/src/LifeboatProxy"
    click GMC "https://github.com/thexappy/remotenet/tree/main/src/MsvcOffensiveGcHelper"
    click MRA "https://github.com/thexappy/remotenet/blob/main/src/RemoteNET/ManagedRemoteActivator.cs"
    click MRO "https://github.com/thexappy/remotenet/blob/main/src/RemoteNET/ManagedRemoteObject.cs"
    click RDP "https://github.com/thexappy/remotenet/tree/main/src/RemoteNET/Internal/Reflection"
    click ROR "https://github.com/thexappy/remotenet/blob/main/src/RemoteNET/Internal/RemoteObjectRef.cs"
    click SDD "https://github.com/thexappy/remotenet/blob/main/src/ScubaDiver.Demangle"
    click RT "https://github.com/thexappy/remotenet/blob/main/src/RemoteNET.Tester"
    click RTs "https://github.com/thexappy/remotenet/blob/main/src/RemoteNET.Tests"
    click SDA_T "https://github.com/thexappy/remotenet/blob/main/src/ScubaDiver.API.Tests"
    click DD "https://github.com/thexappy/remotenet/tree/main/src/DebuggableDummy"
    click ADS "https://github.com/thexappy/remotenet/tree/main/auxiliary/dissector"
```
