A Trio-based async wrapper around Frida that can inject memory patches (currently just "reduce fog density") into RWR and exposes a Quart web interface.
FRIDRWR is a live memory-patcher for Running With Rifles (rwr_game.exe), a 32-bit PC game. It uses Frida to attach to the running game process, inject JavaScript agents, and rewrite specific machine-code bytes to change the game's behavior.
A Quart-Trio webserver runs alongside it on 127.0.0.1:5000 so the user can (eventually) see status / control patches from a browser.
- Runs under
trio.run(no asyncio anywhere). - Opens one top-level nursery with two long-lived tasks (
fridrwr.py:100-102):fridrwr_setup- polls every 15 s forrwr_game.exe; when it finds it, attaches Frida and applies patches.hypercorn.trio.serve(app, …)- the Quart-Trio webserver.
- On Ctrl-C,
trio.Cancelledpropagates down and patches get unapplied so the game doesn't segfault on now-dangling code-cave addresses it was jumping into (fridrwr.py:86-95).
- Searches the game for a specific x87 FPU byte pattern
(
D9 44 24 08 D9 59 4C D9 44 24 04 D9 59 50) - four floating-point loads/stores that configure the game's fog range/offset. - Rewrites them to load 600.0 (range) and -100.0 (offset) from Frida-allocated memory instead of whatever the game would normally compute. Effect: reduce the fog density globally.
fridare/__init__.py- constructs the singletonFridAsyncinstance (fa) and the Quart-Trio app (app); wires Pint / db / routes / filters.fridare/routes.py- two read-only web views:/(index) and/fridrwr(shows the RWR session status).fridare/fridasync/- the heart of it. A thin async wrapper around Frida's sync Python API:fridasync.py-FridAsynckeeps adict[target_name → FAsyncSession]and doesfrida.attachoff-thread viatrio.to_thread.run_sync.session.py- wrapsfrida.core.Session; on init, loads_fridasync.js(utility RPCs: arch, pid, heap size, module lookup,Memory.scanSync, etc.) and caches target process info.script.py/patcher.py-FAsyncScriptwrapsfrida.core.Script;FAsyncPatcherScriptaddsapply()/clear()that call into the injected JS'srpc.exports.patcher.py:61-105-PatchBuilderrenders two Jinja JS templates (jmp_patch.js,nop_patch.js) into per-patch script sources with the user's target pattern, vars, and custom code-writer function stitched in.
patch.js- basePatchclass: scans the target module's memory fortarget_pattern, enforces it matches exactly once, snapshots original bytes, allocates memory for patch-local variables.jmp_patch.js-JmpPatchsubclass: allocates RWX scratch memory, runs the caller-suppliedcw_patch_functo fill it with replacement code via Frida'sX86Writer, appends ajmpback to the target, then overwrites the match site with a 5-byte jmp + NOP sled so the game's original flow detours through your code.clear()restores the original bytes.nop_patch.js-NopPatch: simpler variant that just NOPsnop_lengthbytes atnop_offsetinto the match;clear()restores.