All pages

docs/how-it-works.md

How it works

How it works

For the technically curious, and for server owners deciding whether to allow it.

The plugin hooks one game function, registerRawStreamingFile, the same routine FiveM uses to register loose and server-streamed files. The byte pattern that locates it comes from Cfx's open source tree (gta-streaming-five/src/Streaming.cpp).

It hooks the game module (GTA5.exe) only, never FiveM's own DLLs. FiveM checks its own components against a manifest and stops with a fatal error if one has been changed, so patching FiveM's code is off the table. A hook in the game module is the same surface trainers and PackfileLimitAdjuster.asi use, and it survives full connected sessions. The plugin does subscribe to a few of FiveM's published events (once a frame, first load finished, and for hide_overlay the frame-end drawing event), but that adds an entry to a list and changes no FiveM code.

Base freemode clothing lives inside x64v.rpf and never passes through that function, so waiting to intercept it would wait forever. Instead the plugin calls registerRawStreamingFile itself and registers your loose file under the base slot name. If the game rejects that call because the slot already owns a handle, the plugin locates the slot through its actual streaming module and attaches the local pgRawStreamer handle directly, matching FiveM's occupied-slot mechanism. It does not use FiveM's diagnostic name map because that map omits base-RPF names.

That claim alone is not enough: a streaming slot maps name → id → handle, and whoever writes the handle last owns the slot. Vanilla DLC mounts re-point claimed slots when they load, and FiveM's loader overwrites handles of already-registered slots directly, without calling the hooked function at all. So the plugin remembers the handle its claim produced and re-asserts it once a second: if anything re-pointed the slot, it writes its own handle back. Last writer wins, and the plugin is always the last writer. This is the same handle-overwrite mechanism Cfx's own override path uses in LoadStreamingFile.cpp; the plugin just repeats it. Streamed files that pass through the hook under a claimed name are also redirected to the local file on an exact collection/file match.

Bare-name .ytd files at the root of tex_overrides are registered the same way, under the file name alone. This is the same trust model as a server stream/ folder: an exact-name match replaces exactly that texture dictionary and nothing else.

Tattoo placement works on data, not code. The game parses each overlays.xml into its PedDecorationManager. The plugin locates that manager with the pattern Cfx itself publishes (PatchTattooSort.cpp) and rewrites the position floats of the presets you edited. It never hardcodes struct offsets. Instead it fingerprints your file's preset name hashes and unedited values against memory, and writes only after at least 70% of the presets match exactly. Applied values are re-asserted once a second, like the handles.

The hook is installed without suspending any threads, and the timing is what makes that safe: FiveM loads .asi plugins in LauncherInterface::PostLoadGame, before the game's entry point has ever run, so no thread can be executing game code during the patch. FiveM applies its own startup patches in the same window for the same reason. MinHook's usual thread-freeze step cannot work under FiveM anyway, since CreateToolhelp32Snapshot is blocked. The vendored copy has that code removed rather than skipped, and the comment at the top of minhook/src/hook.c explains why.

The path handed to the game is a plain absolute path, which FiveM's VFS opens without complaint. The game reads the whole resource from your file (header, page flags, data), so there is no size or flag mismatch to manage.

The plugin makes exactly one network request: at startup it asks GitHub for the newest release number (see Update check). Nothing else is transmitted anywhere, and nothing is ever sent to the game server. The plugin reads a local folder and changes what your client draws. Other players keep seeing whatever the server streams.

Why FiveM allows this

The plugin loads because FiveM's own loader is built to load third-party ASIs, not to block them. Four things from Cfx's own source and docs, strongest first:

All four settle one question: whether a plugin is allowed to load. None of them say anything about what a plugin does in memory once loaded. That is a separate question, covered honestly in Ban risk, stated plainly below.

Back to the README