# caremeos-dev/caremeriru architecture

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

- Interactive diagram: https://gitdiagram.com/caremeos-dev/caremeriru
- Repository: https://github.com/caremeos-dev/caremeriru

## Overview

Riru injects a native loader into Android’s zygote, then hooks process-fork and specialization JNI methods so modules can run in app and system-server processes. Its native runtime discovers and manages modules, invokes their lifecycle callbacks, and can hide Riru/module memory from `/proc/maps` scans. A companion daemon provides status, module metadata, and filesystem services over a local socket. The README documents the injection and hook design; some daemon/client wiring is only partially evidenced in the excerpts, so uncertain links are omitted or marked dashed.

Main entry points: [`riru/src/main/cpp/module.cpp`](https://github.com/caremeos-dev/caremeriru/blob/master/riru/src/main/cpp/module.cpp) (Module manager), [`rirud/src/main/java/riru/DaemonUtils.java`](https://github.com/caremeos-dev/caremeriru/blob/master/rirud/src/main/java/riru/DaemonUtils.java) (Daemon utilities), [`rirud/src/main/java/riru/Daemon.java`](https://github.com/caremeos-dev/caremeriru/blob/master/rirud/src/main/java/riru/Daemon.java) (Riru daemon), [`riru/src/main/cpp/loader/loader.cpp`](https://github.com/caremeos-dev/caremeriru/blob/master/riru/src/main/cpp/loader/loader.cpp) (Bridge loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_injection["Injection runtime"]
  node_native_bridge["Native bridge"]
  node_loader["Bridge loader<br/>[loader.cpp]"]
  node_entry["Runtime entry<br/>[entry.cpp]"]
  node_jni_hooks["Fork hooks<br/>[jni_hooks.cpp]"]
end

subgraph group_modules["Module runtime"]
  node_module_api["Module API<br/>[riru.h]"]
  node_module_manager["Module manager<br/>[module.cpp]"]
  node_module_callbacks["Lifecycle callbacks<br/>[jni_hooks.cpp]"]
  node_hide_manager["Hide support<br/>[hide_utils.cpp]"]
  node_hide_memory["Memory anonymizer<br/>[hide.cpp]"]
end

subgraph group_daemon["Daemon services"]
  node_daemon["Riru daemon<br/>[Daemon.java]"]
  node_socket_server["Socket server"]
  node_daemon_utils["Daemon utilities<br/>[DaemonUtils.java]"]
  node_socket_client["Native socket client<br/>[rirud.cpp]"]
end

subgraph group_platform["Platform integration"]
  node_magisk["Magisk integration<br/>[magisk.cpp]"]
  node_elf_utils["ELF utilities<br/>[elf_util.cpp]"]
  node_android_props["Android properties<br/>[android_prop.cpp]"]
  node_selinux_api["SELinux access<br/>[SELinux.java]"]
  node_system_properties["System properties"]
end

node_android(("Android system"))
node_zygote(("Zygote"))

node_android -->|"starts"| node_zygote
node_zygote -->|"loads bridge"| node_native_bridge
node_native_bridge -->|"loads library"| node_loader
node_loader -.->|"enters runtime"| node_entry
node_entry -->|"installs hooks"| node_jni_hooks
node_entry -->|"loads modules"| node_module_manager
node_jni_hooks -->|"dispatches callbacks"| node_module_callbacks
node_module_manager -->|"uses API"| node_module_api
node_jni_hooks -->|"iterates modules"| node_module_manager
node_module_manager -->|"configures hiding"| node_hide_manager
node_hide_manager -.->|"anonymizes memory"| node_hide_memory
node_daemon -->|"starts thread"| node_socket_server
node_daemon -->|"checks status"| node_daemon_utils
node_socket_server -->|"handles requests"| node_daemon_utils
node_socket_client -.->|"exchanges data"| node_socket_server
node_module_manager -.->|"requests module data"| node_socket_client
node_daemon_utils -->|"checks access"| node_selinux_api
node_daemon_utils -->|"reads properties"| node_system_properties
node_module_manager -->|"uses Magisk paths"| node_magisk
node_loader -.->|"resolves ELF"| node_elf_utils
node_daemon -.->|"sets bridge property"| node_android_props

click node_loader "https://github.com/caremeos-dev/caremeriru/blob/master/riru/src/main/cpp/loader/loader.cpp"
click node_entry "https://github.com/caremeos-dev/caremeriru/blob/master/riru/src/main/cpp/entry.cpp"
click node_jni_hooks "https://github.com/caremeos-dev/caremeriru/blob/master/riru/src/main/cpp/jni_hooks.cpp"
click node_module_api "https://github.com/caremeos-dev/caremeriru/blob/master/riru/src/main/cpp/include_riru/riru.h"
click node_module_manager "https://github.com/caremeos-dev/caremeriru/blob/master/riru/src/main/cpp/module.cpp"
click node_module_callbacks "https://github.com/caremeos-dev/caremeriru/blob/master/riru/src/main/cpp/jni_hooks.cpp"
click node_hide_manager "https://github.com/caremeos-dev/caremeriru/blob/master/riru/src/main/cpp/hide_utils.cpp"
click node_hide_memory "https://github.com/caremeos-dev/caremeriru/blob/master/riru/src/main/cpp/hide/hide.cpp"
click node_daemon "https://github.com/caremeos-dev/caremeriru/blob/master/rirud/src/main/java/riru/Daemon.java"
click node_socket_server "https://github.com/caremeos-dev/caremeriru/blob/master/rirud/src/main/java/riru/DaemonSocketServerThread.java"
click node_daemon_utils "https://github.com/caremeos-dev/caremeriru/blob/master/rirud/src/main/java/riru/DaemonUtils.java"
click node_socket_client "https://github.com/caremeos-dev/caremeriru/blob/master/riru/src/main/cpp/util/rirud.cpp"
click node_magisk "https://github.com/caremeos-dev/caremeriru/blob/master/riru/src/main/cpp/magisk.cpp"
click node_elf_utils "https://github.com/caremeos-dev/caremeriru/blob/master/riru/src/main/cpp/util/elf_util.cpp"
click node_android_props "https://github.com/caremeos-dev/caremeriru/blob/master/riru/src/main/cpp/util/android_prop.cpp"
click node_selinux_api "https://github.com/caremeos-dev/caremeriru/blob/master/stub/src/main/java/android/os/SELinux.java"
click node_system_properties "https://github.com/caremeos-dev/caremeriru/blob/master/stub/src/main/java/android/os/SystemProperties.java"

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_native_bridge,node_loader,node_entry,node_jni_hooks toneBlue
class node_module_api,node_module_manager,node_module_callbacks,node_hide_manager,node_hide_memory toneAmber
class node_daemon,node_socket_server,node_daemon_utils,node_socket_client toneMint
class node_magisk,node_elf_utils,node_android_props,node_selinux_api,node_system_properties toneRose
class node_android,node_zygote toneIndigo
```

## Components

### Injection runtime

- **Native bridge**
- [Bridge loader](https://github.com/caremeos-dev/caremeriru/blob/master/riru/src/main/cpp/loader/loader.cpp): `riru/src/main/cpp/loader/loader.cpp`
- [Runtime entry](https://github.com/caremeos-dev/caremeriru/blob/master/riru/src/main/cpp/entry.cpp): `riru/src/main/cpp/entry.cpp`
- [Fork hooks](https://github.com/caremeos-dev/caremeriru/blob/master/riru/src/main/cpp/jni_hooks.cpp): `riru/src/main/cpp/jni_hooks.cpp`

### Module runtime

- [Module API](https://github.com/caremeos-dev/caremeriru/blob/master/riru/src/main/cpp/include_riru/riru.h): `riru/src/main/cpp/include_riru/riru.h`
- [Module manager](https://github.com/caremeos-dev/caremeriru/blob/master/riru/src/main/cpp/module.cpp): `riru/src/main/cpp/module.cpp`
- [Lifecycle callbacks](https://github.com/caremeos-dev/caremeriru/blob/master/riru/src/main/cpp/jni_hooks.cpp): `riru/src/main/cpp/jni_hooks.cpp`
- [Hide support](https://github.com/caremeos-dev/caremeriru/blob/master/riru/src/main/cpp/hide_utils.cpp): `riru/src/main/cpp/hide_utils.cpp`
- [Memory anonymizer](https://github.com/caremeos-dev/caremeriru/blob/master/riru/src/main/cpp/hide/hide.cpp): `riru/src/main/cpp/hide/hide.cpp`

### Daemon services

- [Riru daemon](https://github.com/caremeos-dev/caremeriru/blob/master/rirud/src/main/java/riru/Daemon.java): `rirud/src/main/java/riru/Daemon.java`
- [Socket server](https://github.com/caremeos-dev/caremeriru/blob/master/rirud/src/main/java/riru/DaemonSocketServerThread.java): `rirud/src/main/java/riru/DaemonSocketServerThread.java`
- [Daemon utilities](https://github.com/caremeos-dev/caremeriru/blob/master/rirud/src/main/java/riru/DaemonUtils.java): `rirud/src/main/java/riru/DaemonUtils.java`
- [Native socket client](https://github.com/caremeos-dev/caremeriru/blob/master/riru/src/main/cpp/util/rirud.cpp): `riru/src/main/cpp/util/rirud.cpp`

### Platform integration

- [Magisk integration](https://github.com/caremeos-dev/caremeriru/blob/master/riru/src/main/cpp/magisk.cpp): `riru/src/main/cpp/magisk.cpp`
- [ELF utilities](https://github.com/caremeos-dev/caremeriru/blob/master/riru/src/main/cpp/util/elf_util.cpp): `riru/src/main/cpp/util/elf_util.cpp`
- [Android properties](https://github.com/caremeos-dev/caremeriru/blob/master/riru/src/main/cpp/util/android_prop.cpp): `riru/src/main/cpp/util/android_prop.cpp`
- [SELinux access](https://github.com/caremeos-dev/caremeriru/blob/master/stub/src/main/java/android/os/SELinux.java): `stub/src/main/java/android/os/SELinux.java`
- [System properties](https://github.com/caremeos-dev/caremeriru/blob/master/stub/src/main/java/android/os/SystemProperties.java): `stub/src/main/java/android/os/SystemProperties.java`

### Other components

- **Android system**
- **Zygote**

## Connections

- Android system → Zygote: starts
- Zygote → Native bridge: loads bridge
- Native bridge → Bridge loader: loads library
- Bridge loader → Runtime entry: enters runtime
- Runtime entry → Fork hooks: installs hooks (evidence: `riru/src/main/cpp/entry.cpp`)
- Runtime entry → Module manager: loads modules (evidence: `riru/src/main/cpp/entry.cpp`)
- Fork hooks → Lifecycle callbacks: dispatches callbacks (evidence: `riru/src/main/cpp/jni_hooks.cpp`)
- Module manager → Module API: uses API (evidence: `riru/src/main/cpp/module.cpp`)
- Fork hooks → Module manager: iterates modules (evidence: `riru/src/main/cpp/jni_hooks.cpp`)
- Module manager → Hide support: configures hiding (evidence: `riru/src/main/cpp/module.cpp`)
- Hide support → Memory anonymizer: anonymizes memory
- Riru daemon → Socket server: starts thread (evidence: `rirud/src/main/java/riru/Daemon.java`)
- Riru daemon → Daemon utilities: checks status (evidence: `rirud/src/main/java/riru/Daemon.java`)
- Socket server → Daemon utilities: handles requests (evidence: `rirud/src/main/java/riru/DaemonSocketServerThread.java`)
- Native socket client → Socket server: exchanges data
- Module manager → Native socket client: requests module data
- Daemon utilities → SELinux access: checks access (evidence: `rirud/src/main/java/riru/DaemonUtils.java`)
- Daemon utilities → System properties: reads properties (evidence: `rirud/src/main/java/riru/DaemonUtils.java`)
- Module manager → Magisk integration: uses Magisk paths (evidence: `riru/src/main/cpp/module.cpp`)
- Bridge loader → ELF utilities: resolves ELF
- Riru daemon → Android properties: sets bridge property
