Skip to content

Native plugins

A native plugin is a .dll (.so on Linux) with new code for the game: a frame counter, a new rule, a fix. A mod profile lists it under [[natives]].

A plugin is a program

It runs on your PC with your rights, like any program, and can read, change or delete your files. Allow a plugin only from people you trust. Online play is off while one is loaded.

Allowing a plugin

A plugin loads only after you allow that file. The Mods screen lists the profile's plugins under Plugins, each with where it stands: not allowed yet, allowed (it loads after a restart), running, changed since it was allowed, or not there.

Select one that isn't allowed: a warning asks first, and I trust it allows it. Select an allowed one to stop allowing it. Then Restart now.

A changed file must be allowed again: its row says so. What you allowed is kept in plugins_allowed.txt in the data folder, one line per plugin (<SHA-256> <file name>).

Writing a plugin

At start, once the game's program is in memory and before any of its code runs, the game calls the plugin's des_plugin_init with a table of functions. The interface is port/plugin/des_plugin.h in the source. Through it a plugin:

  • finds a game function's native code by its PS3 address (find);
  • hooks it, keeping the original callable (hook, unhook);
  • reads and writes the PS3's memory (guest) and a hooked function's registers (gpr, fpr);
  • gets a call each frame (on_frame), and writes log lines (log).

The table says which disc runs (disc): addresses are per disc, so a plugin for one disc does nothing on another.

A sample, port/plugin/sample/sample_plugin.c, logs each character sound bank the game loads.

Limits

  • A small game function the compiler copied into its callers isn't called there, so a hook on it misses those callers.
  • Hook in des_plugin_init, not later from another thread.
  • Windows and Linux on x86-64 only. A Mac doesn't load plugins: every other kind of mod works there.