Skip to content

Manifest reference

A plugin folder has up to three TOML files: plugin.toml (required), symbols.toml and settings.toml. All three are strict: an unknown key is an error and the plugin is skipped, with the file and line in the log. anvil check reports the same errors before you ship. From Anvil 1.20 a plugin may also carry translations of its texts, which never make Anvil skip it.

Real files: the hello examples, the template and the plugins in the Plugins page.

From Anvil 1.12, a plugin.toml over 1 MB, or a symbols.toml or settings.toml over 16 MB, is not read.

id = "my-plugin" # [a-z0-9-]+, max 64 characters, unique
name = "My Plugin"
version = "1.0.0" # SemVer
authors = ["Your Name"]
description = "One sentence about the plugin."
api = 2 # plugin API major version
anvil = ">=1.0.0" # Anvil versions the plugin needs
entry = "my_plugin.dll" # DLL file name inside the plugin folder
phase = "main" # "early" or "main"
symbols = "symbols.toml" # game addresses; its build limits the plugin to it
settings = "settings.toml" # what the player can change
affects_gameplay = false # required: true if the plugin may change the simulation
allow_ironman = false # false or "opt-in"
allow_multiplayer = false # false or "opt-in"
load_after = [] # ordering only, not a dependency
issues = "https://github.com/you/my-plugin/issues" # shown in crash reports
repository = "https://github.com/you/my-plugin"
[[dependencies]] # zero or more
id = "anvil-game"
version = "^1"
optional = false
[[conflicts]] # zero or more: this plugin is skipped while one is enabled
id = "other-plugin"
version = "<2"
Field Required Meaning
id yes Unique id, lowercase letters, digits and -, up to 64 characters. Also the folder name under anvil/data/.
name yes Display name.
version yes Plugin version, SemVer.
authors no List of authors.
description no One sentence about the plugin.
api yes Plugin API major version: 2. Anvil 1.0 skips api = 1 plugins with plugin API 1: update the plugin.
anvil no SemVer range of Anvil versions, for example ">=1.0.0". An older Anvil skips the plugin with a log line.
entry yes File name of the plugin DLL inside the plugin folder.
phase no early or main (default); see Writing plugins.
symbols no The plugin’s symbols.toml. Without it the plugin uses no game addresses and loads on every game build.
settings no The plugin’s settings.toml.
affects_gameplay yes true if the plugin can change the state or results of the simulation. See Ironman and multiplayer.
allow_ironman, allow_multiplayer no false (default) or "opt-in": the player may allow the plugin in that mode.
load_after no Plugin ids to load before this one, if present. Ordering only.
issues no Where to report problems; shown with crash reports.
repository no The plugin’s source.
dependencies no Plugins this one needs; see Dependencies and conflicts.
conflicts no Plugins this one cannot run with.

game_builds and [[expect]] from API 1 are gone: symbols.toml replaces both.

Each [[dependencies]] entry has an id, a SemVer version range and an optional flag. Ranges are comparators joined by commas; ^, ~, =, >, >=, <, <= and * are supported.

  • A required dependency that is missing or out of range skips the plugin, and every plugin that depends on it.
  • An optional dependency is loaded first when present and is never required.
  • Plugins load in dependency order within each phase. A cycle, or an early plugin depending on a main plugin, skips the plugins involved.

A [[conflicts]] entry (id, version) skips the declaring plugin while a plugin with that id and a version in the range is enabled; the other one loads normally. The log says conflicts with <id> <version>; disable one of them.

A plugin with affects_gameplay = true depends on the standard plugin anvil-game without declaring it: only anvil-game tells Anvil about ironman and multiplayer sessions. In such a session Anvil suspends all changes of the plugin and puts them back when the session ends. The player can allow a plugin that offers "opt-in" in anvil/anvil.toml:

allow_ironman = ["my-plugin"]
allow_multiplayer = []

A session that is both ironman and multiplayer needs both.

From Anvil 1.22 a plugin can bundle features of different kinds as modules: parts of one plugin, each with its own switch for the player and its own gameplay flags. Without modules, one feature that changes the game makes the whole plugin a gameplay plugin, and Anvil suspends all of it in ironman, interface features included.

