# 0xp1x3l/lgl-modmenu-template architecture

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

- Interactive diagram: https://gitdiagram.com/0xp1x3l/lgl-modmenu-template
- Repository: https://github.com/0xp1x3l/lgl-modmenu-template

## Overview

##### Main Components
- Android Application Layer (Java):
- Activities and UI components: MainActivity, Launcher, Menu, etc.
- CrashHandler and Preferences for managing app state and error handling.
- AndroidManifest.xml is the entry point for defining the app’s components and permissions.
- Native Layer (JNI/C++):
- Subdirectories such as And64InlineHook, KittyMemory, Substrate, and Menu hold the native hooking modules.
- These modules handle low-level tasks like hooking functions, memory patching, and inline hooking at runtime.
- They provide the core functionality to alter game behavior without needing assets stored externally (assets are embedded as base64 strings).
- Build and Configuration Artifacts:
- Gradle scripts (build.gradle files, settings.gradle, gradle wrappers) define dependencies and build settings.
- JNI build files like Android.mk and Application.mk for compiling native libraries.

##### Out Relationships and Interactions
- The Android Java layer acts as the frontend, initializing the mod menu through MainActivity and passing control to the native libraries via JNI interfaces.
- The native modules (And64InlineHook, KittyMemory, Substrate) are tightly integrated:
- And64InlineHook and Substrate modules likely work together to perform function hooking.
- KittyMemory provides memory operations (patching, reading/writing) that the hooks depend upon.
- The Java UI communicates with the native layer through JNI calls, forming a bridge between high-level user interactions and low-level hooking operations.
- Build configuration files connect the components by ensuring both Java and native modules are compiled and packaged properly.

##### Important Architectural Patterns and Design Principles
- Separation of Concerns:
- Clear division between the UI/Java components and the core hooking logic in native C/C++.
- Modular Design:
- Each native module is encapsulated in its own directory (e.g., And64InlineHook, KittyMemory, Substrate), making it easier to update or replace components independently.
- Cross-Layer Integration:
- The use of JNI as an integration layer calls for careful documentation of data flow between Java and native code.
- Build and Deployment:
- Standard Android Studio and Gradle project structure ensures that build scripts and configurations are modular and maintainable.

##### Relevant Technologies and Frameworks
- Android SDK and standard UI frameworks for the Java layer.
- JNI for cross-language integration.
- Native build system using Android.mk and Application.mk for C/C++ code.
- Hooking libraries such as And64InlineHook and Substrate for inlining and dynamic patching.
- Memory manipulation and obfuscation functionalities through KittyMemory and included obfuscator libraries.

