# httpspycharmhelpers/virtualsu architecture

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

- Interactive diagram: https://gitdiagram.com/httpspycharmhelpers/virtualsu
- Repository: https://github.com/httpspycharmhelpers/virtualsu

## Overview

aFakeSU provides a user-space fake-root session on non-root Android: a `su -c` request starts a bundled shell under modified PRoot, which intercepts system calls and presents selected root-like identities, filesystem behavior, mount state, and SELinux labels. Its command wrappers and persistent workdir state support additional property, mount, and labeling operations. Shizuku/Rish can provide shell privileges, with current-user fallback. The README establishes several product-level links; sampled code confirms syscall dispatch and PRoot path/tracee structures, but not every wrapper or integration detail.

Main entry points: [`src/proot-termux/src/syscall/enter.c`](https://github.com/httpspycharmhelpers/virtualsu/blob/main/src/proot-termux/src/syscall/enter.c) (Syscall translation), [`src/su.c`](https://github.com/httpspycharmhelpers/virtualsu/blob/main/src/su.c) (Fake su launcher), [`src/proot-termux/src`](https://github.com/httpspycharmhelpers/virtualsu/tree/main/src/proot-termux/src) (PRoot runtime), [`src/proot-termux/src/tracee/event.c`](https://github.com/httpspycharmhelpers/virtualsu/blob/main/src/proot-termux/src/tracee/event.c) (Trace event loop)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_launch["Session launch"]
  node_su["Fake su launcher<br/>[su.c]"]
  node_wrappers["Command wrappers<br/>[su.c]"]
  node_bash["Bundled Bash<br/>[bash-5.3]"]
end

subgraph group_runtime["Emulated runtime"]
  node_proot["PRoot runtime"]
  node_eventloop["Trace event loop<br/>[event.c]"]
  node_syscalls["Syscall translation<br/>[enter.c]"]
  node_fakeid["Fake identity<br/>[fake_id0.c]"]
  node_exec["Exec translation<br/>[enter.c]"]
  node_bindings["Path bindings<br/>[binding.c]"]
  node_traceestate["Tracee state<br/>[tracee.h]"]
end

subgraph group_state["Virtualized state"]
  node_overlay["Filesystem overlay<br/>[enter.c]"]
  node_props[("Property state<br/>[su.c]")]
  node_mountstate["Mount state<br/>[enter.c]"]
  node_labels["SELinux labels<br/>[terhijack.c]"]
end

subgraph group_access["Shell access"]
  node_shizuku["Shizuku service"]
  node_rish["Rish shell loader"]
end

node_caller(("Shell caller"))

node_caller -->|"runs su command"| node_su
node_su -->|"starts runtime"| node_proot
node_su -->|"runs shell"| node_bash
node_su -->|"generates wrappers"| node_wrappers
node_wrappers -->|"persists properties"| node_props
node_eventloop -->|"dispatches syscalls"| node_syscalls
node_syscalls -->|"reads tracee state"| node_traceestate
node_syscalls -->|"redirects writes"| node_overlay
node_syscalls -->|"emulates mounts"| node_mountstate
node_syscalls -->|"translates paths"| node_bindings
node_syscalls -.->|"applies fake identity"| node_fakeid
node_proot -.->|"traces processes"| node_eventloop
node_proot -.->|"translates execution"| node_exec
node_exec -->|"uses path bindings"| node_bindings
node_su -->|"sets session context"| node_labels
node_caller -.->|"requests shell access"| node_rish
node_rish -->|"uses Shizuku API"| node_shizuku
node_shizuku -.->|"provides shell privilege"| node_su

click node_su "https://github.com/httpspycharmhelpers/virtualsu/blob/main/src/su.c"
click node_wrappers "https://github.com/httpspycharmhelpers/virtualsu/blob/main/src/su.c"
click node_bash "https://github.com/httpspycharmhelpers/virtualsu/tree/main/src/bash-5.3"
click node_proot "https://github.com/httpspycharmhelpers/virtualsu/tree/main/src/proot-termux/src"
click node_eventloop "https://github.com/httpspycharmhelpers/virtualsu/blob/main/src/proot-termux/src/tracee/event.c"
click node_syscalls "https://github.com/httpspycharmhelpers/virtualsu/blob/main/src/proot-termux/src/syscall/enter.c"
click node_fakeid "https://github.com/httpspycharmhelpers/virtualsu/blob/main/src/proot-termux/src/extension/fake_id0/fake_id0.c"
click node_exec "https://github.com/httpspycharmhelpers/virtualsu/blob/main/src/proot-termux/src/execve/enter.c"
click node_bindings "https://github.com/httpspycharmhelpers/virtualsu/blob/main/src/proot-termux/src/path/binding.c"
click node_traceestate "https://github.com/httpspycharmhelpers/virtualsu/blob/main/src/proot-termux/src/tracee/tracee.h"
click node_overlay "https://github.com/httpspycharmhelpers/virtualsu/blob/main/src/proot-termux/src/syscall/enter.c"
click node_props "https://github.com/httpspycharmhelpers/virtualsu/blob/main/src/su.c"
click node_mountstate "https://github.com/httpspycharmhelpers/virtualsu/blob/main/src/proot-termux/src/syscall/enter.c"
click node_labels "https://github.com/httpspycharmhelpers/virtualsu/blob/main/src/terhijack.c"
click node_shizuku "https://github.com/httpspycharmhelpers/virtualsu/blob/main/src/shizuku_ref/ShizukuService.java"
click node_rish "https://github.com/httpspycharmhelpers/virtualsu/blob/main/rish_src_cfr/rikka/shizuku/shell/ShizukuShellLoader.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_su,node_wrappers,node_bash toneBlue
class node_proot,node_eventloop,node_syscalls,node_fakeid,node_exec,node_bindings,node_traceestate toneAmber
class node_overlay,node_props,node_mountstate,node_labels toneMint
class node_shizuku,node_rish toneRose
class node_caller toneIndigo
```

## Components

### Session launch

- [Fake su launcher](https://github.com/httpspycharmhelpers/virtualsu/blob/main/src/su.c): `src/su.c`
- [Command wrappers](https://github.com/httpspycharmhelpers/virtualsu/blob/main/src/su.c): `src/su.c`
- [Bundled Bash](https://github.com/httpspycharmhelpers/virtualsu/tree/main/src/bash-5.3): `src/bash-5.3`

### Emulated runtime

- [PRoot runtime](https://github.com/httpspycharmhelpers/virtualsu/tree/main/src/proot-termux/src): `src/proot-termux/src`
- [Trace event loop](https://github.com/httpspycharmhelpers/virtualsu/blob/main/src/proot-termux/src/tracee/event.c): `src/proot-termux/src/tracee/event.c`
- [Syscall translation](https://github.com/httpspycharmhelpers/virtualsu/blob/main/src/proot-termux/src/syscall/enter.c): `src/proot-termux/src/syscall/enter.c`
- [Fake identity](https://github.com/httpspycharmhelpers/virtualsu/blob/main/src/proot-termux/src/extension/fake_id0/fake_id0.c): `src/proot-termux/src/extension/fake_id0/fake_id0.c`
- [Exec translation](https://github.com/httpspycharmhelpers/virtualsu/blob/main/src/proot-termux/src/execve/enter.c): `src/proot-termux/src/execve/enter.c`
- [Path bindings](https://github.com/httpspycharmhelpers/virtualsu/blob/main/src/proot-termux/src/path/binding.c): `src/proot-termux/src/path/binding.c`
- [Tracee state](https://github.com/httpspycharmhelpers/virtualsu/blob/main/src/proot-termux/src/tracee/tracee.h): `src/proot-termux/src/tracee/tracee.h`

### Virtualized state

- [Filesystem overlay](https://github.com/httpspycharmhelpers/virtualsu/blob/main/src/proot-termux/src/syscall/enter.c): `src/proot-termux/src/syscall/enter.c`
- [Property state](https://github.com/httpspycharmhelpers/virtualsu/blob/main/src/su.c): `src/su.c`
- [Mount state](https://github.com/httpspycharmhelpers/virtualsu/blob/main/src/proot-termux/src/syscall/enter.c): `src/proot-termux/src/syscall/enter.c`
- [SELinux labels](https://github.com/httpspycharmhelpers/virtualsu/blob/main/src/terhijack.c): `src/terhijack.c`

### Shell access

- [Shizuku service](https://github.com/httpspycharmhelpers/virtualsu/blob/main/src/shizuku_ref/ShizukuService.java): `src/shizuku_ref/ShizukuService.java`
- [Rish shell loader](https://github.com/httpspycharmhelpers/virtualsu/blob/main/rish_src_cfr/rikka/shizuku/shell/ShizukuShellLoader.java): `rish_src_cfr/rikka/shizuku/shell/ShizukuShellLoader.java`

### Other components

- **Shell caller**

## Connections

- Shell caller → Fake su launcher: runs su command
- Fake su launcher → PRoot runtime: starts runtime (evidence: `src/su.c`)
- Fake su launcher → Bundled Bash: runs shell
- Fake su launcher → Command wrappers: generates wrappers (evidence: `src/su.c`)
- Command wrappers → Property state: persists properties (evidence: `src/su.c`)
- Trace event loop → Syscall translation: dispatches syscalls (evidence: `src/proot-termux/src/tracee/event.c`)
- Syscall translation → Tracee state: reads tracee state (evidence: `src/proot-termux/src/syscall/enter.c`)
- Syscall translation → Filesystem overlay: redirects writes (evidence: `src/proot-termux/src/syscall/enter.c`)
- Syscall translation → Mount state: emulates mounts (evidence: `src/proot-termux/src/syscall/enter.c`)
- Syscall translation → Path bindings: translates paths (evidence: `src/proot-termux/src/syscall/enter.c`)
- Syscall translation → Fake identity: applies fake identity
- PRoot runtime → Trace event loop: traces processes (evidence: `src/proot-termux/src/tracee/event.c`)
- PRoot runtime → Exec translation: translates execution (evidence: `src/proot-termux/src/execve/enter.c`)
- Exec translation → Path bindings: uses path bindings (evidence: `src/proot-termux/src/execve/enter.c`)
- Fake su launcher → SELinux labels: sets session context
- Shell caller → Rish shell loader: requests shell access
- Rish shell loader → Shizuku service: uses Shizuku API (evidence: `rish_src_cfr/rikka/shizuku/shell/ShizukuShellLoader.java`)
- Shizuku service → Fake su launcher: provides shell privilege