anvil = ">=1.22.0" # older Anvils skip a plugin with [[modules]]
affects_gameplay = false # the plugin's own handle: shared code, reads, services
[[modules]]
id = "ui_size_fix" # [a-z][a-z0-9_]*, at most 32 characters
name = "Large country views at a raised GUI scale"
description = "Optional, shown to the player."
affects_gameplay = false
[[modules]]
id = "drill_all"
name = "Drill all selected armies"
affects_gameplay = true # required, as for the plugin
allow_ironman = "opt-in" # false (default) or "opt-in"
allow_multiplayer = "opt-in"
default = true # on until the player chooses; default true
group = "Armies" # optional subheading (Anvil 1.23), translated like the rest

At most 32 modules; a module that does not affect gameplay offers no opt-in. The plugin acts for a module through its handle: host->module(self, "drill_all", &handle) in C, host.module("drill_all") in C++ (std::nullopt when the player turned it off), and Host::module in anvil-sdk 0.1.10. Every call that takes self takes the handle, so hooks, patches, event subscriptions and anvil-game.commands posts belong to the module. Settings, symbols, folders and services stay the plugin’s.

  • A module the player turned off answers ANVIL_ERROR_DISABLED and gives no handle, so its code never runs. An undeclared one answers ANVIL_ERROR_NOT_DECLARED.
  • Anvil suspends each module by its own flags in ironman and multiplayer, and only its subscriptions get anvil.suspended.
  • The player names a module <plugin>.<module> in anvil/anvil.toml, or switches it in the Manager’s Plugins page. A choice applies at the next start:
disabled_modules = ["smithy.sharp_text"] # turns off a module (wins over enabled_modules)
enabled_modules = ["smithy.extra"] # turns on a module whose default is false
allow_ironman = ["smithy.drill_all"] # a module's opt-in, next to plugin ids
  • The multiplayer hash has a line <plugin>.<module> <version> for every gameplay module that acts, so two players with different gameplay modules see different hashes. From Anvil 1.23 the line also carries the values of the settings that count (see settings.toml).
  • The plugin depends on anvil-game implicitly when it or any module affects gameplay.

The design is Anvil’s ADR 0011.

Every address in eu4.exe that the plugin uses, declared once:

build = "eu4-1.37.5-steam-win64"
[symbol.speed_object] # a function
rva = 0x8024D0
sha256 = "AE4C23FB37CE181F11EF2E3EAF4BAC498572CD06FA1783BB0BBCFE0FE93A1407"
size = 8 # the digest covers the 8 bytes at rva
memory = "code" # code, read or write
signature = "void* (void* session)" # typed in C, C++ and Rust
note = "session vtable slot 0x100: returns the game-speed object"
[symbol.frontend_tick_slot] # a pointer slot, for swap_pointer
rva = 0x1D5A8E8
memory = "read"
points_to = 0x10D2E80
[symbol.root_and_date] # values read from the verified bytes
rva = 0x14321FC
sha256 = "1CB3A5F923B2390CEBF07440FFAC7742C7369FB6B8E4AE06E0DECBC38376D5D8"
size = 13
memory = "code"
values.root = { at = 3, rip_relative = 7, type = "Root", is = 0x233FE78 }
values.date_offset = { at = 9, size = 4, is = 0x1DD0 }
[symbol.physfs_get_write_dir] # by export name instead of RVA
export = "PHYSFS_getWriteDir"
signature = "const char* ()"
  • build is the one game build the plugin runs on. On any other build, or an unknown one, Anvil skips the plugin. For several builds see below.
  • A symbol is a function (signature), a pointer slot (points_to), data (type) or a site (none of them). signature, points_to and type exclude each other.
  • A symbol has exactly one of rva and export. One at an rva needs memory, and sha256 with size or points_to (a data symbol may have neither). For an export, sha256 and size are optional and check the prologue.
  • sha256 is the SHA-256 of the size bytes at the symbol, in hex, with every offset that any lists set to 0 before hashing; any lists offsets that are not compared. While you work you may write the expected bytes instead; see Digests instead of bytes.
  • A block for replace_block may name resume, another symbol where the game continues; the default is the end of the block.
  • A value has at (its offset in the symbol’s bytes) and either size (1, 2, 4 or 8) or rip_relative, the offset of the instruction’s end, which yields an RVA. is states the value the bytes must give: verification checks it, and anvil gen writes it as the constant. A value without is is read when the game loads.
  • Names match [a-z][a-z0-9_]*; they become identifiers in the generated headers.

