# keganhollern/memstream architecture

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

- Interactive diagram: https://gitdiagram.com/keganhollern/memstream
- Repository: https://github.com/keganhollern/memstream

## Overview

##### Main Components

a. Core Components:
- FPGA Interface Layer
- Input Processing System
- Process Management Layer
- Memory Management Interface
- MemProcFS Integration Layer

b. External Dependencies:
- MemProcFS
- VMM (Virtual Memory Management)
- LeechCore (FPGA communication)

**┌─────────────────────────────────────────────┐**
- Client Application              │
- ┬─────────────────────────┘
- ↓
**┌─────────────────────────────────────────────┐**
- MemStream v2 API               │
- ┬─────────────┬─────────────────┤
- FPGA.h     │  Input.h    │   Process.h     │
- ┬──────┴──────┬──────┴────────┬────────┘

**┌──────▼──────┐┌─────▼─────┐┌───────▼────────┐**
- FPGA Access ││ Input     ││ Process         │
- Layer       ││ Handler   ││ Management      │
- ┬──────┘└─────┬─────┘└───────┬────────┘

**┌──────▼──────┬──────▼──────────────▼────────┐**
- LeechCore  │        VMM Layer             │
- ┴───────────────────────────────┘
- ↓
**┌─────────────────────────────────────────────┐**
- Physical FPGA                  │
- ┘

##### Important Details

a. Component Responsibilities:
- FPGA.h: Device configuration and management
- Input.h: Input device capture and event handling
- Process.h: Process memory manipulation
- Utils.h: Helper functions and utilities
- _macros.h: Common macros and definitions

b. Integration Points:
- How MemStream interfaces with MemProcFS
- FPGA communication through LeechCore
- Memory management through VMM

##### Implementation Details

- The v2 namespace containing all major components
- The relationship between FPGA configuration and input handling
- Memory streaming pathways from FPGA to application
- Event callback system for input handling
- Process memory access patterns

##### Future Expansion

- Shellcode injection capabilities
- Process dumping
- Pattern finding
- Code cave detection
- Mono dissection utilities

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Legend
        L1[Component]:::component --- L2[External Dependency]:::external
        L2 --- L3[Hardware Interface]:::hardware
        L4[".h Header File"]:::header --- L5[".cpp Source File"]:::source
        L6["API Boundary"]:::api
    end

    subgraph "Client Application Layer"
        Client["Client Application"]:::component
    end

    subgraph "MemStream v2 API Layer"
        API["MemStream v2 API"]:::api
        FPGA_H["FPGA.h"]:::header
        Input_H["Input.h"]:::header
        Process_H["Process.h"]:::header
        Utils_H["Utils.h"]:::header
        Macros_H["_macros.h"]:::header
    end

    subgraph "Implementation Layer"
        FPGA_CPP["FPGA.cpp"]:::source
        Input_CPP["Input.cpp"]:::source
        Process_CPP["Process.cpp"]:::source
    end

    subgraph "External Dependencies"
        LeechCore["LeechCore"]:::external
        VMM["VMM Layer"]:::external
        MemProcFS["MemProcFS"]:::external
    end

    subgraph "Hardware Layer"
        FPGA["Physical FPGA"]:::hardware
    end

    %% Connections
    Client --> API
    API --> FPGA_H & Input_H & Process_H & Utils_H & Macros_H
    FPGA_H --> FPGA_CPP
    Input_H --> Input_CPP
    Process_H --> Process_CPP
    FPGA_CPP --> LeechCore
    Input_CPP & Process_CPP --> VMM
    VMM & LeechCore --> MemProcFS
    LeechCore --> FPGA

    %% Click Events
    click API "https://github.com/keganhollern/MemStream/tree/main/include/MemStream/v2/"
    click FPGA_H "https://github.com/keganhollern/MemStream/blob/main/include/MemStream/v2/FPGA.h"
    click Input_H "https://github.com/keganhollern/MemStream/blob/main/include/MemStream/v2/Input.h"
    click Process_H "https://github.com/keganhollern/MemStream/blob/main/include/MemStream/v2/Process.h"
    click Utils_H "https://github.com/keganhollern/MemStream/blob/main/include/MemStream/v2/Utils.h"
    click Macros_H "https://github.com/keganhollern/MemStream/blob/main/include/MemStream/v2/_macros.h"
    click FPGA_CPP "https://github.com/keganhollern/MemStream/blob/main/src/v2/FPGA.cpp"
    click Input_CPP "https://github.com/keganhollern/MemStream/blob/main/src/v2/Input.cpp"
    click Process_CPP "https://github.com/keganhollern/MemStream/blob/main/src/v2/Process.cpp"
    click LeechCore "https://github.com/keganhollern/MemStream/blob/main/lib/vmm/leechcore.h"
    click VMM "https://github.com/keganhollern/MemStream/blob/main/lib/vmm/vmmdll.h"

    %% Styles
    classDef component fill:#a8d1ff,stroke:#000
    classDef external fill:#90EE90,stroke:#000
    classDef hardware fill:#FFE5B4,stroke:#000
    classDef header fill:#FFB6C1,stroke:#000
    classDef source fill:#DDA0DD,stroke:#000
    classDef api fill:#F0E68C,stroke:#000
```