##### Specific Elements
- Android Application (UI/Activities)
- JNI Bridge
- Native Modules:
- And64InlineHook
- KittyMemory
- Substrate
- Menu (native UI elements, if any)
- How the UI layer calls into the JNI bridge.
- Data and control flow during the hooking process.
- For example, use rectangles for UI components, hexagons for native libraries, and parallelograms for configuration/build files.
- Annotations:
- Labels that mention important libraries (e.g., “And64InlineHook: Inline hooking for ARM64”, “KittyMemory: Memory patching and reading”), specific build or dependency roles (Gradle scripts), and the integration flow via JNI.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Android Application Layer (Java)"
        A1["MainActivity"]:::android
        A2["Main"]:::android
        A3["Launcher"]:::android
        A4["Menu UI"]:::android
        A5["CrashHandler"]:::android
        A6["Preferences"]:::android
        A7["AndroidManifest"]:::android
        A8["Resources"]:::android
    end

    N0["JNI Bridge"]:::jni

    subgraph "Native Modules (JNI/C++)"
        N1["And64InlineHook"]:::native
        N2["KittyMemory"]:::native
        N3["Substrate"]:::native
        N4["Menu (Native)"]:::native
        N5["JNI Main"]:::native
        N6["JNI Includes"]:::native
    end

    subgraph "Build & Configuration"
        B1["Gradle Build Scripts"]:::build
        B2["JNI Build Files"]:::build
    end

    %% Connections from Android App Layer to JNI Bridge
    A1 -->|"callsJNI"| N0
    A3 -->|"initializesJNI"| N0
    A4 -->|"triggersNative"| N0

    %% Connections from JNI Bridge to Native Modules
    N0 -->|"invokes"| N1
    N0 -->|"invokes"| N2
    N0 -->|"invokes"| N3
    N0 -->|"invokes"| N4
    N0 -->|"invokes"| N5
    N0 -->|"invokes"| N6

    %% Interactions within Native Modules
    N1 -->|"integrates"| N3
    N3 -->|"calls"| N2

    %% Build integration arrows
    B1 -->|"builds"| A1
    B1 -->|"builds"| A2
    B1 -->|"builds"| A3
    B1 -->|"builds"| A4
    B2 -->|"builds"| N1
    B2 -->|"builds"| N2
    B2 -->|"builds"| N3
    B2 -->|"builds"| N4
    B2 -->|"builds"| N5
    B2 -->|"builds"| N6

    %% Click Events for Android Application Layer
    click A1 "https://github.com/0xp1x3l/lgl-modmenu-template/blob/master/app/src/main/java/com/android/support/MainActivity.java"
    click A2 "https://github.com/0xp1x3l/lgl-modmenu-template/blob/master/app/src/main/java/com/android/support/Main.java"
    click A3 "https://github.com/0xp1x3l/lgl-modmenu-template/blob/master/app/src/main/java/com/android/support/Launcher.java"
    click A4 "https://github.com/0xp1x3l/lgl-modmenu-template/blob/master/app/src/main/java/com/android/support/Menu.java"
    click A5 "https://github.com/0xp1x3l/lgl-modmenu-template/blob/master/app/src/main/java/com/android/support/CrashHandler.java"
    click A6 "https://github.com/0xp1x3l/lgl-modmenu-template/blob/master/app/src/main/java/com/android/support/Preferences.java"
    click A7 "https://github.com/0xp1x3l/lgl-modmenu-template/blob/master/app/src/main/AndroidManifest.xml"
    click A8 "https://github.com/0xp1x3l/lgl-modmenu-template/tree/master/app/src/main/res"

    %% Click Events for Native Modules
    click N1 "https://github.com/0xp1x3l/lgl-modmenu-template/tree/master/app/src/main/jni/And64InlineHook"
    click N2 "https://github.com/0xp1x3l/lgl-modmenu-template/tree/master/app/src/main/jni/KittyMemory"
    click N3 "https://github.com/0xp1x3l/lgl-modmenu-template/tree/master/app/src/main/jni/Substrate"
    click N4 "https://github.com/0xp1x3l/lgl-modmenu-template/tree/master/app/src/main/jni/Menu"
    click N5 "https://github.com/0xp1x3l/lgl-modmenu-template/blob/master/app/src/main/jni/Main.cpp"
    click N6 "https://github.com/0xp1x3l/lgl-modmenu-template/tree/master/app/src/main/jni/Includes"

    %% Click Events for Build & Configuration
    click B1 "https://github.com/0xp1x3l/lgl-modmenu-template/blob/master/app/build.gradle"
    click B2 "https://github.com/0xp1x3l/lgl-modmenu-template/blob/master/app/src/main/jni/Android.mk"

    %% Styles
    classDef android fill:#AED6F1,stroke:#1B4F72,stroke-width:2px,color:#000;
    classDef jni fill:#F9E79F,stroke:#B7950B,stroke-width:2px,color:#000;
    classDef native fill:#A9DFBF,stroke:#196F3D,stroke-width:2px,color:#000;
    classDef build fill:#E8DAEF,stroke:#8E44AD,stroke-width:2px,color:#000;
```