Before loading the DLL, Anvil compares every symbol with the running game: the digest of its bytes (any offsets zeroed) and each is, the memory kind against the section, and points_to against the stored pointer. Bytes already changed by other plugins are compared in their original form, so two plugins can rely on the same function. On a mismatch the plugin is skipped with the symbol, the RVA and both digests in the log.

From Anvil 1.7, a file can declare more than one build, for example Steam and the GOG build 1.37.5.2. It lists them in builds instead of build and still declares each symbol once. What a symbol is stays shared; only where it is and what bytes it has (rva, sha256, size, any and points_to) may differ, in a build."<id>" table of the symbol:

builds = ["eu4-1.37.5-steam-win64", "eu4-1.37.5.2-gog-win64"]
[symbol.frame] # the same bytes, another address
sha256 = "6E06F5F68091C944A879D036CD67F041FAC7D1D1B62ADFF485C5EE3A90362A64"
size = 10
memory = "code"
signature = "uintptr_t (void* app, uint8_t outer)"
build."eu4-1.37.5-steam-win64" = { rva = 0x14C25A0 }
build."eu4-1.37.5.2-gog-win64" = { rva = 0x14BC400 }
[symbol.speed_object] # other bytes: a table per build
memory = "code"
values.speed = { at = 3, size = 4 } # 0x418 on Steam, 0x408 on GOG: no is, read at load
[symbol.speed_object.build."eu4-1.37.5-steam-win64"]
rva = 0x8024D0
sha256 = "AE4C23FB37CE181F11EF2E3EAF4BAC498572CD06FA1783BB0BBCFE0FE93A1407"
size = 8
[symbol.speed_object.build."eu4-1.37.5.2-gog-win64"]
rva = 0x801850
sha256 = "8F07B1074C83410F33EBF37059EF5D88E560BD1B81DECD74D35506EC5408E384"
size = 8
  • Each of rva, sha256, size, any and points_to is given either for every build or per build, not both. Each build must pass the rules above on its own; an error names the build.
  • A symbol keeps its id in every build, so the plugin’s code does not change. Anvil uses the running game’s addresses, and a file that does not list the running build skips the plugin.
  • anvil gen writes a value as a constant only when every build has the same one; otherwise the plugin reads it when the game loads (symbol_value).
  • anvil check --exe checks the build of the eu4.exe it is given, so run it once per build. The lock then keeps one check per build.

From Anvil 1.9, a symbol may be missing from one of the builds a file lists, such as Steam code the GOG build does not have. absent names those builds; the symbol’s other keys apply to the builds it is in:

[symbol.lobby_close]
rva = 0x1658D50
sha256 = "621623B29226F30F5005D55F719BC15E2CBADAF7A1AEAFA0B1A2F71213541DD6"
size = 6
memory = "code"
signature = "void (void* lobby)"
absent = ["eu4-1.37.5.2-gog-win64"]
  • On an absent build the symbol is not checked and has no address: address_of returns NULL, and a hook or patch on it fails with ANVIL_ERROR_NOT_DECLARED. Check it before you use it: host->address_of(self, SYM_LOBBY_CLOSE) != NULL in C, host.present(sym::lobby_close) in C++.
  • absent needs builds, cannot list every build, and an absent build gets no build."<id>" table. A resume must name a symbol that is in every build its block is in.
  • Only the builds absent names are exempt: a symbol that does not verify on any other build still skips the plugin.
  • anvil check --exe lists the symbols absent on the exe’s build, and anvil gen names the absent builds in each symbol’s comment.
  • An older Anvil does not know the key and skips the plugin, so declare anvil = ">=1.9.0".

