|
| 1 | +# LuaExMemoryTool |
| 2 | + |
| 3 | +The LuaExMemoryTool is a Rust-based executable that allows running Lua scripts for **external process memory access and manipulation** on Linux and Android systems. |
| 4 | +It uses the **mlua** library to embed Lua and exposes additional native functions for process and memory operations. |
| 5 | + |
| 6 | +> Root access is required. |
| 7 | +
|
| 8 | +## Overview |
| 9 | + |
| 10 | +The project compiles into a standalone executable. |
| 11 | +You provide a `.lua` file path as an argument, and the executable runs that Lua script with extended memory-related APIs. |
| 12 | + |
| 13 | +Supported platforms: |
| 14 | +- Linux |
| 15 | +- Android |
| 16 | + |
| 17 | +## Build |
| 18 | + |
| 19 | +This is a standard Rust project. |
| 20 | + |
| 21 | +Requirements: |
| 22 | +- Rust toolchain |
| 23 | +- Cargo |
| 24 | + |
| 25 | +Build command: |
| 26 | +```bash |
| 27 | +cargo build --release |
| 28 | +```` |
| 29 | + |
| 30 | +The resulting executable will be located under: |
| 31 | + |
| 32 | +``` |
| 33 | +target/release/ |
| 34 | +``` |
| 35 | +
|
| 36 | +## Usage |
| 37 | +
|
| 38 | +Run the executable and pass a Lua script path: |
| 39 | +
|
| 40 | +```bash |
| 41 | +./LuaExMemoryTool script.lua |
| 42 | +``` |
| 43 | + |
| 44 | +Example Lua scripts are provided in the `examples/` directory. |
| 45 | + |
| 46 | +## Lua API |
| 47 | + |
| 48 | +### Process List |
| 49 | + |
| 50 | +Retrieve the list of currently running processes: |
| 51 | + |
| 52 | +```lua |
| 53 | +for _, item in ipairs(get_process_list()) do |
| 54 | + local pid = item.pid |
| 55 | + local package_name = item.name |
| 56 | +end |
| 57 | +``` |
| 58 | + |
| 59 | +Aliases: |
| 60 | + |
| 61 | +* `get_process_list` |
| 62 | +* `process_list` |
| 63 | + |
| 64 | +Each item contains: |
| 65 | + |
| 66 | +* `pid`: number |
| 67 | +* `name`: string |
| 68 | + |
| 69 | +### Kill Process |
| 70 | + |
| 71 | +Terminate a process by PID: |
| 72 | + |
| 73 | +```lua |
| 74 | +kill_process(pid) |
| 75 | +``` |
| 76 | + |
| 77 | +--- |
| 78 | + |
| 79 | +### `process` Class |
| 80 | + |
| 81 | +Used to initialize and manage a target process. |
| 82 | + |
| 83 | +#### Initialization |
| 84 | + |
| 85 | +Initialize by package name: |
| 86 | + |
| 87 | +```lua |
| 88 | +process = process.init("package_name") |
| 89 | +``` |
| 90 | + |
| 91 | +Initialize by PID: |
| 92 | + |
| 93 | +```lua |
| 94 | +process = process.init_via_pid(pid) |
| 95 | +``` |
| 96 | + |
| 97 | +Fields: |
| 98 | + |
| 99 | +* `pid`: number |
| 100 | +* `name`: string |
| 101 | + |
| 102 | +#### Memory Maps |
| 103 | + |
| 104 | +Retrieve memory mappings of the process: |
| 105 | + |
| 106 | +```lua |
| 107 | +for map in process:get_maps() do |
| 108 | + -- ... |
| 109 | +end |
| 110 | +``` |
| 111 | + |
| 112 | +Each map entry contains: |
| 113 | + |
| 114 | +* `start`: number |
| 115 | +* `end`: number |
| 116 | +* `perms`: string |
| 117 | +* `offset`: number |
| 118 | +* `dev`: string |
| 119 | +* `inode`: number |
| 120 | +* `path`: string |
| 121 | + |
| 122 | +--- |
| 123 | + |
| 124 | +### `memory` Class |
| 125 | + |
| 126 | +Used to read and write process memory. |
| 127 | + |
| 128 | +#### Initialization |
| 129 | + |
| 130 | +```lua |
| 131 | +process = process.init("package_name") |
| 132 | +memory = memory.init(process) |
| 133 | +``` |
| 134 | + |
| 135 | +#### Read / Write Methods |
| 136 | + |
| 137 | +Read methods require only an address. |
| 138 | +Write methods require an address and a value. |
| 139 | + |
| 140 | +Supported methods: |
| 141 | + |
| 142 | +* `read_i8(address)` / `write_i8(address, value)` |
| 143 | +* `read_bool(address)` / `write_bool(address, value)` |
| 144 | +* `read_i16(address)` / `write_i16(address, value)` |
| 145 | +* `read_i32(address)` / `write_i32(address, value)` |
| 146 | +* `read_i64(address)` / `write_i64(address, value)` |
| 147 | +* `read_float(address)` / `write_float(address, value)` |
| 148 | +* `read_float64(address)` / `write_float64(address, value)` |
| 149 | +* `read_pointer(address)` / `write_pointer(address, value)` |
| 150 | +* `read_hex(address, length)` |
| 151 | +* `write_hex(address, hex_string)` |
| 152 | + |
| 153 | +## Examples |
| 154 | + |
| 155 | +Example Lua scripts are available in the `examples/` directory and demonstrate: |
| 156 | + |
| 157 | +* Process listing |
| 158 | +* Process initialization |
| 159 | +* Memory map inspection |
| 160 | +* Memory read/write operations |
| 161 | + |
| 162 | +## License |
| 163 | + |
| 164 | +MIT License |
0 commit comments