Riru Documentation

repository·master·Indexed 26 days ago

https://github.com/rikkaapps/riru

A tool for injecting into the zygote process to allow modules to run code within apps or the system server on Android 6.0+ devices rooted with Magisk. Now deprecated in favor of Zygisk. Includes technical details on the RirudSocket interface for communicating with the Rirud daemon, DirIter for directory iteration, and installation requirements.

Tokens
834
Snippets
0
Records
8
Agent score
90%

What's inside Riru

  1. Install Riru

    master

    Riru requires Android 6.0+ devices rooted with Magisk. You can install it using one of two methods:

    Method 1: Via Magisk Manager

    1. Search for "Riru" in Magisk Manager.
    2. Install the module named "Riru".

    Method 2: Manual Installation

    1. Download the zip file from the Riru GitHub releases.
    2. Open Magisk Manager.
    3. Go to Modules -> Install from storage.
    4. Select the downloaded zip file.
  2. Riru Installation Requirements and Troubleshooting

    master

    When installing Riru or Riru modules, be aware of these critical constraints:

    • Recovery Installation: Installing Riru from a custom recovery (like TWRP) is NOT supported. Many recovery implementations are broken, which can result in Riru appearing to be installed but failing to function.
    • SELinux Issues: Riru may fail to work if your third-party ROM has incorrect SELinux rules. Detailed information on this can be found in the Riru wiki.
    • Module Versioning: Modules designed for Riru API v24 or higher do not require mounting files to /system anymore; they load .so files directly from the Magisk path (/sbin or /dev).
  3. Troubleshoot Riru installation issues

    master

    If Riru is not working, check for the following common problems:

    • Incorrect SELinux rules: Some third-party ROMs have incorrect SELinux rules that prevent Riru from functioning.
    • Conflicting modules: Riru will not work if you have modules installed that change the ro.dalvik.vm.native.bridge property (e.g., certain
  4. Riru Compatibility and Limitations

    master

    Riru injects into the zygote to allow modules to run code within apps or the system server. Note the following limitations:

    • Native Bridge Conflict: If you use modules that change the ro.dalvik.vm.native.bridge property (often found in
  5. Iterate through directories with DirIter

    master

    The DirIter class, obtained via RirudSocket::ReadDir, allows you to iterate over files in a directory using an iterator-like pattern.

    • Use operator bool() to check if there are more entries (returns true if a path was successfully read).
    • Use operator++() to advance to the next entry.
    • Use operator*() to get the current entry as a std::string_view.
  6. Communicate with Rirud using RirudSocket

    master

    The RirudSocket class provides the primary interface for communicating with the Rirud daemon. It allows for reading files, reading directories, and performing raw binary reads/writes.

    Key methods:

    • ReadFile(std::string_view path): Reads the content of a file at the specified path.
    • ReadDir(std::string_view path): Returns a DirIter object to iterate over the contents of a directory.
    • ReadMagiskTmpfsPath(): Returns the Magisk tmpfs path.
    • ReadNativeBridge(): Returns the native bridge path.
    • Read(T &obj): Reads a fundamental type or enum from the socket.
    • Write(const T &obj): Writes a fundamental type or enum to the socket.
    • Write(std::string_view str): Writes a string to the socket.
  7. RirudSocket Action and Code Enums

    master

    The following enums define the communication protocol constants used by RirudSocket:

    Action (uint32_t):

    • READ_FILE = 4
    • READ_DIR = 5
    • WRITE_STATUS = 2 (Internal use)
    • READ_NATIVE_BRIDGE = 3 (Internal use)
    • READ_MAGISK_TMPFS_PATH = 6 (Internal use)
    • READ_MODULES = 7

    CODE (uint8_t):

    • OK = 0
    • FAILED = 1