From Anvil 1.10 a symbol states the SHA-256 of its bytes, so your repository, zip and Workshop item hold no code of eu4.exe. The older key bytes writes the expected bytes out as hex pairs (?? for any byte); it stays valid for all of plugin API 2 and is the handy form while you work, but it copies pieces of the game into every file you share. Write it locally, for example:

[symbol.my_site]
rva = 0x123450
bytes = "40 53 ?? ?? 90 90" # an invented example, not the game's code
memory = "code"

and before you commit, run tools/symbols-to-digest.py on symbols.toml. It needs no game: it replaces each bytes with sha256, size and any (any = [2, 3] here) and writes is for each value that is the same in every build and does not lie on a ??; then run anvil check --exe once per build.

  • sha256, size and any are placement keys like bytes, shared or per build. bytes and sha256 exclude each other per placement.
  • A mismatch names both digests, not the first differing byte, and a port to another game build needs the old eu4.exe, because the repository no longer holds the pattern.
  • An older Anvil does not know the keys and skips the plugin, so declare anvil = ">=1.10.0".
  • Describe the game’s code in note and comments by its address and what it does, not by the names a debugger shows.

ADR 0003 has the reasons and the limits: a digest is not secrecy.

anvil check --exe writes symbols.lock next to plugin.toml: the SHA-256 of eu4.exe, a digest of symbols.toml, the build and the result. Commit it. Without the game, anvil check fails when the lock is missing, does not match symbols.toml, or says result = "problems", so CI catches a symbol that was never checked against the game.

What the player can change:

[setting.log_menu_returns]
type = "bool" # bool, int, float, enum, string or key
default = true
label = "Log each return to the menu"
description = "Writes a line to anvil.log whenever the game returns to the main menu."
restart = false # false: applies at once; default true: at the next start
[setting.mode]
type = "enum"
values = [{ name = "off", label = "Off" }, { name = "on", label = "On" }]
default = "off"
label = "Mode"
[setting.panel_key]
type = "key"
default = "Ctrl+Shift+F12"
label = "Panel key"
  • type, default and label are required; description, group and restart are optional.
  • int and float take optional min, max and step; enum takes values.
  • A key is a binding such as "Ctrl+Shift+F12", or "" for none.

From Anvil 1.23 (declare anvil = ">=1.23.0": an older Anvil skips a plugin with these keys) settings follow the plugin’s modules:

[setting.flip_ratio]
type = "float"
default = 1.5
label = "Flip ratio"
module = "flows" # a module of plugin.toml: shown under it, off with it
advanced = true # folded under "Advanced" in the overlay and the Manager
[setting.log_flows]
type = "bool"
default = false
label = "Log flows"
affects_gameplay = false # does not change the game
[retired.flows_mode] # a setting you removed for the module's own switch
module = "flows"
off = ["off"] # these saved values turn the module off
on = ["on", "verify"] # these turn it on
[retired.flows_ironman]
module = "flows"
ironman = [true] # allows it in ironman, if flows offers allow_ironman = "opt-in"
  • Settings that count. In a plugin or module that changes the game, every setting counts for the game unless it says affects_gameplay = false; a key setting does not count by default. The values in effect of the settings that count join their owner’s line in the multiplayer hash (lode 1.2.0 cooldown_months=24 flip_ratio=1.5, names sorted), so players with different values see different codes, and they are locked during a multiplayer game. A restart = true value saved for the next start counts from that start.
  • Retired settings. At the first start of the new version, a player’s saved value of a [retired.<name>] that is in its off or on turns <plugin>.<module> off or on in anvil/anvil.toml (as the overlay’s switch does, so it also turns on a module with default = false), and one in its ironman or multiplayer allows the module there (the module must offer that opt-in). It holds at that same start, and every saved value of the name is removed from the player’s file. Both are written to anvil.log. Each list is optional, a value cannot be in both off and on, and a setting and a retired setting cannot share a name. Several retired settings may name one module; from Anvil 1.24, when a player’s values of them disagree (one in an off, another in an on), the module is off, whatever their order in the file. Give the module the old setting’s default: the player’s file holds only values that differ from the default, so a player who kept the old default has nothing to move, and the module’s default decides for them.

The player’s values live in anvil/data/<plugin-id>/settings.toml, only those that differ from the default, as name = value. The file can be edited by hand while the game is closed. An invalid value falls back to the default with a warning in the log. For a test, an environment variable ANVIL_<ID>_<NAME> (upper case, - as _) overrides a value for one session.

The plugin reads validated values through the generated headers: cfg::<name>.get() in C++, host->setting_bool(self, CFG_<NAME>) and its siblings in C. See Settings in the Host API.

From Anvil 1.20, the overlay and Anvil Manager show a plugin’s description and its settings’ label, description, group and option labels in the player’s language when the plugin carries translations/<code>.toml: one file per language, named fr, de, es, zh-Hans, zh-Hant, ja, ko or pl. Each maps the English words of plugin.toml and settings.toml to that language’s words:

translations/fr.toml
status = "draft" # "checked" once a native speaker checked it
[text]
"Log each return to the menu" = "Noter chaque retour au menu"
"Writes a line to anvil.log whenever the game returns to the main menu." = "Écrit une ligne dans anvil.log chaque fois que le jeu revient au menu principal."
  • A text without a translation, and every text in a language without a file, is shown in English. The plugin’s name always is.
  • The key is the English text itself: when you change an English text, change its key and translation in every file. Until then the player sees the new English words, never a translation of the old ones.
  • Chinese, Japanese and Korean words are drawn with the fonts of Windows.
  • plugin.toml does not name the folder, so an Anvil before 1.20 ignores it: translations need no newer anvil range. A file that does not parse is left out with a warning in anvil.log; the plugin still loads.
  • anvil_add_plugin copies translations/*.toml into the built plugin folder.
  • The template carries all eight files for its one setting.

anvil gen (in the SDK’s bin/) writes headers from symbols.toml and settings.toml. anvil_add_plugin runs it at build time; call it yourself for other build systems:

Terminal window
anvil gen [--lang c|cpp|rust|rust-sdk] [--settings <settings.toml>] <symbols.toml|settings.toml>... <out-dir>
File Contents
symbols.gen.h SYM_<NAME> ids, sym_<name>_fn function pointer types, SYMVAL_<SYMBOL>_<VALUE> values
symbols.gen.hpp namespace sym: one typed constant per symbol, for example sym::speed_object
settings.gen.h CFG_<NAME> ids and CFG_<NAME>_<OPTION> enum indices
settings.gen.hpp namespace cfg: cfg::<name>.get()
symbols.gen.rs, settings.gen.rs the same ids, function types and values for Rust (--lang rust or rust-sdk only)

Without --lang it writes the C and C++ headers. From Anvil 1.25:

  • --lang rust-sdk writes the same symbols.gen.rs as --lang rust, with a module typed for the anvil-sdk crate: each function symbol with its type, for Host::hook_symbol.
  • --lang given more than once writes each language named, e.g. --lang c --lang cpp.
  • Besides C++ keywords and a value named id, value or symbol_name, anvil gen refuses names that the C++ header cannot hold: a symbol named id, value or symbol_name, a value with its symbol’s name, a setting named id, get, setting_name, restart, default_value, minimum or maximum, and an enum option with its setting’s name. anvil check reports them at their line, whatever language the plugin uses.

Declare the types named in signature and type before including the header.

anvil check validates a plugin without starting the game:

Terminal window
anvil check <plugin folder> [--exe <eu4.exe>] [--format text|json|github] [--complete-translations]
anvil check --game <game folder> [--format text|json|github] [--host-version <x.y.z>]
  • Without --exe: the schemas of the three files, names that anvil gen would refuse, and the symbols.lock check. This is what CI runs.
  • Translations (Anvil 1.20): a file that does not parse, a file name that is not one of the eight codes and an entry no text of the plugin has any more are errors; a text without a translation, and a language without a file, are warnings. --complete-translations makes them errors, for a plugin that ships every language.
  • Modules (Anvil 1.22): one line per module with its flags and default, and a warning when the anvil range admits a release without modules.
  • Settings of modules (Anvil 1.23): a module or retired module that plugin.toml does not declare is an error. Warnings: the anvil range admits a release without module, advanced, affects_gameplay, [retired.*] or a module’s group; a setting named as a module; two [retired.*] of one module of which one has an on list (Anvil 1.24); a setting without affects_gameplay in a plugin or module that offers multiplayer.
  • With --exe: also the build, every symbol’s bytes, memory kind, pointers, exports and values, and instruction boundaries: the declared bytes of a function or site must be whole instructions, and a hook must not relocate JRCXZ, JECXZ or LOOP*. From Anvil 1.26 also a short branch before the last relocated instruction, and a hook whose overwritten bytes are all ??, as the loader refuses them. It rewrites symbols.lock. From Anvil 1.26 an exe of a build the file does not declare, or one this Anvil does not know, is reported and leaves symbols.lock alone.
  • With --game: checks every plugin in the game’s anvil/plugins/ and resolves them as the loader would: what loads in which order, what is skipped and why, and warnings for plugins whose code symbols overlap. From Anvil 1.24 it also shows the next start’s plan: whether that start is in safe mode, and what it writes before any plugin loads (approved copies to make or remove, retired settings to move into anvil.toml). The JSON report has them in next_start (safe_mode, unfinished_starts, and writes with remove, copies and retired). From Anvil 1.26 the plugins’ anvil ranges are checked against the Anvil installed in that folder (the version of its version.dll), as its loader checks them, not against the CLI’s own version; without an Anvil there it uses its own and says so. --host-version sets the version to check against. An anvil.toml that does not parse, or a list of the wrong type, is a problem, since the loader then loads no plugin.
  • --format github prints ::error file=…,line=… annotations, so run it from the repository root in GitHub Actions.

Exit codes: 0 OK, 1 problems, 2 cannot check.

After a game update, anvil port places a plugin’s symbols in the new build. It needs the old eu4.exe as well as the new one, so keep a copy before the game updates:

Terminal window
anvil port symbols.toml --from <old eu4.exe> --to <new eu4.exe> --build <new build id> --out symbols.toml

From Anvil 1.12, --build must be the id this Anvil has for the new eu4.exe, since a file with any other id never loads. Add --unknown-build for a build it does not know yet; the id then needs the form eu4-<version>-<store>-win64.

Add --from-build <id> when this Anvil does not know the old eu4.exe, and --format json for a report you can feed to a generator. Without --out nothing is written.

It compares the code of both builds with the addresses the linker chose set aside, and adds a build."<id>" entry to each symbol, keeping your comments and layout. Symbols with sha256 stay digests. The tool never touches eu4.exe.

A wrong address is worse than none, so a symbol stays for you to place when:

  • its code has no match in the new build, or more than one;
  • the only match is out of order with the functions around it, or refers to other code;
  • an operand differs that no values entry declares, because your plugin may depend on it;
  • it fails what anvil check --exe would report for the new build.

Each of those gets a comment in the file with the reason and, where one is known, an address to look at. The file does not parse until you place the symbol or declare it absent; an export has no address to drop, so anvil check --exe reports it on the new build instead. The entry of a function whose operands changed is placed, with a warning to read it.

anvil port edits each symbol’s own [symbol.<name>] table. From Anvil 1.25 it refuses, before writing anything, a file with a symbol written as an inline table or with dotted keys under [symbol]; write that symbol as a table of its own first.

Exit codes: 0 every symbol placed, 1 some left for you, 2 cannot port. Then run anvil check --exe for each build, which needs an Anvil that knows the new one.

On the two builds we have, Steam 1.37.5 and GOG 1.37.5.2, it placed 98.4% of the symbols in our five plugin files with no wrong address, but those builds are close. Expect a longer list after a real update, which it has not met yet.