Files
ClassicAPI/src/Offsets.h
T
Brues 35b8eaa376 feat(tooltip): grow the line pool on demand, as 4.3.4 does
Replace the scan-time grow to a fixed 60 lines with 4.3.4's
CGTooltip::AddLine grow: co-hook the add-line gate (FUN_00530270, which
every Lua method and native builder goes through) and, when the line
about to be added takes the last slot, build the next TextLeft/Right
pair and append it through the engine's own AddFontStrings body
(FUN_00529940). The pool keeps one spare line after every add, with no
cap, and tooltips no longer pre-build 30 unused line pairs.

New lines start hidden (the clear only hides lines below numLines) and
take the engine's line gap constant instead of a literal.
2026-10-26 16:44:34 -05:00

12400 lines
739 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// This file is part of ClassicAPI.
//
// ClassicAPI is free software: you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software Foundation, either
// version 3 of the License, or (at your option) any later version.
//
// ClassicAPI is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with
// ClassicAPI. If not, see <https://www.gnu.org/licenses/>.
#pragma once
enum Offsets {
// `.text` section bounds of this client (VA; see CLAUDE.md "Target
// binary"). Code scans read only inside them.
SECTION_TEXT_START = 0x00401000,
SECTION_TEXT_END = 0x007FEDAC,
FUN_FRAME_SCRIPT_INITIALIZE = 0x7039E0,
FUN_INVALID_FUNCTION_PTR_CHECK = 0x42A320,
FUN_LOAD_SCRIPT_FUNCTIONS = 0x490250,
// Fatal-error dispatcher. `__fastcall(uint code)`. Writes `code`
// to `DAT_00882738` and chains into the process-teardown path;
// `FUN_00403BC0` reads the code at exit and shows a localized
// popup keyed off it. Code `10` = "interface files are corrupt"
// — the engine fires this from FrameXML's `FUN_0048FBF0` hash
// mismatch and per-addon `FUN_0051F240` hash mismatch (plus
// other call sites we haven't pinned down by byte pattern).
// Hooked by `Security::FrameXMLBypass` to suppress code 10 so
// our in-memory file modifications (Bindings.xml splice +
// embedded `!!!ClassicAPI` addon) don't trigger termination.
FUN_FATAL_ERROR = 0x00401560,
// Master glue Lua init — clean linear caller of all 5 glue batch
// trampolines (60 main + 11 char-select + 24 char-create + 10 realm
// + 4 frame globals = 109 total). Body: 0x0046ABB0..0x0046ABD2,
// 35 bytes, single caller (FUN_0046A7B0). Runs once per glue boot:
// initial launch and every world→glue return (log out). Post-hook
// is the glue analog of `FUN_LOAD_SCRIPT_FUNCTIONS` — by the time
// it returns, `VAR_LUA_STATE` points at the freshly populated glue
// state, so `FrameScript_RegisterFunction` writes land on it.
FUN_LOAD_GLUE_SCRIPT_FUNCTIONS = 0x0046ABB0,
// Binding manager internals used by the direct-action/override binding backport.
//
// Stock Lua `SetBinding` wrapper (`int __fastcall(lua_State *)`).
// The SetBindingSpell/Item/Macro/Click wrappers delegate to it after
// constructing their action command, preserving punctuation-key
// normalization, current-set selection, the Boolean return value, and the
// native UPDATE_BINDINGS notification.
FUN_SCRIPT_SET_BINDING = 0x004B8000,
// Hardware-key dispatch, before the normal binding table is resolved:
// int __thiscall(manager, key, isDown)
// Hooking here lets owner-scoped override bindings remain a separate
// layer rather than temporarily mutating the character/account binding
// table. The normal dispatcher is called unchanged when no override wins.
FUN_BINDING_KEY_DISPATCH = 0x004B7990,
// Executes a resolved binding command:
// int __thiscall(manager, command, isDown)
// Vanilla has no SPELL/ITEM/MACRO/CLICK direct-action command handlers. The
// hook recognizes those four families and delegates every native command
// to the client.
FUN_BINDING_COMMAND_EXECUTE = 0x004B7B50,
// Binding-manager `this`-relative flag, set to 1 while a resolved binding
// command runs. FUN_BINDING_KEY_DISPATCH writes 1 immediately before its
// call to FUN_BINDING_COMMAND_EXECUTE and 0 immediately after. Override
// commands dispatched outside that engine path must mirror it so native
// command handlers observe the same manager state a real keypress produces.
// Verified in the FUN_BINDING_KEY_DISPATCH disassembly.
OFF_BINDING_MANAGER_EXECUTING = 0xD8,
// Frame-script execution context and its nesting depth (the `DAT_00ceeac0`
// dance referenced below). Shared by the binding dispatcher and the
// tooltip/frame script invokers. FUN_BINDING_KEY_DISPATCH saves the context
// pointer, zeroes it for the nested command, restores it afterward, and
// floors the depth back to 0. `Bindings::Api` mirrors this when it runs an
// override command outside the engine's own dispatch. Verified in that
// disassembly.
VAR_FRAMESCRIPT_EXEC_CONTEXT = 0x00CEEAC0,
VAR_FRAMESCRIPT_EXEC_CONTEXT_DEPTH = 0x00CEEAC4,
// The binding manager — 4.3.4's CGUIBindings, minus its modified clicks.
// `*VAR_BINDINGS_MANAGER`, a 0xDC-byte object made by FUN_004B6050 (FrameXML
// init FUN_0048FBF0) and destroyed by FUN_004B6100 (UI teardown
// FUN_00490BD0), so it is rebuilt on every world load and /reload. Binding
// sets as 4.3.4 numbers them: 0 default, 1 account, 2 character, 3 current;
// set N's table is at `mgr + 0x30 + N*0x28` (list head at +0x3C).
// OFF_BINDINGS_SAVE_SET (+0xD0) is m_saveSet (1 or 2, what
// GetCurrentBindingSet returns); +0xD4 the dirty-set mask.
VAR_BINDINGS_MANAGER = 0x00B71290,
OFF_BINDINGS_SAVE_SET = 0xD0,
BINDING_SET_DEFAULT = 0,
BINDING_SET_ACCOUNT = 1,
BINDING_SET_CHARACTER = 2,
BINDING_SET_CURRENT = 3,
BINDING_SET_COUNT = 4,
// CGUIBindings::Load — `int __thiscall(mgr, const char *path, MD5_CTX *md5,
// CStatus *status)`, `ret 0xC` (the caller at 0x00490006 loads ECX from
// VAR_BINDINGS_MANAGER; the prologue saves it); a null status means
// VAR_BINDINGS_LOAD_STATUS. Reads the file with FUN_FILE_READ, builds a tree
// with FUN_XML_TREE_LOAD and loads every root `<Binding>`; any other node
// gets "Unknown node type %s in %s". Called for FrameXML's Bindings.xml
// (0x00490018) and for each addon's (FUN_0051F240).
// The status is used only through `Add` (vtable +0xC), with at most two
// string arguments after the format.
FUN_BINDINGS_LOAD_FILE = 0x004B6F70,
VAR_BINDINGS_LOAD_STATUS = 0x00B7124C,
STR_BINDINGS_UNKNOWN_NODE = 0x00846FB4, // "Unknown node type %s in %s" (file bytes)
// CGUIBindings::LoadBindings — `void __fastcall(int set, const char *text)`:
// clears the set, then binds every `bind KEY COMMAND` line. Sources:
// WTF\DefaultBindings.wtf into set 0 (FUN_004B62B0), then the account /
// character binding files into sets 1 / 2 (FUN_004B6240, which finishes
// with FUN_004B64B0 — 4.3.4's FinishLoadBindings).
FUN_BINDINGS_LOAD_SET = 0x004B6140,
// CGUIBindings::SaveBindings — `void __thiscall(mgr, int set, HANDLE file)`,
// `ret 8`: writes the set's `bind %s %s\r\n` lines through
// FUN_OS_WRITE_FILE. Called by the binding-file writer FUN_004B65B0.
FUN_BINDINGS_SAVE_SET = 0x004B6520,
// CGUIBindings::CopyBindings — `void __thiscall(mgr, int source, int dest)`,
// `ret 8`. Its gate FUN_00494A50(8) always passes (only actions 0, 2, 4,
// 10 and 11 are gated). Fires UPDATE_BINDINGS (0x182) when dest is current.
FUN_BINDINGS_COPY_SET = 0x004B6310,
// CGUIBindings::GetCommandAction for the current set — `const char
// *__thiscall(mgr, const char *key)`: the command bound to exactly `key`,
// or null. Script_GetBindingAction (FUN_SCRIPT_GET_BINDING_ACTION, which
// pushes "" for null) is its only Lua caller.
FUN_BINDINGS_GET_COMMAND_ACTION = 0x004B7DA0,
FUN_SCRIPT_GET_BINDING_ACTION = 0x004B8120,
// The manager's command table (4.3.4's m_commands), a Storm
// TSHashTable<_, HASHKEY_STRI> keyed by command name, filled from
// Bindings.xml. The engine inlines its lookup (FUN_BINDING_COMMAND_EXECUTE):
// hash = FUN_SSTR_HASH_HT(name); bucket = slots[hash & mask] (12 bytes:
// +0 link offset, +8 first node); a node is +0 hash, +0x14 name, and
// `*(node + linkOffset + 4)` is the next; a null or odd pointer ends the
// chain. Same layout as each binding set's key table (set N at
// `mgr + 0x30 + N*0x28`: slots +0xC4, mask +0xCC for set 3 in
// FUN_BINDINGS_GET_COMMAND_ACTION), so slots/mask are table +0x1C/+0x24.
// Verified in both disassemblies.
OFF_BINDINGS_COMMAND_TABLE = 0x08,
OFF_HASHTABLE_SLOTS = 0x1C,
OFF_HASHTABLE_MASK = 0x24,
OFF_HASHTABLE_NODE_NAME = 0x14,
// Storm SStrHashHT — `uint32_t __stdcall(const char *)` (callee pops its
// one argument; FUN_BINDINGS_GET_COMMAND_ACTION calls it with no cleanup).
// The case-insensitive string hash of HASHKEY_STRI tables.
FUN_SSTR_HASH_HT = 0x0064B3F0,
// CGGameUI::IsKeyDown for the merged modifiers — `int __fastcall(int
// which)`: 0 shift, 1 ctrl, 2 alt. IsShiftKeyDown / IsControlKeyDown /
// IsAltKeyDown (0x00488590..0x00488600) and the engine's own modifier
// reads (edit boxes, world clicks, mouse events, action use) call it.
// It is 4.3.4's EventIsKeyDown, taking any KEY code — 0..2 are 1.12's
// merged meta keys — and the console's key handler asks it whether the
// console toggle key is held.
// 4.3.4's version answers from the binding manager's held-modifier mask
// while a key binding runs; `Input::Modifier` co-hooks it to do the same.
FUN_GAMEUI_IS_KEY_DOWN = 0x0041F8F0,
// OsWriteFile — `int __fastcall(HANDLE /*ecx*/, const void *buffer /*edx*/,
// uint32_t size, uint32_t *written)`, `ret 8`.
FUN_OS_WRITE_FILE = 0x0042A5D0,
// " " — the token delimiter LoadBindings splits a `bind` line's key with.
VAR_STR_SPACE_DELIM = 0x0082EE00,
// GameTooltip script-method prologue helpers (used to resolve self → CFrameScriptObject*).
// Underlying Lua C API names per [[docs/LuaCAPI.md]] are `lua_rawgeti`
// (0x6F3BC0) and `lua_touserdata` (0x6F3740). The Set* method prologue's
// call sequence
// PushObject(L, idx, 0); // == lua_rawgeti(L, idx, 0) — pushes the
// // lightuserdata at table[0]
// GetObject(L, -1); // == lua_touserdata(L, -1) — extracts
// // the raw CFrameScriptObject *
// is the canonical "Lua frame table → C++ object" path. The reverse
// (`GameTooltip:GetOwner` etc.) is just `lua_rawgeti(L, REGISTRY,
// [cobj+OFF_COBJECT_LUA_REF])` — the engine pre-allocates
// the registry handle when the frame is created from Lua.
FUN_FRAMESCRIPT_PUSH_OBJECT = 0x6F3BC0,
FUN_FRAMESCRIPT_GET_OBJECT = 0x6F3740,
// Within a CGFrame, the embedded LayoutFrame sub-object starts here.
// Engine code that wants to invoke LayoutFrame methods polymorphically
// (anchoring, positioning) stores the LayoutFrame* — i.e.
// `(Frame*)obj + 0x24` — instead of the bare Frame*. Reverse
// lookups (e.g. GameTooltip:GetOwner) subtract this back out.
OFF_FRAME_LAYOUT_SUBOBJECT = 0x24,
// Inner spell-tooltip builder (CGTooltip::BuildSpell), called from
// Script_GameTooltip_SetSpell at 0x00532E92. `uint __thiscall(spellID,
// compact, cooldownMs, pet, showRank, talent, rebuild)`, RET 0x1C — the
// first six of 4.3.4's CGTooltip::SetSpell(spellId, brief, cooldown,
// isPet, showSubtext, …, talent, …, append, …) in order. `rebuild`
// skips the clear and the spellID stash (+0x39C) and, unlike 4.3.4's
// append, always heads the block with "\n" TOOLTIP_TALENT_NEXT_RANK
// instead of the name line (talent or not). A TRADESPELL record builds
// its created item's tooltip instead. Returns 1 when it added the
// cooldown line (cooldownMs != 0, recovery >= 60s) or a chance-to line.
FUN_GAMETOOLTIP_BUILD_SPELL_TOOLTIP = 0x0052E610,
// Existing GameTooltip method-table entries we dispatch to from
// backported convenience methods. Each is `int __fastcall(void *L)`
// expecting the standard self+args layout on the Lua stack.
// (Slot numbers are the method-registry index per `docs/raw_methods.txt`.)
// `SetText(text [, r, g, b, a, wrap])`: clear (FUN_GAMETOOLTIP_CLEAR), one
// line, then the has-text flag + Show vmethod — the exact sequence the
// engine's own macro branch (FUN_GAMETOOLTIP_SET_MACRO) runs, reachable
// through an entry point no sibling DLL has detoured. Pushes nothing.
FUN_SCRIPT_GAMETOOLTIP_SET_TEXT = 0x00531B90, // slot 9
// `SetOwner(frame [, anchor [, x [, y]]])` and `GetAnchorType()`: the engine's
// own methods (slots 4 and 5). SetOwner reads the anchor NAME from Lua
// argument 3 with a case-insensitive chain (see TOOLTIP_ANCHOR_*); GetAnchorType
// maps the stored code back, sending any code it does not know to
// "ANCHOR_NONE".
FUN_SCRIPT_GAMETOOLTIP_SET_OWNER = 0x005310D0,
FUN_SCRIPT_GAMETOOLTIP_GET_ANCHOR_TYPE = 0x005313E0,
// `SetHyperlink(link)`: type-gates self, then SStrCmpI-prefix-matches the
// argument against "item:" (id:enchant:suffix:unique ->
// FUN_GAMETOOLTIP_BUILD_ITEM) and "enchant:" (a spellID in
// VAR_SPELL_RECORDS whose record has `+0x0C == 3` ->
// FUN_GAMETOOLTIP_BUILD_SPELL_TOOLTIP), else raises "Unknown link type"
// (`0x00532269`). A full `|H...|h` link fails the prefix test. Co-hooked
// by `Tooltip::Hyperlink` for full links, `spell:` / `quest:`, and
// trade-skill `enchant:` links. SuperWoW patches a jump at `0x00532210`
// (after the `item:` test) that adds `quest:` and resumes at `enchant:`.
FUN_SCRIPT_GAMETOOLTIP_SET_HYPERLINK = 0x00531FD0, // slot 12
// `SetAction(slot)`: cooldown via FUN_ACTION_SLOT_COOLDOWN, clear, then
// attack → "ATTACK" text; item-by-ID → FUN_GAMETOOLTIP_BUILD_ITEM (owned
// instance via FUN_INVMGR_FIND_ITEM_BY_ID, else bare itemID); spell →
// FUN_GAMETOOLTIP_BUILD_SPELL_TOOLTIP(spellID, brief /*1 unless the
// UberTooltips cvar int is set*/, cooldownRemainingMs, 0, 1, 0, 0);
// macro → FUN_GAMETOOLTIP_SET_MACRO (name only). Pushes 1 when the
// builder returned non-zero (FrameXML keeps refreshing), else nil.
// `Tooltip::SetAction` re-registers the name in front of it for macro
// slots with a `#showtooltip` directive and tail-calls it otherwise.
FUN_SCRIPT_GAMETOOLTIP_SET_ACTION = 0x005322A0, // slot 13
FUN_SCRIPT_GAMETOOLTIP_SET_INVENTORY_ITEM = 0x00532EE0, // slot 19
FUN_SCRIPT_GAMETOOLTIP_SET_BAG_ITEM = 0x00534620, // slot 30 — (bag, slot)
// Macro-slot tooltip: `__thiscall(tooltip, uint macroID)` — clear +
// SetText(entry+OFF_MACRO_NAME) + Show. Internal, not a script entry.
FUN_GAMETOOLTIP_SET_MACRO = 0x0052B040,
// `Script_GameTooltip_SetUnit` (slot 31): self typecheck, lua_isstring(2),
// FUN_TOKEN_TO_GUID (raises on an unknown token), then — only for a
// non-zero GUID — FUN_GAMETOOLTIP_BUILD_UNIT. Always pushes nil (the
// builder returns 0 on every path). The token string is discarded after
// the resolve; `Unit::Tooltip` re-registers the name in front of it to
// keep the token for `GetUnit` and tail-calls it with the untouched stack.
FUN_SCRIPT_GAMETOOLTIP_SET_UNIT = 0x005349B0,
FUN_SCRIPT_GAMETOOLTIP_SET_UNIT_BUFF = 0x00534AC0, // slot 32
FUN_SCRIPT_GAMETOOLTIP_SET_UNIT_DEBUFF = 0x00534E30, // slot 33
FUN_SCRIPT_GAMETOOLTIP_SET_TALENT = 0x00535170, // slot 34
// Iterator that registers an array of frame-method bindings on a per-frame-type
// method registry (e.g. VAR_GAMETOOLTIP_METHOD_REGISTRY for GameTooltip).
// __fastcall(ecx = MethodEntry table, edx = count, [stack] = context).
FUN_REGISTER_FRAME_METHODS = 0x00701D80,
VAR_GAMETOOLTIP_METHOD_REGISTRY = 0x00C0CF20,
// CGameTooltip line pool. The engine caps AddLine (FUN_00530270) at
// `numLinesAllocated`, which the XML-OnLoad scan (FUN_00529650, vtable
// slot 9) sets to the count of contiguous `<name>TextLeftN`/`TextRightN`
// FontStrings the template declares (30). Tooltip::LinePool grows it on
// demand inside AddLine, appending through FUN_GAMETOOLTIP_ADD_FONT_STRINGS.
// Each array is a {count@+0x0, cap@+0x4, data@+0x8} descriptor.
OFF_GAMETOOLTIP_NUM_LINES_ALLOC = 0x320, // int — pool size AddLine gates on
OFF_GAMETOOLTIP_TEXTLEFT_DESC = 0x324, // {count,cap,data}; data (+0x8) = CSimpleFontString*[]
OFF_GAMETOOLTIP_TEXTRIGHT_DESC = 0x330, // symmetric right column
OFF_GAMETOOLTIP_WRAPFLAG_DESC = 0x33C, // per-line wrap int[]
// __thiscall(tooltip, left, right), `ret 8` — the core of the
// `GameTooltip:AddFontStrings` method (0x00530C40): bumps
// numLinesAllocated, grows the three arrays to it, stores the pair and a
// 0 wrap flag in the new last slot. 4.3.4's CGTooltip::AddFontStrings.
FUN_GAMETOOLTIP_ADD_FONT_STRINGS = 0x00529940,
// GameTooltip:SetHyperlinkCompareItem (Tooltip::Compare) — builds the
// equipped item's tooltip natively (no Lua roundtrip) and appends
// colored stat deltas. FUN_GAMETOOLTIP_BUILD_ITEM is the engine's own
// item-tooltip builder that SetInventoryItem/SetHyperlink call:
// __thiscall(self, itemID, guid*, guid*, a4, a5, a6, headerFlag, a8, a9)
// Proven arg shape from FUN_005353b0/FUN_00535700 (all flags 0 → a clean
// item tooltip). The builder's own headerFlag (param_7) path merges the
// "Currently Equipped" text into the name line and force-wraps it, so we
// build clean (flag 0) and prepend the grey header ourselves by shifting
// the line FontStrings — see FUN_FONTSTRING_SET_* / OFF_FONTSTRING_*.
// FUN_GAMETOOLTIP_ADD_LINE is the raw add-line body (see LinePool notes);
// its color args are pointers to a 4-byte packed color {b,g,r,a} — the
// Lua AddLine handler (FUN_00531630) builds it as 0xFF<rr><gg><bb>, i.e.
// uint32 `0xFF000000 | r<<16 | g<<8 | b` in little-endian memory.
FUN_GAMETOOLTIP_BUILD_ITEM = 0x0052B650,
// OnTooltipSetItem support. FUN_GAMETOOLTIP_SCRIPT_RESOLVER is the
// CGGameTooltip vtable method (vtable 0x00808F60) that maps a script name
// to its handler slot; __thiscall(self, const char *name) -> int* slot,
// 0 if the name isn't a tooltip script. It first delegates to the base
// frame resolver, then checks OnTooltipSetDefaultAnchor(+0x444) /
// OnTooltipCleared(+0x44c) / OnTooltipAddMoney(+0x454) — each an 8-byte
// {handler, context} slot. Vanilla has no OnTooltipSetItem, and the object
// (alloc size 0x460) has no free 8-byte slot, so we co-hook this to hand
// out a C-side per-tooltip cell for that name. FUN_FRAME_INVOKE_SCRIPT is
// the engine's real script invoker __fastcall(handler /*ecx = slot[0]*/,
// frame /*edx*/): it binds the global `this` = frame and runs the handler
// under its own protected lua_pcall (0 args). We call it directly from the
// item-builder co-hook to fire OnTooltipSetItem.
// NOTE: the clear fires OnTooltipCleared via the wrapper FUN_00702690
// (self, &slot), which additionally stamps the global exec-context
// (DAT_00ceeac0) from slot[1]. That context mutation is only valid from
// the engine's top-level frame-script dispatch — firing it from deep in a
// nested Lua->C->Lua stack (e.g. an addon's SetAuctionItem wrapper)
// corrupts the outer script's context and faults. So we skip the wrapper
// and call the inner invoker, which is self-contained.
FUN_GAMETOOLTIP_SCRIPT_RESOLVER = 0x005295D0,
FUN_FRAME_INVOKE_SCRIPT = 0x00704D50,
// The arg-passing sibling of FUN_FRAME_INVOKE_SCRIPT — every frame
// script that carries values (OnClick(button), OnMouseWheel(delta),
// OnUpdate(elapsed), OnValueChanged(value), OnKeyDown(key), OnEvent's
// args, …) funnels through here. __cdecl(int handlerRef, void *frame,
// const char *fmt, void *vaPtr): fmt is a printf-style spec string
// (`%d`/`%u`/`%f`/`%s`), vaPtr points at the packed vararg buffer
// (4-byte stride for d/u/s, 8 for f). It sets the `arg1..argN` globals
// from the format (saving/restoring the previous values), sets the
// `this` global to `frame`, then runs the handler under a protected
// lua_pcall with **zero Lua args** and the engine error handler
// (VAR_FRAMESCRIPT_ERROR_HANDLER_REF) as errfunc. FUN_FRAME_INVOKE_SCRIPT
// is the same shape for the no-arg scripts (OnShow/OnHide/OnEnter/…).
// `Frame::ScriptArgs` co-hooks both to additionally pass the handler
// modern positional args (self, arg1..argN). The frame's own Lua object
// ref lives at frame+OFF_COBJECT_LUA_REF (refcount at
// OFF_COBJECT_LUA_REFCOUNT); FUN_FRAMESCRIPT_OBJECT_SCRIPT_REGISTER
// lazily creates it when the refcount is 0.
FUN_FRAME_RUN_SCRIPT_ARGS = 0x00704F10,
// The base ScriptObject's OnEvent handler slot — an 8-byte
// {handler, context} pair at frame+0x0C (from FUN_00702590, the base
// resolver every frame-type resolver chains through, and confirmed by
// the event dispatchers FUN_00703E50 / FUN_00703F50 passing `frame+0xC`
// as the slot). `*(int*)(frame + OFF_FRAME_ONEVENT_SLOT)` is the OnEvent
// handler ref; `Frame::ScriptArgs` compares it against the handler ref
// the runner is invoking to detect an OnEvent dispatch (exact — each
// SetScript makes a distinct ref, so a function bound to two scripts
// still differs per slot) and prepend the `event` positional.
OFF_FRAME_ONEVENT_SLOT = 0x0C,
// Registry ref (an int, not a pointer) to the frame-script message
// handler the engine passes as the `errfunc` to every script pcall —
// read as `*(int*)VAR_FRAMESCRIPT_ERROR_HANDLER_REF`, pushed via
// lua_rawgeti(REGISTRY, ref). Set once at engine init.
VAR_FRAMESCRIPT_ERROR_HANDLER_REF = 0x008722C8,
// The base Frame script-name resolver — __thiscall(frame, const char *name)
// -> int* slot, 0 for an unknown name. Maps the standard base-frame scripts
// to their 8-byte {handler, context} slots on the frame (OnLoad@+0x118,
// OnUpdate@+0x128, OnEnter@+0x140, … OnKeyUp@+0x190) after delegating to the
// ScriptObject base FUN_00702590 (OnEvent@+0xC). Every frame TYPE's resolver
// chains through this (the tooltip resolver above calls it first), so
// `Frame::ExtraScripts` co-hooks it to make the scripts 1.12 lacks
// (OnAttributeChanged, OnEnable, ...) SetScript/GetScript/HookScript-able:
// for those names the co-hook hands back an external per-frame cell. Same
// pattern + ABI modeling as FUN_GAMETOOLTIP_SCRIPT_RESOLVER.
FUN_FRAME_SCRIPT_RESOLVER = 0x0076A0D0,
// Button widget script-name resolver — __thiscall(button, const char *name)
// -> int* slot, 0 for an unknown name. Sits at vtable+0xC on all four
// button-family vtables (Button + subclasses). Delegates to the base frame
// resolver FUN_FRAME_SCRIPT_RESOLVER first, then maps the two button
// scripts: OnClick -> button+0x4CC, OnDoubleClick -> button+0x4D4 (each an
// 8-byte {handler, context} slot). Vanilla has no PreClick/PostClick, so
// `Frame::ClickEvents` co-hooks this to hand out an external per-button cell
// for those two names — same technique as FUN_GAMETOOLTIP_SCRIPT_RESOLVER.
FUN_BUTTON_SCRIPT_RESOLVER = 0x00778C50,
// Button OnClick / OnDoubleClick script slot offsets (the Button resolver's
// returns for those two names; each an 8-byte {handler ref, exec context}).
// `Frame::ClickEvents` matches a fire at the runner hook below against
// slotPtr == button + one of these to scope GetMouseButtonClicked.
OFF_BUTTON_ONCLICK_HANDLER = 0x4CC,
OFF_BUTTON_ONDOUBLECLICK_HANDLER = 0x4D4,
// CSimpleFrame script slots — the base-frame resolver FUN_0076A0D0's returns
// (it chains to CScriptObject FUN_00702590 first, OnEvent @ +0xC). Derived as
// one table, recorded as one: OnLoad +0x118, OnSizeChanged +0x120, OnUpdate
// +0x128, OnShow +0x130, OnHide +0x138, OnEnter +0x140, OnLeave +0x148,
// OnMouseDown +0x150, OnMouseUp +0x158, OnMouseWheel +0x160, OnDragStart
// +0x168, OnDragStop +0x170, OnReceiveDrag +0x178, OnChar +0x180, OnKeyDown
// +0x188, OnKeyUp +0x190. Only the two mouse-button slots are named:
// `Frame::ClickEvents` scopes GetMouseButtonClicked around their fires —
// the exact set 3.3.5's frame manager brackets (its CSimpleFrame::OnMouseDown
// FUN_0048fc30 and OnMouseUp FUN_0048fce0 write [frameMgr+0x1234]; its
// OnDragStart does not; confirmed live on 3.3.5, 2026-09-15). The dispatches
// are FUN_0076BF70 (mouse-down: records the drag candidate at +0xFC..+0x110,
// then fires) and FUN_0076C040 (mouse-up: dispatches OnDragStop/OnReceiveDrag
// instead when a drag was pending), each via FUN_FRAME_RUN_SCRIPT_VARIADIC
// (frame, frame + slot, "%s", name).
OFF_FRAME_ONMOUSEDOWN_SLOT = 0x150,
OFF_FRAME_ONMOUSEUP_SLOT = 0x158,
// The OnEnter / OnLeave slots. The frame's enter (0x0076B6A0) and leave
// (0x0076B6F0) fire them, when set, with FUN_FRAME_FIRE_SCRIPT (0x0076B6E5,
// 0x0076B753).
OFF_FRAME_ONENTER_SLOT = 0x140,
OFF_FRAME_ONLEAVE_SLOT = 0x148,
// The no-argument script fire: `void __thiscall(frame, int *slot)`, `ret 4`.
// It stamps the exec context from slot[1] and calls FUN_FRAME_INVOKE_SCRIPT
// with slot[0]. The caller tests slot[0] first.
FUN_FRAME_FIRE_SCRIPT = 0x00702690,
// CSimpleButton's cursor enter (vtable slot +0x4C, `__thiscall(button)`,
// `ret`) and leave (+0x50, `__thiscall(button, int removed)`, `ret 4`).
// For a button that is not disabled, they run the frame's enter/leave
// (0x0076B6A0 / 0x0076B6F0: companion frame, highlight, OnEnter/OnLeave)
// and the label refresh 0x00779810. Then they always notify the C++
// listener at +0x31C. Button 0x0081C7F8, CheckButton 0x0081CB80 and the
// vtable at 0x008045C0 hold them. The nameplate and hyperlink buttons
// have their own. Prologues 56 8B F1 8B 86 / 55 8B EC 56 8B F1: no
// relative branch, and no other client DLL names either address.
FUN_BUTTON_ON_ENTER = 0x00779490,
FUN_BUTTON_ON_LEAVE = 0x007794E0,
// CSimpleButton::SetText: `void __thiscall(button, const char *text)`,
// `ret 4`. Null text does nothing. With no label it creates one
// (0x00770D30(this, 2, 1)), then FUN_FONTSTRING_SET_TEXT(label, text, 1).
// Lua Button:SetText (0x00780D20) and 4.3.4's SetFormattedText call it.
FUN_BUTTON_SET_TEXT = 0x00778DC0,
// Button::Click vmethod (Button vtable 0x0081C7F8 + 0x94) — __thiscall(button,
// buttonMask, fromScript), RET 8. Gate [+0x328] != 0 (enabled); runs the
// internal C++ click listener at +0x314 (vtable+0x10; set by FUN_00779740,
// never Lua-visible); iff [+0x4CC] is set, maps the mask through a jump
// table (targets @0x007795F4, index bytes @0x0077960C) to the engine's name
// literal and fires FUN_FRAME_RUN_SCRIPT_VARIADIC(button, button+0x4CC,
// "%s", name). Mask: 1 Left, 2 Middle, 4 Right, 8 Button4, 0x10 Button5,
// anything else "UNKNOWN". `fromScript` is 1 from Script_Click
// (FUN_007826C0 — folds its optional string to a mask: no arg -> 1,
// unrecognized or empty -> 0 -> "UNKNOWN") and 0 from both input handlers
// (mouse-down FUN_00779210 fires it for *Down registrations, mouse-up
// FUN_007792D0 for *Up, routing to +0x98 DoubleClick instead when [+0x4D4]
// is set and the previous click was <= 300 ms ago); the base ignores it.
// Every Lua-creatable button reaches this function: Button holds it in its
// vtable, CheckButton's override FUN_00785550 toggles +0x4DC then calls it;
// the nameplate button FUN_007CB910 and the game-UI button FUN_004C1820
// chain to it too. Only the hyperlink button FUN_007A3510 (vtable
// 0x0081D5B0) does not — it forwards to its owner's OnHyperlinkClick and
// never fires OnClick. `Frame::ClickEvents` co-hooks it to bracket EVERY
// click with PreClick/PostClick and the GetMouseButtonClicked scope, with
// or without an OnClick handler — the 3.3.5 shape (CSimpleButton::Click
// FUN_0096fd70 -> FUN_0096f090 fires PreClick, OnClick, PostClick as three
// independent `if (slot)` blocks).
//
// An earlier note here said SuperWoW inline-hooks this prologue and that a
// second MinHook faults (ERROR #132) — the reason PreClick/PostClick were
// first implemented at the runner and needed an OnClick handler to fire. A
// literal scan (2026-09-15) of every DLL the client loads — SuperWoWhook,
// nampower, perf_boost, pngscreenshots, regfix, transmogfix, UnitXP_SP3,
// VanillaHelpers, VanillaMultiMonitorFix, AuctionQueryThrottle,
// VanillaLooseLoader, VanillaMinimapTracking — finds NO reference to this
// address (absolute or RVA), while SuperWoWhook's real targets
// (SetEventCount, RebuildEventTable, SignalEventParam, ClearCastingSpell)
// all appear as plain literals, so the method would have found it. The #132
// sighting was real; this function was not its trigger. Prologue
// 55 8B EC 83 EC 14 56 8B CE — no relative branch in the first 6 bytes,
// internal jumps all target >= 0x7795B1: MinHook-safe.
FUN_BUTTON_CLICK = 0x00779540,
// Button::DoubleClick (vtable +0x98, shared by all five button-family
// vtables) — same shape, fires +0x4D4. NOT hooked: 3.3.5 fires no
// PreClick/PostClick around a double-click (FUN_0096f150 fires only
// OnDoubleClick), and its GetMouseButtonClicked scope comes from the runner
// gate on OFF_BUTTON_ONDOUBLECLICK_HANDLER. Reference only.
FUN_BUTTON_DOUBLECLICK = 0x00779650,
// Variadic front of the runner below — __cdecl(frame, slotPtr, fmt, ...),
// forwards &va as vaPtr to FUN_FRAME_RUN_SCRIPT_WITH_CONTEXT. The entry
// every input-script fire in the engine uses (25 call sites, byte-scanned).
// `Frame::ClickEvents` fires PreClick/PostClick through it so they take the
// identical path to the engine's own OnClick fire.
FUN_FRAME_RUN_SCRIPT_VARIADIC = 0x007026F0,
// The engine's "%s" format literal — the fmt every mouse-button script fire
// passes (OnClick, OnDoubleClick, OnMouseDown, OnMouseUp, OnDragStart) and
// the per-token unit-event broadcast uses. Passed by pointer so our fires
// are byte-identical to the engine's.
VAR_SCRIPT_FMT_S = 0x0082E280,
// The engine's button-name literals, exactly as FUN_BUTTON_CLICK's jump
// table selects them — so a PreClick/PostClick arg1 built from these is
// pointer-identical to the arg1 the engine hands OnClick.
VAR_BUTTON_NAME_LEFT = 0x00878864, // "LeftButton" mask 0x01
VAR_BUTTON_NAME_MIDDLE = 0x00878854, // "MiddleButton" mask 0x02
VAR_BUTTON_NAME_RIGHT = 0x00878848, // "RightButton" mask 0x04
VAR_BUTTON_NAME_4 = 0x00878840, // "Button4" mask 0x08
VAR_BUTTON_NAME_5 = 0x00878838, // "Button5" mask 0x10
VAR_BUTTON_NAME_UNKNOWN = 0x00838044, // "UNKNOWN" any other mask
// Frame-script runner WITH exec-context stamping — __cdecl(void *frame,
// int *slotPtr, const char *fmt, void *vaPtr). Saves DAT_00ceeac0, stamps
// it from slotPtr[1] (the cell's context), then calls FUN_FRAME_RUN_SCRIPT_ARGS
// (the arg'd runner Frame::ScriptArgs hooks) and restores. Every arg'd
// input-script fire funnels through here via FUN_007026F0 (its variadic
// forwarder); the event dispatcher FUN_00703F50 is the only other caller.
// ONE hook, owned by `Frame::RunnerHook`, fans out to subscribers that each
// claim a disjoint slot address (a second MinHook here would abort the
// whole install — subscribe instead): `Frame::ClickEvents` gates on the
// four mouse-button script slots (OnClick/OnDoubleClick on buttons,
// OnMouseDown/OnMouseUp on every frame) and scopes GetMouseButtonClicked
// around the fire — the runner is where the engine hands over the button
// NAME, so it is the scope point by design; `Frame::UnitEvent` gates on
// `slotPtr == frame + OFF_FRAME_ONEVENT_SLOT` (the dispatcher's per-frame
// OnEvent fire) and suppresses the call when a RegisterUnitEvent filter
// rejects arg1. PreClick/PostClick themselves fire from a co-hook on
// FUN_BUTTON_CLICK (see there — an earlier note here claimed SuperWoW
// owned that vmethod, which a per-DLL literal scan disproved).
FUN_FRAME_RUN_SCRIPT_WITH_CONTEXT = 0x00702710,
// The other per-object tooltip builders, co-hooked the same way as
// FUN_GAMETOOLTIP_BUILD_ITEM to back OnTooltipSetSpell / OnTooltipSetUnit /
// OnTooltipSetGameObject (see Tooltip::SetEvents). Each is the single funnel
// its Set*/mouseover paths converge on and clears the tooltip
// (FUN_00530050) before repopulating, so firing after it covers every way
// that object type gets set:
// - Spell FUN_GAMETOOLTIP_BUILD_SPELL_TOOLTIP (0x0052E610, 7 stack args,
// RET 0x1c) — SetSpell/SetSpellByID/SetTalent/SetShapeshift funnel.
// - Unit (0x00529fe0, __thiscall(self, guid*), RET 4) — SetUnit +
// the two engine mouseover paths (FUN_004919d0 / FUN_00492890).
// Returns an int the caller (Script_GameTooltip_SetUnit) tests, so the
// co-hook must forward the original's return value.
// - GameObject (0x0052aa20, __thiscall(self, guid*), RET 4) — the GO
// hover populator; resolves the GO (TYPEMASK_GAMEOBJECT) and writes the
// GO field at +0x370.
FUN_GAMETOOLTIP_BUILD_UNIT = 0x00529FE0,
FUN_GAMETOOLTIP_BUILD_GAMEOBJECT = 0x0052AA20,
// Pointer to the GameTooltip CFrameScriptObject the engine's mouseover
// setter builds into (`DAT_00b4b3c4`; the value at this address is the
// tooltip object). `Frame::Attributes` reads it to build the unit tooltip
// for offline/out-of-range party & raid members, which FUN_00492890 skips.
VAR_GAMETOOLTIP_OBJECT_PTR = 0x00B4B3C4,
// The tooltip's OnTooltipSetDefaultAnchor handler slot (the `{handler,
// context}` pair the script resolver maps that name to). The engine
// mouseover setter fires this before building to (re)establish the
// tooltip owner/anchor via FrameXML's GameTooltip_SetDefaultAnchor —
// without it a rebuild after the tooltip was hidden has no owner and
// stays invisible. `Frame::Attributes` fires it (via the self-contained
// FUN_FRAME_INVOKE_SCRIPT) before the offline roster build.
OFF_TOOLTIP_SET_DEFAULT_ANCHOR_HANDLER = 0x444,
FUN_GAMETOOLTIP_ADD_LINE = 0x00530270, // __thiscall(self, left, right, lColorBGRA*, rColorBGRA*, wrap)
OFF_GAMETOOLTIP_NUM_LINES = 0x31C, // int — live line count (AddLine index; +0x320 is the cap)
// The displayed item's identity is read via the existing
// OFF_TOOLTIP_ITEM_ID (+0x398) / OFF_TOOLTIP_ITEM_GUID_LO (+0x380) —
// link paths set the itemID, CGItem paths (SetInventoryItem/…) set only
// the GUID (see Tooltip::Compare::TooltipItemID and item/Tooltip.cpp).
// Line-shift primitives for prepending the grey "Currently Equipped"
// header. The per-line CSimpleFontString objects live in the parallel
// arrays at OFF_GAMETOOLTIP_TEXTLEFT/RIGHT_DESC (+8 = data). Each stores
// its text buffer pointer at +0xF0 and its 4-byte {b,g,r,a} color behind
// the pointer at +0xB8 (both verified from the setters below). We read a
// line's text/color and re-apply them one slot down, then set line 0.
// __thiscall(fs, text, expand), ret 8. expand = 1 (Lua SetText 0x0079D829,
// CSimpleButton::SetText) rewrites the |1 / |2 grammar escapes first.
FUN_FONTSTRING_SET_TEXT = 0x00771D80,
// The grammar pass, 4.3.4's LanguageProcess with only its rules 1 and 2:
// `char *__fastcall(text)`, returns the text or a static rewrite of it.
// Callers: AddChatLine 0x0049AF18, StartChatBubble 0x004B1611,
// FUN_FONTSTRING_SET_TEXT 0x00771D98 (expand = 1), UpdatePlate 0x006C703F.
FUN_EXPAND_GRAMMAR_ESCAPES = 0x007716F0,
// Its rules, `char *__thiscall(text)`, each output to the static
// 0x00CF1CC8 (0x1000 bytes): |1 Korean particles, |2 French articles.
FUN_EXPAND_KOREAN_PARTICLES = 0x00771770,
FUN_EXPAND_FRENCH_ARTICLES = 0x007719A0,
FUN_FONTSTRING_SET_COLOR = 0x0077F750, // __thiscall(region, colorBGRA*) — generic region color setter (fontstrings + textures)
// Generic region color GETTER — `void __thiscall(region, uint32* outBGRA)`,
// writes the packed {b,g,r,a} (0xFFFFFFFF when the region has no explicit
// color). The read half of Texture:GetVertexColor (FUN_0079aa50); paired
// with FUN_FONTSTRING_SET_COLOR above. Backs EditBox:GetHighlightColor.
FUN_REGION_GET_COLOR = 0x0077F8C0,
OFF_FONTSTRING_TEXT = 0xF0, // char* — current text buffer
// The fixed text size (XML `bytes`, 0 = none): SetText (FUN_FONTSTRING_SET_TEXT)
// copies with SStrCopy(text, src, n), which keeps n − 1 bytes; with 0 the
// buffer grows to any length (0x00771E0F / 0x00771E4D). 0x00771680 sets it.
OFF_FONTSTRING_FIXED_TEXT_SIZE = 0xE8,
OFF_FONTSTRING_COLOR_PTR = 0xB8, // ptr → 4-byte {b,g,r,a} color storage
// A line's FontString is only positioned once shown: set the desired
// flag at +0xC4 then call SHOW (FUN_0077fcb0) / HIDE (FUN_0077fc60) —
// the exact pair AddLine (FUN_00530270) and the clear use. Moving text
// into a previously-empty (hidden) cell without this leaves it
// unpositioned, so the line-shift must replicate it.
FUN_FONTSTRING_SHOW = 0x0077FCB0, // __fastcall(fs) — realizes +0xC4
FUN_FONTSTRING_HIDE = 0x0077FC60, // __fastcall(fs)
OFF_FONTSTRING_SHOWN_FLAG = 0xC4, // int — desired-shown flag
// The per-tooltip clear only HIDES line FontStrings (sets +0xC8 = 0)
// and clears the left text; right-column text buffers are left intact.
// So a shift must decide a cell's content by its actually-shown flag
// (+0xC8), not by whether +0xF0 still holds (stale) text.
OFF_FONTSTRING_VISIBLE = 0xC8, // int — actually-shown flag
// FontString creation primitives used by Tooltip::LinePool to build the
// extra lines entirely in C++ (no addon Lua). Calling conventions and
// offsets mirrored from Script_CreateFontString (0x00773C30),
// Script_SetFontObject (0x0079D1A0 → 0x00770C60), and Script_SetPoint
// (0x007A2540 → 0x00767C70) — see TODO #97's investigation update.
VAR_SIMPLEFONTSTRING_POOL = 0x00CF4D10, // CSimpleFontString free-list pool (allocator `this`)
VAR_SIMPLEFONTSTRING_CLASS_TAG = 0x00846544, // ".?AVCSimpleFontString@@" (alloc debug tag)
FUN_REGION_POOL_ALLOC = 0x00760450, // __thiscall(pool, zeroInit=0, tag, line=-2) -> raw mem
FUN_SIMPLEFONTSTRING_CTOR = 0x00770D30, // __thiscall(mem, parent, layer, sublayer) -> fs
FUN_REGION_SET_NAME = 0x0076C650, // __thiscall(region, name) — registers _G[name]
FUN_FONTSTRING_SET_FONT = 0x00770C60, // __thiscall(fs + OFF_FONTSTRING_FONT_HOLDER, fontObject)
// CSimpleFontString::SetFont — `uint32_t __thiscall(fs, const char *path,
// float height, uint32_t flags, uint8_t force)`, `ret 0x10` (0x007715F7):
// builds and installs the font unless unchanged; 0 when it fails. Script
// FontString:SetFont (0x0079D4F0) converts the height as
// Game::PixelToInternal does, parses the flags (FONT_FLAG_*), and on
// success clears bit 0 of OFF_FONTSTRING_FONT_FLAGS (benilla-re ui/fonttext).
FUN_SIMPLEFONTSTRING_SET_FONT = 0x007714F0,
OFF_FONTSTRING_FONT_FLAGS = 0xD4,
FONT_FLAG_OUTLINE = 1, // ParseFontFlags 0x006F1A90: OUTLINE 1, MONOCHROME 2, THICKOUTLINE 4
FUN_REGION_SET_POINT = 0x00767C70, // __thiscall(region+OFF_REGION_ANCHOR, point, relAnchor, relPoint, x, y, flag=1)
OFF_FONTSTRING_FONT_HOLDER = 0xCC, // font-reference sub-object (SetFont `this`)
OFF_FONTSTRING_FONT_OBJECT = 0xD0, // font object pointer (holder + 4)
OFF_REGION_ANCHOR = 0x24, // LayoutFrame anchor sub-object (SetPoint `this` / relativeTo base)
// --- GetPoint dangling-anchor guard (Frame::GetPointGuard) ---
// `Script_GetPoint` walks a region's 9 anchor-node slots at
// region+0x28. Each node with vtable VAR_ANCHOR_VTABLE_WITH_RELATIVE
// carries a RAW `relativeTo` pointer at +0x0C (the anchor target's
// LayoutFrame inner = target CFrame base + OFF_REGION_ANCHOR). When the
// target frame is freed the pointer is never cleared; GetPoint then does
// `MOV EAX,[relativeTo-0x24+4]` at 0x007A2452 → ERROR #132. The rel-less
// anchor node type (vtable 0x0081C42C, 12 bytes) has NO relativeTo field
// and its readers never deref one, so only 0x44C nodes can dangle.
FUN_GET_POINT = 0x007A2340, // engine Script_GetPoint (Region registry idx 15); delegate target
FUN_REGION_CLEAR_POINT_BY_RELATIVE = 0x00767E70, // __thiscall(region+OFF_REGION_ANCHOR, relativeTo, doRelayout): frees+NULLs every anchor node on this region whose GetRelativeTo()==relativeTo (pointer compare, never derefs the target). The engine's own "my anchor target was removed" cleanup — the one NOT called on target destruction, which is the bug.
OFF_REGION_ANCHOR_ARRAY = 0x28, // region base + 0x28 = anchor-node slot[0] (= OFF_REGION_ANCHOR + 4)
REGION_ANCHOR_SLOT_COUNT = 9, // one slot per FRAMEPOINT_* enum (0..8)
OFF_ANCHOR_NODE_RELATIVE_TO = 0x0C, // raw relativeTo ptr within a 0x44C anchor node
VAR_ANCHOR_VTABLE_WITH_RELATIVE = 0x0081C44C, // .rdata vtable of anchor nodes that carry a relativeTo (vs rel-less 0x0081C42C)
// The point names the XML loader and SetPoint share (benilla-re
// ui/anchors "Point slots and point names"), 4.3.4's StringToFramePoint /
// FramePointToString: `int __fastcall(const char *name, int *point)` (1 when
// known, case-insensitive) and `const char *__fastcall(int point)`
// ("UNKNOWN" for none).
FUN_STRING_TO_FRAME_POINT = 0x006F1840,
FUN_FRAME_POINT_TO_STRING = 0x006F1890,
DRAWLAYER_ARTWORK = 2,
DRAWLAYER_OVERLAY = 3,
FRAMEPOINT_TOPLEFT = 0,
FRAMEPOINT_TOP = 1,
FRAMEPOINT_TOPRIGHT = 2,
FRAMEPOINT_LEFT = 3,
FRAMEPOINT_CENTER = 4,
FRAMEPOINT_RIGHT = 5,
FRAMEPOINT_BOTTOMLEFT = 6,
FRAMEPOINT_BOTTOM = 7,
FRAMEPOINT_BOTTOMRIGHT = 8,
// FUN_REGION_SET_POINT stores offsets in *internal* coordinates, not
// pixels. Script_SetPoint converts: `internal = pixel * [0x00832A44] /
// ([0x00832A4C] * 1024)` (FUN_0041ae60's factor × input ÷
// (FUN_0041ad70's return × DAT_007ffd68)). Both globals are runtime
// UI-scale floats; passing raw pixels makes offsets ~1000× too large.
// The REVERSE conversion (internal → UI pixels) is what the Script_*
// measure getters push: Script_GetStringWidth (0x0079E510) — and our
// GetStringHeight backport — compute `px = internal * [0x00832A4C] *
// 1024 / [0x00832A44]` (FUN_0041AE40(FUN_0041AD70() × DAT_007FFD68 × v)).
//
// These four floats are the engine's Coordinate statics — the same block
// 3.3.5/4.3.4 keep as s_aspectRatio / s_ddcWidthScale / s_ddcHeightScale /
// s_aspectCompensation (Base/Coordinate.cpp in the 4.3.4 decomp; the 1.12
// image carries the identical static initializers 4/3, 0.8, 0.6, 1.0 at
// 0x00832A40). The anchor ("DDC", diagonal-normalized) space spans
// ddcWidthScale × ddcHeightScale across the screen, so the width scale IS
// the screen width in anchor units — the px→internal numerator above —
// and the height scale its Y sibling. Set together by the engine's
// CoordinateSetAspectRatio: comp = aspect × 0.75, s = 1/√(aspect²+1),
// height = s, width = aspect × s. Verified via the gxu text position
// converter FUN_0041ade0: block/node positions are stored NORMALIZED,
// x = anchor / width scale, y = anchor / height scale.
VAR_COORD_ASPECT_RATIO = 0x00832A40,
VAR_COORD_DDC_WIDTH_SCALE = 0x00832A44,
VAR_COORD_DDC_HEIGHT_SCALE = 0x00832A48,
VAR_COORD_ASPECT_COMPENSATION = 0x00832A4C,
UI_COORD_SCALE_UNIT = 1024, // DAT_007ffd68
// gxu text-raster dimensions — INT dwords holding the live render-target
// size in PIXELS ({0,0,640,480} fallback), written by FUN_005c2b50 from
// the render-target rect (FUN_0058a240) whenever it changes; every font
// page re-rasterizes on change (the FUN_005ca6f0 walk). These are the
// normalized→pen multipliers: the origin finalize FUN_005cdf70 computes
// node origin (+0x70/+0x74) = round(normalizedPos × [raster]) after
// folding the justify shift (right: +widthLimit, centre: +half) and
// vertical align; the emitter's font-height helper FUN_005C6FA0 is
// round(fontSize × [VAR_TEXT_RASTER_Y]) the same way (x sibling
// FUN_005C7010 uses _X). So TEXT PEN UNITS ARE RENDER-TARGET PIXELS, and
// pen-per-anchor = [VAR_TEXT_RASTER_*] / [VAR_COORD_DDC_*_SCALE] per
// axis — the exact conversion Text::InlineTexture's flush uses to place
// icon regions (verified against a live probe: rasterX/anchorW matched
// the measured origin÷rect-edge quotient to four digits).
VAR_TEXT_RASTER_Y = 0x00C2B9A0,
VAR_TEXT_RASTER_X = 0x00C2B9A4,
// GxCapsWindowSize — `__fastcall(float rect[4])`: the graphics device's
// live render-window rectangle (device vtable +0x5C), the source the
// two globals above are read from by GxuFontUpdateViewport
// (0x005C2B50). Layout {y0, x0, y1, x1}: width = r[3] - r[1], height =
// r[2] - r[0] — the font code's fallback writes {0, 0, 480, 640}, and
// BakePortrait takes its width from r[3] - r[1] of the sibling
// GxCapsScreenSize (0x0058A250).
FUN_GX_CAPS_WINDOW_SIZE = 0x0058A240,
// gxu text-node invalidate/reset — `__fastcall(node)`. Zeroes the
// built-line count (+0x9C, the draw builder's early-out gate), resets the
// link-rect state (+0x80/+0x90) and wrap cache (+0x68/+0x6C), and frees
// all 8 page buffers — the next paint's pre-pass re-runs the builder, so
// the emitter re-bakes the node from scratch. This is what the node
// colour setter FUN_005CCB40 calls on a colour change for accumulation
// (bit-3-clear) nodes; InlineTexture's flush calls it for a SEGMENTED
// bit-3 node whose BASE colour RGB changed (glue AddonList toggle), since
// baked per-glyph RGB can't be patched in place (|c runs own theirs).
FUN_TEXT_NODE_INVALIDATE = 0x005CDEF0,
// gxu font-face flags word. Bit 0 (0x1) = thin outline, bit 3 (0x8) =
// thick outline: the emitter's prologue (FUN_005CCBE0) reads
// *(fontFace+0x180) and grows the line height by [FLOAT_OUTLINE_EXTRA_*]
// pen px for outlined faces, because outline INK extends past the glyph
// metrics; the rebuild/color-sync shadow paths test the same bits. The
// inline-texture lead/trail pads read the same flags so an icon clears an
// outlined neighbour's ink (the coin-into-digits clip).
OFF_FONTFACE_FLAGS = 0x180,
// The engine's outline ink allowance, .rdata float constants (4.0 / 2.0
// pen px total, i.e. ~2 / ~1 px per side) — the exact values the emitter
// adds to line height for bit 3 / bit 0 outlined faces. Read live so we
// stay bit-identical with the engine's own compensation. The 2.0 constant
// double-duties as the MINIMUM font size numerator in the node ctor
// (FUN_005cd6d0 / FUN_005ccb80: fontSize floored at [0x801628]/rasterY =
// 2 pen px).
FLOAT_OUTLINE_EXTRA_THICK = 0x0080306C,
FLOAT_OUTLINE_EXTRA_THIN = 0x00801628,
// The node's BUILT line count — incremented once per emitted wrapped line
// by the draw builder (FUN_005CDC20, including the \n break case) and the
// builder's own early-out gate (`if (node+0x9C != 0) return`); zeroed by
// the node invalidate (FUN_TEXT_NODE_INVALIDATE). The render truth for
// FontString:GetNumLines once the node has painted.
OFF_TEXT_NODE_BUILT_LINES = 0x9C,
// Wrap break-array computer: `__thiscall(fs, const char *text, float
// wrapWidth /*fs-internal units*/, int *outBreaks, int cap)` → segment
// count (byte offsets into text, [0]=0). Routes through FUN_005C2430 →
// the wrap stepper, so it is icon-aware via the stepper co-hook. Verified
// from the GameTooltip auto-size (FUN_00530640), which fills a 20-entry
// array and measures each segment via FUN_FONTSTRING_MEASURE_SUBSTRING.
// Prologue 55 8B EC 56 8B F1, RET 0x10. Co-hooked by Text::InlineTexture
// to give the wrap stepper the fontstring's layout scale.
FUN_FONTSTRING_BREAK_ARRAY = 0x00772B60,
// Substring width measure: `__thiscall(fs, const char *text, int len)` →
// ST0 (len 0 = strlen). Same measure-core call + `out / fs+0x7C` shape as
// GetStringWidthInternal, but for an ARBITRARY string in the fs's font —
// no cache. Callers (xrefs): the GameTooltip auto-size FUN_00530640, which
// measures each WRAPPED SEGMENT of a wrap-enabled line between the
// FUN_00772B60 break positions and takes the max as the tooltip width —
// the icon-relevant consumer (an earlier note claimed nothing consumed
// this function; the xref list refutes it) — plus the editbox
// caret/selection cluster (FUN_0077DA80, FUN_0077DE70, FUN_0077D0D0).
FUN_FONTSTRING_MEASURE_SUBSTRING = 0x00772AE0,
// Fit-to-width: `int __thiscall(fs, const char *text, uint32_t bytes,
// float width)` → how many characters of `text` fit `width` (fs units;
// bytes 0 = strlen), RET 0xC. Calls FUN_0044d860 → GxuFontGetMaxChars-
// WithinWidth (0x5c2190 → 0x5c6c50) and returns its EAX count (benilla
// names it MeasureText and types it float — the disassembly returns the
// kernel's int). Callers (xrefs): CSimpleEditBox::RebuildLabel 0x77d71a
// (the single-line visible window), MeasureWindow 0x77d38a and
// GetIndexAtPoint 0x77d2e0 (mouse → cursor). Co-hooked by
// Text::InlineTexture so icons take their width.
FUN_FONTSTRING_FIT_TEXT = 0x00772BC0,
// FontString → gxu face resolution, for fs-level (measure-hook) callers
// that need the face the RENDER will use. The rebuild (FUN_007724a0)
// passes [fs+0xE0] (the font HANDLE) to the block creator FUN_0044d420,
// which hands [handle+0x20] to FUN_005c1c30 → FUN_005cd6d0, which stores
// it at node+0x44 — the emitter's face (`this` for every glyph call, and
// the +0x180 outline-flags carrier). So face = [[fs+0xE0]+0x20].
OFF_FONTSTRING_FONT_HANDLE = 0xE0,
OFF_FONT_HANDLE_FACE = 0x20,
// CSimpleTexture (`Texture` widget) creation + operate primitives, used by
// Text::InlineTexturePool to render inline |T icons as engine-owned,
// managed-pool, resident-kept textures (the residency fix — see
// docs/InlineTextureResidency.md). Mirrors Script_CreateTexture
// (FUN_00773A20) and the Texture frame-method handlers; the sibling of the
// CSimpleFontString path above. Same FUN_REGION_POOL_ALLOC / SetPoint /
// Show / Hide / SetColor (FUN_FONTSTRING_SET_COLOR) as the FontString pool.
VAR_SIMPLETEXTURE_POOL = 0x00CF4CE0, // &DAT_00cf4ce0 CSimpleTexture free-list pool (`this`)
VAR_SIMPLETEXTURE_CLASS_TAG = 0x00846588, // ".?AVCSimpleTexture@@" (alloc debug tag)
FUN_SIMPLETEXTURE_CTOR = 0x0076FC40, // __thiscall(mem, parent, layer, sublayer) -> tex
// --- MaskTexture object API (frame:CreateMaskTexture / Texture:AddMaskTexture) ---
// CreateMaskTexture mints its mask region by calling the engine's own
// Script_CreateTexture (reads (frame,name,layer,template) off the Lua stack and
// pushes the new CSimpleTexture), then hides it — the mask is a source, never drawn.
// The draw hook reads the mask's HTEXTURE (OFF_SIMPLETEXTURE_HTEXTURE, +0xCC, set
// by SetTexture and valid while hidden) + its rect (FUN_REGION_GET_RECT); the
// +0xC4 shown flag is OFF_REGION_DESIRED_SHOWN (defined below).
FUN_SCRIPT_CREATE_TEXTURE = 0x00773A20, // Script frame:CreateTexture, __fastcall(L)->int
// CSimpleTexture::SetTexture(path). Loads via FUN_00449D90, stores the owned
// HTEXTURE at +0xCC (releases the old via DecRef FUN_0041AED0), marks dirty.
// `__thiscall(tex, path, 0, *VAR_TEXTURE_BLEND_DEFAULT, 0) -> u32`. The
// ownership + engine batched region-draw is the residency win. Same-path
// early-out makes pooled reuse cheap.
FUN_SIMPLETEXTURE_SET_TEXTURE = 0x00770200,
// Script_Texture_SetTexture — the Lua `texture:SetTexture(...)` handler. Its
// NUMERIC branch (arg 2 a number) clamps r/g/b/a to [0,1] and fills the
// texture with a solid colour via FUN_00770360; its string branch loads a
// path through FUN_00770200 above. texture/ColorTexture.cpp aliases this whole
// handler as the 7.0 `SetColorTexture` (which IS exactly the numeric form), so
// the clamp and opaque-alpha default come straight from the engine.
FUN_SCRIPT_TEXTURE_SET_TEXTURE = 0x0079BB40,
// Script_Texture_SetTexCoord — the Lua `texture:SetTexCoord(...)` handler
// (entry 17 of the Texture method batch at 0x0087C128). Takes the 4-arg
// (left, right, top, bottom) and 8-arg corner forms and writes through to
// FUN_SIMPLETEXTURE_SET_TEXCOORD below. texture/Atlas.cpp delegates to this
// handler rather than the native setter so an atlas set inherits the engine's
// own arg validation and both coordinate forms.
FUN_SCRIPT_TEXTURE_SET_TEXCOORD = 0x0079BEB0,
// `texture:GetTexCoord()` (entry 16 of the same batch). Always returns 8
// values — four (x, y) corner pairs read from region +0x104 in the order
// UL, LL, UR, LR. texture/Atlas.cpp co-hooks both this and the setter so an
// atlas'd texture's coordinates address the sprite rather than the file it
// sits in; the pair is the only place that mapping is applied.
FUN_SCRIPT_TEXTURE_GET_TEXCOORD = 0x0079BDF0,
// CSimpleTexture::SetTexCoord — `__thiscall(tex, float[4])`. Struct field
// order is {top, left, bottom, right} = {v0, u0, v1, u1} (verified from the
// SetTexCoord handler 0x0079BEB0's Lua-arg → struct mapping). Natural
// texcoords (no v-flip — the engine region path is top-left origin).
FUN_SIMPLETEXTURE_SET_TEXCOORD = 0x00770410,
OFF_SIMPLETEXTURE_HTEXTURE = 0xCC, // owned HTEXTURE ref (diagnostic)
// The four drawn-quad corner POSITIONS: 4 vertices of {x, y, z} floats (0xC
// stride), order BL, TL, BR, TR (from FUN_REGION_STORE_CORNERS's writes). The
// region draw enqueue FUN_00772fd0 (0x00772fd0) hands region+0xD4 straight to
// the vertex batch as FOUR INDEPENDENT vertices — and region+0x104 as the
// matching 4 per-corner texcoords — never re-deriving an axis-aligned rect.
// So writing ROTATED x,y here draws a rotated quad with NO corner clipping
// (unlike 4.3.4's SetRotation, which rotates the texcoords instead). Used by
// texture/Rotation.cpp for Texture:SetRotation.
OFF_SIMPLETEXTURE_CORNERS = 0xD4,
// Region corner-store: `__thiscall(region, const float rect[4])` writes the
// drawn quad corners into region+0xD4..+0x100 from the rect ({yA,left,yB,right}
// screen px). The renderer only draws a region whose +0xD4 corners are
// populated (verified: the draw gate tests region+0xD4 != 0), and normally
// SetPoint→layout-resolve calls this. We call it directly to place an icon by
// its screen rect with NO anchors (anchoring 100+ textures/frame corrupts the
// UI-manager pending-layout list — the FUN_00765650 crash). Co-hooked by
// texture/Rotation.cpp, which re-applies rotation right after the engine
// restores the axis-aligned corners (layout resolve / SetTexCoord).
FUN_REGION_STORE_CORNERS = 0x007705B0,
// CSimpleTexture::OnFrameSizeChanged — `__thiscall(texture+OFF_REGION_ANCHOR,
// const float *oldRect)`, the layout callback: lays out dependents, then
// writes the corners from the new rect (cropped when +0x124 is set) with
// FUN_REGION_STORE_CORNERS. 4.3.4's CSimpleTexture::OnFrameSizeChanged
// (0x004F8E30), less its playing-animation leg, which Animation::Region
// adds back with a co-hook. Verified by decompile (benilla-re regions.md).
FUN_TEXTURE_ON_FRAME_SIZE_CHANGED = 0x00770670,
// Texcoord crop applied to a {top,left,bottom,right} screen rect before the
// corner-store: shrinks right→left and bottom→top by the region's per-corner
// texcoord span (ABS of the +0x104 U/V differences). No-op for full 0..1
// texcoords. `__thiscall(region, float rect[4])`, rect in/out. The crop
// itself is unconditional; every engine call site gates it on
// OFF_REGION_TEXCOORD_MODIFIES_RECT below — with the flag clear (the
// default) a partial SetTexCoord draws at the region's FULL size, so
// callers replicating an engine store must apply the same gate.
FUN_REGION_TEXCOORD_CROP = 0x00770570,
// The SetTexCoordModifiesRect flag (int). Written from the Lua boolean by
// Script_SetTexCoordModifiesRect (0x0079C080, `piVar4[0x49]`), read back
// 1/nil by Script_GetTexCoordModifiesRect (0x0079C120). All three
// FUN_REGION_TEXCOORD_CROP call sites test it: the SetTexCoord writers
// (FUN_00770410 4-arg, FUN_007704C0 8-arg corner form) crop+store only
// when set, and the layout-resolve store path (FUN_00770670) crops when
// set / stores the raw anchor rect (+0x40..+0x4C) when clear. Zero by
// default (region ctor), so the crop never runs unless an addon opts in.
OFF_REGION_TEXCOORD_MODIFIES_RECT = 0x124,
// The region's pixel-shader slot (CGxShader*, 0 = fixed-function). This IS
// the engine's desaturation state: Script_SetDesaturated (0x0079C1E0)
// stores the UI Desaturate shader here via FUN_SIMPLETEXTURE_SET_SHADER,
// Script_IsDesaturated (0x0079C2C0) tests it != 0, the batch append
// FUN_00772FD0 copies it into the layer entry (+0x18), and the layer draw
// FUN_0076FB00 binds it per region with GxRs selector GXRS_PIXEL_SHADER.
// The region ctor FUN_0076FC40 zeroes it. texture/Desaturation.cpp selects
// its per-level shader objects through this slot — see the "Texture
// desaturation" block.
OFF_SIMPLETEXTURE_SHADER = 0x128,
// Get the region's resolved screen rect: `__thiscall(region+OFF_REGION_ANCHOR,
// float out[4]) -> int` (1 = valid, 0 = not laid out yet). Reads the anchor
// sub-object's +0x40..+0x4C = {bottom, left, top, right} — 4.3.4's
// CLayoutFrame::GetRect and its CRect {minY, minX, maxY, maxX}, in DDC
// (Script_GetBottom 0x007A1CE0 reads out[0], Script_GetTop 0x007A1BC0
// out[2]) — gated on the rect-valid bit [+0x3c]&1. This is the engine's own source for the corner
// rect (see FUN_00770410's SetTexCoord path); texture/Rotation.cpp reads it to
// rebuild axis-aligned corners before rotating.
FUN_REGION_GET_RECT = 0x00768320,
// __thiscall(region+OFF_REGION_ANCHOR) -> int (nonzero = layout dirty, needs a
// resolve). GetLeft gates its resolve on this. Paired with the flag-1 resolve
// below to read a hidden region's rect synchronously.
FUN_REGION_LAYOUT_DIRTY = 0x00768310,
// __thiscall(region+OFF_REGION_ANCHOR, int flag /*stack; pass 0*/) — force a
// synchronous layout resolve: recomputes the region's rect (+0x64) from its
// anchors right now, instead of waiting for the render's pending-layout pass.
// Verified from Show (FUN_0077FCB0 at 0x0077FCE1: PUSH 0; LEA ECX,[ESI+0x24];
// CALL). Load-bearing for tick-time icon placement: SetTexCoord
// (FUN_00770410) stores the DRAW CORNERS (+0xD4) from the rect as a side
// effect, so without a realize between SetPoint and SetTexCoord the corners
// are stored from the STALE pre-anchor rect — the region's rect then resolves
// correctly (diagnostics look perfect) but the renderer draws the corners,
// which stay zero/stale → invisible icons (and the old build's frozen
// top-left icons: corners stored from the zero rect at first apply).
FUN_REGION_LAYOUT_REALIZE = 0x00768060,
// CSimpleFontString::RebuildString — destroys the old gxu text node and
// creates the fresh one (FUN_0044d420), storing it at fs+0xF8. Gated on the
// fs dirty bit (+0x60 & 1), so it fires on TEXT CHANGES, not per frame.
// Co-hooked by Text::InlineTexture to map text node → owning fontstring —
// the key that lets inline-icon regions anchor to their owning line
// (1.12 chat lines ARE CSimpleFontStrings: the ScrollingMessageFrame's
// display refresh FUN_00788750 SetTexts/anchors/shows one fs per visible
// line — verified against the 4.3.4 CSimpleEmbeddedTexture model, which
// anchors its icon regions to the owning fontstring the same way).
FUN_FONTSTRING_REBUILD_STRING = 0x007724A0,
// fs+0xF8 holds an HTEXTBLOCK handle, NOT the node itself: FUN_0044d420
// allocates the 12-byte handle {vtbl, refcount, node}, FUN_005c1c30 writes
// the created text node into handle+8, and FUN_0041af10 AddRefs and returns
// the handle. The layout's node (what the emitter/paint hooks see) is
// therefore *( *(fs+0xF8) + 8 ).
OFF_FONTSTRING_TEXT_BLOCK = 0xF8, // HTEXTBLOCK handle (0 when dirty/empty)
// CSimpleFontString live text color: count at +0xB4, array pointer at +0xB8
// (uint32 BGRA per slot; slot 0 = the base color, alpha = byte 3; a parallel
// per-glyph alpha-byte array hangs off +0xA8/+0xA4). Written by the fs
// SetColor (FUN_FONTSTRING_SET_COLOR 0x0077F750: stores the dword at
// (*(u32**)(fs+0xB8))[0] + the alpha byte at (*(u8**)(fs+0xA8))[0], then
// fires the color-update vmethod +0x20). Count 0 = never colored = default
// opaque white. THE CHAT-FADE SIGNAL: the ScrollingMessageFrame's fader
// (FUN_00788460, gated on the SetFading flag at smf+0x360; per-line state
// {rgba@+4, shown@+8, timeVisibleLeft@+0xC, fadeLeft@+0x10} in the
// stride-0x10 line array at smf+0x3A4) animates each visible line
// fontstring's alpha byte through this same SetColor every frame, then
// hides the fs at fade end. Text::InlineTexturePool mirrors this byte onto
// the line's icon regions each tick so inline icons fade with their line
// (regions parent to the CHAT FRAME, so the frame's own alpha byte —
// frame+0xC8, per Script_GetAlpha 0x00774DC0 — already modulates them via
// the engine's parent×region product; only the fs's own component needs
// mirroring).
OFF_FONTSTRING_COLOR_COUNT = 0xB4,
OFF_FONTSTRING_COLOR_ARRAY = 0xB8,
OFF_TEXTBLOCK_NODE = 0x8, // the gxu text node inside the handle
// Byte of fontstring state flags; bit 1 = "text block needs rebuild".
// RebuildString (0x7724A0) gates on it at entry, releases the old block
// (+0xF8 = 0), and only CREATES a new one if the fs rect is resolved —
// a SetText during an unresolved rect leaves the fs blockless with the
// refcounted zombie node still painting. If the bit is also clear at that
// point, nothing ever rebuilds (the stuck-blockless state InlineTexture's
// flush nudges by re-setting this bit).
OFF_FONTSTRING_DIRTY_FLAGS = 0x60,
// The per-node draw builder: walks a node's wrapped lines and calls the
// glyph emitter (FUN_TEXT_EMITTER) once per line. Called from the paint's
// per-node pre-pass FUN_005cd6a0 (`__thiscall(node)`, no stack args). We
// co-hook it to stamp exact BUILD BOUNDARIES for the emitter's first-line
// detection — the old `text == node+text-ptr` heuristic silently failed on
// pfUI-processed chat lines (stale/preprocessed pointer), leaving inherited
// records on reused node addresses (ghost icons) or never clearing them.
FUN_TEXT_DRAW_BUILDER = 0x005CDC20,
// The gxu text-node FREE: unlinks the node from its layout lists and pushes
// it onto the node free list (DAT_00c2b98c) for reuse. Single caller —
// FUN_005c1d00, the HTEXTBLOCK handle release (handle vtbl 0x008026e4 dtor
// 0x0044D5C0 → 0x005c1d00 → here). This is the choke point where every
// text node dies and its address becomes reusable: InlineTexture hooks it
// to erase ALL per-node state exactly at death, making stale-record and
// stale-owner bugs (ghost icons, orphaned records) structurally impossible
// instead of heuristically guarded.
FUN_TEXT_NODE_FREE = 0x005CD950,
// Ensure a text node is laid out: `__fastcall(node)` -> FUN_005cd3f0 + the
// draw builder FUN_005CDC20 (runs the glyph emitter and finalizes the node
// origin +0x70/+0x74), then clears node+0xc0. Same "ensure built" the paint
// pass (FUN_005c8fe0) calls per node; safe to call directly (the builder
// re-lays the node — a clean node just re-emits the same glyphs). Verified
// callers: the paint pass and FUN_005cd4d0 (the width/resize helper).
// Text::InlineTexture drives it PRE-RENDER from the SMF-refresh early-apply
// so a chat line's icons are recorded before the frame draws.
FUN_TEXT_ENSURE_BUILT = 0x005CD6A0,
// CScrollingMessageFrame display refresh — `__thiscall(smf, int newestIdx)`.
// Rebuilds the visible line set bottom-up: per slot it SetTexts the line
// fontstring (FUN_00788af0 -> SetText FUN_00771d80 + enqueue-resolve
// FUN_007680e0 flag 1), (re)anchors newly-allocated lines, shows/hides by
// message. Every new message shifts the newest index, so EVERY visible slot
// is re-SetText'd -> its inline icons must be recomputed; the engine builds
// the line lazily at paint, so icons land one frame after the glyphs (the
// one-frame lag). Text::InlineTexture co-hooks this and, post-refresh,
// forces each icon-bearing line to resolve+build and applies its icon
// placement synchronously — pre-render (the refresh runs from the SMF's
// Lua/event-driven methods, never mid-render), so icons draw with their
// glyphs the same frame. Line-entry layout verified from the decompile:
// count@+0x3A0, stride-0x10 entry array@+0x3A4, entry+8 = the line fs.
FUN_SMF_DISPLAY_REFRESH = 0x00788750,
OFF_SMF_LINE_COUNT = 0x3A0, // int: allocated visible-line count
OFF_SMF_LINE_ARRAY = 0x3A4, // base of the stride-0x10 line-entry array
SMF_LINE_STRIDE = 0x10, // per-line-entry stride
OFF_SMF_LINE_FONTSTRING = 0x8, // entry+8 = the line's CSimpleFontString
// THE pen↔anchor unit bridge. RebuildString (0x7724A0) multiplies every
// text-unit quantity by region+0x7C when crossing into node creation:
// nodePos = inset×s + rect corner, nodeFontH = fontPx×s, spacing = +0xF4×s,
// and divides rect extents by s for the text-unit width/height. SetParent
// (FUN_0076AB10) propagates the parent's +0x7C down the frame tree — it's
// the per-object layout/UI-scale chain. This single scalar is what every
// earlier "derive the scale" attempt (13/16, ownerH/fontH) was guessing at.
OFF_LAYOUT_SCALE = 0x7C, // float: anchor units per text/pen unit
OFF_FONTSTRING_INSET_X = 0x110, // float, text units (RebuildString posX term)
OFF_FONTSTRING_INSET_Y = 0x114, // float, text units (RebuildString posY term)
// CSimpleFontString::OnFrameSizeChanged — `__thiscall(fs+OFF_REGION_ANCHOR,
// const float *oldRect)`: rebuilds the string when the rect's size changed,
// else moves it to inset × OFF_LAYOUT_SCALE + the rect's min corner
// (rect[1] x, rect[0] y) with FUN_TEXTBLOCK_SET_STRING_POS. 4.3.4's
// CSimpleFontString::OnFrameSizeChanged (0x004FE350), less its
// playing-animation leg, which Animation::Region adds back with a co-hook.
// Verified by decompile.
FUN_FONTSTRING_ON_FRAME_SIZE_CHANGED = 0x00772D40,
// TextBlockSetStringPos — `void __fastcall(HTEXTBLOCK, const float pos[3])`:
// divides the DDC x/y by the screen scale (UnscaleScreenXY 0x0041ADE0) and
// stores them with GxuStringSetPosition (0x005C2770 → CGxString::SetPosition
// 0x005CCB10, which writes OFF_TEXT_NODE_POSITION and refinalizes the
// origin). The call SetTextOffset (0x00772100) and OnFrameSizeChanged use.
FUN_TEXTBLOCK_SET_STRING_POS = 0x0044D600,
// CSimpleRegion::SetParentAndLayer — __thiscall(region, parentFrame, layer,
// show). Handles old-parent unlink + new-parent region-registry insert +
// conditional Show. Verified from the region base ctor FUN_0077F640 and the
// message frame's per-line setup (FUN_00788750 calls it with (frame, 2, 1)).
FUN_REGION_SET_PARENT_AND_LAYER = 0x0077FD10,
OFF_REGION_PARENT = 0x9C, // region's parent frame ptr (read by Show's gates)
OFF_REGION_DESIRED_SHOWN = 0xC4, // Show (FUN_0077FCB0) NO-OPS unless this is set;
// engine callers always write it before show/hide
OFF_REGION_ACTUALLY_SHOWN = 0xC8, // 1 after Show completed (the realize latch)
// Owning-frame recovery for the inline-icon pool (the 3.3.5 ownership model,
// no overlay). Chat renders through the strata walker FUN_007657d0 →
// per-frame draw-list rebuild FUN_00765920 → per-layer render FUN_0076FB00 →
// text paint (NOT through the child-frame render FUN_0076B3F0). So
// Text::InlineTexturePool co-hooks the two below:
// • FUN_FRAME_DRAWLIST_REBUILD — `__fastcall(frame)`, receives the frame
// cleanly and owns its 5 inline draw layers at frame + OFF_FRAME_LAYER_BASE
// + i*FRAME_LAYER_STRIDE. We record layer→frame so the layer-render hook
// can recover the owning frame with no offset-scan / vtable guessing.
// • FUN_FRAME_LAYER_RENDER — `__fastcall(layer)`, the per-layer paint that
// directly wraps the chat text paint. We bracket the icon pool's pass here
// (the flush runs nested) and look the frame up in the layer→frame map.
FUN_FRAME_DRAWLIST_REBUILD = 0x00765920,
FUN_FRAME_LAYER_RENDER = 0x0076FB00,
OFF_FRAME_LAYER_BASE = 0x1C, // first inline draw layer, region-relative
FRAME_LAYER_STRIDE = 0x30, // per-layer stride
FRAME_LAYER_COUNT = 5, // BACKGROUND..OVERLAY
// Resolved on-screen rect of a region: 4 floats at regionBase+0x64 (=
// LayoutFrame+0x40), in GxU SCREEN PIXELS — verified: FUN_00770670 reads
// them and FUN_007705b0 stores them straight as GxU vertex corners. Layout is
// {yA, left, yB, right} (x at [1]/[3], y at [0]/[2]); use min/max to get
// left/top without pinning which y index is top.
OFF_REGION_RECT = 0x64,
// "Currently displayed thing" state fields on a GameTooltip frame
// instance. Each Set* path writes one of these (and zero or two
// others), and the per-tooltip Clear at FUN_00530050 zeroes all of
// them on Hide/before-redraw. The Get* methods are simple reads —
// whichever field is non-zero tells us what kind of tooltip is up.
//
// Verified by decoding the builder functions:
// - BuildItemTooltip (0x0052B650) writes +0x380/+0x384 (item
// GUID, only when there's a real CGItem) and
// +0x398 (itemID) at 0x0052B6CE / 0x0052B6FE.
// - BuildSpellTooltip (0x0052E610) writes +0x39C (spellID) at
// 0x0052E6D5 (param_7==0 branch — skipped for
// the next-rank tooltip side-build).
// - BuildUnitTooltip (FUN_00529FE0) writes +0x368/+0x36C (unit
// GUID) — see SetUnit block below.
// - BuildGameObjectTooltip (0x0052AA20) writes +0x370/+0x374
// (gameobject GUID) at 0x0052AA52 / 0x0052AA59.
// Only call site is the in-world hover handler
// FUN_00492890; no Lua `SetGameObject` method.
// - Clear (FUN_GAMETOOLTIP_CLEAR) zeroes unit(+0x368)/GO(+0x370)/
// itemID(+0x398)/spell(+0x39c) — but NOT the item GUID +0x380/+0x384.
// That omission means the item GUID goes stale across a switch to a
// tooltip that shows no item (SetUnitAura, SetEquipmentSet, …), so
// GameTooltip:GetItem would resolve the *previous* item. We co-hook
// the clear (Tooltip::Clear) to zero +0x380/+0x384 too, so
// every fresh tooltip resets it and only the item builder re-sets it.
// All 14 Set*/builder paths route through this clear, so the co-hook
// covers them uniformly. __fastcall(self).
FUN_GAMETOOLTIP_CLEAR = 0x00530050,
// Vanilla's own, never-exposed "texture on the last line" — `void
// __thiscall(tooltip, const char *texturePath)`, `ret 4`. Unreferenced in
// the 1.12 binary (no calls, no pointers). It takes the next of the three
// textures the XML-OnLoad scan (FUN_00529650) binds from
// `<name>Texture1..3` into OFF_GAMETOOLTIP_TEXTURES (`%sTexture%d`,
// 0x0052987C; the loop stops at 3) and, for the last line N:
// - re-anchors line N TOPLEFT → line N-1 BOTTOMLEFT at (texture width,
// VAR_TOOLTIP_LINE_GAP), reading the width through the texture's
// vtable +0x1C — it never sizes the texture (the template's 12x12);
// - clears the texture's anchors (thunk_FUN_00767620) and anchors its
// RIGHT to line N's LEFT;
// - if line N+1 is in the pool, re-anchors it to line N at
// (-width, gap), cancelling the shift for the lines below;
// - sets the file (FUN_SIMPLETEXTURE_SET_TEXTURE), shows it, records N
// in OFF_GAMETOOLTIP_TEXTURE_LINES and bumps
// OFF_GAMETOOLTIP_NUM_TEXTURES.
// Every re-anchor REPLACES the line's offset, so a second texture on line
// N, or one on line N+1, breaks the layout (`Tooltip::AddTexture` refuses
// both). No-op with fewer than 2 lines or all 3 textures used.
// FUN_GAMETOOLTIP_CLEAR undoes it (0x005300F2..0x005301CF): re-anchors
// line N at (0, gap) but line N+1 at (0, 0), hides the texture and zeroes
// the count (not the line indices). `Tooltip::Clear` restores line N+1's
// gap.
FUN_GAMETOOLTIP_ADD_TEXTURE = 0x005303D0,
OFF_GAMETOOLTIP_TEXTURES = 0x34C, // CSimpleTexture *[3]
OFF_GAMETOOLTIP_TEXTURE_LINES = 0x358, // uint32[3] — line index each texture sits on
OFF_GAMETOOLTIP_NUM_TEXTURES = 0x364, // uint32 — textures in use
// .rdata float -2.0 that the texture routine and the clear pass as the
// line gap in pixels (matching GameTooltipTemplate's TextLeftN y offset),
// converted with the SetPoint pixel → layout-unit chain
// (Game::PixelToInternal).
VAR_TOOLTIP_LINE_GAP = 0x008038DC,
OFF_TOOLTIP_ITEM_GUID_LO = 0x380, // 0 for SetItemByID (no CGItem); stale-safe via the clear co-hook
OFF_TOOLTIP_ITEM_GUID_HI = 0x384,
OFF_TOOLTIP_ITEM_ID = 0x398,
OFF_TOOLTIP_SPELL_ID = 0x39C,
// Auction/compare descriptor. Script_GameTooltip_SetAuctionItem
// (0x00535810) has no CGItem instance, so it stashes the listing's
// random-property (suffix) id at tooltip+0x424 and marks the
// compare-descriptor valid by writing the builder's compare flag to
// this[0x110] (tooltip+0x440) = 1 (SetAuctionItem passes param_6=1;
// every other Set* path passes 0, and the builder writes it on each
// param_7==0 build — so +0x440 is a reliable per-build gate, not
// stale). This is 1.12's analog of 3.3.5's `tooltip[0x130]`-gated
// `piVar5[0x2d]` random-property read in GameTooltip:GetItem. GetItem
// reads +0x424 (only when +0x440 is set) to put the suffix in the link.
OFF_TOOLTIP_COMPARE_FLAG = 0x440,
OFF_TOOLTIP_COMPARE_SUFFIX = 0x424,
// Unit GUID written by the inner unit-tooltip builder
// (FUN_00529FE0) when `tooltip:SetUnit(token)` resolves the token
// to a non-zero GUID. Cleared by the same `FUN_00530050` clear
// that handles the item/spell IDs above, so `(lo|hi) == 0` means
// "no unit currently displayed" — same gating pattern HasSpell /
// HasItem use.
OFF_TOOLTIP_UNIT_GUID_LO = 0x368,
OFF_TOOLTIP_UNIT_GUID_HI = 0x36C,
// GameObject GUID written by the in-world hover tooltip populator
// (FUN_0052AA20) — there is no Lua-callable `SetGameObject` method
// in vanilla, so this slot only ever fills when the player mouses
// over a gameobject in the world (nodes, chests, doors, etc.).
// Same clear/gating semantics as the unit GUID slot.
OFF_TOOLTIP_GAMEOBJECT_GUID_LO = 0x370,
OFF_TOOLTIP_GAMEOBJECT_GUID_HI = 0x374,
// Owner frame stored by `tooltip:SetOwner(frame, anchor)` and
// compared by `IsOwned`. Holds `owner_CObject + OFF_FRAME_LAYOUT_SUBOBJECT`
// (i.e. the LayoutFrame*, not the bare Frame*), or 0 if unowned.
// Verified via the helper at 0x0052FFE0 invoked by SetOwner's tail
// (writes `[this+0x314] = arg+0x24`) and Script_GameTooltip_IsOwned
// at 0x00530FE0 (reads `[edi+0x314]` and compares against the same
// `+0x24`-offset value).
OFF_TOOLTIP_OWNER = 0x314,
// Tooltip layout state — 4.3.4's CGTooltip m_anchorType / m_offsetX /
// m_offsetY / m_padding / m_minimumWidth. Offsets and padding are stored
// in internal units (Game::PixelToInternal), not pixels. Verified from the
// setters: FUN_0052FFE0 (SetOwner's tail) writes owner +0x314, anchor
// +0x318, offsets +0x3C4/+0x3C8; Script_SetPadding writes +0x3BC through
// FUN_00530630; Script_SetMinimumWidth writes the raw width to +0x3C0.
OFF_TOOLTIP_ANCHOR_TYPE = 0x318,
OFF_TOOLTIP_PADDING = 0x3BC,
OFF_TOOLTIP_MIN_WIDTH = 0x3C0,
OFF_TOOLTIP_OFFSET_X = 0x3C4,
OFF_TOOLTIP_OFFSET_Y = 0x3C8,
// The anchor codes `OFF_TOOLTIP_ANCHOR_TYPE` holds. 1.12's own numbering
// (4.3.4's differs: it has ANCHOR_BOTTOM and ANCHOR_TOP in it), read off
// Script_SetOwner's name chain (FUN_005310D0) and the position routine's
// switch (FUN_0052FE90): LEFT 0, RIGHT 1, BOTTOMLEFT 2, BOTTOMRIGHT 3,
// TOPLEFT 4, TOPRIGHT 5, CURSOR 6, NONE 7, PRESERVE 8. That name chain
// is case-insensitive and sends any other name to LEFT.
TOOLTIP_ANCHOR_LEFT = 0,
TOOLTIP_ANCHOR_RIGHT = 1,
TOOLTIP_ANCHOR_BOTTOMLEFT = 2,
TOOLTIP_ANCHOR_BOTTOMRIGHT = 3,
TOOLTIP_ANCHOR_TOPLEFT = 4,
TOOLTIP_ANCHOR_TOPRIGHT = 5,
TOOLTIP_ANCHOR_CURSOR = 6,
TOOLTIP_ANCHOR_NONE = 7,
TOOLTIP_ANCHOR_PRESERVE = 8,
// ClassicAPI's own codes for the two names 4.3.4 has and 1.12 does not.
// The engine never stores them; its position routine falls out of its
// switch for any code above 5, which is why `Tooltip::Layout` hooks it. Its
// fade code treats every code but CURSOR as "fade" (FadeOut, 0x00530AE0),
// and GetAnchorType's default is "ANCHOR_NONE".
TOOLTIP_ANCHOR_TOP = 9,
TOOLTIP_ANCHOR_BOTTOM = 10,
// The position routine — `__thiscall(tooltip, int force)`, `ret 4`; 4.3.4's
// CGTooltip::ResetPosition. Does nothing without an owner or for PRESERVE.
// Unless the type is NONE (or `force` is 0), it first clears the frame's
// points (FUN_00767ED0), then re-anchors for the six corner types with
// FUN_00767C70(this + 0x24, point, owner, ownerPoint, x, y, 1). CURSOR
// gets no anchor here — it follows the mouse elsewhere. The same switch
// runs on every SetOwner.
FUN_TOOLTIP_RESET_POSITION = 0x0052FE90,
// CGItem → fully-dressed item link string. __fastcall(ecx = CGItem *)
// → const char *. Reads the item's itemID, quality, permanent
// enchant ID, random-properties seed/factor, and unique ID off the
// CGItem's instance block + descriptor, builds the dressed name via
// FUN_005D8BC0 (handles random-suffix decoration like "Foo of the
// Bear"), then sprintf's into the global buffer at DAT_00C0CF68 and
// returns its address. The returned pointer is to a long-lived
// engine global, safe to read until the next call.
//
// Same helper Script_GetContainerItemLink (0x004F9930) and
// Script_GetInventoryItemLink (0x004C8C10) call after resolving
// their slot-form args. Bypassing them lets us build dressed links
// for tooltips set via SetMerchantItem / SetLootItem / etc. where
// the item isn't in the player's bag/equipment.
FUN_GAMETOOLTIP_BUILD_ITEM_LINK = 0x0052AE00,
// CGItem → decorated instance display name. __thiscall(ecx = CGItem *,
// char *outBuf, uint outSize). Reads the instance's random-suffix ID
// off the descriptor (+0x98, gated on the broken flag) and writes the
// plain — uncolored, unbracketed — display name into outBuf:
// "Ethereum Torque of the Sorcerer" when a suffix is present, the base
// ItemStats name otherwise (via the item cache + ItemRandomProperties
// localized suffix at record +0x1c). This is the inner name builder
// FUN_GAMETOOLTIP_BUILD_ITEM_LINK wraps in brackets, so the name it
// produces matches GetItemLink's bracketed name and modern
// C_Item.GetItemName exactly. Inner formatter FUN_005D8B00.
FUN_ITEM_BUILD_INSTANCE_NAME = 0x005D8BC0,
// Inner name formatter behind FUN_ITEM_BUILD_INSTANCE_NAME, callable
// WITHOUT a CGItem: `__fastcall(char *out /*ecx*/, uint outSize /*edx*/,
// uint32 itemID, int suffixID)`. Fetches the ItemStats record for itemID
// and, when suffixID is a valid ItemRandomProperties row with a localized
// suffix name (record +0x1c + locale*4), formats base + suffix via
// ITEM_SUFFIX_TEMPLATE; otherwise the base name. Lets the by-STRING item
// paths (GetItemNameByID, C_Item.GetItemInfo) apply an item link's random
// suffix without a live item instance.
FUN_ITEM_BUILD_NAME_FROM_ID = 0x005D8B00,
// Engine's inventory swap-and-send. Same primitive
// `Script_EquipCursorItem` (0x00489660) uses after the cursor's
// source location has been resolved. Sends opcode 0x10D
// (CMSG_SWAP_INV_ITEM) for same-container swaps or 0x10C
// (CMSG_SWAP_ITEM) for cross-container, then runs the packet
// through the engine's own send pipeline at FUN_005AB630.
// (0x10C is SWAP_ITEM; CMSG_AUTOEQUIP_ITEM is 0x10A and belongs to
// the cursor/equip builder FUN_005E1480, not this one.)
//
// Signature:
// void __thiscall(
// CGPlayer *this,
// u32 srcItemGuidLo, u32 srcItemGuidHi,
// u32 srcContainerGuidLo, u32 srcContainerGuidHi,
// u32 srcLinearSlot,
// u32 dstContainerGuidLo, u32 dstContainerGuidHi,
// u32 dstLinearSlot,
// int flag);
//
// `flag` IS NOT COSMETIC — it gates a pre-send confirmation check,
// and with 0 this function can decide to send NOTHING AT ALL.
// Before building the packet, and only when the DESTINATION is not
// an equipment or bag-container slot, it resolves the item being
// moved (the destination's item when the source is an equipment
// slot, otherwise the source's) and then either:
// - stashes the parameters and returns, when that item is not in
// the item cache yet; or
// - stashes the parameters, fires event 0x120 (the bind
// confirmation dialog) and returns, when the item's `m_bonding`
// (record +0x194) is 2 (BIND_WHEN_EQUIPPED) and `FUN_005EA930`
// reports this character could equip it.
// Both paths send no packet and report nothing, since the function
// returns void — so a caller that moves a Bind-on-Equip item it
// could wear just silently does not move it.
//
// Passing 1 skips the gate, which is what the engine itself does
// when it re-issues a swap after the player accepts the dialog. That
// is correct for any caller whose two endpoints are both bag content
// slots, since nothing there can bind an item.
//
// Linear-slot encoding for sources/dests in player invMgr:
// 0..18 paperdoll (1-based slot - 1)
// 19..22 equipped bag containers (bag IDs 1..4 themselves)
// 23..38 backpack contents (1-based bag-0 slot S → 22 + S)
// For sources in a CGContainer (equipped bag B = 1..4), the
// container GUID is the bag's own GUID and srcLinearSlot is
// 0-based within that bag (1-based Lua slot - 1).
//
// This call neither reads nor writes the cursor-state globals at
// [0xBE0810] / [0xBE0814]; cursor visibility is purely a side
// effect of the cursor-pickup path that normally precedes it.
// Calling this directly produces a server-side swap with no
// client-side cursor manipulation.
FUN_INVENTORY_SWAP = 0x005E0C40,
// Sister helper to FUN_INVENTORY_SWAP — packet builder for
// `CMSG_SPLIT_ITEM` (opcode 0x10E). Same __thiscall ABI shape;
// the item-GUID args (param_1, param_2) are unused padding for
// ABI parity. Packet wire format:
// [0x10E, srcBag, srcSlot, dstBag, dstSlot, count]
// where srcBag/dstBag are byte-converted from container GUIDs by
// the same `FUN_005e13b0` helper the swap function uses
// (`0xFF` = INVENTORY_SLOT_BAG_0 / player, `19..22` = equipped bags).
//
// Server semantics are all-or-nothing: any failure
// (insufficient source, dest has different item, dest would
// overflow maxStack) leaves source untouched and emits
// `SMSG_INVENTORY_CHANGE_FAILURE`. No cursor involvement on send
// or response.
//
// Signature:
// void __thiscall(
// CGPlayer *this,
// u32 unused1, u32 unused2, // ABI padding
// u32 srcContainerLo, u32 srcContainerHi,
// u32 srcLinearSlot, // only low byte hits the wire
// u32 dstContainerLo, u32 dstContainerHi,
// u32 dstLinearSlot, // only low byte
// u32 count); // only low byte
FUN_INVENTORY_SPLIT = 0x005E1210,
// Third sibling in the same packet-builder family — `__thiscall`,
// same shared bag-byte converter (`FUN_005E13B0`), same send
// pipeline (`FUN_005AB630`). Builds `CMSG_AUTOSTORE_BAG_ITEM`
// (opcode 0x10B): "take this item and put it wherever it belongs
// in that container", with the DESTINATION SLOT CHOSEN BY THE
// SERVER. Wire format:
// [0x10B, srcBag, srcLinearSlot, dstBag]
//
// Signature — EIGHT stack args, `RET 0x20`. The count is from the
// RET, not from a decompiler parameter list: the last slot
// (`EBP+0x24`) is never READ by the body, but it IS popped, so a
// 7-arg declaration leaves the callee popping four bytes too many
// and ESP walks on every call. Trailing-ignored-arg is this
// family's habit — it is where swap keeps its `flag` and split its
// `count` — but the family is NOT uniform in arity: those two take
// nine (`RET 0x24`), this one eight.
// void __thiscall(
// CGPlayer *this,
// u32 unused1, u32 unused2, // EBP+0x08/+0x0C, unread
// u32 srcContainerLo, u32 srcContainerHi,
// u32 srcLinearSlot, // only low byte hits the wire
// u32 dstContainerLo, u32 dstContainerHi,
// u32 unused3); // EBP+0x24, unread but popped
//
// Note there is no dst slot argument at all — that is the point of
// the opcode. Server-side (`HandleAutoStoreBagItemOpcode`) it runs
// `CanStoreItem(dstBag, NULL_SLOT, …)`, which is a TWO-PASS search:
// first "merge into existing non-full stacks of this item" (filling
// a position/count vector, so one stack can be distributed across
// several destinations), then "find a free slot" for whatever count
// is left. So this single packet performs partial-stack
// consolidation with no stack-size lookup on our side at all.
//
// Note the value in that is NOT that the client's stack size could
// be wrong: 1.12 has no item DBC, so stack size arrives from the
// server and is cached in itemcache.wdb, and the client's copy
// normally agrees by construction. The value is availability —
// `C_Item.GetItemMaxStackSizeByID` is nil until an item's data has
// arrived, so anything that sizes stacks first has a cold-cache
// hole, and the server never needs to size them.
//
// The converter returns `0xFF` for any GUID absent from the
// player's invMgr container array, and the player's own GUID is
// absent — so passing the PLAYER as the destination sends
// `dstBag = 0xFF` (INVENTORY_SLOT_BAG_0), which the server reads as
// "search every bag". The builder guards that case: a converted
// `0xFF` is only allowed through when the destination GUID really is
// the player's, otherwise it drops the send silently. Consequence:
// the backpack is not separately addressable as a destination (it
// IS the player container), so bagID 0 means "anywhere it fits".
FUN_INVENTORY_AUTOSTORE = 0x005E12E0,
// Bank counterpart — `CMSG_AUTOSTORE_BANK_ITEM` (opcode 0x282).
// THREE stack args, `RET 0xC`. Wire: [0x282, srcBag, srcSlot].
// void __thiscall(
// CGPlayer *this,
// u32 srcContainerLo, u32 srcContainerHi,
// u32 srcLinearSlot); // only low byte hits the wire
//
// No destination of any kind, because the server DERIVES THE
// DIRECTION FROM THE SOURCE (`HandleAutoStoreBankItemOpcode`):
// a bank source runs `CanStoreItem(NULL_BAG, NULL_SLOT, …)` and
// lands in the inventory; an inventory source runs
// `CanBankItem(NULL_BAG, NULL_SLOT, …)` and lands in the bank.
// Both are the same merge-into-existing-stacks-then-free-slot
// search as 0x10B, just aimed at the other side.
//
// So this opcode moves an item ACROSS the inventory/bank boundary
// and cannot move one within its own side. Bank-internal
// consolidation is not expressible through autostore at all — it
// needs per-pair moves (`FUN_INVENTORY_SPLIT` / `_SWAP`).
//
// Unlike its siblings this one validates the source itself before
// sending: resolves the container by GUID (`FUN_00468460` with
// typeMask 1), bounds-checks the slot against the container's item
// array, and bails when the GUID in that slot is zero.
FUN_INVENTORY_AUTOSTORE_BANK = 0x005E18F0,
// Registers a single global Lua function. __fastcall(name, func).
FUN_FRAMESCRIPT_REGISTER_FUNCTION = 0x00704120,
// `FrameScript_Object::ScriptRegister(this, name)` — `__thiscall`,
// `this` = a `CFrameScriptObject *`. On first call (when `this+0x04`
// is zero) builds a Lua wrapper table `{[0] = lightuserdata(this)}`
// with `_G["__framescript_meta"]` as metatable, `luaL_ref`s it into
// the registry, stores the refkey at `this+0x08`. Always increments
// `this+0x04` (the Lua-side refcount). Optional `name` argument
// installs `_G[name] = wrapper` for engine-named frames.
//
// We call this in `PushNamePlateFrame` so the engine and our own
// C_NamePlate getters operate on the **same** wrapper table —
// every push through `lua_rawgeti(REGISTRY, this+0x08)` (the
// canonical engine path) lands on the same Lua object pfUI
// received in `NAME_PLATE_CREATED`, so addon-set fields
// (`plate.nameplate = decoratedButton`) survive engine-side
// re-fetches. Earlier note in `Info.cpp` warned about pinning the
// refcount; for pool-managed nameplates the engine never
// un-registers them anyway, so the pin is benign.
FUN_FRAMESCRIPT_OBJECT_SCRIPT_REGISTER = 0x00701BD0,
// The rest of the script-object life cycle (benilla-re ui/script, ui/frames):
// FUN_SCRIPT_OBJECT_CONSTRUCT `__fastcall(object)` fills the 0x24-byte
// header: base vtable, holder count 0 (+4), table ref -2 (+8), OnEvent
// slot (+0xC), event index (+0x14..+0x20).
// FUN_SCRIPT_OBJECT_DESTRUCT `__fastcall(object)` unregisters its events,
// releases OnEvent and frees the index array.
// FUN_SCRIPT_OBJECT_UNLOCK `__thiscall(object, name)` - the inverse of
// FUN_FRAMESCRIPT_OBJECT_SCRIPT_REGISTER: counts a holder down, at zero
// clears the table's [0] and frees its ref; a non-null name's global
// is set to nil.
// FUN_SCRIPT_OBJECT_BASE_RESOLVE_SCRIPT `__thiscall(object, name)` - the
// base vtable+0x0C: the OnEvent slot for "OnEvent", else 0.
// FUN_SCRIPT_OBJECT_SET_SCRIPT_TEXT `bool __thiscall(object, name, text)`,
// `ret 8` - compiles an XML script body into the slot vtable+0x0C
// gives (chunk name "<name>:<script>", context 0), releasing the old.
// FUN_SCRIPT_RELEASE `void __stdcall(uint32_t *slot)` - frees a slot's
// handler ref.
// An object's methods are found through its vtable+0x08, `int
// __thiscall(object, L, name)` (`ret 8`, push and return 1, or 0), which
// the shared metatable's __index (0x007020B0) calls with t[0]. Base
// vtable 0x00811F4C; subclasses add IsA(name) at +0x18 and the type name at
// +0x1C (Font's 0x0081C8BC).
FUN_SCRIPT_OBJECT_CONSTRUCT = 0x00701AE0,
FUN_SCRIPT_OBJECT_DESTRUCT = 0x00701B40,
FUN_SCRIPT_OBJECT_UNLOCK = 0x00701CD0,
FUN_SCRIPT_OBJECT_BASE_RESOLVE_SCRIPT = 0x00702590,
FUN_SCRIPT_OBJECT_SET_SCRIPT_TEXT = 0x007025C0,
FUN_SCRIPT_RELEASE = 0x00702670,
// `this+0x04` Lua refcount, incremented by `ScriptRegister`. We
// read it as a "has the engine ever exposed this CObject to Lua"
// probe — equivalent to checking `this+0x08 > 0` but more direct.
OFF_COBJECT_LUA_REFCOUNT = 0x04,
// `this+0x08` — the CObject's Lua-registry ref (an int key into the
// registry table). `lua_rawgeti(REGISTRY, this[+0x08])` pushes the
// frame's Lua-side object. Lazily populated by ScriptRegister when the
// refcount above is 0.
OFF_COBJECT_LUA_REF = 0x08,
// Direct cvar lookup — `__fastcall(const char *name) → CVar* | NULL`.
// Hash-table by-name lookup over the CVar registry; same call
// `Script_GetCVar` makes internally before the engine wraps the
// result in lua_pushstring + a "CVar doesn't exist" error path.
// Calling it directly lets us skip both the Lua roundtrip and the
// unknown-cvar error — we coerce NULL to false instead, matching
// modern `C_CVar.GetCVarBool` semantics.
//
// The returned struct holds the value string at `+0x20` (read by
// `Script_GetCVar` at `0x00488BF9` as `mov edx, [eax+0x20]; call
// lua_pushstring`). The value is the raw `char *` the engine
// stores; reading it directly is safe for the lifetime of the
// cvar (vanilla cvars don't get re-allocated outside `/console
// set` flows, which we don't race here).
FUN_FIND_CVAR = 0x0063DEC0,
OFF_CVAR_VALUE_STR = 0x20,
// The value parsed as a float — a cache the setter maintains, next to the
// int at +0x28. The tab-target search FUN_00494200 reads its range cvars
// through it (`fld [cvar+0x24]`).
OFF_CVAR_VALUE_FLOAT = 0x24,
// The value parsed as an integer (SStrToInt), stored by the inner setter
// FUN_0063E0B0 beside the float at 0x0063E127. The scriptMemory watchdog
// FUN_00495590 reads the cvar through it.
OFF_CVAR_VALUE_INT = 0x28,
// Launch switches — Storm's SCmd registry (benilla-re storm/scmd; same
// code as 4.3.4's SCmd.cpp). Boot, in `InitializeGlobal` (`FUN_00402350`):
// 0x0040235C CALL FUN_REGISTER_CLIENT_SWITCHES
// -> registers the client's 17 switches (table 0x007FF8B8),
// then JMPs to 0x00419C70, which registers the 15 base
// switches and parses GetCommandLineA() against them all
// 0x00402370 MOV ECX, "Config.wtf"
// 0x00402375 CALL FUN_CVAR_CONFIG_INITIALIZE
// The parse STOPS at the first switch it does not know (ProcessFlags
// returns 0, the token loop breaks), so every switch after an unregistered
// one is silently ignored. Ours must therefore be registered before
// 0x00419C70 runs. DllMain is too early for that: the switch-list heads are
// built by a CRT static initializer (0x0064EEE0 -> 0x0064EEF0 writes
// 0x00C53F24..2C), which runs after every injected DllMain, and the
// registrar dereferences the head. So `Config::CommandLine` redirects the
// call at 0x0040235C and registers there, which is 4.3.4's order
// (`InitializeGlobal`: SCmdRegisterArgList(s_wowArgList), CmdLineProcess()).
//
// Both call sites run during boot, BEFORE VanillaFixes calls our `Load`
// export, so they are redirected from DllMain (VF injects every dlls.txt
// DLL while the process is still CREATE_SUSPENDED). A rel32 store needs no
// trampoline.
CALL_INIT_REGISTER_CLIENT_SWITCHES = 0x0040235C,
// `void __cdecl(void)` — see above.
FUN_REGISTER_CLIENT_SWITCHES = 0x00403BA0,
// `int __stdcall(const record *list, uint32_t count)`; each 16-byte record
// is {flags, id, name, callback}. Flag 0x20000 = takes a string value.
// Names must be shorter than 16 characters (the registrar's
// `strlen < 0x10` gate at 0x0064FE20).
FUN_SCMD_REGISTER_ARG_LIST = 0x0064FDC0,
// `int __stdcall(uint32_t id, char *buffer, uint32_t size)`. Writes "" first;
// returns 1 when a switch with `id` is registered (given or not), 0 otherwise.
// A value is at most 255 bytes: the tokenizer's buffer is 256.
FUN_SCMD_GET_STRING = 0x0064F270,
// The config initializer, `void __fastcall(const char *filename)`. It keeps
// the pointer at `VAR_CONFIG_FILENAME_PTR`, which then drives BOTH sides:
// load — `0x0063D428`: `MOV ECX,[0x00C4EDD4]; CALL 0x0063D820`
// save — `FUN_0063D980` builds `"WTF\"` + the same pointer
// So one pointer names the file for reading and writing. `Config::FileSwitch`
// redirects the boot call to pass the `-config` value instead of
// "Config.wtf", which is 4.3.4's `InitializeGlobal`:
// `ConsoleInitializeClientCVar(CmdLineGetString(CMD_CONFIG) or "Config.wtf")`.
CALL_INIT_CONFIG_INITIALIZE = 0x00402375,
FUN_CVAR_CONFIG_INITIALIZE = 0x0063D380,
// Where `FUN_CVAR_CONFIG_INITIALIZE` stores that pointer. Read by the loader call above
// and by the save.
VAR_CONFIG_FILENAME_PTR = 0x00C4EDD4,
// The config writer, `"WTF\" + [VAR_CONFIG_FILENAME_PTR]`. `int(void)`
// (decompiled). Returns 1 at once unless VAR_CVAR_CONFIG_DIRTY is set;
// otherwise clears it and writes `SET name "value"` for every cvar with
// CVAR_FLAG_ARCHIVE, taking the value from OFF_CVAR_STAGED_STR, else
// OFF_CVAR_VALUE_STR, else OFF_CVAR_DEFAULT_STR, and skipping any that
// equals the default. Called from the /reload + logout teardown
// FUN_00490BD0, from FUN_0046B500 (glue), and from the cvar shutdown
// FUN_0063DAF0 — cold paths only.
FUN_CVAR_CONFIG_WRITE = 0x0063D980,
// u8 "config needs saving". Set by the inner setter FUN_0063E0B0 only when
// its last argument (a6) is nonzero, and by the staged-value path in
// FUN_SET_CVAR_VALUE; cleared by FUN_CVAR_CONFIG_WRITE.
VAR_CVAR_CONFIG_DIRTY = 0x00C4EDD8,
// `CVar::Register` — what `Script_RegisterCVar` calls after a `FindCVar`
// miss (the call at `0x00488B8A`). `__fastcall`; ECX = name, EDX = help
// line, then six stack args: flags, defaultValue, changeCallback,
// category, scriptHidden, userData (the boot registrations at
// FUN_00402BA0 settle the EDX/default slots: `("scriptMemory", "Memory
// used by the scripting system", 0, "49152", 0, 4, 0, 0)`).
// new name — copies the help into the record (+0x3C, 0x80 bytes), runs
// the default through FUN_SET_CVAR_VALUE with apply 1 (so the callback
// sees it, and a rejection leaves the value EMPTY), ORs in archive
// (bit 0) and, for scriptHidden 0, bit 31; then registers a console
// command of the cvar's name with the category and help.
// existing name — ORs the flags, replaces callback and userData, calls
// the callback with the current value (result ignored), offers the
// default with apply 0 (fills only an empty default/reset slot), and
// sets bit 31 for scriptHidden 0. Help and category are NOT updated.
// Config.wtf loads before any registration, so a cvar with a saved line
// always takes the existing-name path, keeping the `set` command's
// category 5 and no help — the engine's own cvars included. Idempotent
// across `/reload`. See `CVar::Factory` for the wrapper.
FUN_REGISTER_CVAR = 0x0063DB90,
// `CVar::Set` — `__thiscall(cvar /*ecx*/, value, apply, setReset,
// setDefault, force)`: ECX = cvar and all FIVE others on the stack
// (`RET 0x14`). NOT `__fastcall`, which would put `value` in EDX and
// corrupt ESP (see `CVar::Factory`). With apply it first fires the change
// callback at `[cvar+0xBC]` as `char __fastcall(cvar /*ecx*/, prevValue
// /*edx*/, newValue /*stack*/, userData /*stack*/)` — 0 REJECTS the
// change (verified at `0x0063DF7D`). force is what marks the config
// dirty. Every caller outside the registrar passes 1, 0, 0, 1
// (`Script_SetCVar` at `0x00488CA8`). Always returns 1.
FUN_SET_CVAR_VALUE = 0x0063DF50,
// `CVar::SetReadOnly` — `void __thiscall(cvar /*ecx*/, char readOnly)`,
// `RET 4`: ORs CVAR_FLAG_READ_ONLY in for nonzero, clears it for zero.
// Its only two callers set it on `realmList`, `realmName` and
// `scriptMemory` (the name table at 0x0083DE4C): `CGGameUI::InitializeGame`
// (FUN_0048F480) at 0x0048F579 sets the bit on entering the world, before
// it jumps to the interface build that runs FUN_LOAD_SCRIPT_FUNCTIONS, and
// `CGGameUI::ShutdownGame` at 0x00491252 clears it on leaving. So those
// three are writable on the glue screens and read-only in the world.
FUN_CVAR_SET_READ_ONLY = 0x0063E030,
// CVar struct fields (beyond the value string at +0x20 above).
OFF_CVAR_FLAGS = 0x1C,
// Hash mask of the cvar registry, and its initialised/not sentinel. Every
// lookup gates on it (`if (mask == 0xFFFFFFFF) return 0`) and the registrar
// builds the table on first use when it sees the sentinel, so a value other
// than 0xFFFFFFFF means at least one cvar has been registered — the closest
// thing this client has to "the cvar system is up".
VAR_CVAR_HASH_MASK = 0x00C4EDB8,
CVAR_HASH_MASK_UNINITIALIZED = 0xFFFFFFFF,
// The default value, kept alongside the live one at OFF_CVAR_VALUE_STR.
// `cvarlist` (FUN_0063D6F0) compares the two and appends "(default: %s)"
// when they differ, which is what identifies each; +0x34 is the reset
// value it prints the same way, and +0x38 holds a staged value (below).
OFF_CVAR_DEFAULT_STR = 0x30,
// The staged value (CVAR_FLAG_STAGED below). FUN_CVAR_CONFIG_WRITE prefers
// it over the live value when non-null.
OFF_CVAR_STAGED_STR = 0x38,
// Flag bits within OFF_CVAR_FLAGS, each from the code that acts on it:
// 0x1 archive — the registrar forces it on, and the config writer
// (FUN_0063D980) skips any cvar without it.
// 0x2 staged — FUN_SET_CVAR_VALUE stores the new value at +0x38 and
// marks the config dirty INSTEAD of applying it, so the change
// lands on a later run rather than now.
// 0x4 read only — Script_SetCVar (FUN_00488C10) tests this before
// doing anything else and raises `"%s" is read only`, and the inner
// setter FUN_0063E0B0 silently ignores the write. Toggled only by
// FUN_CVAR_SET_READ_ONLY.
// 0x80000000 visible to Lua. FUN_FIND_CVAR rejects any cvar without it
// (`if (-1 < (int)flags) return 0` — the flags read as SIGNED), and
// GetCVar / SetCVar / C_CVar.* all go through that lookup, so a cvar
// missing this bit cannot be reached from Lua at all. It is set when
// the registrar's `registerConsole` argument is 0.
//
// That last bit is how the engine handles a Config.wtf line it does not
// recognise. The config loader FUN_0063D820 runs each `SET` line as a
// console command, and the `set` handler FUN_0063D500 looks the name up
// with FUN_0063DE30 — the SAME hash walk minus the bit-31 test — and
// registers a new cvar with registerConsole = 1 when it finds nothing —
// with flags 0, which the registrar then ORs the archive bit into, so the
// config writer saves it straight back out.
//
// So ANY line left in Config.wtf becomes a cvar on the next boot, whether
// or not the client implements a setting by that name: it is preserved
// across sessions and stays writable from the console, while being
// invisible to Lua. realmlist.wtf runs through the same `set` path, so a
// line there materialises in Config.wtf the same way. Such a cvar appears
// in the console command list and returns nil from every Lua cvar getter,
// which is consistent rather than a gap.
CVAR_FLAG_ARCHIVE = 0x1,
CVAR_FLAG_STAGED = 0x2,
CVAR_FLAG_READ_ONLY = 0x4,
OFF_CVAR_CALLBACK = 0xBC,
OFF_CVAR_USERDATA = 0xC0,
// Console categories — the registrar's category argument, an index into
// the nine 0x18-byte {id, name} entries at 0x008653A0 that `help
// <category>` (FUN_0063FDC0) matches by name. Same ids as 3.3.5/4.3.4's
// CATEGORY_* enum. `Script_RegisterCVar` passes 9, which matches no
// entry, so a Lua-registered cvar is listed under no category.
CVAR_CATEGORY_DEBUG = 0,
CVAR_CATEGORY_GRAPHICS = 1,
CVAR_CATEGORY_CONSOLE = 2,
CVAR_CATEGORY_COMBAT = 3,
CVAR_CATEGORY_GAME = 4,
CVAR_CATEGORY_DEFAULT = 5,
CVAR_CATEGORY_NET = 6,
CVAR_CATEGORY_SOUND = 7,
CVAR_CATEGORY_GM = 8,
// Engine-side Lua C functions backing the in-game CVar globals.
// Standard `int __fastcall(void *L)` ABI. We don't register them
// ourselves in-game — the engine already does at boot — but we
// re-register the same pointers on the glue Lua state so login /
// char-select GlueXML can read and write CVars too (vanilla 1.12
// exposes none of these in glue by default). CVar storage is
// process-global, so a write from either state is visible to the
// other.
FUN_SCRIPT_REGISTER_CVAR = 0x00488B00,
FUN_SCRIPT_GET_CVAR = 0x00488BA0,
FUN_SCRIPT_SET_CVAR = 0x00488C10,
FUN_SCRIPT_GET_CVAR_DEFAULT = 0x00488CF0,
// `Script_RunScript` — the C function backing `_G.RunScript(code)`
// in-game. `int __fastcall(void *L)`. Mirrored onto the glue Lua
// state in `src/script/Run.cpp` so GlueXML can also `RunScript("...")`
// — useful for slash-command-style debug helpers at the login /
// realm / char-select screens.
FUN_SCRIPT_RUN_SCRIPT = 0x0048B980,
// Game::ResolveUnitToken — __fastcall(ecx = const char *token) → CGUnit_C *.
// Returns the unit pointer for "player", "target", "party1", etc. Use this
// rather than the global at 0x00B41414 — that global holds something
// related (its +0xC0 has the player GUID) but is NOT the same CGPlayer_C
// pointer the inventory routines expect.
FUN_RESOLVE_UNIT_TOKEN = 0x00515940,
// Set the player's current target to a GUID —
// `__fastcall(uint64_t *guid)`. Validates the GUID resolves to a unit
// (typemask 8) then commits the selection (CMSG_SET_SELECTION +
// client-side target). This is what `Script_TargetUnit` (0x004899D0)
// calls after resolving its token→GUID; we call it directly with a
// GUID we already have (e.g. a totem creature). NOTE: reads `guid[0]`
// (lo) and `guid[1]` (hi) through the pointer.
FUN_TARGET_BY_GUID = 0x00489A40,
// The engine's find-a-unit-by-name search, behind `TargetByName`,
// `AssistByName` and `FollowByName`.
// `uint64_t __fastcall(const char *name /*ecx*/, uint32_t typeMask /*edx*/,
// int mode, int exactMatch, float maxDistance)`
// Walks party, then raid, then every object, and returns the best GUID
// (0 = none). `typeMask` is the object typemask the candidates are
// resolved against: 8 (unit, what `TargetByName` passes) or 0x10 (player,
// what assist and follow pass). `mode` selects which candidate sets run
// (1 skips the party/raid pre-pass, 3 skips the raid one); target and
// assist pass 0, follow passes 2. `maxDistance` is a float bit pattern —
// the callers all pass 0x7F7FFFFF (FLT_MAX).
//
// `exactMatch` picks the rule in the per-candidate predicate
// `FUN_00493C60`: clear takes the longest case-insensitive PREFIX match,
// tied by distance; set requires a full match, and that hit stops the
// walk immediately.
FUN_UNIT_FIND_BY_NAME = 0x00493AA0,
// Tab targeting — 4.3.4's TargetNearestEnemy(reverse, type), which 1.12
// has whole: `FUN_TARGET_NEAREST_CYCLE` (0x00493F60),
// `void __fastcall(int reverse, int mode)`. The native TargetNearestEnemy
// / Friend / PartyMember / RaidMember (0x00489A80..0x00489AE0) are
// `FUN_TARGET_NEAREST_CYCLE(FUN_LUA_TO_BOOLEAN_LOOSE(L, 1, 0), mode)`.
// It keeps one snapshot (array 0x00B4B428: cap / +4 count / +8 data,
// 16-byte {guidLo, guidHi, distSq, inFront} entries; cursor 0x00B4E3AC,
// sort time 0x00B4E3B0, last press 0x00B4E3B4, mode 0x00B4E3B8), rebuilt
// after 3000 ms, on a mode change, or when the cursor wraps 1000 ms after
// the sort. The rebuild enumerates visible objects through FUN_00494200:
// keep a unit FUN_TARGET_CANDIDATE_VALID accepts that is within
// targetNearestDistance in front (a 60° arc) or targetNearestDistanceRadius
// anywhere, is not a CREATURETYPE_FLAG_NOT_TAB_TARGET type, and is visible
// (FUN_WORLD_OBJECT_VISIBLE); sorted in-front first, then nearest
// (FUN_00494450). Commits through FUN_SET_SELECTION_BY_GUID.
FUN_TARGET_NEAREST_CYCLE = 0x00493F60,
//
// `FUN_TARGET_CANDIDATE_VALID` (0x00493E40) — the cycle's per-mode
// predicate, 4.3.4's UnitMatchesTargetType.
// `__fastcall(CGUnit *player /*ecx*/, CGUnit *candidate /*edx*/, int
// mode) → int` (nonzero = valid). Modes: 1 = enemy (attackable, alive,
// not UNIT_DYNFLAG 0x20, stand state != 7 — 4.3.4's type 1), 2 = friend
// (assistable, health > 0 — 4.3.4's type 3), 3 = party, 4 = raid; any
// other mode → 1 (4.3.4's `default:`). `Target::Nearest` co-hooks it to
// add TARGET_MODE_ANY / _ENEMY_PLAYER / _FRIEND_PLAYER.
FUN_TARGET_CANDIDATE_VALID = 0x00493E40,
TARGET_MODE_ENEMY = 1,
TARGET_MODE_FRIEND = 2,
// ClassicAPI modes (4.3.4's types 0 / 2 / 4); values past the engine's.
TARGET_MODE_ANY = 5,
TARGET_MODE_ENEMY_PLAYER = 6,
TARGET_MODE_FRIEND_PLAYER = 7,
// CVar* slots of the tab-target ranges (4.3.4 hard-codes 41 / 10),
// registered in FUN_0048FBF0's cvar block: targetNearestDistance
// (default 41, 0x0048FDBE) and targetNearestDistanceRadius (default 10,
// 0x0048FD7F). Read the float at OFF_CVAR_VALUE_FLOAT.
VAR_CVAR_TARGET_NEAREST_DISTANCE = 0x00B4E2A8,
VAR_CVAR_TARGET_NEAREST_DISTANCE_RADIUS = 0x00B4D8FC,
// World::QueryObjectVisible — `bool __fastcall(worldObject)`: non-null
// and `[+0x94] == 0`. A unit's world object is at OFF_CGOBJECT_WORLD_OBJECT
// (the tab search passes `unit[0x38]`).
FUN_WORLD_OBJECT_VISIBLE = 0x006704C0,
// WorldObjectRenderCallback — every entity node's render callback
// (`node+0xB4`). DrawEntityModels (0x00683DD0) calls it once a frame per
// scene entity: edx = pass (1 in sight, 2 the rest of the bands), stack =
// guidLo, guidHi, one unused word; ecx (the node's argument) is
// overwritten unread. `int __fastcall(ctx, pass, lo, hi, unused)`, RET 0xC,
// returns 1 (disassembly of 0x00481540; benilla-re terrain/scene.md).
FUN_WORLD_OBJECT_RENDER_CALLBACK = 0x00481540,
// AddPickCandidate — FUN_WORLD_OBJECT_RENDER_CALLBACK's only callee for
// the resolved object (call at 0x0048158A), skipped when the object is
// released or its slot 0x78 is 0. `void __thiscall(worldFrame, object,
// pass)`, RET 0x8 (disassembly of 0x004815D0).
FUN_ADD_PICK_CANDIDATE = 0x004815D0,
// DrawEntityModels — the scene's entity drain: walks the in-sight list
// calling each node's callback with pass 1, then the rest with pass 2.
// `void __cdecl()`, plain RET (disassembly of 0x00683DD0; benilla-re
// terrain/scene.md "Entity draw").
FUN_DRAW_ENTITY_MODELS = 0x00683DD0,
OFF_CGOBJECT_WORLD_OBJECT = 0xE0,
// CGWorldFrame::GetScreenCoordinates — `bool __thiscall(worldFrame, const
// float world[3], float screen[2])`, `ret 8`: true when the point is in
// the world frame's rect. Mirrors 4.3.4's (WorldFrame.cpp): camera
// position `[frame+OFF_GAME_STATE_CAMERA_PTR]+0x08`, near clip `+0x38`,
// view-projection at OFF_WORLDFRAME_VIEW_PROJECTION through
// FUN_C44_TRANSFORM, then NDCToDDC less the frame's negative rect origin.
// 1.12 writes x / y only; 4.3.4 also returns the depth (the transformed z).
// The world frame is `*VAR_GAME_STATE_PTR`.
FUN_WORLDFRAME_GET_SCREEN_COORDS = 0x00483EE0,
OFF_WORLDFRAME_VIEW_PROJECTION = 0x3B0,
// C4Vector × C44Matrix — `C4Vector *__fastcall(C4Vector *out /*ecx*/,
// const C4Vector *v /*edx*/, const C44Matrix *m)`, `ret 4`.
FUN_C44_TRANSFORM = 0x007BCB40,
// CGCamera::Forward — vtable slot, `void __thiscall(camera, float out[3])`:
// the camera's forward vector (the matrix row at camera+0x14, turned by
// the transport when on one). 4.3.4's CGWorldFrame::GetCameraFacing. The
// world frame's camera update adds it to the position for the look-at
// point (0x004830CA). Camera vtable 0x00808A9C, slot 0x00511F40.
VTBL_CAMERA_FORWARD = 0x04,
OFF_CAMERA_POSITION = 0x08,
// `FUN_SET_SELECTION_BY_GUID` (0x00493540) — canonical target setter the
// native tab-cycle commits through. `__stdcall(uint32_t guidLo, uint32_t
// guidHi)` — `ret 8` at 0x004935E0; TargetByName (0x00489D60) and
// OnSpriteRightClick push the pair and never clean it. Validates + fires
// CMSG_SET_SELECTION + client target + event 0xC3, and maintains the
// current-selection globals below. Passing {0,0} clears the target.
FUN_SET_SELECTION_BY_GUID = 0x00493540,
// Inside it, after CMSG_SET_SELECTION and the usable refresh: the
// PLAYER_TARGET_CHANGED fire (`call FUN_FIRE_EVENT_NO_ARGS`, ecx 0xC3),
// then — when the player was attacking an attackable target — the melee
// restart on the new one (`call FUN_ATTACK_START`, ecx player, arg
// &VAR target GUID). 4.3.4 CGGameUI::Target runs its
// stopAutoAttackOnTargetChange test at the same point. Both E8 calls,
// targets checked against the exe.
CALL_SET_SELECTION_FIRE_TARGET_CHANGED = 0x0049389C,
CALL_SET_SELECTION_ATTACK_START = 0x004938C8,
// CGGameUI::OnSpriteRightClick — the world right-click on an object:
// `int __stdcall(uint32_t guidLo, uint32_t guidHi)`, `ret 8`. No active
// player → 1; GUID not an object → 0; else targets it
// (FUN_SET_SELECTION_BY_GUID) and calls the object's right-click (vtable
// +0x60, passing the autoloot-modifier state from FUN_0041F8F0) → 1.
// Callers: the sprite-click handler 0x00492CE0 (4.3.4's
// HandleSpriteClick, byte-for-byte) and 0x004949F0. 4.3.4's version adds
// an aura-334 gate and skips the target for creatures with type flag
// 0x20000000; 1.12 has neither. nampower detours it (its offsets.hpp).
FUN_ON_SPRITE_RIGHT_CLICK = 0x00492820,
// Current target-selection GUID (lo/hi), written by
// `FUN_SET_SELECTION_BY_GUID` — 4.3.4's CGGameUI::m_lockedTarget. The tab
// cycle compares it with its cursor entry; TargetDirection starts from it.
VAR_CURRENT_SELECTION_GUID_LO = 0x00B4E2D8,
VAR_CURRENT_SELECTION_GUID_HI = 0x00B4E2DC,
// ── Hover cursor (the engine's "can I interact with this" verdict) ───
// SetCursorMode: `void __fastcall(uint32_t mode)` — `cmp [0xBE2C2C],ecx;
// jz ret; mov [0xBE2C2C],ecx; jmp send`. Every world-cursor classifier
// ends in it (ShowBaseCursor 0x523D30 tail-jumps into it with the base
// mode). Modes index `Interface\Cursor\<name>.blp`: 1 Point, 2 Cast,
// 3 Buy, 4 Attack, 5 Interact, 6 Speak, 7 Inspect, 8 Pickup, 9 Taxi,
// 10 Trainer, 11 Mine, 12 Skin, 13 GatherHerbs, 14 PickLock, 15 Mail,
// 16 LootAll, 17 Repair, 18 Item, 19 SkinHorde, 20 SkinAlliance;
// mode + 20 is the `Unable` form; 41 a game object's named cursor
// (benilla-re ui/worldcursor).
FUN_SET_CURSOR_MODE = 0x00523C20,
VAR_CURSOR_BASE_MODE = 0x00BE2C4C,
CURSOR_MODE_POINT = 1,
CURSOR_MODE_CAST = 2,
CURSOR_MODE_ATTACK = 4,
CURSOR_MODE_LAST_NAMED = 20,
CURSOR_MODE_UNABLE_OFFSET = 20,
CURSOR_MODE_CUSTOM = 0x29,
// s_cursorNames: `const char *[42]`, mode -> image name (0 and 41 null;
// 21..40 carry their own "Unable…" names). The loader formats
// `Interface\Cursor\%s.blp` from it (0x5236C0); dumped from the exe.
VAR_CURSOR_NAMES = 0x00853B88,
// FormatGameObjectCursorFile — `void __thiscall(go, char *buf, uint32_t
// size)`, ret 8: the record-named cursor's file, `Interface\Cursor\
// Unable%s.blp` when not usable (IsUsable); writes nothing without a
// record. ClassifyHoveredGameObject passes a 0x104-byte buffer.
FUN_GAMEOBJECT_FORMAT_CURSOR_FILE = 0x005F8790,
CURSOR_FILE_SIZE = 0x104,
// CGWorldFrame::ClassifyHoveredUnit / ClassifyHoveredCorpse —
// `void __thiscall(CGWorldFrame *, object)` (the frame is
// `*VAR_GAME_STATE_PTR`); set the cursor mode for a
// hovered unit / corpse and do nothing else (decompiled: the unit one
// reads `this` only for the frame clock +0x65BC, the corpse one not at
// all). Called by ClassifyHoveredObject (0x4828D0) on type word
// 9 / 0x19 and 0x81 after the object's IsMouseoverable answers nonzero.
FUN_WORLD_FRAME_CLASSIFY_UNIT = 0x00482200,
FUN_WORLD_FRAME_CLASSIFY_CORPSE = 0x00482740,
// CGGameObject_C::GetCursor — `uint32_t __thiscall(go)`: 0 when not
// interactable, CURSOR_MODE_CUSTOM for a record-named cursor, else the
// handler's mode (+20 when not usable). IsUsable — `bool __thiscall(go)`,
// the same usability the named cursor's `Unable` prefix reads (0x5F8790).
// ClassifyHoveredGameObject (0x4826E0) is GetCursor + SetCursorMode plus
// a custom-cursor texture load for 41.
FUN_GAMEOBJECT_GET_CURSOR = 0x005F8760,
FUN_GAMEOBJECT_IS_USABLE = 0x005F8810,
// Object type words (descriptor OBJECT_FIELD_TYPE) the hover dispatch
// switches on, exactly (0x4828D0): unit, player, game object, corpse.
OBJECT_TYPE_WORD_UNIT = 0x09,
OBJECT_TYPE_WORD_PLAYER = 0x19,
OBJECT_TYPE_WORD_GAMEOBJECT = 0x21,
OBJECT_TYPE_WORD_CORPSE = 0x81,
// CGUnit_C::GetNamePlateScreenPos — `bool __fastcall(unit, worldFrame,
// float screen[2])`, ret 4: the unit's name position (GetNamePosition
// 0x608640: head attachment 18, 29 mounted, else 1.25 × scale × box
// height above the feet) raised by VAR_NAMEPLATE_LIFT, projected with
// FUN_WORLDFRAME_GET_SCREEN_COORDS — where a nameplate is seated.
FUN_UNIT_GET_NAMEPLATE_SCREEN_POS = 0x0060F7F0,
// GetNamePosition's no-attachment factor (1.25) and the plate lift (2/3
// yard), both floats.
VAR_NAME_HEIGHT_FACTOR = 0x0080C5D0,
VAR_NAMEPLATE_LIFT = 0x0080ABFC,
// CGObject scale (+0x90, float, 1.0 at construction) and box height
// (+0xBC, float, max.z - min.z of the model box) — GetNamePosition's
// no-attachment inputs (benilla-re objectbase / unitnames).
OFF_CGOBJECT_SCALE = 0x90,
OFF_CGOBJECT_BOX_HEIGHT = 0xBC,
// CLayoutFrame::SetWidth / SetHeight — `void __thiscall(region +
// OFF_REGION_ANCHOR, float internal)`, ret 4: store +0x50 / +0x54 and
// lay the frame out.
FUN_LAYOUT_SET_WIDTH = 0x007683D0,
FUN_LAYOUT_SET_HEIGHT = 0x007683F0,
// Front-cone half angle of the tab-target collector (0x494200): pi times
// 1/6, both read from these floats (stored into 0xB4D8F4 on first use).
VAR_TARGETING_PI = 0x00804488,
VAR_TARGETING_ONE_SIXTH = 0x00803568,
// HeadingBetweenPoints — `float __fastcall(const float *from, const
// float *to)`: atan2 of the y and x differences (the tab collector's
// heading).
FUN_HEADING_BETWEEN_POINTS = 0x0047F220,
// ── Unit script registration (which units fire unit events) ──────────
// 4.3.4's CGUnit_C::m_scriptRegistration: a mask at unit+0xC90 of the
// reasons the UI watches this unit. FUN_UNIT_SCRIPT_RECOMPUTE rebuilds it
// from scratch: 0x1 player, 0x2 pet, 0x10 party, 0x20 party pet, 0x100
// raid, 0x200 raid pet, 0x1000 target (4.3.4's UpdateScriptRegistration,
// same bits). Only 0 ↔ nonzero is read: the first bit starts watching the
// unit's descriptor fields (FUN_0051bbb0), the last one stops it
// (FUN_0051bdb0), and a watched unit's field changes fire unit events
// through FUN_UNIT_EVENT_BROADCAST. Callers of the recompute: the target
// setter, the pet-change handler FUN_005e2660, the party/raid update
// FUN_005e5720, and the unit post-init FUN_005fbe00 (vtable 0x0080C504),
// so a unit that comes back into range is recomputed. The unit disable
// FUN_UNIT_DISABLE clears the whole mask. SuperWoW and WeirdUtils patch
// the recompute's initial value (0x0060C560) to 0x2000 for every unit
// (loot sparkle), so bit 0x2000 (4.3.4's focus bit) is taken here, and
// UnitXP references 0x0060C578 in its body. Unit::TokenEvents co-hooks
// the recompute to keep UNIT_SCRIPT_REG_TOKENS on units that have a
// ClassicAPI token (focus, nameplateN, markN).
OFF_CGUNIT_SCRIPT_REGISTRATION = 0xC90,
// ClassicAPI's bit for those units (4.3.4's focus bit is 0x2000, taken
// here — see above; 0x4000 is 4.3.4's arena bit).
UNIT_SCRIPT_REG_TOKENS = 0x8000,
FUN_UNIT_SCRIPT_RECOMPUTE = 0x0060C520, // void __fastcall(unit)
// `void __thiscall(unit, uint32_t bits)`, RET 4 — 4.3.4's RegisterScript
// (OR the bits, starting the watch on 0 → nonzero) / UnregisterScript
// (clear them, stopping it at → 0). The target clear uses the latter
// with 0x1000.
FUN_UNIT_SCRIPT_REGISTER = 0x0060C4A0,
FUN_UNIT_SCRIPT_UNREGISTER = 0x0060C4F0,
// `int __fastcall(const uint64_t *guid)` — 4.3.4's IsRaidMemberOrPet:
// you, your pet, a party member or their pet (FUN_004e80a0), a raid
// member or their pet (FUN_004bafd0). The engine keeps the target on a
// unit leaving the object table only when this is true.
FUN_UNIT_IS_GROUP_MEMBER_OR_PET = 0x00491900,
// CGUnit_C::Disable — `void __fastcall(unit)`, run as a unit leaves the
// object table: ClearTarget(guid) unless FUN_UNIT_IS_GROUP_MEMBER_OR_PET,
// then UnregisterScript(0xFFFFFFFF). 4.3.4's version (via BreakTarget)
// also drops the focus, and also when the unit is dueling you; 1.12's
// has no duel exception.
FUN_UNIT_DISABLE = 0x005FBB60,
// ClearTarget — `void __fastcall(int sendPacket /*ecx*/, int /*edx*/,
// uint32_t guidLo, uint32_t guidHi)`, RET 8: clears the target when it is
// that GUID (or any target for 0), UnregisterScript(0x1000) on the unit,
// and with sendPacket set sends CMSG_SET_SELECTION and fires event 0xC3.
FUN_CLEAR_TARGET = 0x00493910,
// CGUnit_C::UnitReaction — `int __thiscall(unit, other)` → reaction
// 0..7; Script_UnitIsFriend (0x00516930) reads above 3 as friendly.
FUN_UNIT_REACTION = 0x006061E0,
// CGUnit_C::GetSelectionHighlightColor — vtable slot 11, `int __thiscall
// (unit, uint32_t *argb)`, EDI = unit throughout. Colours the name above
// the head (PLAYERNAMEDESC refetch) and the selection circle. Its
// player-controlled, non-hostile, not-in-party exits are where 4.3.4
// checks the friends list: the PvP one loads green (`mov eax,[0xC4D8B4]`,
// A1 B4 D8 C4 00, 5 bytes; ECX/EDX free after) and the unflagged one blue
// (`mov ecx,[0xC4DA4C]`, 8B 0D 4C DA C4 00, 6 bytes; EAX = the out
// pointer, EDX free after). Verified by disassembly.
FUN_UNIT_SELECTION_COLOR = 0x00605960,
SITE_SELECTION_COLOR_PVP_EXIT = 0x00605C84,
SITE_SELECTION_COLOR_UNFLAGGED_EXIT = 0x00605CE7,
VAR_SELECTION_COLOR_PVP = 0x00C4D8B4,
VAR_SELECTION_COLOR_UNFLAGGED = 0x00C4DA4C,
// Sets the refetch-colour bit (+0x18 bit 1) on every name record, so each
// name re-asks FUN_UNIT_SELECTION_COLOR on its next draw. `void __cdecl()`;
// 4.3.4's PlayerNameTriggerColorUpdateAll.
FUN_PLAYER_NAME_MARK_ALL_COLOR_DIRTY = 0x006C7800,
// CGUnit_C::IsPVPUI — `bool __thiscall(unit)`: the PvP flag of the unit's
// charmer or creator, else its own. FUN_UNIT_SELECTION_COLOR's PvP test
// (and Script_UnitIsPVP's for a unit object). Verified by disassembly.
FUN_UNIT_IS_PVP_UI = 0x00605FF0,
// CGPartyInfo::IsMember — `int __thiscall(const uint64_t *guid)`: 1 for
// the active player or one of the four party members. The party test
// FUN_UNIT_SELECTION_COLOR makes after skipping the player. Verified by
// disassembly.
FUN_PARTY_IS_MEMBER = 0x004E7F70,
// The combat log's object namer (0x006264E0) asks the name and creature
// caches with this empty callback, so a miss sends the query and the
// next line has the name. `void __stdcall(void *, int)`, returns at once.
// (The namer itself is not called: in game, with the Octo DLL set, it
// returns the GUID's hex string instead of a name. combatlog/Entry.cpp
// makes its steps.)
FUN_COMBAT_LOG_NAME_QUERY_DONE = 0x00626620,
// The combat log's spell-miss line — `void __fastcall(int missType /*ecx*/,
// int spellId /*edx*/, uint32 casterLo, casterHi, targetLo, targetHi,
// uint8 damageShield)`, RET 0x14. Every spell miss reaches it: the
// SMSG_SPELL_GO miss list, a missile's arrival (0x0061D870 / 0x0061DD50),
// and SMSG_SPELLLOGMISS (0x005E7E00, the only caller that passes
// damageShield = 1). Drops missType 0 and spells with Attributes 0x180 or
// an empty name itself (disassembly, 0x0062BAB9-0x0062BB07).
FUN_COMBAT_LOG_SPELL_MISS = 0x0062BAB0,
// The combat log's cast-failure line — `void __fastcall(void *player
// /*ecx*/, int spellId /*edx*/, const char *text)`, RET 4. The failure
// reporter Spell_C_SpellFailed (0x006E21FC) calls it with the active
// player's object and the error text just shown (the shown error when its
// own text is empty), as 4.3.4 calls UnitCombatLogSpellFail. Returns for a
// null player or spell (disassembly, 0x0062C37C-0x0062C38E).
FUN_COMBAT_LOG_SPELL_FAIL = 0x0062C360,
// A unit's death — `void __fastcall(CGUnit *unit)`: writes the death
// line (0x0062C160), shows the pending XP gain, plays the death animation
// and sound. Its one caller is CGUnit_C::OnDied (0x006058AE), from the
// health field's watcher; 4.3.4's OnDeathAnimate, which logs UNIT_DIED.
FUN_PRESENT_UNIT_DEATH = 0x00625190,
// Whether the spell that created a unit (UNIT_CREATED_BY_SPELL) has a
// summoning or totem first effect (50, 74, 87-90, 104-107) — `bool
// __thiscall(CGUnit *unit)`. The death line uses it to write
// UNITDESTROYEDOTHER instead of UNITDIESOTHER (benilla-re
// objectlayer/combatlogmessages, Deaths).
FUN_UNIT_IS_SUMMONED = 0x0062C2D0,
// Combat-feedback fire — `void __fastcall(const uint64_t *guid /*ecx*/,
// const char *action /*edx*/, int amount, int school, uint32_t hitInfo)`,
// RET 0xC. Picks a modifier from the amount's sign and hitInfo (amount >
// 0: 0x80 CRITICAL, else 0x4000 GLANCING, else 0x8000 CRUSHING; else 0x20
// ABSORB, else 0x800 BLOCK, else 0x40 RESIST; none → "") and fires
// UNIT_COMBAT (0xB6) (token, action, modifier, amount, school) for each
// token of FUN_UNIT_TOKENS_FROM_GUID. The second caller of that map.
// nampower REPLACES this function (CGGameUI_ShowCombatFeedback, a
// hadesmem detour that never calls the original and fires for its own
// token list) — do not co-hook it. Its direct call sites are the four
// wrappers' CALLs (0x004946C2 spell damage "WOUND", 0x00494711 attack
// round, 0x00494736 spell miss, 0x00494758 heal); Unit::TokenEvents
// redirects them (see FUN_UNIT_EVENT_BROADCAST).
FUN_UNIT_COMBAT_FEEDBACK = 0x00494600,
UNIT_COMBAT_FEEDBACK_CALL_SITES = 4,
UNIT_EVENT_UNIT_COMBAT = 0xB6,
VAR_STR_UNIT_COMBAT_FORMAT = 0x0084333C, // "%s%s%s%d%d"
VAR_STR_EMPTY = 0x00882748, // ""
VAR_STR_UNNAMED = 0x0084C7F0, // "<unnamed>" — the display name of a frame with no name (see VTBL_SCRIPTOBJECT_GET_NAME)
VAR_STR_COMBAT_CRITICAL = 0x00843370,
VAR_STR_COMBAT_GLANCING = 0x00843364,
VAR_STR_COMBAT_CRUSHING = 0x00843358,
VAR_STR_COMBAT_ABSORB = 0x00843350,
VAR_STR_COMBAT_BLOCK = 0x0083F300,
VAR_STR_COMBAT_RESIST = 0x00843348,
// The chat-send text parser — `bool __fastcall(const char *text, char
// *out, int size)`, 4.3.4's ChatParserParseText; only caller
// Script_SendChatMessage (0x0049F60F), before the drunk filter. Replaces
// `%t`/`%n` (either case) with the target's name (object name, else the
// name cache, else TARGET_TOKEN_NOT_FOUND); any other `%x` writes a
// placeholder and makes it return false. 4.3.4 adds `%f` for the focus
// and a `{rtN}` prefix on both names (Chat::ChatTokens).
// Prologue 53 8B DC 83 EC 08.
FUN_CHAT_PARSE_TEXT = 0x005083A0,
// FrameScript_GetText — `const char *__fastcall(const char *name, int
// edx /*-1*/, int gender /*stack, 0*/)`, RET 4. With (-1, 0) it returns
// the global string `name`, or "" when unset.
FUN_FRAMESCRIPT_GET_TEXT = 0x00703BF0,
// Local-player CGObject-like global. Not the same pointer as
// ResolveUnitToken("player") returns — that one's the canonical
// CGPlayer_C used by inventory etc. This pointer's +0xC0 field
// holds the local player's 64-bit GUID, and the visible-object
// iterator at FUN_CLNT_OBJ_MGR_ENUM_VISIBLE_OBJECTS walks its
// +0xAC list. Useful for "is this GUID me?" checks without
// round-tripping through Lua. Also a NULL-check proxy for "is
// the object manager initialised" — engine iterators deref this
// unconditionally on entry, so callers must skip on the glue /
// character-select screen.
VAR_LOCAL_PLAYER_PTR = 0x00B41414,
OFF_LOCAL_PLAYER_GUID = 0xC0,
// `__fastcall(ecx = const char *token) → uint64_t GUID` — the
// inner token-to-GUID step that `FUN_RESOLVE_UNIT_TOKEN` calls
// before doing the active-object lookup. Returns the unit's
// GUID without depending on the unit being visible / loaded as
// a CGObject, so `partyN` / `raidN` resolve correctly even when
// the member is out of range or on a different continent
// (`Script_UnitName` uses this path too; that's why `UnitName`
// already works for OOR party members in vanilla).
//
// Internal dispatch:
// - "player" → `[localPlayer + 0x08]` (GUID ptr)
// - "target" → `DAT_00B4E2D8`/`DAT_00B4E2DC` globals
// - "mouseover" → `DAT_00B4E2C8`/`DAT_00B4E2CC` globals
// - "partyN" → `FUN_004E81A0(slot)` → `[VAR_PARTY_GUIDS + slot*8]`
// - "raidN" → `FUN_00491940(slot)` → raid GUID array
// - "partypetN", "raidpetN" similar (pet-slot variants)
// - "<arbitrary name>" → raises "Unknown unit name: %s" via
// the engine's error helper (so this
// still errors on bad tokens — same
// semantics as the existing
// `UnitGUID` documented behavior).
//
// Don't use this from code paths that need to handle literal
// character names — see CLAUDE.md "Resolving input to a name"
// for the `lua_pcall(UnitName)` workaround. For pure unit-token
// input it's the right primitive. To ask "is this string a unit
// token?" without eating that error, use
// `Unit::TokenResolve::IsUnitToken` (protected probe).
//
// Verified on the Turtle build: the unknown-token fallthrough
// (`jne` at 0x00515C14) is patched to `jmp 0x00D06670`, in the
// added `.tdata` section — that stub parses a `0x<16 hex>` GUID
// literal and otherwise re-enters the stock error tail at
// 0x00515C1A with ("Unknown unit name: %s", token). So the error
// is intact, AND this client resolves GUID literals natively,
// with no SuperWoW involved (relevant to `unit/TokenExtensions.cpp`,
// which adds that family itself only when SuperWoW is absent).
FUN_TOKEN_TO_GUID = 0x00515970,
// `__fastcall(const uint64_t *guid /*ecx*/, int *outCount /*edx*/) ->
// char** tokenArray` — the engine's GUID → unit-token REVERSE map. Fills
// a reused static buffer array (the returned pointer) with the name
// string of every ENGINE-NATIVE token currently pointing at `guid` and
// writes the count to `*outCount`. Checks, in order: player, pet, target,
// party1..4, partypet1..4, raid1..40, raidpet1..40, npc, mouseover — the
// same slots the per-token unit-event broadcast `FUN_00515e50` fans out
// to (that function is just this map + a fire-per-token loop). Does NOT
// know ClassicAPI's synthetic `focus` / `nameplateN` tokens (the engine
// has no concept of them) — callers add those separately. Non-throwing:
// returns count 0 pre-world (resolves the active player internally and
// bails if absent). The returned array is a shared static reused on the
// next call, so snapshot the strings before doing anything that could
// re-enter. nampower names this `GetNamesFromGUID` (left as an unfilled
// TODO in its offsets.hpp). Used by `Unit::Identity::TokensForGUID` for
// the phase-2 `UNIT_SPELLCAST_*` remote-unit fan-out.
FUN_UNIT_TOKENS_FROM_GUID = 0x00515C50,
// Mouseover GUID globals — the `"mouseover"` token resolves to these
// (see the token-dispatch list above). Written ONLY by
// `FUN_SET_MOUSEOVER_UNIT`; zero when nothing is moused over. Holds the
// hovered OBJECT of any type (its setter switches on unit / player /
// game object 0x21 / corpse 0x81), so it is 4.3.4's
// CGGameUI::m_currentObjectTrack, not just a unit. Used by
// `Unit::Mouseover` to detect the loss transition and by
// `Unit::Interact` for InteractUnit("mouseover").
VAR_MOUSEOVER_GUID_LO = 0x00B4E2C8,
VAR_MOUSEOVER_GUID_HI = 0x00B4E2CC,
// The engine's single mouseover set/clear chokepoint —
// `__stdcall(guidLo, guidHi, arg3, arg4)` (early returns are all
// `ret 0x10`, and the caller pushes 4 without cleaning). It is the
// ONLY writer of `VAR_MOUSEOVER_GUID_*`, so every mouseover
// gain/loss/change flows through it. On a unit gain it fires
// `UPDATE_MOUSEOVER_UNIT` itself (via `FUN_FIRE_EVENT_NO_ARGS(0x150)`
// in the friendly/hostile-unit tooltip case); on loss it clears the
// GUID but fires nothing — the gap `Unit::Mouseover` closes.
// Change-gated by its callers (if it ran per-frame the gain fire
// would spam every frame while hovering, which vanilla doesn't), so
// it's a cool hook target.
FUN_SET_MOUSEOVER_UNIT = 0x00492890,
// Event ID of `UPDATE_MOUSEOVER_UNIT` (name-table slot
// `0x00BE16D8` → `(0x16D8 - 0x1198) / 4`). Fired with no args via
// `FUN_FIRE_EVENT_NO_ARGS`; Lua handlers read `UnitExists("mouseover")`.
EVENT_UPDATE_MOUSEOVER_UNIT = 0x150,
// `SStrCmpI(a, b, n)` — Storm's case-insensitive memcmp-style
// comparator. **`int __stdcall(const char *a, const char *b, int n)`**
// — the function ends with `ret 0xc`, so the callee pops the
// 3-arg stack frame. Declaring it as `__cdecl` and calling makes
// MSVC emit a redundant `add esp, 12` post-call, drifting ESP
// upward by 12 per call and corrupting the caller's stack frame
// — manifested as a deep-Lua crash whose `L` pointer landed in
// `.text`. Returns 0 when the first `n` characters match
// (ignoring case) or both strings end before `n`.
FUN_SSTR_CMP_I = 0x0064A4C0,
// UNIT_FIELD_TARGET within `m_objectFields` — 64-bit GUID at byte
// offsets +0x28 (lo) / +0x2C (hi). Verified by disassembling
// `FUN_TOKEN_TO_GUID`'s suffix walker at `0x00515A1C-A2C`:
// `mov eax, [obj + 0x110]; mov edi, [eax + 0x28]; mov ebx, [eax + 0x2c]`
// — reads the target GUID to chain `targettarget`-style tokens.
// Distinct from the higher field offsets in the
// `OFF_UNIT_FIELD_*` block; UNIT_FIELD_TARGET is one of the few
// 1.12 offsets that matches the CMaNGOS-documented vanilla
// layout.
OFF_UNIT_FIELD_TARGET = 0x28,
// Owner/controller GUID fields within `m_objectFields`, each a 64-bit
// GUID (lo/hi). Both byte-verified from engine readers:
// CHARMEDBY +0x10 — `Script_UnitIsCharmed`
// (`mov ecx,[eax+0x10]; or ecx,[eax+0x14]; jz`).
// CREATEDBY +0x20 — the unit owner/title builder `FUN_0052FD30`
// reads `[desc+0x20]`/`[+0x24]` as the summoner GUID.
// A pet/guardian/totem's owner lives in CREATEDBY; a charmed unit's in
// CHARMEDBY. `Unit::Pet` reads these to find a minion's player owner.
// (The engine uses only these two for ownership.) UNIT_FIELD_SUMMONEDBY
// sits between them at +0x18 (the binary's UpdateField table at
// 0x0083D940: index 6, count 2); the combat log reads it to tell a pet
// from a guardian, as 4.3.4's GetCombatLogObjectFlags does.
OFF_UNIT_FIELD_CHARMEDBY = 0x10,
OFF_UNIT_FIELD_SUMMONEDBY = 0x18,
OFF_UNIT_FIELD_CREATEDBY = 0x20,
// A game object's OBJECT_FIELD_CREATED_BY (UpdateField table 0x0083BEB0:
// index 0, count 2), the first field of the block a CGGameObject_C holds
// at `+0x110` — the same slot as a unit's descriptor (OFF_UNIT_DESCRIPTOR).
OFF_GAMEOBJECT_FIELD_CREATED_BY = 0x00,
// UNIT_CREATED_BY_SPELL — the spell that summoned this unit (descriptor
// byte +0x230, field index 0x8C). Set for every spell-summoned unit:
// totems (the shaman's totem-drop spell), pets, guardians, wild summons.
// Verified two ways: the unit-title builder `FUN_0052FD30` reads
// `[desc+0x230]` as the summoning spell (then switches on its Spell.dbc
// Effect[0] to pick "Guardian"/"Creation"), and the server stamps it
// with `m_spellInfo->Id` (tortoise-wow `EffectSummonTotem`/
// `EffectSummonGuardian`/`EffectSummon`). A broadcast field, so it's
// readable for any unit in range. `Unit::Pet` exposes it as
// `UnitCreatedBySpell`. NB: this is the SUMMONING spell — distinct from
// the spell a totem casts (that's server-side only, never broadcast).
OFF_UNIT_FIELD_CREATED_BY_SPELL = 0x230,
// Pet-vs-minion discriminator for an owned unit: `int __fastcall(unit)`.
// `0x00605570` is really the engine's **creature-type resolver** — it's
// `Script_UnitCreatureType`'s (`0x0051A280`) inner helper and returns the
// `CreatureType.dbc` id (1=Beast, 3=Demon, 7=Humanoid, …), via three
// paths in order: a display-override at descriptor `+0x212`, then the
// creature-cache type at `[unit+0xB30]+0x18`, then the player-race type
// at `ChrRaces[[unit+0x110]+0x78]+0x24`. `FUN_UNIT_CREATURE_TYPE` is the
// canonical name; `FUN_UNIT_PET_MINION_CLASS` is a historical alias for
// the same address.
//
// The pet/minion use: the unit-title builder `FUN_0052FD30` calls it as
// `(fn(unit) != 1) + 1` → 1 = "X's Pet" title, 2 = "X's Minion". That
// works because it's really testing "is this a Beast (type 1)": hunter
// pets are Beasts, warlock minions are Demons (type 3) — so `!= 1`
// cleanly separates them, which neither the GUID (pets and guardians
// share the 0xF14… prefix) nor UNIT_FLAG_PLAYER_CONTROLLED reliably does.
FUN_UNIT_PET_MINION_CLASS = 0x00605570,
FUN_UNIT_CREATURE_TYPE = 0x00605570,
// Party / raid roster counts and the party GUID array referenced
// in the `FUN_TOKEN_TO_GUID` dispatch comment above. Used by
// `UnitTokenFromGUID` to cap its candidate iteration — solo
// players skip all 88 group tokens; a 5-person party scans 4
// slots instead of 40.
//
// - `VAR_PARTY_GUIDS` — 4-slot QWORD array (one GUID per party
// member, low+high dwords). Walked by `Script_GetNumPartyMembers`
// (`FUN_004E86D0`) at `0x004E86D0` to compute the count.
// - `VAR_RAID_MEMBER_COUNT` — single int maintained by the
// engine's raid-roster handler. Read directly by
// `Script_GetNumRaidMembers` (`FUN_004BB530`).
VAR_PARTY_GUIDS = 0x00BC6F48,
PARTY_MAX_SLOTS = 4,
VAR_RAID_MEMBER_COUNT = 0x00B713E0,
RAID_MAX_SLOTS = 40,
// Chat-message dispatcher — builds the chat line and the speech bubble
// and fires the CHAT_MSG_* event (through FUN_0049B0B0).
//
// Calling convention: `__fastcall`, `RET 0x28` — ECX = the MESSAGE
// text, EDX = chat type, then 10 stack args: senderName, languageID,
// channel, targetName, flags ("AFK"/"DND"/"GM"), speaker GUID (lo, hi),
// rank, GUID (lo, hi). The speaker GUID is what the bubble spawn
// FUN_00608AC0 resolves; the last pair is the GUID read right before
// the message text. (ECX was previously mislabeled "sender name";
// `MOV ECX,[EBP-0x10]` in FUN_0049D560 is the message.) Called from:
// - FUN_0049D560, the SMSG_MESSAGECHAT handler (return address
// CHAT_DISPATCH_RET_PACKET)
// - the two pending-chat callers (`__AUPENDINGCHAT` entries queued by
// FUN_0049CAE0): FUN_0049CCC0, the name-query callback, dispatches a
// sender's queued messages once that name arrives (return address
// CHAT_DISPATCH_RET_PENDING_NAME) — the normal path for a sender the
// name cache did not know; FUN_0049D230 drains what was queued out of
// world (0x008435FC set; FUN_004908C0 clears it on entering the world
// and drains, return address CHAT_DISPATCH_RET_PENDING_DRAIN)
// - many client-made messages (system notices, channel notices, …)
// that pass 0 for both GUID pairs
//
// Which pair holds the sender depends on the packet layout (vmangos
// ChatHandler::BuildChatPacket, matching FUN_0049D560's reads): say/
// party/yell send the sender twice; monster say/yell send sender, name,
// TARGET; monster emote/whisper and raid boss emote/whisper send name,
// TARGET; everything else sends the sender once. So the last pair is the
// sender for player chat and the monster's TARGET for monster chat.
//
// Hooked (once) by `Chat::Dispatch`, which orchestrates the concerns
// sharing this choke point: `Chat::EventArgs` (the sender GUID behind
// the event's arg12 and `GetCurrentChatGUID()`), `Chat::IconFilter` (strip player-injected `|T`
// icon spoofs from chat + speech bubbles), and `Chat::RaidMarkers`
// (expand `{rtN}`/`{skull}`/… into inline markers).
FUN_CHAT_DISPATCH = 0x0049A870,
CHAT_DISPATCH_RET_PACKET = 0x0049DBD0, // after the CALL at 0x0049DBCB
CHAT_DISPATCH_RET_PENDING_NAME = 0x0049CFC6, // after the CALL at 0x0049CFC1
CHAT_DISPATCH_RET_PENDING_DRAIN = 0x0049D437, // after the CALL at 0x0049D432
// Pending-chat entry (200 bytes, allocated by FUN_0049CAE0). Both pending
// callers pass entry+OFF_PENDING_CHAT_CHANNEL as dispatch arg 5 and
// entry+OFF_PENDING_CHAT_FLAGS as arg 7, but zeros for both GUID pairs;
// the GUID the entry waits on (the dispatch's last pair) stays at
// OFF_PENDING_CHAT_GUID.
OFF_PENDING_CHAT_GUID = 0x10, // u64
OFF_PENDING_CHAT_CHANNEL = 0x2C, // char[0x80]
OFF_PENDING_CHAT_FLAGS = 0xB8, // char[5]
SMSG_MESSAGECHAT = 0x96,
// CHAT_MSG_* event fire, `__fastcall(text, chatType)` + 6 stack args
// (senderName, languageID, channelString, targetName, flags, channel
// record), RET 0x18. Three callers: FUN_CHAT_DISPATCH, FUN_0049B1B0
// (client-made messages) and FUN_CHAT_TEXT_EMOTE. Its one FUN_FIRE_EVENT
// call is PATCH_CHAT_EVENT_FIRE_CALL, 10 args after the format:
// text, sender, language, channelString, target, flags, zoneChannelID,
// channelNumber, channelName, (channel record +0x98). Turtle sends chat
// type 0x5E through .tdata (0x00D06040) to change the event id, which
// jumps back to the PUSH ECX right before that CALL.
FUN_CHAT_EVENT_FIRE = 0x0049B0B0,
PATCH_CHAT_EVENT_FIRE_CALL = 0x0049B199, // E8 rel32 → FUN_FIRE_EVENT
VAR_STR_CHAT_EVENT_FORMAT = 0x00844608, // "%s%s%s%s%s%s%d%d%s%d"
// CHAT_MSG_TEXT_EMOTE builder, `__fastcall(const u64 *senderGuid, emote,
// const char *target, emoteNum)`, RET 8. Called by the SMSG_TEXT_EMOTE
// handler and its pending-emote queue; fires through FUN_CHAT_EVENT_FIRE
// without passing the GUID on.
FUN_CHAT_TEXT_EMOTE = 0x0049B200,
// Per-player inventory manager lives at this offset on the player object.
// +0x00 = u32 slot count (OFF_INVMGR_SLOT_COUNT), +0x04 = u64* GUID
// array (see OFF_INVMGR_GUID_ARRAY below for the slot-range map).
OFF_PLAYER_INVENTORY_MANAGER = 0x1D38,
OFF_INVMGR_SLOT_COUNT = 0x00,
// --- Descriptor-field observer system --------------------------------
// The engine's generic "watch a descriptor field range for changes"
// mechanism (nodes tagged "__AUCMirrorHandler__", 0x30 bytes). The
// registrar attaches a node to the object's per-field observer anchors;
// each node keeps a private MIRROR of the watched bytes, seeded from
// the live value at registration. During SMSG_UPDATE_OBJECT processing
// the dispatcher FUN_00465570 memcmps live vs mirror and invokes the
// callback only on a real change (the mirror is then re-synced by
// FUN_004667A0). Firing engine events from the callback is sanctioned —
// the engine's own bag observer does exactly that.
//
// Registrar — __fastcall(int bank /*ecx*/, uint32_t fieldOffset /*edx*/,
// uint32_t guidLo, uint32_t guidHi, int size, const void *callback,
// void *userArg1, void *userArg2). `guid` selects the watched OBJECT
// (player, item, container, …); `bank` selects its field bank
// (1 = ITEM, 2 = CONTAINER, 4 = PLAYER — the engine's per-bag
// manager FUN_004F91A0 registers bank-2 observers on each equipped
// bag's CGContainer); `fieldOffset` is BANK-relative (container
// SLOT_1 = 8, not its descriptor-absolute 0x20). The engine's
// inventory setup FUN_004F8CC0 registers the player's bag/backpack/
// bank/keyring GUID ranges this way; AddActiveWatchers (0x005DD8A0)
// covers the equipment slots (FUN_INV_SLOT_CHANGED_OBSERVER).
FUN_DESC_OBSERVER_REGISTER = 0x00467E70,
// Unregister — __fastcall(int bank /*ecx*/, uint32_t fieldOffset
// /*edx*/, uint32_t guidLo, uint32_t guidHi, const void *callback,
// void *userArg1). Removes the node matching (callback, userArg1)
// from that object+field's observer list; harmless no-op when
// nothing matches. What FUN_004F91A0 calls for an unequipped bag.
FUN_DESC_OBSERVER_UNREGISTER = 0x00467FB0,
// Observer callback ABI (verified from the dispatcher's call site at
// 0x004655DC + the engine callback FUN_004F8DB0's RET 0x10):
// int __fastcall cb(uint32_t fieldOffset /*ecx, as registered*/,
// uint32_t size /*edx*/,
// uint32_t guidLo, uint32_t guidHi,
// const uint32_t *oldValue /*the node's mirror*/,
// void *userArg1) → return 1, callee cleans 0x10.
// The live (new) value is NOT passed — read it from the object (the
// engine's bag callback reads the invMgr GUID array).
// ---- Unit-event token observers (Unit::TokenObserver) ---------------
// The engine makes target/party/raid/pet/mouseover units fire per-token
// unit events (UNIT_HEALTH, UNIT_MANA, UNIT_AURA, …) by watching bank-UNIT
// descriptor fields: FUN_0051bbb0 loops event index i in
// [0, EVENT_NAME_UNIT_MAX); for each whose static name slot is non-null it
// registers a bank-3 observer on field i*4 (per-index size below) with
// callback FUN_0051bd50 → the broadcast FUN_00515e50(guid, i), which fires
// event i once per token referencing the guid. The FIELD INDEX IS THE EVENT
// ID (health field +0x40 → event 16 = UNIT_HEALTH). Unit::TokenObserver
// replicates that exact loop with a caller's own callback to make synthetic
// tokens (focus, nameplateN) first-class; the registrar always appends a
// fresh node (FUN_00467f00, no dedup), so ours coexists with the engine's —
// a unit that is also the target fires both "target" and our token. The
// broadcast always fires with format "%s" + the token (DAT_0082e280).
// Per-index watched size (FUN_0051bbb0's switch): i∈{0,2,4,10}=8,
// 0x29=0xD8 (UNIT_FIELD_AURA), 0x6B=0x30, 0xA7/0xAE=0x1C, else 4.
VAR_EVENT_NAME_TABLE_STATIC = 0x00BE1198, // char*[] boot name array; slot i (base+i*4) non-null ⇒ real event i
EVENT_NAME_UNIT_MAX = 0xB6, // FUN_0051bbb0's loop bound
// CGPlayer_C::AddActiveWatchers' inventory-slot observer
// (OnInventorySlotChanged) — registered on the active player's inv slots
// 0..22 (equipment INCLUDED), bank and keys; observer ABI above, RET
// 0x10. Unlocks the arriving item (UnlockItem 0x495420) and signals
// PLAYERBANKSLOTS_CHANGED for bank slots. The ancestor of 4.3.4's
// InventoryUpdate (0x0056DBD0), which fires PLAYER_EQUIPMENT_CHANGED
// right after that same unlock — Player::Equipment co-hooks it to do so.
FUN_INV_SLOT_CHANGED_OBSERVER = 0x005DDCF0,
// PLAYER_FIELD_INV_SLOT_HEAD — first of the 19 equipment-slot u64 GUID
// fields in the player descriptor (0x4A8..0x538, stride 8; 0x540 is
// the first equipped-bag slot). 0-based slot = (offset - 0x4A8) >> 3;
// Lua inventory slot (GetInventoryItemLink etc.) = that + 1.
OFF_DESC_PLAYER_EQUIP_FIRST = 0x4A8,
DESC_PLAYER_EQUIP_SLOTS = 19,
// PLAYER_QUEST_LOG_1_1 — first of the 20 quest slots in the player
// descriptor, each 0xC bytes ({questID, ?, flags}). 0-based slot =
// (offset - 0x28) / 0xC, exactly what FUN_QUEST_SLOT_ANNOUNCE_OBSERVER
// computes from the field offset it was registered on. The CGPlayer
// sub-struct mirrors the same block at `[player + OFF_CGPLAYER_INFO] +
// OFF_CGPLAYER_INFO_QUEST_LIST` (same field and stride, different base —
// that's the copy FUN_QUEST_LOG_REBUILD walks).
OFF_DESC_PLAYER_QUEST_LOG_FIRST = 0x28,
DESC_PLAYER_QUEST_LOG_SLOT_SIZE = 0xC,
DESC_OBSERVER_BANK_PLAYER = 4,
DESC_OBSERVER_BANK_UNIT = 3, // CGUnit descriptor bank (FUN_0051bbb0's watch loop)
// The engine's inventory-alerts recompute (4.3.4's
// CGCharacterInfo::UpdateInventoryAlerts) — walks the equipment slots,
// reads each item's durability / max durability / broken flag, fills
// the per-slot alert table at [DAT_00B71F60], and fires
// UPDATE_INVENTORY_ALERTS (event 501). Its seven callers (Ghidra xrefs)
// mirror 4.3.4's set: the type-wide item-field watchers registered by
// 0x005D9360 via 0x00468070 — ITEM_FIELD_DURABILITY (0x005D97C0, calls
// it unconditionally, like 4.3.4's OnUpdateDurability), flags bit 0x10
// on equipped slots (0x005D96E0), enchantment (via 0x005D9A90), ammo
// stack count (0x005D9400) — plus the visible-item change of ANY player
// (0x005DEE30, before its active-player check), player setup
// (0x004C6D30) and Lua UpdateInventoryAlertStatus (0x004C9560).
// Player::Equipment co-hooks it to fire UPDATE_INVENTORY_DURABILITY,
// exactly where 4.3.4 does. void __fastcall(), no args.
FUN_INVENTORY_ALERTS_RECOMPUTE = 0x004C7EE0,
// ItemMgr::GetItemBySlot — __thiscall(this, slot) → CGItem* (NULL if empty).
// Slot is the engine's linearized slot index, not bagID/slot tuple.
FUN_ITEMMGR_GET_ITEM_BY_SLOT = 0x006228A0,
// CGUnit visible-items helper used by `Script_GetInventoryItemLink` for
// non-player units (target/party/inspect targets). __thiscall(this=unit,
// int 0-based slot) → visible-item entry*, or NULL if slot is out of
// [0, 18]. Reads `[unit + 0xE68]` (visible-items array base for the
// unit) and indexes `base + 0x118 + slot * 0x30`. Each 0x30-byte entry
// holds the itemID at `+0x08`; the engine reads it back exactly that
// way before feeding it to `_GetRecord` for hyperlink construction
// (verified in `Script_GetInventoryItemLink` at `0x004C8D05`-`0x4C8D34`).
//
// **Crash hazard**: `[unit + 0xE68]` is uninitialized for NPCs
// (CGCreature_C objects). The helper has no NULL check — it computes
// `garbage + 0x118 + slot*0x30` and returns that as a valid pointer.
// The engine relies on callers to gate this with `UnitPlayerControlled`
// first; we do the same in `Item::InventoryID`.
FUN_UNIT_GET_VISIBLE_ITEM = 0x005F0D60,
OFF_VISIBLE_ITEM_ITEM_ID = 0x08,
// CGUnit m_objectFields pointer offset. Different from CGItem's
// descriptor at +0x114 — these are sibling classes under CGObject
// with class-specific descriptor offsets.
OFF_UNIT_DESCRIPTOR = 0x110,
// A creature's LIVE creature_template entry — in the INSTANCE BLOCK at
// `[unit + OFF_UNIT_GUID_PTR]` (GUID @+0x00, entry @+0x0C), the same
// shape as CGItem's block (GUID @+0x00, itemID @+0x0C). NOT the
// descriptor's OBJECT_FIELD_ENTRY slot (+0xC), which reads 0 for
// creatures exactly as it does for items (in-game probe: a Gordunni
// Mage-Lord read desc 0 / block 5239 / GUID bits 5236). This is what the
// engine keys the creature NAME query on: `FUN_00604600` resolves the unit
// and calls the creature cache with `[[unit+8] + 0xC]`; it is registered
// as the OBJECT-bank field-0xC handler (`FUN_006041f0` →
// `FUN_00468070(0, 0xC, 4, 0x604600)`). Do NOT derive a creature id from
// the GUID's entry bits instead: the server builds the GUID from the spawn
// row's FIRST creature id (`Creature::CreateFromProto` →
// `Object::_Create(guidlow, creature_id[0], …)`) and applies the rolled
// template with `UpdateEntry` → `SetEntry` only, so multi-id spawns (6,935
// Turtle rows) and respawn re-rolls put a different template behind the
// same GUID entry — Turtle's Gordunni rows are {5236, 5238, 5239} and
// every one of them carries 5236 in its GUID. Read by `Unit::CreatureID`.
OFF_UNIT_INSTANCE_ENTRY = 0x0C,
// ── Nameplates (CGNamePlateFrame) ──────────────────────────────────
//
// The same machinery as 3.3.5's (decomp: WoW/Source/Ui/NamePlateFrame.h,
// Object/ObjectClient/Unit_C.cpp), verified function by function:
// FUN_006086E0 = CGUnit_C::NamePlateAddOrUpdate — acquire (FUN_006087F0,
// the recycle-or-allocate GetNewNameplateFrame), bind (FUN_007CB6D0 =
// CGNamePlateFrame::Initialize, which copies the unit's GUID into the
// plate), then sort it onto the shown list (FUN_00608870 =
// NamePlateSort);
// FUN_00608A10 = CGUnit_C::DestroyNamePlate — unlink from the shown
// list, link onto the recycle list (head 0x00C4D920 / tail 0x00C4D91C),
// hide, zero unit+0xE60. Its callers are all real releases: the unit
// destructor FUN_005FB5E0, the despawn reset FUN_005FBB60, the name
// cache callback FUN_005FB840 (drops the plate so it rebuilds with the
// name), the show/hide decision, and FUN_0060F890 =
// NamePlateClearAll, which walks the shown list itself and resolves
// each plate's unit by GUID with FUN_00468460 — the model
// NamePlate::Walk follows.
//
// VAR_NAMEPLATE_LIST_HEAD is the shown list's first plate (0 or a
// low-bit-tagged sentinel ends it); each plate's next is at
// OFF_NAMEPLATE_LINK_NEXT. Sorted by NamePlateSort, which inserts a plate
// before the first one at the same or a nearer screen-centre distance —
// so the list runs FARTHEST first. A recycled plate keeps its old GUID
// until Initialize rebinds it; a plate on the shown list is always bound.
// unit+0xE60 is the unit's plate (CGUnit_C::m_namePlateFrame).
// Chat bubbles: the active CGChatBubbleFrames sit on one intrusive Storm
// TSList — 3.3.5's CGChatBubbleFrame list (decomp: Ui/ChatBubbleFrame.h).
// VAR_CHAT_BUBBLE_LIST_HEAD is the first bubble (0 or a low-bit-tagged
// sentinel ends it); each bubble's next is at OFF_CHAT_BUBBLE_LINK_NEXT.
// The same walk as the engine's per-frame update FUN_004B1060 and
// teardown FUN_004B0F80.
VAR_CHAT_BUBBLE_LIST_HEAD = 0x00B6F038,
OFF_CHAT_BUBBLE_LINK_NEXT = 0x318,
// The bubble text builder FUN_004B1600 (benilla ui/chatbubble "Bubble
// text") strips the line's escapes into a 0x800-byte stack buffer, then
// sets it on the bubble's FontString (bubble+0x31C) with this
// `CALL FUN_FONTSTRING_SET_TEXT` (E8 rel32; ECX = fs, stack = buffer, 1).
// 4.3.4's CGChatBubbleFrame::Initialize runs ParseRaidIcons at the same
// point (strip → raid icons → SetText); ChatBubble::RaidIcons redirects it.
PATCH_CHAT_BUBBLE_SET_TEXT_CALL = 0x004B16C0,
VAR_NAMEPLATE_LIST_HEAD = 0x00C4D92C,
OFF_NAMEPLATE_LINK_NEXT = 0x4E0,
OFF_NAMEPLATE_GUID = 0x4E8,
OFF_UNIT_NAMEPLATE = 0xE60,
// CGNamePlateFrame vtable: the 40 virtual slots the plate constructor
// stores as the frame's vfptr. Slot 10 (+0x28) is
// FUN_FRAME_SET_FRAME_ALPHA, which is how the plate fade writes 0xFF /
// 0x7F. Verified against benilla-re (`s_namePlateVtable`) and by dumping
// this image: slot 10 reads 0x0076A690. A frame whose vfptr is this
// address is a live default plate (addon-built plates are normal frames).
VAR_NAMEPLATE_VTABLE = 0x0081DE50,
// CGCreature client-side creature-data cache row. Populated by the
// engine when an NPC GUID becomes visible (the same row the
// `CreatureCache` SMSG fills with the templated NPC's name,
// subname, etc.). NULL for unsynced units or for player CGUnits
// (players don't have a row in this cache — their name comes from
// the SMSG_NAME_QUERY_RESPONSE-fed name cache at `0x00C0E228`).
//
// Layout of the cache row:
// +0x00 ?
// +0x0C name C-string ptr (alias of UNIT_NAME for creatures)
// +0x10 subName C-string ptr ("Innkeeper", "<Master Trainer>", etc.)
// +0x1C CreatureFamily id (→ CreatureFamily.dbc), 0 = none
//
// Used by `Script_UnitName`'s creature path and by VanillaMinimapTracking's
// subname-based blip filter (`src/Blips.cpp::ExtractUnitSubName`).
OFF_UNIT_CREATURE_CACHE_ROW = 0xB30,
OFF_CREATURE_CACHE_SUB_NAME = 0x10,
// CreatureFamily id within the +0xB30 cache row — the value the engine's
// `Script_UnitCreatureFamily` (`0x0051A310`) reads via its family helper
// `FUN_006055e0` (`[unit+0xB30] ? [row+0x1C] : 0`) before mapping it
// through `CreatureFamily.dbc` for the localized name. `UnitCreatureFamilyID`
// returns the raw id. Same field as `OFF_CREATURE_FAMILY` in the creature
// cache data block, reached through the unit here.
OFF_CREATURE_CACHE_FAMILY = 0x1C,
// Pointer to the CGUnit's 8-byte GUID at `*(CGUnit + 0x08)`. Verified
// in `Script_GetInventoryItemLink` at `0x004C8CB0`-`0x004C8CB5`:
// `mov eax, [esi+8]; mov edi, [eax]; mov ecx, [eax+4]` reads the
// GUID's lo+hi dwords through this indirection. CGItem uses the same
// offset for its instance block (also containing a GUID + itemID),
// so the layout is consistent across CGObject subclasses — but the
// contents differ per class.
OFF_UNIT_GUID_PTR = 0x08,
// UNIT_FIELD_FLAGS within m_objectFields. Bit 3 (`0x08`) is
// `UNIT_FLAG_PLAYER_CONTROLLED`, which `Script_UnitPlayerControlled`
// (`0x00516410`) tests via `mov eax, [m_objectFields + 0xA0];
// shr eax, 3; test al, 1`.
// CGUnit m_objectFields current/max stat offsets, **verified
// empirically** on Turtle WoW (1.12.1) by `_classicapi_DescDump`
// searching for the live `UnitMana` value at descriptor offsets:
//
// +0x40 HEALTH (current)
// +0x44 POWER1 (current mana — verified at multiple values)
// +0x48 POWER2 (current rage)
// +0x4C POWER3 (current focus)
// +0x50 POWER4 (current energy)
// +0x54 POWER5 (current happiness)
// +0x58 MAXHEALTH (= 807 at full HP in test data)
// +0x5C MAXPOWER1 (max mana — stays at 1435 even when current = 443)
// +0x60..+0x6C MAXPOWER2..5
// +0x70 LEVEL (= 26 in test data)
// +0xA0 FLAGS (verified separately via `Script_UnitPlayerControlled`)
//
// **The 1.12.1 layout is offset 0x18 (= 6 fields) earlier than the
// CMaNGOS-documented vanilla layout** (which puts HEALTH at field
// 0x16 = +0x58). My initial implementation read MAXHEALTH/MAXMANA
// when I wanted current values — caused `IsUsableSpell` to falsely
// return usable even when mana was below cost. Trust the binary
// (and `_classicapi_DescDump` if you ever need to re-verify), not
// external emulator field tables.
OFF_UNIT_FIELD_HEALTH = 0x40,
OFF_UNIT_FIELD_POWER1 = 0x44,
// POWER1..5 are 4 bytes each, contiguous from +0x44:
// +0x44 mana / +0x48 rage / +0x4C focus / +0x50 energy / +0x54 happiness.
OFF_UNIT_FIELD_MAXHEALTH = 0x58,
OFF_UNIT_FIELD_MAXPOWER1 = 0x5C,
// MAXPOWER1..5 are 4 bytes each, contiguous from +0x5C (same
// mana/rage/focus/energy/happiness order as POWER1..5). Vanilla
// 1.12 has 5 power types; the WotLK additions (Runes / Runic Power)
// don't exist in this descriptor layout.
// UNIT_MOD_CAST_SPEED — the cast-time multiplier float (1.0 = normal,
// <1.0 = faster). The server folds it into `SpellEntry::GetCastTime`
// (`castTime *= GetFloatValue(UNIT_MOD_CAST_SPEED)`); the client reads it
// in `FUN_006e3340` at descriptor `+0x22c`. Backs `UnitSpellHaste`
// (`haste% = (1/mult - 1) * 100`). nampower surfaces the raw float as its
// `modCastSpeed` unit field.
OFF_UNIT_MOD_CAST_SPEED = 0x22C,
UNIT_POWER_MIN_TYPE = 0,
UNIT_POWER_MAX_TYPE = 4, // happiness; types 5/6 only valid post-WotLK
// Per-power-type display divisor. Raw descriptor values get
// divided by this before they're surfaced through Lua. Vanilla
// 1.12 stores rage as 0..1000 (internally) and divides by 10 to
// show 0..100; happiness is stored at 1000x scale and divides
// by 1000. Engine reads from `Script_UnitMana` at
// `0x006E7130 + type * 4` (= `0x0086F978`). Same trick the
// 3.3.5/4.x clients use; the table is per-client, the design is
// stable.
//
// [0] = 1 MANA
// [1] = 10 RAGE
// [2] = 1 FOCUS
// [3] = 1 ENERGY
// [4] = 1000 HAPPINESS
VAR_UNIT_POWER_DIVISOR_TABLE = 0x0086F978,
// GetPowerDisplayDivisor — `int __fastcall(int powerType)`, the reader of
// the table above (1 for a negative type). benilla-re spell symbols.
FUN_POWER_DISPLAY_DIVISOR = 0x006E7130,
OFF_UNIT_FIELD_LEVEL = 0x70,
// UNIT_FIELD_BYTES_0 dword at +0x78; byte 3 (= +0x7B) is the unit's
// primary power type (one of UNIT_POWER_MIN_TYPE..MAX_TYPE).
// Verified at `0x005179E6` in vanilla's `Script_UnitPowerType`:
// mov edx, [eax + 0x110]
// movzx eax, byte ptr [edx + 0x7B]
OFF_UNIT_DESCRIPTOR_POWER_TYPE_BYTE = 0x7B,
// UNIT_FIELD_STAT0..4 — the fully-computed (base+item+buff) primary
// stats, broadcast in the descriptor. Order Str/Agi/Sta/Int/Spirit;
// STAT4 (Spirit) = fieldIndex 0x94 → +0x250 (from the UpdateField name
// table; cross-checked in-game: descriptor +0x250 read 173→182 when a
// +9-Spirit item was equipped). What GetStat(STAT_SPIRIT) returns
// server-side; used by GetSpellBonusHealing for the Spiritual-Guidance
// (aura 175) spirit→healing conversion.
OFF_UNIT_FIELD_STAT_SPIRIT = 0x250,
// UNIT_FIELD_RESISTANCES[0] = armor (the fully-computed total), fieldIndex
// 0x95 → +0x254 (7 resistances: armor, then the 6 magic schools). What
// GetArmor() / GetResistance(SPELL_SCHOOL_NORMAL) returns; used by
// GetSpellBonusHealing for Turtle's Ironclad (aura 199) armor→healing.
OFF_UNIT_FIELD_RESISTANCE_ARMOR = 0x254,
OFF_UNIT_FIELD_FLAGS = 0xA0,
UNIT_FLAG_PLAYER_CONTROLLED = 0x08,
// Bit 19 of UNIT_FIELD_FLAGS — `Script_UnitAffectingCombat` at
// `0x00517E4A`-`0x517E5C` tests it via `mov eax, [fields+0xA0];
// shr eax, 19; test al, 1`. We use it for `InCombatLockdown`,
// which in 1.12 collapses to "is the local player in combat" — no
// secure-frame system here, so the modern lockdown semantics
// reduce to a plain combat flag check.
UNIT_FLAG_IN_COMBAT = 0x00080000,
// Bit 29 of UNIT_FIELD_FLAGS — set by the engine when the player is
// feigning death (Hunter's `Feign Death`). Standard vanilla
// `UNIT_FLAG_FEIGN_DEATH = 0x20000000` per emulator source. Tested
// by `UnitIsFeignDeath(unit)` — works on any unit since
// UNIT_FIELD_FLAGS is broadcast in object updates.
UNIT_FLAG_FEIGN_DEATH = 0x20000000,
// Bit 24 of UNIT_FIELD_FLAGS — set by the engine when a player is
// possessed (priest's `Mind Control`, warlock's `Subjugate Demon`).
// Standard vanilla `UNIT_FLAG_POSSESSED = 0x01000000` per emulator
// source (CMaNGOS/TrinityCore). Read by `UnitIsPossessed(unit)`.
UNIT_FLAG_POSSESSED = 0x01000000,
// Bit 25 of UNIT_FIELD_FLAGS — the unit can't be selected (tortoise-wow
// and vmangos UnitDefines.h agree). 4.3.4 drops the focus when a unit
// gains it (CGUnit_C::OnFlagChanged → BreakTarget); 1.12 has no reader.
UNIT_FLAG_NOT_SELECTABLE = 0x02000000,
// Bit 20 of UNIT_FIELD_FLAGS — on a flight path (vmangos
// UNIT_FLAG_TAXI_FLIGHT). The stand setter FUN_PLAYER_SEND_STAND_STATE
// refuses while it is set (benilla-re objectlayer/standstate#the-sit-gate).
UNIT_FLAG_TAXI_FLIGHT = 0x00100000,
// `UNIT_FIELD_CHANNEL_OBJECT` lo/hi (64-bit GUID of the object the
// unit is currently channeling onto — bobber for fishing, lock for
// lockpicking, etc.). CMaNGOS vanilla field 20 (= 0x50) minus the
// 1.12.1 -0x18 unit-fields shift = 0x38. Verified empirically by
// diffing the player descriptor during fishing: 0x38/0x3C went
// `0 → bobber GUID` (high half `0xF110xxxx` = the vanilla
// GameObject-GUID prefix), back to 0 on cast end.
//
// Note: not every channel populates this. The warlock's Ritual of
// Summoning channel leaves it at 0 — that channel binds to the
// participants via the spell, not via UNIT_CHANNEL_OBJECT.
OFF_UNIT_FIELD_CHANNEL_OBJECT = 0x38,
// `UNIT_FIELD_CHANNEL_SPELL` (u32 spell ID the unit is currently
// channeling, or 0). CMaNGOS vanilla field 144 (= 0x240) minus the
// -0x18 shift = 0x228. Verified empirically: the warlock's diff
// shows `0x228 = 0 → 0x2BA` (698 = Ritual of Summoning) for the
// duration of his channel; same value appears on every clicker
// participating in the ritual; fishing populates it with 7620
// (Fishing spell ID). Broadcast UpdateField, so it's readable for
// any visible unit, not just the local player.
OFF_UNIT_FIELD_CHANNEL_SPELL = 0x228,
// `UNIT_FIELD_BASEATTACKTIME` (main-hand @ field 0x78, off-hand @ field
// 0x79) and `UNIT_FIELD_RANGEDATTACKTIME` (field 0x7A) — byte offset =
// field index * 4. Verified two ways: (1) the in-binary UpdateField
// name table at VA `0x0083A6EC` gives field index 0x78 for the string
// "UNIT_FIELD_BASEATTACKTIME" and 0x7A for "UNIT_FIELD_RANGEDATTACKTIME";
// (2) `Script_UnitAttackSpeed` (`0x00518E50`) reads `[descriptor+0x1E0]`
// / `[+0x1E4]` and `Script_UnitRangedDamage` (`0x00518910`) reads
// `[descriptor+0x1E8]` — exactly `field*4`. These already carry the
// player's current (hasted) swing time; the server writes the modified
// value directly into the broadcast field rather than sending a
// separate haste multiplier, so there is no client-side way to recover
// the UNHASTED weapon delay from these — that has to come from the
// weapon's own `OFF_ITEMSTATS_DELAY`. Used by `Combat::Swing`.
OFF_UNIT_FIELD_BASEATTACKTIME = 0x1E0, // main-hand swing time, ms
OFF_UNIT_FIELD_OFFHANDATTACKTIME = 0x1E4, // off-hand swing time, ms
OFF_UNIT_FIELD_RANGEDATTACKTIME = 0x1E8, // ranged swing time, ms
// Aura arrays in the unit's `m_objectFields` descriptor (at `unit
// + OFF_CGUNIT_OBJECT_FIELDS`). 48 total auras packed as two
// parallel sub-ranges (32 buffs, then 16 debuffs) sharing the
// flags / levels / applications side-arrays indexed by absolute
// slot (0..47). Derived by decompiling `Script_UnitBuff`
// (`0x00519500`) and `Script_UnitDebuff` (`0x005198F0`):
//
// Script_UnitBuff iterates desc[+0xA4 .. +0x124) step 4 (slots 0..31)
// Script_UnitDebuff iterates desc[+0x124 .. +0x164) step 4 (slots 32..47)
// Both read flag nibble at desc[+0x164 + slot/2] >> ((slot&1)*4) & 0xF
// and gate on `(nibble & 0x0E) != 0` (visibility)
// Both read stacks at desc[+0x1AC + slot] and display as `byte + 1`
//
// For our purposes we don't decode individual flag bits — we
// distinguish helpful vs harmful by absolute slot range, and we
// derive `dispelName` from `Spell.dbc[+0x10]` (see
// `OFF_SPELL_DISPEL_TYPE` below), not from the flags nibble.
OFF_UNIT_FIELD_AURA = 0xA4, // u32 spell ID per slot, 48 slots total
// UNIT_AURA event id for FUN_UNIT_EVENT_BROADCAST. The per-token unit
// events use field-index == event-id; the aura field is index 0x29
// (OFF_UNIT_FIELD_AURA 0xA4 >> 2), per Unit::TokenObserver's watched set.
UNIT_EVENT_UNIT_AURA = 0x29,
OFF_UNIT_FIELD_AURAFLAGS = 0x164, // 4 bits per aura, 2 per byte, covers all 48
OFF_UNIT_FIELD_AURALEVELS = 0x17C, // u8 caster level per aura, 48 bytes
OFF_UNIT_FIELD_AURAAPPLICATIONS = 0x1AC, // u8 (stacks-1) per aura, display value = byte+1
UNIT_AURA_BUFF_COUNT = 32, // slot range 0..31 (helpful)
UNIT_AURA_DEBUFF_COUNT = 16, // slot range 32..47 (harmful)
UNIT_AURA_TOTAL = 48,
UNIT_AURA_VISIBLE_MASK = 0x0E, // nibble mask used by the engine's visibility gate
// Per-slot flag nibble bits. THE MEANING OF 0x02/0x04/0x08 IS NOT THE SAME
// ON EVERY SERVER, so read them only through `Aura::Data::IsSlotHarmful`,
// which picks the right interpretation.
//
// Stock (vmangos SpellAuraDefines.h + SetAuraFlag, verified): the bits are
// CANCELABLE 0x01, EFF_INDEX_2 0x02, EFF_INDEX_1 0x04, EFF_INDEX_0 0x08 —
// one bit per spell effect index that carries an aura, plus cancelable for
// a positive aura. NO POLARITY IS ENCODED. Polarity comes from the slot
// range instead (0..31 helpful, 32..47 harmful), which is exact because
// the slot search is a strict if/else on IsPositive and never crosses over.
// Reading 0x08 as "harmful" here would really be reading "effect index 0
// has an aura", which is true of nearly every aura — so nearly every BUFF
// would come back as a debuff.
//
// Turtle (tortoise-wow SetAuraFlag, verified) replaces the effect-index
// bits with polarity: positive gets 0x04 (+ CANCELABLE unless
// SPELL_ATTR_CANT_CANCEL), negative gets 0x08. It has to, because Turtle
// also drops the `else` in the slot search so a debuff spills into 0..31
// once the 16 harmful slots are full (and sets UNIT_FLAG_AURAS_VISIBLE so
// the client still renders it). There the range is unreliable and the
// nibble is the real answer — the exact inverse of stock.
UNIT_AURA_FLAG_CANCELABLE = 0x01,
UNIT_AURA_FLAG_HELPFUL = 0x04, // Turtle only; stock = EFF_INDEX_1
UNIT_AURA_FLAG_HARMFUL = 0x08, // Turtle only; stock = EFF_INDEX_0
// PLAYER_FIELD_MOD_DAMAGE_DONE_POS/NEG — the player's per-school spell
// damage bonus. Offsets from the engine's own UpdateField name/index
// table in `.rdata` (20-byte entries `{char* name, u32 fieldIndex, u32
// count, ...}` at VA 0x83B6C8): POS = fieldIndex 0x3F5 count 7 → byte
// offset fieldIndex*4 = 0xFD4; NEG = 0x3FC → 0xFF0. Seven int32 each,
// one per school (0 physical .. 6 arcane); net bonus = POS − NEG.
//
// **Read these off `[player + OFF_CGPLAYER_INFO]` (the +0xE68 CGPlayer
// sub-struct), NOT the broadcast descriptor at +0x110.** The descriptor
// copy is never sent to the client and reads zero (verified in-game: the
// whole post-skills PLAYER descriptor region is zero on a geared L60 —
// vanilla never displayed spell power, so the server doesn't broadcast
// it). The +0xE68 struct holds the client's fully-computed value
// (gear + enchants + buffs + talents + sets baked in). Same base +
// offsets nampower's GetSpellPower uses; verified 613 generic / 647 Fire
// on a geared mage. Read by GetSpellBonusDamage in [src/spell/BonusDamage.cpp].
// (No MOD_HEALING_DONE equivalent — vanilla lacks the field entirely;
// GetSpellBonusHealing is derived instead.)
OFF_PLAYER_FIELD_MOD_DAMAGE_DONE_POS = 0xFD4,
OFF_PLAYER_FIELD_MOD_DAMAGE_DONE_NEG = 0xFF0,
// Reusable "is this spell record a user-visible aura" predicate.
// `__fastcall(spellRecord*) -> bool`. Hides a spell whose Attributes
// has bit 7 (the high bit of the byte at +0x18), whose AttributesEx
// has 0x10000000, or any of whose three EffectApplyAuraName values
// (+0x16C..+0x174) is a tracking aura (0x2C, 0x2D, 0x97). A spell with
// a nonzero aura-vision requirement at +0x2B0 shows only when bit
// (vision - 1) of the active player's `[player+0xE68]+0x10C1` byte is
// set (verified by decompile; benilla-re ui/auradisplay). Both
// `Script_UnitBuff` and `Script_UnitDebuff` call it to filter their
// aura iteration; we call it the same way.
FUN_SPELL_IS_VISIBLE_AURA = 0x00519860,
// The two tests behind UnitBuff/UnitDebuff's third (raid filter)
// argument, both `__fastcall -> uint` (verified by decompile of
// `Script_UnitDebuff` 0x005198F0 and benilla-re ui/auradisplay):
// CASTABLE_AURA(spellID): the player knows the spell (known-spell
// bitmap, else the pet spellbook) and its record has
// AttributesEx3 (+0x24) 0x4000 clear, effect 0's implicit target A
// (+0x148) not 1 (self),
// and no effect 0x1B/0x23/0x77/0x80/0x81 — "a buff you can cast on
// others". UnitBuff passes the aura's spell ID.
// DISPEL_TYPE_KNOWN(dispelType): the dispel type is in the player's
// dispel list. UnitDebuff passes the aura's Spell.dbc Dispel
// (`OFF_SPELL_DISPEL_TYPE`), not a spell ID.
FUN_SPELL_IS_CASTABLE_AURA = 0x004B3870,
FUN_DISPEL_TYPE_KNOWN = 0x004B3920,
// The TOOLTIP variant of the gate: what `Script_GameTooltip_SetUnitBuff`
// (0x00534AC0) / `SetUnitDebuff` (0x00534E30) apply per slot while
// turning a Lua index into a slot. `__fastcall(spellRecord) -> bool`:
// Attributes & 0x80 (HIDDEN_CLIENTSIDE) clear, AttributesEx & 0x10000000
// (NO_AURA_ICON) clear, and no EffectApplyAuraName in {44, 45, 151}
// (the tracking auras). Verified by decompile; differs from the UnitBuff
// gate above, so an index into one space is not an index into the other
// — `GameTooltip:SetUnitAura` counts with THIS one when it translates.
FUN_GAMETOOLTIP_AURA_VISIBLE = 0x00534DF0,
// Player-only aura timing tables. Unlike UNIT_FIELD_AURA (which is
// populated for any unit but has no timing info), these are the
// local player's own buffs/debuffs with full duration data — the
// server broadcasts cast/duration only for the player's own auras.
//
// VAR_PLAYER_BUFF_TABLE: 48-entry array, 16 bytes each, packed from
// the front in insertion order (a record's position is NOT its slot).
// Filled by `FUN_004E44B0` from the descriptor (verified by decompile):
// +0x00 (int) slotCode: -1 = empty, else the absolute aura slot
// 0..47. Doubles as the index into the expiration table.
// +0x04 (int) spellID.
// +0x08 (byte) caster level (UNIT_FIELD_AURALEVELS).
// +0x09 (byte) stack count (applications byte + 1).
// +0x0A (byte) the slot's flag nibble; bit 0x1 = cancelable.
// +0x0C (int) until-cancelled: 1 when the spell has no finite
// duration (missing SpellDuration row, or base < 0 and
// per-level <= 0), or when the nibble lacks the
// cancelable bit and an effect is 0x23/0x77/0x80/0x81.
// `GameTooltip:SetPlayerBuff` (0x00532B00) skips the
// time-left line when it is set, and `GetPlayerBuff`
// returns it as its second result.
//
// VAR_PLAYER_BUFF_EXPIRATION_TABLE: `uint32[48]` of absolute
// expiration timestamps in ms, indexed by SLOT (not record position).
// Same epoch as `FUN_OS_TICKCOUNT_MS` and Lua's `GetTime()` (which
// multiplies tickcount by 0.001). Written only by the duration packet
// handler `FUN_004E4390` (SMSG 0x137: slot, ms) and zeroed only at
// interface setup, so a slot KEEPS its last expiry after its aura ends
// (benilla-re ui/auradisplay#the-duration-packet): an aura that never
// gets a duration reads the previous occupant's. The until-cancelled
// flag above is what tells those apart.
//
// `FUN_004E4450(position)` does the `expirationTable[slotCode] -
// currentMs` math (0 once elapsed) for `GetPlayerBuffTimeLeft`.
VAR_PLAYER_BUFF_TABLE = 0x00BC6040,
VAR_PLAYER_BUFF_EXPIRATION_TABLE = 0x00BC5F68,
PLAYER_BUFF_TABLE_COUNT = 48,
PLAYER_BUFF_ENTRY_STRIDE = 16,
OFF_PLAYER_BUFF_SLOT_CODE = 0x00,
OFF_PLAYER_BUFF_SPELL_ID = 0x04,
OFF_PLAYER_BUFF_UNTIL_CANCELLED = 0x0C,
// CMSG_CANCEL_AURA sender — `__fastcall(int spellID)`. Builds an
// opcode-0x136 packet (`{opcode=0x136, spellID}`) and ships it.
// Used directly by `CancelSpellByID` / `CancelSpellByName` to
// skip `Script_CancelPlayerBuff`'s client-side gates (the
// per-entry cancelable flag at `[+0x0A]` and the fallback
// AttributesEx `0x04` check) and let the server be the source
// of truth for what's cancelable.
//
// **Crash hazard**: bounds-checks `spellID` against Spell.dbc
// count and sets the record pointer to NULL on OOR, then
// unconditionally dereferences `[record + 0x1C]`. Callers MUST
// pre-validate via `Spell::Lookup::RecordForID(spellID)` (which
// also catches empty record slots) before calling.
FUN_CANCEL_AURA_SEND = 0x006E7040,
// `GetTickCount`-style millisecond counter the engine uses as its
// time source. Same value Lua's `GetTime()` reads (scaled by
// 0.001 to seconds). `__fastcall void → uint32_t` (no args, ms
// tick count in EAX).
FUN_OS_TICKCOUNT_MS = 0x0042B790,
// OsGuiGetWindow — `HWND __fastcall(int which)`: 0 returns the game
// window, 1 `GetActiveWindow()`, 2 `GetForegroundWindow()`, anything
// else null. (benilla-re core/input "Message filter and idle sleep",
// verified.) Confirmed against C:\WoW\Octo\WoW.exe: `sub ecx,0 /
// je game-window / dec ecx / je jmp [GetActiveWindow] / dec ecx /
// je jmp [GetForegroundWindow] / xor eax; ret`, with the game window
// read from `[0x00884EA0]` — exactly 32 bytes, matching the symbol size.
FUN_OS_GUI_GET_WINDOW = 0x00435C30,
// Effective cast time (ms) for a spell, fully resolved:
// `__fastcall int32_t(int spellID, int pet /*0 = local player, 1 = pet*/,
// int allowNegative /*0 = clamp negatives to 0*/)`. Computes
// SpellCastTimes base + level scaling, applies the cast-time
// SpellMod (op 10, via FUN_006e6af0), then multiplies by the
// caster's cast-speed/haste mod (descriptor +0x22c). This is the
// exact helper the engine's own cast-start path (FUN_006ec910)
// uses for the cast-bar end time, so reading it keeps our
// UnitCastingInfo end time in lockstep with the engine. 0 for
// instant / no-cast-time spells.
FUN_GET_CAST_TIME = 0x006E3340,
// Effective power cost (mana/rage/energy/…) for a spell:
// `__fastcall uint32_t(int spellID, int pet /*0 = local player, 1 = pet*/)`.
// Computes ManaCost base + per-level + ManaCostPercent-of-resource,
// applies the descriptor power-cost modifiers, then the cost
// SpellMod (op 0xE / 14). 0xFFFFFFFF on invalid input / no player.
// Read by C_Spell.GetSpellPowerCost (the full helper, like the cast
// time one — beats replicating op 14 via Spell::Mod since it also
// folds in the descriptor cost mods).
FUN_GET_SPELL_COST = 0x006E31B0,
// Power per second of a channel/funnel: `__fastcall int32_t(int spellID,
// int pet)` → `(L − baseLevel)·ManaPerSecondPerLevel + ManaPerSecond`,
// no modifier; −1 without a record (benilla-re spell/records#power-cost).
// 4.3.4 `GetSpellInfo` reports this instead of the cost (with
// isFunnel = true) when it is positive.
FUN_GET_SPELL_POWER_PER_SECOND = 0x006E3300,
// Divisor that turns a stored power amount into its displayed units:
// `__fastcall uint32_t(int powerType)` → `[0x0086F978 + 4·type]`, 1 for a
// negative type. Table {1, 10, 1, 1, 1000} — rage is stored in tenths
// (Heroic Strike's 15 rage is 150 in Spell.dbc). Verified by disassembly;
// same table as 3.3.5's `s_powerDisplayMod`.
FUN_GET_POWER_DISPLAY_DIVISOR = 0x006E7130,
// The engine's spell-castability verdict for the LOCAL player — the
// function behind `IsUsableAction` for a player spell slot (the spell
// branch of the per-slot recompute `FUN_004E5050`) and behind the
// spellbook grey-out recompute (`FUN_004B31C0`, which fires
// SPELL_UPDATE_USABLE):
// `char __fastcall(const uint8_t *spellRecord /*ecx*/,
// int *outNoMana /*edx*/)`.
// Resolves the player internally (no unit arg). Verified check order
// (decompiled): Effect[0] == ATTACK → always usable; dead / ghost unless
// CASTABLE_WHILE_DEAD (0x800000); the player-control flag
// (`DAT_00B4B3E4`, toggled with PLAYER_CONTROL_LOST / _GAINED) — with
// control lost only spells usable while fleeing / confused / charmed
// pass; totems + reagents in bags (`FUN_006E4000`); equipped-item
// class / subclass, main-hand / off-hand and ammo (`FUN_006E40E0`);
// combo points for finishers (AttributesEx 0x500000); Stances /
// StancesNot against the shapeshift byte (`FUN_00612480`, the
// Battle-Stance-Whirlwind case); ONLY_STEALTHED (0x20000);
// CANT_USED_IN_COMBAT (0x10000000); CasterAuraState; TargetAuraState
// (+ can-attack / can-assist on the current target); DISABLED_WHILE_
// ACTIVE (0x2000000) while the spell is active; and LAST
// `cost(FUN_GET_SPELL_COST) <= currentPower` (PowerType -2 = health) —
// the ONLY branch that sets `*outNoMana = 1`. Returns nonzero (low
// byte) when usable. Does NOT check cooldown, spell knowledge, silence
// or school lockouts — a knowledge gate belongs in the caller, and it's
// valid to feed an item's on-use spell record (which the player never
// "knows"). Read by `Spell::Usable` (IsUsableSpell) and `Item::Usable`
// (item on-use spells). Returns 0 cleanly pre-world (no player).
FUN_SPELL_IS_USABLE = 0x006E3D60,
// The player-control flag: nonzero while the player controls the
// character, cleared with PLAYER_CONTROL_LOST (fear, charm, taxi).
// FUN_SPELL_IS_USABLE reads it for spells; the action bar's per-slot
// usable recompute (FUN_004E5050) reads it for a slot with no spell, so
// an item with no on-use spell is usable only with control (benilla-re
// ui/actionbar#slots-with-no-spell).
VAR_PLAYER_HAS_CONTROL = 0x00B4B3E4,
// IsItemSpellHeld — `uint32_t __fastcall(int itemID)`: nonzero when the
// spell history holds a disabled-while-active record for the item's
// first on-use spell (a spell marked disabled while active, whose
// cooldown waits for its effect to end).
// Looks the record up with a callback, so call it only for a cached item
// or it queries. The action bar's item gate (FUN_004E5050, 0x004E50D7);
// 4.3.4's Spell_C_NeedsCooldownEvent. Verified by decompile (benilla-re
// spell/cooldowns#held-records).
FUN_ITEM_SPELL_HELD = 0x006E2FC0,
// CheckCasterStateForSpell — the cast request's last refusal check:
// `char __fastcall(void *caster /*ecx*/, int /*edx unused*/,
// const uint8_t *spellRecord, void *item)`, ret 8;
// 1 = every rung passed. A refusal reports through FUN_006E1A00 and
// returns 0, so nothing is sent. Its one caller is the cast request
// (FUN_006E4B60) at CALL_TRY_CAST_CHECK_CASTER_STATE (benilla-re
// spell/castgates; xrefs confirm the single call).
FUN_CHECK_CASTER_STATE_FOR_SPELL = 0x006094F0,
CALL_TRY_CAST_CHECK_CASTER_STATE = 0x006E4F3B,
// The cast request's (FUN_006E4B60) two reads of its target GUID, the
// argument halves at [ebx+0xC] / [ebx+0x10] (Ghidra):
// CheckSpellTargetRange — `uint8_t __fastcall(void *caster, const
// uint8_t *record, uint64_t guid, uint8_t report)`, ret 0xC. A zero
// GUID takes the selection. Range-checks only a unit the spell's target
// word admits (attackable for 0x80, assistable for 0x100 / party 0x8 /
// raid 0x4, ...), refusing out of range (0x59) or too close (0x76);
// anything else passes. Called with report 1.
// The targeting arm (Spell_C_TargetSpell) — `uint8_t __fastcall(void
// *caster, const uint8_t *record, uint64_t guid)`, ret 8. Binds the
// main-hand item (Attributes 0x200), else the GUID, else the selection;
// with none bound, the player when autoSelfCast is on; a zero target
// word sends at once. 0 = nothing bound: the request then refuses
// (word 0x80: 0x0A / 0x09) or raises the targeting cursor.
FUN_CHECK_SPELL_TARGET_RANGE = 0x006E4440,
CALL_CAST_CHECK_TARGET_RANGE = 0x006E4F26,
FUN_SPELL_TARGET_ARM = 0x006E5250,
CALL_CAST_TARGET_ARM = 0x006E5038,
// GetSpellHostility — `int __thiscall(const uint8_t *record)`: 2 harmful,
// 1 helpful, 0 neither, from the Targets word and the implicit targets
// (benilla-re spell/handlers#hostility-classifier).
FUN_SPELL_HOSTILITY = 0x006EA280,
// Inside it: the mounted rung's `mov edx,[ecx+0x1FC]` (8B 91 FC 01 00
// 00, then `test edx,edx; jle pass`; refuses 0x39) and the stand rung's
// `call [edx+0xA4]` (FF 92 A4 00 00 00, GetStandState, then `test
// eax,eax; jz pass`; refuses 0x3E). Both 6 bytes; EDI = caster at both.
SITE_CASTER_STATE_MOUNT_READ = 0x00609C7C,
SITE_CASTER_STATE_STAND_CALL = 0x00609CAD,
// CheckSpellShapeshiftForm — `char __thiscall(void *unit,
// const uint8_t *spellRecord, int *outReason)`, ret 8. Refuses with
// SPELL_FAILED_NOT_SHAPESHIFT when StancesNot (+0x30) covers the form,
// or the unit is shapeshifted and Attributes has 0x10000; with
// SPELL_FAILED_ONLY_SHAPESHIFT when Stances (+0x2C) misses it
// (decompiled). Called from the caster-state check and from
// FUN_SPELL_IS_USABLE only (xrefs).
FUN_CHECK_SPELL_SHAPESHIFT_FORM = 0x00612480,
CALL_CASTER_STATE_SHAPESHIFT_FORM = 0x00609E50,
CALL_SPELL_USABLE_SHAPESHIFT_FORM = 0x006E3EBF,
// Vanilla SpellCastResult codes (vmangos SpellDefines.h order, matching
// the rung reasons above).
SPELL_FAILED_NOT_SHAPESHIFT = 0x3D,
SPELL_FAILED_ONLY_SHAPESHIFT = 0x56,
// CGPlayer_C::SendStandStateChange — `void __thiscall(void *player,
// uint32_t state)`, ret 4. Sends CMSG_STANDSTATECHANGE and applies the
// state locally; a no-op while mounted, on a taxi, dead, channeling or
// moving (benilla-re objectlayer/standstate#the-sit-gate).
FUN_PLAYER_SEND_STAND_STATE = 0x005ED430,
// Effective spell/channel duration (ms):
// `__fastcall int(const void *spellRecord, int pet /*0 = player,
// nonzero = pet*/, int skipMod /*0 = apply mods*/)`. Verified by
// disassembly: `d = (L − BaseLevel)·perLevel + base`, replaced by the
// row's max once `d >= max` (no `max > 0` guard, no floor on the level
// term), then the duration SpellMod (op 1) unless skipMod. `L` is
// `FUN_SPELL_CASTER_LEVEL`'s — the player's or pet's level capped at the
// spell's MaxLevel. The "infinite" rows (base −1, max −1) come back −1.
// Same `pet` selector as the cast-time/cost helpers.
// Used for UnitChannelInfo's channel end time. Note: takes the spell
// RECORD pointer, not a spellID.
FUN_GET_SPELL_DURATION = 0x006EA000,
// Pure spell range check against a target:
// `char __fastcall(void *caster /*ecx*/, void *target /*edx*/,
// int spellID, char *outMinMaxFlag)`.
// Computes the spell's min/max range via `FUN_006e3480` (which folds
// in the target's bounding radius), reads both objects' world
// positions (GetPosition, vtable+0x14), and compares center-to-center
// squared distance. Returns low byte 1 = in range, 0 = out (too close
// OR too far); `*outMinMaxFlag` is set to 1 on a max-range (too far)
// failure so the caller can pick a "too close" vs "out of range" error
// string — we ignore it. Both objects must be non-null (it dereferences
// the GetPosition result without a null check). This is the geometric
// core the action-button range coloring uses: `Script_IsActionInRange`
// (`0x004E7550`) → `FUN_004E56F0` → `FUN_006E4440` → here. We call it
// directly for `C_Spell.IsSpellInRange` rather than `FUN_006E4440`,
// which additionally gates on target type and folds "range N/A" into
// the same truthy return as "in range" (so it can't yield true/false/
// nil cleanly).
FUN_SPELL_RANGE_CHECK = 0x006E47B0,
// Spell min/max range resolver: `void __fastcall(void *caster /*ecx*/,
// uint32_t spellID /*edx*/, float *minRange, float *maxRange,
// void *target)`. Zeroes both and returns for a null caster or an
// unknown spell; forces `max = 100.0` (`DAT_008118d4`) for
// `Attributes & 0x404` without reading any range row; otherwise folds
// the `SpellRange.dbc` row with both units' combat reach, the
// stationary +8/3 bonus, the slot-17 ranged-item scale, and the op-5
// spell modifier. Null-safe on the caster (unlike
// `FUN_SPELL_RANGE_CHECK`, which needs both positions readable). This
// is what `FUN_SPELL_RANGE_CHECK` calls for its window, and what
// `ActionHasRange` (`0x4E75D0`) gates on.
FUN_GET_MIN_MAX_RANGE = 0x006E3480,
// Near-zero range epsilon `ActionHasRange` (`0x4E75D0`) compares
// against: `|min|`/`|max|` below this counts as rangeless, while a NaN
// counts as ranged (`fcomp` then `test ah,5; jp` at `0x4E5885`
// passes unordered). Verified by a direct float dump of the image:
// exactly 2^-22 (0x34800000) at this address. Read live, not hardcoded.
VAR_HAS_RANGE_EPSILON = 0x008029D4,
// The two floats `FUN_006e3480`'s COMBAT-RANGE branch folds into its
// max-range output: `casterReach + targetReach + LEEWAY`, floored at
// MIN. Verified by a direct float dump of the image (1.33333 / 5.0);
// these are the same constants tortoise-wow's server uses for the
// identical formula (`BASE_MELEERANGE_OFFSET = 1.33f`,
// `ATTACK_DISTANCE = 5.0f`, `Unit::GetCombatReach`/
// `Unit::CanReachWithMeleeAutoAttackAtPosition`). Read live (not
// hardcoded) by `Combat::SwingRange`'s DEDICATED melee range check —
// see that module for why it can't reuse `FUN_SPELL_RANGE_CHECK`
// above: that core (and every other consumer of `FUN_006e3480`, e.g.
// the action-bar range glow) computes full 3D distance, but the
// SERVER'S actual melee-attack gate
// (`WorldObject::CanReachWithMeleeSpellAttack`,
// `Unit::CanReachWithMeleeAutoAttackAtPosition`) is explicitly 2D
// (X/Y only) — the tortoise-wow source even comments "melee spells
// ignore Z-axis checks". Any Z offset between the two units makes the
// client's blended 3D check reject a swing the server already allows
// (verified in-game: rejected at 5.08yd 3D distance from center while
// landing hits — the standing engine mechanism for the GENERIC
// spell-range check was simply never asked to gate a real auto-attack
// decision before this feature existed, so there's nothing "engine
// native" to mirror for that exact semantic; mirroring the SERVER'S
// formula with the engine's own live constants is the closest fit).
VAR_MELEE_REACH_LEEWAY = 0x0080B058,
VAR_MELEE_REACH_MIN = 0x0080A1E8,
// Pure attackability test: `bool __thiscall(void *attacker /*ecx*/,
// void *target /*one stack arg, callee pops it — RET 0x4*/)`.
// `Script_UnitCanAttack` (`0x00516C50`) is a thin Lua wrapper over
// exactly this call; `FUN_006e4440` (the melee swing resolver) consults
// the same helper before a white hit lands. NOT `__fastcall` — verified
// by disassembly (`MOV ESI,[EBP+8]` reads the second unit off the
// stack; `MOV EDI,ECX` takes the first off ECX; both `RET`s pop 4
// bytes). Ghidra's decompile of the one caller renders the call as
// plain `FUN_00606980(this,pvVar4)`, which reads as fastcall(ecx,edx)
// but isn't — trust the disassembly's prologue over that pseudocode
// (same trap `FUN_SET_CVAR_VALUE` bit us with). Declaring this
// `__fastcall` sends the second arg through EDX, which the callee never
// reads, so it dereferences whatever garbage sits at `[ebp+8]` instead
// — crashed in-game (ERROR #132, `[ecx+0xA0]` off a bogus `ecx=4`).
//
// No position/range check — purely faction/state (hostility, PvP flags,
// stealth-detection-independent attackability). Used by `Combat::SwingRange`
// to gate the "can I even attack the current target" case Blizzard's
// `IsTargetWithinSwingRange` reports as a nil (no-check) answer.
FUN_UNIT_CAN_ATTACK = 0x00606980,
// `SMSG_SPELL_GO` inner handler — `void __fastcall(uint64_t *itemGUID,
// uint64_t *casterGUID, uint32_t spellId, CDataStore *packet)`. The
// engine has already decoded item/caster/spell into args; the packet
// read cursor sits at the post-header body (castFlags, hit/missed
// target lists, target mask). This is the ONLY place the client sees
// an aura's *caster* — the unit aura array stores spell IDs but never
// who applied them. `Aura::Source` co-hooks this (alongside nampower,
// which detours the same function) to cache `(targetGuid, spellId) →
// casterGuid` for `C_UnitAuras` sourceUnit + non-player expiration.
// Packet layout mirrored from nampower's SpellGoHook (verified on the
// same Octo/Turtle 1.12.1 client). Per-cast frequency, not per-frame.
FUN_SPELL_GO = 0x006E7A70,
// SMSG packet handler that processes `SMSG_SPELL_START` (opcode
// `0x131`) among others — `int __fastcall(uint32_t unk, uint32_t
// opCode, uint32_t unk2, CDataStore *packet)`. For `0x131` the body is
// `itemGuid(packed), casterGuid(packed), spellId(u32), castFlags(u16),
// castTime(u32), targetMask, …`. This is the only place the client sees
// *another* unit's cast with a server-authoritative cast time, so
// `Spell::Cast` co-hooks it (gated on `opCode == 0x131`) to back
// remote-unit `UnitCastingInfo` / `UnitChannelInfo`. Mirrored from
// nampower's SpellStartHandlerHook.
FUN_SPELL_START_HANDLER = 0x006E7640,
// `SMSG_SPELL_DELAYED` handler — `int __stdcall(uint32_t *opCode,
// CDataStore *packet)`. Body: `guid(u64), delayMs(u32)`. The server
// only sends this to the affected caster — empirically confirmed on
// Turtle (melee-pushback test: only the victim's client received it) —
// so remote units' pushback is NOT recoverable client-side; only the
// local player's cast pushback is trackable. `Spell::Cast` co-hooks it
// to extend the tracked cast's end time so the bar reflects pushback.
// Mirrored from nampower's SpellDelayedHook.
FUN_SPELL_DELAYED = 0x006E74F0,
// `MSG_CHANNEL_START` handler — `int __stdcall(uint32_t *opCode,
// CDataStore *packet)`. Body: `spellId(u32), durationMs(u32)`. Sent
// only to the caster when their channel begins, with the server-
// authoritative duration. `Spell::Cast` co-hooks it to stamp the
// player's channel — required for cast-then-channel spells (Mind
// Control: 3 s cast then 60 s channel), whose SMSG_SPELL_START only
// covers the cast phase. Address + layout mirrored from nampower's
// SpellChannelStartHandlerHook (they hook it too — accepted co-hook
// collision, per-channel-start frequency).
FUN_SPELL_CHANNEL_START = 0x006E7550,
// `MSG_CHANNEL_UPDATE` handler (`FUN_006e75f0`) — same `int __stdcall(
// uint32_t *opCode, CDataStore *packet)` shape. Body: a single u32 =
// the channel's new REMAINING time (ms). Sent to the caster on damage
// pushback (which shortens a vanilla channel) and once more at the
// channel's end (remaining == 0). Verified at 0x006e75f0: reads the u32,
// then fires vanilla's `SPELLCAST_CHANNEL_UPDATE(remaining)` (event
// 0x157) on pushback or `SPELLCAST_CHANNEL_STOP` (0x158) at end — but
// stores the new end NOWHERE, so `Spell::Cast`'s g_channel.endMs
// (computed once at start) never reflects pushback. Co-hooked to
// re-anchor endMs (and fire UNIT_SPELLCAST_CHANNEL_UPDATE). nampower
// hooks it too (SpellChannelUpdateHandlerHook — accepted co-hook, per-
// pushback frequency, same as the START sibling).
FUN_SPELL_CHANNEL_UPDATE = 0x006E75F0,
// `SMSG_SPELL_FAILED_OTHER` handler — `int __stdcall(uint32_t *opCode,
// CDataStore *packet)`, same shape as FUN_SPELL_DELAYED. Body:
// `casterGuid(u64, plain), spellId(u32)`. In (v)mangos cores this is
// broadcast to observers when a started cast aborts (interrupt, death,
// movement, fizzle) — but Turtle's core does NOT send it (verified
// in-game: interrupts arrive with neither this nor SMSG_SPELL_FAILURE;
// observers learn of the abort via SuperWoW instead — see
// FUN_UNIT_CLEAR_CASTING_SPELL). `Spell::Cast` co-hooks it anyway as a
// backstop for servers that do send it, invalidating the matching
// remote-cast cache entry (and the player's own server-stamped chained
// recast). Address + packet layout mirrored from nampower's
// SpellFailedOtherHandlerHook.
FUN_SPELL_FAILED_OTHER = 0x006E8E40,
// `SMSG_SPELL_FAILURE` handler — same `int __stdcall(uint32_t *opCode,
// CDataStore *packet)` shape. Body: `casterGuid(u64, plain),
// spellId(u32), result(u8)` — a superset of FAILED_OTHER's with a
// trailing result byte. Decompiled at 0x006E8D80: resolves the caster
// unit (FUN_00468460 typemask 8) and stops its cast visual via the SAME
// unit methods FAILED_OTHER's handler calls (FUN_0060d040 +
// FUN_00614150), plus extra channel/visual cleanup. Servers derived
// from (v)mangos broadcast BOTH packets from Spell::SendInterrupted,
// but which one a given core actually emits per abort path varies —
// `Spell::Cast` co-hooks this one alongside FAILED_OTHER so a remote
// interrupt evicts the cast cache regardless of which sibling arrives.
// nampower calls this SpellFailedHandler (offsets.hpp) but doesn't
// hook it.
FUN_SPELL_FAILURE = 0x006E8D80,
// `Spell_C_SpellFailed` — the CLIENT-side cast-failure entry, distinct
// from the two SMSG_SPELL_FAILURE/_OTHER packet handlers above. Fires
// for the local player's own cast rejections (out of range, no mana,
// "spell not ready", LoS, interrupted, …). `__fastcall(uint32_t
// spellId, uint8_t spellResult /*edx*/, int unk1, int unk2, bool
// failedByServer)` — signature per nampower's Spell_C_SpellFailedT.
// Backs `UNIT_SPELLCAST_FAILED` (`Spell::CastEvents`). Not hooked
// elsewhere in this project (we hook the packet handlers, not this).
FUN_SPELL_C_SPELL_FAILED = 0x006E1A00,
// `Spell_C_SpellFailed` result code for a fake/suppressed failure
// (Unleashed Potential and similar) — the engine's SPELL_FAILED_DONT_
// REPORT. nampower filters it out of its failure event; so do we.
SPELL_FAILED_DONT_REPORT = 23,
// `CGUnit_C::ClearCastingSpell` — `__thiscall void(CGUnit *unit,
// int spellID, char notify, char cleanup)` (nampower names the offset
// but never hooks it). THE engine choke point for "this unit stopped
// casting": gated on `spellID == [unit+0xC8C]` (the unit's live
// current-cast spellID, set by SMSG_SPELL_START processing), it zeros
// that field and clears the casting flag (bit 0x400 at [unit+0xD58]).
// Ten callers converge here: both failure-packet handlers, the
// SPELL_GO handler (natural completion), the movement handler
// (0x006018f0 — moving units aren't casting), the health-diff handler
// (0x006046f0, death), the unit animation-event dispatcher
// (0x0060e0a0), the local cancel path (0x006e7040, sends
// CMSG_CANCEL_CAST), and Spell_C_SpellFailed. Hooking THIS instead of
// individual packets makes remote-cast eviction independent of which
// packet the server actually sends — load-bearing on Turtle, whose
// core does NOT broadcast SMSG_SPELL_FAILURE / SMSG_SPELL_FAILED_OTHER
// on interrupt (verified: neither handler fires while the victim's
// cast visual demonstrably stops).
FUN_UNIT_CLEAR_CASTING_SPELL = 0x0060D040,
// CGUnit field: the unit's current-cast spellID (0 = not casting).
// The regular-cast analog of OFF_UNIT_FIELD_CHANNEL_SPELL — but a
// plain CGUnit member, NOT a descriptor UpdateField (client-derived
// from SMSG_SPELL_START, not server-broadcast state).
OFF_UNIT_CAST_SPELL = 0xC8C,
// CGUnit field: the unit's sheath state as a plain int member (NOT a
// descriptor UpdateField). 0 = sheathed / no weapon shown, 1 = melee
// weapon drawn, 2 = ranged weapon drawn. Read and written by the engine's
// own sheath toggler `FUN_005EB480` (behind `ToggleSheath`) and its setter
// `FUN_00611CF0` (`*(this+0xD40) = newState`, saving the prior state to
// `+0xD3C`). `Unit::Sheath::GetSheathState` reads the local player's value
// and returns it 1-based (Lua's GetSheathState is 1=None/2=Melee/3=Ranged).
OFF_UNIT_SHEATH_STATE = 0xD40,
// NetClient message dispatch — `__thiscall void(void *conn, uint32_t
// arg, CDataStore *packet)`. Reads the u16 opcode off the packet
// cursor, then invokes `[conn + opcode*4 + 0x74]` (the handler table
// FUN_005ab650 / FUN_00537a60 register into; per-handler userParam
// parallel table at +0xD64). EVERY server message the client processes
// funnels through here (the raw-ingress sibling at 0x00537B10 only
// special-cases 0x1DD compressed-moves before queueing into this).
// Useful as a temporary whole-protocol sniff point: co-hook, peek the
// u16 at the cursor, restore, log. `Net::PacketDispatch` co-hooks it as
// the single fan-out point for incoming-packet subscribers — the
// collision-avoiding alternative to each feature MinHook-ing its
// per-opcode SMSG handler (which nampower/SuperWoW also hook). nampower
// does NOT hook this funnel (it detours the per-opcode handlers), so
// moving our parsing here removes those shared prologues.
FUN_NET_MESSAGE_DISPATCH = 0x00537AA0,
// Incoming spell-subsystem SMSG opcodes — the u16 message ids the engine
// dispatch table (see FUN_006e7150) maps to per-opcode handlers. Used by
// the `Net::PacketDispatch` subscribers that replaced the per-handler
// co-hooks. Verified from the registrar: 0x131/0x132 both route to
// FUN_006E7640 (it branches on the opcode; the 0x132 path decodes and
// calls the SpellGo builder FUN_006E7A70).
SMSG_SPELL_START = 0x131,
SMSG_SPELL_GO = 0x132,
SMSG_SPELL_FAILURE = 0x133,
SMSG_SPELL_COOLDOWN = 0x134,
SMSG_SPELL_CHANNEL_START = 0x139,
SMSG_SPELL_CHANNEL_UPDATE = 0x13A,
SMSG_SPELL_DELAYED = 0x1E2,
SMSG_SPELL_FAILED_OTHER = 0x2A6,
// Melee swing result broadcast. Body (verified against the server's own
// writer, tortoise-wow Unit::SendAttackStateUpdate): u32 hitInfo,
// packedGuid attacker, packedGuid victim, u32 totalDamage, u8 subCount,
// per-sub {u32 school, f32 coeff, u32 damage, u32 absorb, i32 resist},
// u32 targetState, u32, u32 spellId, u32 blocked. `Aura::JudgementRefresh`
// reads through totalDamage.
SMSG_ATTACKERSTATEUPDATE = 0x14A,
// hitInfo bit 2 — the swing came from the OFF hand, not main hand
// (tortoise-wow `HITINFO_LEFTSWING`; `Unit::AttackerStateUpdate` sets
// `HITINFO_NORMALSWING`(0) for `BASE_ATTACK`, this for `OFF_ATTACK`).
// Read by `Combat::Swing` to pick which hand a white-hit packet resets.
HITINFO_LEFTSWING = 0x4,
// `SMSG_ATTACKERSTATEUPDATE`'s `targetState` field, value 3 — the swing
// was parried. `Unit::AttackerStateUpdate`'s parry-haste block (server)
// shortens the PARRYING unit's own next-swing timer by a fixed formula
// when this fires with `victim == local player`; `Combat::Swing` mirrors
// it (tortoise-wow `VictimState::VICTIMSTATE_PARRY`).
VICTIMSTATE_PARRY = 3,
// Attack-start broadcast — sent when a unit begins a *melee* auto-attack
// (`Unit::SendMeleeAttackStart`, called from `Unit::Attack`). Body:
// attackerGuid(u64), victimGuid(u64) — PLAIN 64-bit GUIDs, not packed
// (verified against the server's own writer: `ObjectGuid`'s `ByteBuffer`
// operator is a raw `buf << uint64(guid.GetRawValue())`, no pack-guid
// mask byte). `Unit::Attack` also unconditionally
// `ResetAttackTimer(OFF_ATTACK)`s here — the one
// off-hand reset that isn't itself a white-hit or a cast — so
// `Combat::Swing` treats this as an OffHand reset for the local player.
SMSG_ATTACKSTART = 0x143,
// An inventory move the server refused. Routed to the shared handler
// `FUN_005E38C0` (registered at `0x005E3039`), whose 0x112 case reads:
// u8 error (0 = no error, nothing follows); u32 required level only when
// error == 1; u64 item1; u64 item2; u8 bag. It shows the message itself
// (`FUN_00622630` maps the code to a game-message row, then
// `FUN_00496720`) and unlocks both items. `EquipmentSet::Pending` reads it
// to fail a set swap that touched either item.
SMSG_INVENTORY_CHANGE_FAILURE = 0x112,
// NetClient send — `__thiscall void(void *conn, CDataStore *packet)`.
// The outgoing counterpart of FUN_NET_MESSAGE_DISPATCH: every CMSG the
// client sends funnels through it (the argless wrapper `FUN_005AB630`,
// nampower's ClientServices_Send, resolves the connection singleton
// with the packet in ECX and calls this). The packet's leading u32 is
// the opcode; `m_size - m_read` is what goes on the wire.
// `Aura::ComboDuration` co-hooks it to snapshot combo points the
// moment CMSG_CAST_SPELL leaves — before the server consumes them —
// which also covers nampower-queued casts (they re-enter the engine's
// cast path and send normally, unlike a Spell_C_CastSpell co-hook,
// which nampower's trampoline re-entry would bypass).
FUN_NET_SEND = 0x005379A0,
// Outgoing opcode: CMSG_CAST_SPELL. Body: `spellId(u32),
// targetFlags(u16), <target per flags>`.
OP_CMSG_CAST_SPELL = 0x12E,
// Outgoing opcode: CMSG_SPLIT_ITEM, built by FUN_INVENTORY_SPLIT (body
// documented there): u8 srcBag, u8 srcSlot, u8 dstBag, u8 dstSlot,
// u8 count. The server answers a successful split with a NEW item
// object for the split-off half (tortoise-wow `Player::SplitItem` →
// `CloneItem`), or SMSG_INVENTORY_CHANGE_FAILURE.
OP_CMSG_SPLIT_ITEM = 0x10E,
// The bag byte the item packets use for the player's own inventory
// (paperdoll, backpack, bank main slots); any other bag byte is the
// player slot that holds the container (19..22 bags, 63..68 bank
// bags). Seen in FUN_INVENTORY_SWAP's `FUN_005e13b0` conversion.
INVENTORY_SLOT_BAG_0 = 0xFF,
// Spell.dbc DurationIndex (column 30) — row into SpellDuration.dbc.
// Offset = 30*4, consistent with the verified neighbors
// (CastingTimeIndex col 18 = +0x48, PowerType col 31 = +0x7C).
OFF_SPELL_RECORD_DURATION_INDEX = 0x78,
// SpellDuration.dbc — records/count slots per docs/DBCs.md (the
// engine's own reader `FUN_GET_SPELL_DURATION` bounds-checks the index
// against `[0x00C0D82C]` and loads `[0x00C0D828]`). Record:
// `{id@+0, baseMs@+4 (i32), perLevelMs@+8 (i32), maxMs@+0xC (i32)}`
// (`OFF_SPELLDURATION_*`). Base −1 is infinite — the only such row is
// 21 {−1, 0, −1}; the engine's until-cancelled test (`0x004E44B0`) is
// `base < 0 && perLevel < 1`. Row 427 (Resurrection Sickness) is
// {−600000, +60000/level, 600000}: the servers take `abs(base)`.
// Combo-point finishers are exactly the rows with base != max: the
// server computes `base + (max - base) * comboPoints / 5`
// ((v)mangos CalculateSpellDuration — verified against the DBC:
// Rupture 6000/16000 = 6+2*CP, Kidney Shot 1000/6000 = 1+1*CP,
// Slice and Dice 6000/21000 = 6+3*CP, Expose Armor 30000/30000 =
// fixed). NOTE: rows can dangle — Turtle's client DBC has no record
// for Rip's DurationIndex 87 (records[87] == NULL), which is why
// Rip reads duration 0 client-side there.
VAR_SPELL_DURATION_RECORDS = 0x00C0D828,
VAR_SPELL_DURATION_COUNT = 0x00C0D82C,
OFF_SPELLDURATION_BASE_MS = 0x04,
OFF_SPELLDURATION_PER_LEVEL_MS = 0x08,
OFF_SPELLDURATION_MAX_MS = 0x0C,
// Combo points, within the CGPlayer `+0xE68` sub-struct (see
// OFF_CGPLAYER_INFO). Verified from Script_GetComboPoints
// (0x0051A190): CP count byte at `[player+0xE68]+0x1029`, the combo
// TARGET's guid (u64) at `[player+0xE68]+0x838` (compared against
// the current-target global 0x00B4E2D8 before the Lua function
// reports a non-zero count).
OFF_CGPLAYER_COMBO_POINTS = 0x1029,
OFF_CGPLAYER_COMBO_TARGET = 0x838,
// ---- Frame-method registries beyond GameTooltip's ------------------
// Same per-type registry mechanism as VAR_GAMETOOLTIP_METHOD_REGISTRY
// (docs/BlizzardScriptAPI.md "Frame types & their methods" has the
// full 23-table catalogue). The dispatcher resolves methods through
// the type hierarchy, so a method added to the REGION base registry
// (the 19-entry core-layout table: GetWidth/SetPoint/…) is callable
// on every region type — frames, buttons, textures, fontstrings.
// `Frame::Modern` uses these to backport modern API (SetSize,
// SetShown, SetResizeBounds).
VAR_REGION_METHOD_REGISTRY = 0x00CF54B4,
VAR_FRAME_METHOD_REGISTRY = 0x00CF4D38,
VAR_TEXTURE_METHOD_REGISTRY = 0x00CF5434,
VAR_FONTSTRING_METHOD_REGISTRY = 0x00CF5400,
// Button — 39 methods (table 0x00879D00), ctx per docs/raw_methods.txt.
// CheckButton inherits it through the dispatcher's type walk. `Frame::
// ClickMask` re-registers `RegisterForClicks` here (most recent
// registration wins — the Texture::Desaturation mechanism) to add AnyUp /
// AnyDown in front of the engine's entry.
VAR_BUTTON_METHOD_REGISTRY = 0x00CF4E14,
// The engine's Button:SetTextFontObject / GetTextFontObject - entries 5
// and 6 of the Button method table 0x00879D00 (ctx VAR_BUTTON_METHOD_REGISTRY,
// docs/raw_methods.txt). Standard `int __fastcall(void *L)`. 3.0 renamed
// them SetNormalFontObject / GetNormalFontObject; Frame::Modern
// registers those names over them.
FUN_SCRIPT_BUTTON_SET_TEXT_FONT_OBJECT = 0x00780400,
FUN_SCRIPT_BUTTON_GET_TEXT_FONT_OBJECT = 0x007804C0,
// The engine's `Button:RegisterForClicks(...)` (Button table entry 35) —
// standard `int __fastcall(void *L)`. Loops `lua_isstring(L, i)` from
// index 2 until the first non-string, SStrCmpI's each against exactly ten
// literals (LeftButtonDown 0x1 / LeftButtonUp 0x100, Middle 0x2 / 0x200,
// Right 0x4 / 0x400, Button4 0x8 / 0x800, Button5 0x10 / 0x1000 — low
// byte = press, high byte = release), an unknown name contributing 0, and
// ASSIGNS the OR to button+0x330 via FUN_BUTTON_SET_CLICK_MASK. So a call
// with only unknown names (e.g. the modern "AnyUp") zeroes the mask and
// the button stops responding to every real click, silently — Button:Click
// ignores the mask, so programmatic clicks still work and hide it.
// `Frame::ClickMask` appends the five expansions of AnyUp / AnyDown to the
// Lua stack and tail-calls this, so the engine's parser, setter and error
// text stay in force.
FUN_SCRIPT_BUTTON_REGISTERFORCLICKS = 0x00782490,
// CSimpleButton's mouse handlers, Button vtable 0x0081C7F8 (ctor 0x00778733)
// slots +0x68 OnLayerMouseDown (0x00779210) / +0x6C OnLayerMouseUp
// (0x007792D0), each `__thiscall(button, CMouseEvent *)` over the base
// frame's (0x0076BF70 / 0x0076C040: drag, then OnMouseDown / OnMouseUp with
// the button name). Same logic as 4.3.4's, minus its `btn` argument (the
// virtual click that skips the hit test): a button not disabled clicks on
// press when the press bit of the mouse button is in OFF_BUTTON_CLICK_MASK
// and the cursor is in the hit rect, then goes pushed unless locked; on
// release, a pushed button clicks for the release bit (or double-clicks
// when OnDoubleClick is set and the last click is within 300 ms), then
// goes normal unless locked. VAR_BUTTON_IN_CLICK is set around the click.
OFF_BUTTON_STATE = 0x328, // 0 disabled, 1 normal, 2 pushed
OFF_BUTTON_STATE_LOCKED = 0x32C,
OFF_BUTTON_CLICK_MASK = 0x330, // press bits low byte, release bits << 8
OFF_BUTTON_LAST_CLICK_MS = 0x334,
BUTTON_STATE_DISABLED = 0,
BUTTON_STATE_NORMAL = 1,
BUTTON_STATE_PUSHED = 2,
// CSimpleButton::Enable — `void __thiscall(button, int enable)`, `ret 4`,
// vtable+0x90 of the four button-family vtables; Script Enable / Disable
// and the constructor reach it, and CheckButton's override 0x00785490
// calls it first. Like 4.3.4's, it returns at once when the state would
// not change (enable with OFF_BUTTON_STATE nonzero, disable with it 0).
FUN_BUTTON_ENABLE = 0x00779160,
// Button vmethod Enable(enable) — FUN_BUTTON_ENABLE, or CheckButton's
// override. Script Enable / Disable (0x0077FEF0 / 0x0077FFD0) call it
// through this slot with 1 / 0 (Ghidra).
VTBL_BUTTON_ENABLE = 0x90,
// Button vmethods: Click(mask, 0) — FUN_BUTTON_CLICK — DoubleClick(mask,
// 0) and SetButtonState(state, 0).
VTBL_BUTTON_CLICK = 0x94,
VTBL_BUTTON_DOUBLE_CLICK = 0x98,
VTBL_BUTTON_SET_STATE = 0x9C,
VAR_BUTTON_IN_CLICK = 0x00CF4DA0,
// The click vmethod's callers that know 3.3.5's `down`, each a 6-byte
// `FF 92 94 00 00 00` (call [edx+VTBL_BUTTON_CLICK]) with ECX = the button
// and EDX = its vtable (capstone): the press handler 0x00779210 (slot 26)
// clicks a down-registered button (down = 1), the release handler
// 0x007792D0 (slot 27) an up-registered one (down = 0), and Script_Click
// 0x007826C0 clicks from its four name branches with `(mask, 1)` —
// LeftButton, MiddleButton, RightButton-or-UNKNOWN, no name.
SITE_BUTTON_PRESS_CLICK = 0x00779285,
SITE_BUTTON_RELEASE_CLICK = 0x007793A9,
SITE_SCRIPT_CLICK_LEFT = 0x007827B6,
SITE_SCRIPT_CLICK_MIDDLE = 0x007827E2,
SITE_SCRIPT_CLICK_RIGHT = 0x00782811,
SITE_SCRIPT_CLICK_DEFAULT = 0x00782826,
BUTTON_DOUBLE_CLICK_MS = 300,
// Button::SetClickMask — __thiscall(button, mask): writes +0x330. The
// ctors call it with the type default (Button 0x100 = LeftButtonUp;
// hyperlink button 0x500). Reference only.
FUN_BUTTON_SET_CLICK_MASK = 0x00779730,
// EditBox — 48 methods (table 0x0087BB68), ctx per
// docs/BlizzardScriptAPI.md. Backs `EditBox:SetCursorPosition` /
// `GetCursorPosition` (`EditBox::Methods`), the modern cursor / focus /
// text-state methods vanilla's EditBox lacks.
VAR_EDITBOX_METHOD_REGISTRY = 0x00CF5378,
// Model frame — backs `Model:SetGlow` (`Model::Glow`). Registry ctx per
// docs/raw_methods.txt (table 0x00878948, 23 methods: SetModel/
// SetSequence/ReplaceIconTexture/…).
VAR_MODEL_METHOD_REGISTRY = 0x00CF0C8C,
// Model frame-script type id, lazily assigned by the engine on the first
// Model method call (`Script_SetModel` FUN_0076d950 prologue:
// `if (id == 0) id = ++counter`). Mirror the lazy-assign so a Model
// type-check works even before any stock Model method has run; the IsA
// check itself is the CFrameScriptObject vmethod at vtable+0x10, shared by
// every frame type.
VAR_MODEL_LUA_TYPE_ID = 0x00CF0C5C,
VAR_FRAMESCRIPT_TYPE_ID_COUNTER = 0x00CEEF6C,
// Frame-script type ids for the other classes we register methods on —
// same lazy-assign mechanism as VAR_MODEL_LUA_TYPE_ID, one id per CLASS
// shared by all of its methods (VAR_GAMETOOLTIP_LUA_TYPE_ID is read or
// written by ~45 functions in the GameTooltip method block).
//
// Each was read from the prologue of a method that can only belong to
// that class. That matters: a BASE-class method registered into several
// tables carries the base's id, so sampling `GetObjectType` or
// `GetDrawLayer` risks a gate that accepts unrelated types. Frame is from
// `Script_RegisterEvent` (FUN_00774A40) and Texture from
// `Script_SetDesaturated` (FUN_0079C1E0), both cross-checked against the
// first entry of their table; GameTooltip from
// `Script_GameTooltip_SetSpell` (FUN_00532D10). Pairs 1:1 with the
// VAR_*_METHOD_REGISTRY values above.
VAR_GAMETOOLTIP_LUA_TYPE_ID = 0x00C0D414,
VAR_FRAME_LUA_TYPE_ID = 0x00CF0C10,
// Button's (Button:RegisterForClicks reads it at 0x00782496).
VAR_BUTTON_LUA_TYPE_ID = 0x00CF4D88,
VAR_REGION_LUA_TYPE_ID = 0x00CF0C3C,
VAR_TEXTURE_LUA_TYPE_ID = 0x00CF4CDC,
VAR_FONTSTRING_LUA_TYPE_ID = 0x00CF2CCC,
VAR_EDITBOX_LUA_TYPE_ID = 0x00CF4DB4,
// Slider's (Script Slider:GetValue reads it at 0x007908C0); its method
// table 0x0087B260 registers into VAR_SLIDER_METHOD_REGISTRY.
VAR_SLIDER_LUA_TYPE_ID = 0x00CF4F48,
VAR_SLIDER_METHOD_REGISTRY = 0x00CF5208,
// CSimpleSlider::OnLayerMouseDown — `void __thiscall(slider, CMouseEvent
// *)`, `ret 4`, slot +0x68 of the Slider vtable 0x0081CF60 (its only
// reference): sets the drag bit 0x8 of +0x314, applies the press as a
// move (vtable +0x3C), then calls the base frame's FUN_FRAME_ON_MOUSE_DOWN.
// Unlike 4.3.4's (CSimpleSlider.cpp:317) it reads no disabled flag.
FUN_SLIDER_ON_MOUSE_DOWN = 0x00789CA0,
// CSimpleFrame::OnLayerMouseDown — `void __thiscall(frame, CMouseEvent *)`,
// `ret 4`: drag arming, then the OnMouseDown script with the button name.
FUN_FRAME_ON_MOUSE_DOWN = 0x0076BF70,
// StatusBar's (Script StatusBar:SetMinMaxValues reads it at 0x0078F4B6).
VAR_STATUSBAR_LUA_TYPE_ID = 0x00CF4E5C,
// The value block a Slider (vtable 0x0081CF60) and a StatusBar (0x0081CA68)
// share in shape: flags, then min, then the slider's span (max - min) or
// the bar's max, then the value. Read and written by both classes'
// SetMinMaxValues / SetValue below.
OFF_VALUE_FLAGS = 0x314,
OFF_VALUE_MIN = 0x318,
OFF_SLIDER_SPAN = 0x31C,
OFF_STATUSBAR_MAX = 0x31C,
OFF_VALUE_VALUE = 0x320,
VALUE_FLAG_RANGE_SET = 0x2,
VALUE_FLAG_VALUE_SET = 0x4,
// CSimpleSlider::SetMinMaxValues — `void __thiscall(slider, float min,
// float max)`, `ret 8`: stores min and max - min, ORs 0x3 into the flags,
// then with VALUE_FLAG_VALUE_SET calls FUN_SLIDER_SET_VALUE on the value.
// Called by Slider:SetMinMaxValues (0x00790874), LoadXML and SetValueStep.
FUN_SLIDER_SET_MIN_MAX_VALUES = 0x007898F0,
// CSimpleSlider::SetValue — `void __thiscall(slider, float)`, `ret 4`.
FUN_SLIDER_SET_VALUE = 0x00789930,
// CSimpleStatusBar::SetMinMaxValues — `void __thiscall(bar, float min,
// float max)`, `ret 8`: stores min (max when min > max) and max, ORs 0x3
// into the flags, then with VALUE_FLAG_VALUE_SET clears it and calls the
// bar's SetValue (vtable OFF_VMT_STATUSBAR_SET_VALUE) on the value. Called
// by StatusBar:SetMinMaxValues (0x0078F584), LoadXML and the unit-frame /
// nameplate health bars.
FUN_STATUSBAR_SET_MIN_MAX_VALUES = 0x00783270,
// CSimpleStatusBar::SetValue's vtable slot (0x007832D0), `void
// __thiscall(bar, float)`, as FUN_STATUSBAR_SET_MIN_MAX_VALUES calls it.
OFF_VMT_STATUSBAR_SET_VALUE = 0x90,
// The method hash StatusBar's 10 methods (table 0x0087B010) register into
// (RegisterStatusBarMethods 0x007900A0).
VAR_STATUSBAR_METHOD_REGISTRY = 0x00CF51CC,
// The bar texture (CSimpleTexture *) and the orientation (0 HORIZONTAL,
// 1 VERTICAL), as CSimpleStatusBar::OnFrameUpdate reads them.
OFF_STATUSBAR_BAR_TEXTURE = 0x324,
OFF_STATUSBAR_ORIENTATION = 0x328,
// Flags bit 0: the fill needs laying out. SetValue, SetMinMaxValues and
// FUN_STATUSBAR_INSTALL_BAR_TEXTURE set it; OnFrameUpdate clears it.
VALUE_FLAG_CHANGED = 0x1,
// CSimpleStatusBar::OnFrameUpdate — `void __thiscall(bar, float
// elapsed)`, `ret 4` (the decompile hides the argument), vtable slot 14:
// passes `elapsed` to FUN_FRAME_ON_UPDATE, then with VALUE_FLAG_CHANGED, a range, a
// value and a bar texture sets the texture's coordinates to {0, 0, 1,
// fill} (horizontal) or {0, 0, fill, 1} (vertical) through
// FUN_SIMPLETEXTURE_SET_TEXCOORD and clears the bit. The texture's
// OFF_REGION_TEXCOORD_MODIFIES_RECT crop draws the filled part.
FUN_STATUSBAR_ON_FRAME_UPDATE = 0x007833C0,
// CSimpleStatusBar::InstallBarTexture — `void __thiscall(bar, texture,
// int drawLayer)`, `ret 8`: deletes the old bar texture, parents the new
// one to the bar in the layer, sets its OFF_REGION_TEXCOORD_MODIFIES_RECT
// to 1 and sets VALUE_FLAG_CHANGED. Pins no points.
FUN_STATUSBAR_INSTALL_BAR_TEXTURE = 0x007831F0,
// CLayoutFrame::SetAllPoints — `void __thiscall(region+OFF_REGION_ANCHOR,
// relative+OFF_REGION_ANCHOR, int doResize)`, `ret 8`. The bar's
// SetBarTexture-by-path (0x00783140) pins a new texture with (bar, 1).
FUN_LAYOUT_SET_ALL_POINTS = 0x00767DB0,
// CSimpleTexture::SetTexCoord, corner form — `void __thiscall(tex, const
// float[8])`: UL, LL, UR, LR (x, y) pairs into +0x104, crop and store only
// with OFF_REGION_TEXCOORD_MODIFIES_RECT. The 8-argument SetTexCoord.
FUN_SIMPLETEXTURE_SET_TEXCOORD_CORNERS = 0x007704C0,
// CFrameScriptObject vtable slot 4 — the `IsA(typeId)` predicate every
// frame class implements, and the gate every engine method applies to its
// `self` before touching it. `char __thiscall(void *self, int typeId)`.
OFF_VMT_FRAMESCRIPT_ISA = 0x10,
// The three errors an engine frame method raises for a bad `self`, as
// .data string literals. None contains a `%`, so they are safe to hand
// straight to the variadic `lua_error`, and reading the engine's own
// strings keeps our diagnostics identical to the stock ones.
STR_FS_THIS_NON_TABLE = 0x00847EF8,
STR_FS_THIS_NON_OBJECT = 0x00847EC0,
STR_FS_WRONG_OBJECT_TYPE = 0x00847E98,
// The loaded model instance a CSimpleModelFFX keeps at +0x318. It is the
// SAME CModel class CGUnits keep at unit+0xD8 — verified via
// FUN_007110d0 (the geoset-range setter), whose submesh walk and +0x98
// visibility-array writes match the instance layout probed in-game.
OFF_SIMPLEMODELFFX_MODEL_INSTANCE = 0x318,
// The frame's installed camera (a handle; SimpleModelInstallCamera
// 0x0076CE80 AddRefs what it stores) and its facing in radians.
OFF_SIMPLEMODEL_CAMERA = 0x31C,
OFF_SIMPLEMODEL_FACING = 0x39C,
// vtable slot 38: the per-paint root-transform rebuild (PlayerModel's
// 0x00505C50 also ends a turn). `__thiscall(frame)`.
VTBL_SIMPLEMODEL_UPDATE_MODEL = 0x98,
// `CM2Scene *__thiscall(frame)` — the frame's scene, made on first use.
FUN_SIMPLEMODEL_GET_SCENE = 0x0076CFC0,
// ---- PlayerModel / DressUpModel / TabardModel (benilla ui/playermodel) --
// CGCharacterModelBase: a Model frame (0x3F8 bytes) that shows a copy of a
// unit's model or a creature display. DressUpModel and TabardModel extend
// it (0x410 bytes). Type ids from the prologues of Script_SetUnit
// (0x00505D70) and DressUpModel Script_Undress (0x00504C00); registry ctx
// per docs/BlizzardScriptAPI.md. The dispatcher walks the type hierarchy,
// so a PlayerModel method reaches DressUpModel and TabardModel too.
VAR_PLAYERMODEL_METHOD_REGISTRY = 0x00BE09D8,
VAR_PLAYERMODEL_LUA_TYPE_ID = 0x00BE0A24,
VAR_DRESSUPMODEL_METHOD_REGISTRY = 0x00BE0938,
VAR_DRESSUPMODEL_LUA_TYPE_ID = 0x00BE0920,
// The pane's creature display record: a creature-cache record whose
// +0x2C (OFF_CREATURE_DISPLAYID) is the only field read, by
// AttachDisplayModel. The constructor, SetUnit (0x00505B50) and SetDisplay
// write it; the show hook (0x00505D49) reads it to rebuild the model.
// Those four are the only accesses in 0x00500000..0x00507000.
OFF_PLAYERMODEL_DISPLAY_RECORD = 0x3F0,
// SetDisplay — `__thiscall(pane, record)`: clears the unit GUID, stores
// the record and, if the frame is visible, builds the model.
FUN_PLAYERMODEL_SET_DISPLAY = 0x00505CB0,
// AttachDisplayModel — `__thiscall(pane, record)`: creates the display's
// model in the pane's scene, applies its skins (ApplyCreatureDisplay
// 0x004797B0), installs it (vtable +0x90), registers the done callback
// and arms Stand. No character compositor: 4.3.4's SetUpModel adds it.
FUN_PLAYERMODEL_ATTACH_DISPLAY_MODEL = 0x00505A70,
// ConfigureCamera — `__thiscall(pane)`, run by the model-ready hook
// (0x00505B30): a frozen copy of the model's camera index 1, or a fixed
// camera at the bounding-box centre. 4.3.4's ConfigureCamera is this plus
// the portrait-zoom and distance-scale steps.
FUN_PLAYERMODEL_CONFIGURE_CAMERA = 0x00505890,
// The engine's Lua PlayerModel:SetRotation(angle) — `int __fastcall(L)`.
FUN_SCRIPT_PLAYERMODEL_SET_ROTATION = 0x00505F00,
// DressUpModel fields (benilla ui/dressup): the character component, and
// the main- and off-hand lanes, 8 bytes each: byte 0 item class (0 =
// empty), byte 3 inventory type, byte 4 sheathe type.
OFF_DRESSUPMODEL_COMPONENT = 0x3F8,
OFF_DRESSUPMODEL_MAIN_HAND_LANE = 0x3FC,
OFF_DRESSUPMODEL_OFF_HAND_LANE = 0x404,
// UnequipCharacterSlot — `__thiscall(component, slot 0..11)`.
FUN_CHARCOMP_UNEQUIP_SLOT = 0x00478960,
// DetachHeldItemSlot — `__fastcall(model, bodySlot 0xF/0x10,
// sheatheType, bool shield)`; Undress passes `invType == 14` as shield.
FUN_DETACH_HELD_ITEM_SLOT = 0x0047A310,
// TryOnItem — `__thiscall(pane, itemID)`: the worker behind TryOn.
FUN_DRESSUPMODEL_TRY_ON_ITEM = 0x00504540,
// CGGameUI::DisplayError — `__cdecl(id, ...)`: shows a catalogue game
// error. TryOnItem shows 0x13 (ERR_NOT_EQUIPPABLE) at 0x00504B2F.
FUN_GAMEUI_DISPLAY_ERROR = 0x00496720,
GAME_ERROR_NOT_EQUIPPABLE = 0x13,
// ---- M2 model cameras --------------------------------------------------
// GetCameraCount — `__thiscall(model)`: data +0x124 after waiting for the
// shared data. GetCamera — `__thiscall(model, index)`, unchecked.
// GetCameraById (0x00713540) indexes with M2LookupIndex's result
// unchecked, so a model without that id reads past the array; we look the
// id up ourselves and bound it by the count. M2LookupIndex is
// `__fastcall(id, table)` → uint16, 0xFFFF past the table's end; the
// camera-id table is {count, uint16 *} at `[model+0x30]+0x130` + 0x12C.
FUN_M2MODEL_GET_CAMERA_COUNT = 0x007134D0,
FUN_M2MODEL_GET_CAMERA = 0x00713590,
FUN_M2_LOOKUP_INDEX = 0x00710310,
OFF_M2MODEL_SHARED = 0x30,
OFF_M2SHARED_DATA = 0x130,
OFF_M2DATA_CAMERA_ID_LOOKUP = 0x12C,
// SetAnimated — `__thiscall(model, bool)`; M2SceneAnimateAndCollect —
// `__thiscall(scene, const float *cameraPos)`. ConfigureCamera runs both
// (with the frame's facing zeroed) before it copies a model camera.
FUN_M2MODEL_SET_ANIMATED = 0x00710B90,
FUN_M2SCENE_ANIMATE = 0x00707680,
// ---- Camera properties (benilla camera#properties) -------------------
// Get/SetVectorProperty `__fastcall(camera, id, float[3] [, keep])`,
// Get/SetScalarProperty `__fastcall(camera, id [, float])`. Ids: 7 eye,
// 8 target, 4 field of view.
FUN_CAMERA_GET_VECTOR = 0x007ABF80,
FUN_CAMERA_GET_SCALAR = 0x007AC0B0,
FUN_CAMERA_SET_VECTOR = 0x007AC250,
FUN_CAMERA_SET_SCALAR = 0x007AC3A0,
CAMERA_PROP_FOV = 4,
CAMERA_PROP_EYE = 7,
CAMERA_PROP_TARGET = 8,
// ---- ModelFFX glow (benilla glue/select#the-modelffx-frame) ----------
// The glue ModelFFX frame's show (vtable slot 12, 0x0046FA60) writes the
// glow strength 0.30 (0x008380B4) to the light state's +0x110 and makes
// ffxGlow current; the effect reads it per draw. GetLightState is
// `__stdcall()`. ModelFFX's vtable is 0x00803960.
FUN_MODELFFX_ON_SHOW = 0x0046FA60,
FUN_GET_LIGHT_STATE = 0x006D48B0,
OFF_LIGHT_STATE_GLOW = 0x110,
VTBL_MODELFFX = 0x00803960,
// --- Character-model compositor ("CharComponent", `Model::DisplayInfo`) --
// The engine object that dresses a character-based model: resolves the
// hair / facial-hair geosets (CharHairGeosets, CharacterFacialHairStyles —
// beards, earrings, teeth), loads the baked NPC body texture or composites
// the player one, and applies equipment geosets (sleeves / robe→trousers /
// boots / tabard / cape, FUN_00477520). Units keep one at unit+0xD30,
// driven by CGUnit_C::UpdateCharacterCustomization (FUN_005fb200) — the
// single caller-of-record this whole API was derived from — behind the
// poll gate FUN_00607da0 (dress only once FUN_MODEL_INSTANCE_LOADED says
// the model is in). The portrait renderer (Script_SetPortraitTexture →
// FUN_00524f60) waits on FUN_CHARCOMP_PUMP before rendering, which is why
// portraits always show the finished appearance.
FUN_CHARCOMP_CREATE = 0x00475FB0, // () -> builder from the engine pool at 0x00B42720; 0 on exhaustion
FUN_CHARCOMP_DESTROY = 0x00476000, // (builder /*ecx*/) — releases refs (FUN_00476ac0), returns node to pool
// __thiscall(builder, CharCompInfo*) -> bool. Copies 0x5B dwords
// (0x16C bytes) to builder+0x18, validates race against ChrRaces, resolves
// skin/hair/facial sections + geosets. Caller must AddRef the model first
// (FUN_005fb200 does); the builder owns that ref from then on.
FUN_CHARCOMP_SET_INFO = 0x00476B90,
// __thiscall(builder, slot 0..9, itemDisplayInfoID) — feed one NPC
// equipment piece (validated against ItemDisplayInfo.dbc, no-op for 0 /
// out-of-range). Units pass CreatureDisplayInfoExtra +0x20..+0x44.
FUN_CHARCOMP_SET_ITEM = 0x00478AA0,
// __thiscall(builder, int *unused /*engine passes 0*/) -> bool done.
// The per-frame pump: composites pending texture regions; the baked-NPC
// path short-circuits to the geoset apply (FUN_00477520) and returns 1 on
// the first call. Keep calling until it returns 1.
FUN_CHARCOMP_PUMP = 0x00477860,
// Model-instance API used around the compositor:
FUN_MODEL_INSTANCE_ADDREF = 0x00710390, // (model /*ecx*/)
// __thiscall(model, tryLoad, recurseChildren) -> bool loaded. The engine's
// dress gate (FUN_00607da0) passes (0, 0) — a passive check.
FUN_MODEL_INSTANCE_LOADED = 0x007103D0,
// Attached-child list on a model instance (helm/shoulder item models the
// compositor attaches via FUN_00712f70). Head + sibling-next verified from
// FUN_MODEL_INSTANCE_LOADED's recurseChildren walk.
OFF_MODEL_INSTANCE_CHILD_HEAD = 0x1DC,
OFF_MODEL_INSTANCE_CHILD_NEXT = 0x1E4,
// __thiscall(model, callback, userData) — stores the instance's pre-render
// callback pair (instance+0x3BC/+0x3C0). CSimpleModelFFX::SetModelInstance
// (FUN_0076cd30) registers FUN_SIMPLEMODELFFX_LIGHT_FOG_CB with the frame
// as userData on ITS instance only; attached children have an empty slot
// and render UNLIT (pure black — verified in-game: a light tint colored
// the body but not the equipment). `Model::DisplayInfo` fills each child's
// slot with the same pair so equipment lights like the body.
FUN_MODEL_INSTANCE_SET_RENDER_CB = 0x007134B0,
// __fastcall-shaped engine callback (never called by us directly): applies
// the owning frame's fog (+0x3A4/+0x3A8) and light struct (+0x324, written
// by Script_SetLight via FUN_0076cf30) to the render context each time the
// instance is drawn.
FUN_SIMPLEMODELFFX_LIGHT_FOG_CB = 0x0076D680,
// Engine Script_* method implementations `Frame::Modern` delegates to
// (each `int __fastcall(void *L)`, reading self at stack index 1).
// Addresses from the docs/raw_methods.txt catalogue. Show/Hide are
// PER-BRANCH (Frame vs Texture vs FontString each register their own
// script function with its own object typecheck), so SetShown is
// registered per branch with the matching delegates.
FUN_SCRIPT_REGION_SETWIDTH = 0x007A1F20,
FUN_SCRIPT_REGION_SETHEIGHT = 0x007A2150,
FUN_SCRIPT_REGION_GETWIDTH = 0x007A1E00,
FUN_SCRIPT_REGION_GETHEIGHT = 0x007A2030,
// Region rect getters (return a number, or nil when the region has no
// resolved rect). All on the REGION base registry → callable on any
// region type. Used by Frame::Modern's IsMouseOver.
FUN_SCRIPT_REGION_GETLEFT = 0x007A1980,
FUN_SCRIPT_REGION_GETRIGHT = 0x007A1AA0,
FUN_SCRIPT_REGION_GETTOP = 0x007A1BC0,
FUN_SCRIPT_REGION_GETBOTTOM = 0x007A1CE0,
// In-game GetCursorPosition (0x0046DAD0 is the glue-state copy). Pushes
// (x, y) in the same k = FUN_0041ad70()*DAT_007ffd68 space the region
// rect getters use — so dividing by the region's effective scale puts
// the cursor in the region's logical coordinate space.
FUN_SCRIPT_GETCURSORPOSITION = 0x0048B820,
// Region effective-scale field: `piVar[0x1f]` (float) read by both
// GetEffectiveScale (0x00774FC0) and internally by GetLeft/Top/etc. —
// present on every region object, so it's the all-region way to get the
// effective scale without the Frame-only GetEffectiveScale method.
OFF_REGION_EFFECTIVE_SCALE = 0x7C,
// Global UI/screen context pointer (every frame's +0xA0 field mirrors
// it; GetCursorPosition reads the cursor from *ptr + 0x1118). Its
// +0xCFC slot holds the frame currently being moved/sized via
// StartMoving/StartSizing (0 when idle) — the drag target. Backs
// Frame::Modern's IsDragging: StopMovingOrSizing (0x00776990) gates its
// clear on `*(context+0xCFC) == self`, i.e. the IsDragging predicate.
VAR_UI_CONTEXT_PTR = 0x00CF0BD8,
OFF_UI_CONTEXT_DRAG_TARGET = 0xCFC,
// Frame currently under the mouse (the CFrameScriptObject* that
// `GetMouseFocus` returns): `*(*VAR_UI_CONTEXT_PTR + 0x7C)`. 0 when the
// cursor is over no mouse-enabled frame. `Frame::Attributes` polls this to
// drive the `mouseover` override from the hovered frame's `unit` attribute.
OFF_UI_CONTEXT_MOUSE_FOCUS = 0x7C,
// The mouse-focus pass — `int __fastcall(const MouseEvent *event,
// context)`, an input handler (registered by 0x00765C6C) that also runs
// from the layout update 0x007657BE when the re-pick flag (+0x1100) is
// set. That re-pick passes the context's saved copy of the last mouse
// event, `context + OFF_UI_CONTEXT_SAVED_MOUSE_EVENT`; `cmp ebx,edi` at
// 0x00766114 tells the two apart, as 3.3.5's CSimpleTop::OnMouseMove does
// for its `motion` (`mouseData != &top->m_mousePosition`). It stores the
// new focus at +0x7C, then calls the old focus's leave (vtable+0x50, 0)
// and the new focus's enter (vtable+0x4C) (Ghidra).
FUN_UI_MOUSE_FOCUS_PASS = 0x007660D0,
OFF_UI_CONTEXT_SAVED_MOUSE_EVENT = 0x1104,
// Head of the engine's frame list (`*(*VAR_UI_CONTEXT_PTR + 0xCC4)`),
// and each frame CObject's next-in-enumeration pointer at +0x308 — the
// list `Script_EnumerateFrames` (0x00705F60) walks. A node with its low
// bit set (or null) is the end sentinel. `Tooltip::FrameStack` walks it
// (4.3.4's CSimpleTop::m_frames).
OFF_UI_CONTEXT_FRAME_LIST_HEAD = 0xCC4,
OFF_FRAME_ENUM_NEXT = 0x308,
// Frame level, a plain int at CObject +0xC4 (the value `Script_GetFrameLevel`
// at 0x007744A0 pushes as `frame[0x31]`). Read directly for stack ordering.
OFF_FRAME_LEVEL = 0xC4,
// Frame strata, an int at +0xC0: `Script_GetFrameStrata` (0x007742A0)
// pushes FUN_FRAME_STRATA_TO_STRING([frame+0xC0]).
OFF_FRAME_STRATA = 0xC0,
// `int` — nonzero when the frame is effectively shown (4.3.4's
// CSimpleFrame::m_visible). `Script_IsVisible` (0x007758D0) pushes
// `[frame+0xD4] != 0`.
OFF_FRAME_VISIBLE = 0xD4,
// Enabled-input bitmask (4.3.4's m_enabledEventsBitmask), one bit per
// input event type: bit `1 << SIMPLE_EVENT_*`. `Script_IsMouseEnabled`
// (0x00777130) pushes `([frame+0xCC] >> 2) & 1`.
OFF_FRAME_ENABLED_EVENTS = 0xCC,
// Input event types (4.3.4's CSimpleEventType). EnableMouse (0x00777070)
// enables / disables type 2 through FUN_0076AF00 / FUN_0076AF50.
SIMPLE_EVENT_MOUSE = 2,
// The UI context's input queues (4.3.4's CSimpleTop::m_eventqueue[type]
// [strata]): `ctx + OFF_UI_CONTEXT_EVENT_QUEUES + (strata +
// FRAME_STRATA_COUNT * type) * EVENT_QUEUE_STRIDE`. Each holds node
// pointers at +OFF_EVENT_QUEUE_DATA (count at +OFF_EVENT_QUEUE_COUNT);
// a node is `{frame, priority}`, kept sorted by priority high to low
// (default priority = frame level). FUN_0076AF00 adds a frame only while
// it is visible (OFF_FRAME_VISIBLE) — via the register routine
// FUN_00764AA0 — so a queue holds exactly the shown frames with that input
// enabled. The mouse-focus pass FUN_007660D0 walks the mouse queues from
// strata 8 down to 0 and makes the first frame whose mouse handler
// (vtable+0x3C, base 0x0076B320 → FUN_FRAME_HIT_TEST) hits the focus.
OFF_UI_CONTEXT_EVENT_QUEUES = 0xD10,
FRAME_STRATA_COUNT = 9,
EVENT_QUEUE_STRIDE = 0x1C,
OFF_EVENT_QUEUE_DATA = 0x08,
OFF_EVENT_QUEUE_COUNT = 0x10,
// The mouse hit test — `int __thiscall(frame, const float point[2])`,
// point {x, y} in DDC. Needs the frame's rect valid, then tests the hit
// rect at +0xD8..+0xE4 (layout rect less the hit-rect insets); a frame
// with FRAME_FLAG_SCROLLED tests it clipped to its nearest ancestor
// without that flag. No side effects (the vtable+0x3C wrapper adds the
// drag-start check before calling it).
FUN_FRAME_HIT_TEST = 0x0076B020,
// FrameStrataToString — `const char *__fastcall(int strata /*ecx*/)`.
// Scans the 8-entry `{int strata, const char *name}` table at 0x008119F8
// (BACKGROUND = 1 … TOOLTIP = 8); anything else → "UNKNOWN" (0x00838044).
FUN_FRAME_STRATA_TO_STRING = 0x006F1820,
// The cursor in NDC: two floats {x, y} at `*VAR_UI_CONTEXT_PTR + 0x1118`
// (4.3.4's CSimpleTop::m_mousePosition). GetCursorPosition (0x0048B820)
// and the mouse hit test FUN_007664F0 both read it and convert it with
// FUN_COORD_NDC_TO_DDC.
OFF_UI_CONTEXT_MOUSE_POSITION = 0x1118,
// NDCToDDC — `void __fastcall(float *outX /*ecx*/, float *outY /*edx*/,
// float x, float y)`, `ret 8`: x × VAR_COORD_DDC_WIDTH_SCALE,
// y × VAR_COORD_DDC_HEIGHT_SCALE. Either out pointer may be null. DDC is
// the space frame rects (FUN_REGION_GET_RECT) are stored in.
FUN_COORD_NDC_TO_DDC = 0x0041AD80,
// The two default tooltip line colors, packed {b,g,r,a} like every
// FUN_GAMETOOLTIP_ADD_LINE color: text 0xFFFFFFFF (static init 0x00528E90)
// and title 0xFFFFD200 (static init 0x00528E50) — 4.3.4's
// s_tooltipTextColor / s_tooltipTitleColor. The gray 0xFF808080 is the
// right column of the spell builder's name line (benilla-re
// s_tooltipGray, verified) — 4.3.4's s_tooltipGrayColor.
VAR_TOOLTIP_TEXT_COLOR = 0x00C0CF60,
VAR_TOOLTIP_TITLE_COLOR = 0x00C0D3E8,
VAR_TOOLTIP_GRAY_COLOR = 0x00C0D3C4,
FUN_SCRIPT_FRAME_SHOW = 0x00775750,
FUN_SCRIPT_FRAME_HIDE = 0x00775810,
FUN_SCRIPT_FRAME_SETMINRESIZE = 0x00776020,
FUN_SCRIPT_FRAME_SETMAXRESIZE = 0x007762A0,
FUN_SCRIPT_FRAME_GETSCRIPT = 0x00774780,
FUN_SCRIPT_FRAME_SETSCRIPT = 0x007748D0,
// `frame:RegisterEvent(event)` (Frame registry, `Script_RegisterEvent`) —
// standard `int __fastcall(void *L)`: resolves self at 1, reads the event
// name at 2, calls FUN_FRAME_REGISTER_EVENT. `Frame::UnitEvent` delegates
// `RegisterUnitEvent` to it by stack reshape so chain membership stays
// engine-owned (self typecheck, error text, and DllMain's RegisterEvent
// hook all run as for a plain call). Siblings from the same method table,
// referenced in comments only: UnregisterEvent 0x00774B30 (calls
// FUN_FRAME_UNREGISTER_EVENT), RegisterAllEvents 0x00774C20,
// UnregisterAllEvents 0x00774CF0 (calls FUN_FRAME_UNREGISTER_ALL_EVENTS).
FUN_SCRIPT_FRAME_REGISTEREVENT = 0x00774A40,
// `frame:EnableMouse(enable)` (Frame registry) — `Frame::Attributes` calls
// it so a unit-attributed frame registers as the mouse-focus (bare frames
// otherwise never hover). Standard `int __fastcall(void *L)` Script_* shape.
FUN_SCRIPT_FRAME_ENABLEMOUSE = 0x00777070,
// (The button click dispatcher is FUN_BUTTON_CLICK, defined with the frame
// script slots near FUN_FRAME_RUN_SCRIPT_WITH_CONTEXT. A note here used to
// forbid hooking it on a SuperWoW-collision theory that a per-DLL scan has
// since disproved — see that definition. `Frame::Attributes` chains a normal
// OnClick on its opted-in frames for its own reasons, not because of it.)
// Frame GetAlpha (`[frame+OFF_FRAME_ALPHA] / 255`).
// `Frame::Alpha` co-hooks GetAlpha to return the own alpha it keeps,
// since the byte it reads holds the drawn alpha; Frame::Modern's
// GetEffectiveAlpha calls it for its `self` type check, then reads the
// byte.
FUN_SCRIPT_FRAME_GETALPHA = 0x00774DC0,
// Hyperlink scripts. ScrollingMessageFrame and SimpleHTML share a base
// whose GetScriptByName override (0x007A3700, in the vtables at slots
// 0x0081D03C and 0x0081D68C) adds OnHyperlinkEnter / Leave / Click, held
// at +0x320 / +0x328 / +0x330. Each fires through its own vtable function
// (Enter 0x007A3780, Leave 0x007A37B0, Click 0x007A37E0), which runs the
// script through the input-script forwarder 0x007026F0 →
// FUN_FRAME_RUN_SCRIPT_WITH_CONTEXT with slotPtr = frame + the slot below,
// only when one is set. `Frame::HyperlinksEnabled` gates them there, as a
// `Frame::RunnerHook` subscriber.
OFF_HYPERLINK_ENTER_SLOT = 0x320,
OFF_HYPERLINK_LEAVE_SLOT = 0x328,
OFF_HYPERLINK_CLICK_SLOT = 0x330,
// Method registries (the Ctx of each class's method table): the
// ScrollingMessageFrame table 0x0087B5C0 (AddMessage, ScrollUp, SetMaxLines,
// ...), the SimpleHTML table 0x0087BA80 (SetText, SetHyperlinkFormat, ...).
VAR_SCROLLINGMESSAGEFRAME_METHOD_REGISTRY = 0x00CF5294,
VAR_SIMPLEHTML_METHOD_REGISTRY = 0x00CF5328,
// Clamp to screen. A region's layout object is its anchor sub-object at
// OFF_REGION_ANCHOR (Script GetLeft: `lea ebx, [edi+0x24]` before the rect
// reader 0x00768320). SetClampedToScreen (0x00768CC0) sets
// LAYOUT_FLAG_CLAMPED in the layout flags at OFF_LAYOUT_FLAGS and calls
// FUN_LAYOUT_RESIZE(layout, 0).
//
// FUN_LAYOUT_CALC_RECT — `int __thiscall(layout, float rect[4])`, `ret 4`,
// rect = bottom, left, top, right in layout units (the order Script
// GetBottom/GetLeft/GetTop/GetRight read from 0x00768320's copy). It
// resolves the four edges from the anchors, returns 0 if any is
// unresolved, and for a clamped frame slides the rect onto the screen, in
// this order: right if left < 0, up if bottom < 0, left if right >
// FUN_0041AE60(1) = [VAR_COORD_DDC_WIDTH_SCALE], down if top >
// FUN_0041AE70(1) = [VAR_COORD_DDC_HEIGHT_SCALE] (so a frame bigger than the
// screen ends up flush with the top right). Its only caller is the layout
// update at 0x00768D20, which caches the result at layout+0x40..0x4C.
//
// Units: Script GetLeft pushes Game::InternalToPixel(rect.left) divided by
// OFF_REGION_EFFECTIVE_SCALE, so a length in the frame's own units is
// Game::PixelToInternal(length * effectiveScale) in layout units.
// `Frame::ClampRectInsets` hooks FUN_LAYOUT_CALC_RECT to clamp the rect
// grown by the frame's insets instead.
OFF_LAYOUT_FLAGS = 0x3C,
LAYOUT_FLAG_CLAMPED = 0x10,
FUN_LAYOUT_CALC_RECT = 0x00767A20,
// CSimpleFrame's size-changed vmethod: `void __thiscall(frame, float w,
// float h)`, `ret 8`, in 25 frame-type vtables (the EditBox and
// ScrollFrame overrides 0x0077A8D0 / 0x007871F0 call it). Its only work is
// firing the frame's OnSizeChanged script (slot +0x120) through the
// variadic forwarder with "%f%f" (0x00878830); it is the only code that
// fires that slot. `w` / `h` arrive as the screen rect's size in layout
// units (the frame's effective scale applied) and are pushed as they are;
// 3.3.5 divides out the scale and converts to UI units as GetWidth does
// (FUN_0041AE40(FUN_0041AD70() * DAT_007FFD68 * v) =
// Game::InternalToPixel). Co-hooked by frame/SizeChanged.cpp to do both.
FUN_FRAME_ON_SIZE_CHANGED = 0x0076B660,
// Frame levels. CSimpleFrame's level setter 0x0076A4F0 — `void
// __thiscall(frame, int level, int children)`, `ret 8`: clamps a negative
// level to 0, returns early for an unchanged one, stores it at +0xC4, and
// with `children` nonzero moves each child frame (the +0x300 list) of the
// same strata (+0xC0) by the same amount, recursively. Script
// SetFrameLevel (0x00774560) and XML frameLevel (0x00769820) pass 0; a few
// engine callers pass 1 (0x004905F5, 0x007651D8). SetParent (0x0076AB10)
// first gives the frame the parent's strata through the recursive strata
// setter 0x0076A470, then the parent's level + 1 (or level 0 for no
// parent), passing 0, so the frame's children keep the levels they had.
// 3.3.5 passes 1 at both SetParent calls. These are the `push 0` of that
// argument (`6A 00`) at each call; `Frame::Levels` rewrites the immediate
// to 1.
PATCH_SETPARENT_LEVEL_CHILDREN = 0x0076AB6B, // before `call` at 0x0076AB71 (parent)
PATCH_SETPARENT_NIL_LEVEL_CHILDREN = 0x0076ABAC, // before `call` at 0x0076ABB2 (no parent)
// Frame alpha. The byte at OFF_FRAME_ALPHA (0..255) is what the frame's
// regions are drawn with (each region's recolor reads it) and what
// FUN_SCRIPT_FRAME_GETALPHA returns (`[frame+0xC8] / 255`); it has one
// writer, FUN_FRAME_SET_FRAME_ALPHA (0x0076A6A2). Script SetAlpha
// (0x00774E90: clamp to 0..1, * 255) and the XML `alpha` attribute (frame
// LoadXML, 0x00769A10..0x00769A8A) both reach it through the frame's
// vtable+VTBL_FRAME_SET_FRAME_ALPHA — `void __thiscall(frame, uint8)`,
// `ret 4`: `if (alpha == a) return; alpha = a;`, then vtable+0x20(0)
// (recolor) on each region in the OFF_FRAME_REGION_LIST list and
// vtable+0x28(a) on each child frame in the OFF_FRAME_CHILD_LIST list — the
// same value, copied down. FUN_FRAME_SET_PARENT doesn't touch alpha, so a
// frame parented after its parent's alpha was set keeps its own. Both lists
// are intrusive: node+4 next, node+8 object, a NULL or low-bit-1 link ends
// them. The Model family's vtables (0x00803960, 0x00808260, 0x008083A8,
// 0x008084F8, 0x0081C608) override the slot with 0x0076D120, which calls
// this setter and then hands the byte to its model (+0x318); every other
// frame vtable holds the setter itself. `Frame::Alpha` co-hooks the setter
// and SetParent for 3.x's model.
OFF_FRAME_ALPHA = 0xC8,
OFF_FRAME_REGION_LIST = 0x1B8,
OFF_FRAME_CHILD_LIST = 0x300,
VTBL_FRAME_SET_FRAME_ALPHA = 0x28,
VTBL_REGION_RECOLOR = 0x20,
// CScriptObject vtable+0x04 — `const char *__thiscall GetName()`, NULL for
// an unnamed object. The frame-script usage errors (Script_GetScript
// 0x00774780, Script_SetScript 0x007748D0, ~90 more sites) format the
// object as `GetName() ?: VAR_STR_UNNAMED` — 4.3.4's
// FrameScript_Object::GetDisplayName, inlined.
VTBL_SCRIPTOBJECT_GET_NAME = 0x04,
FUN_FRAME_SET_FRAME_ALPHA = 0x0076A690,
// CSimpleFrame::SetParent — `void __thiscall(frame, CSimpleFrame *parent)`,
// `ret 4`; Script SetParent reaches it through vtable+0x14. No-op for the
// same parent; otherwise unlinks from the old parent's child list
// (0x0076AAB0), stores the parent at OFF_REGION_PARENT, takes the parent's
// strata (+0xC0), level + 1 (+0xC4), layout scale (OFF_LAYOUT_SCALE) and a
// flag bit, and links into the new parent's child list (0x0076AA20). Also
// what CreateFrame's parent argument and the XML frame factory go through:
// the frame constructor calls it directly (0x00769318, its only direct
// caller), after storing the alpha byte (0x007690D2), both list heads and
// the base vtable (0x007692E5).
FUN_FRAME_SET_PARENT = 0x0076AB10,
// CSimpleFrame destructor body — `void __thiscall(frame)`, plain `ret`.
// Called or tail-called by the base vtable's slot-0 deleting destructor
// (0x00769380) and every derived frame class's destructor (16 call sites,
// including the engine-pooled ChatBubbleFrame's at 0x004B0BB6). Deletes the
// frame's regions and child frames and unlinks it from its parent through
// 0x0076AAB0, never through SetParent or the alpha setter. `Frame::Destruction`
// hooks it and fans out (Frame::Alpha, the animation groups).
FUN_FRAME_DESTRUCTOR = 0x007693B0,
// Scroll clipping. A frame a ScrollFrame draws carries FRAME_FLAG_SCROLLED
// in its flags (OFF_FRAME_FLAGS): the strata pass leaves it out when it
// builds a level's layers (`test ah, 0x20` at 0x007659DF), and the
// ScrollFrame draws it instead, from the render callback it queues after
// its last layer (0x007871C0 -> 0x00787220). That callback narrows the
// viewport to the ScrollFrame's rect and calls the scroll child's
// vtable+0x40 (0x0076B3F0), which draws the frame's layers and then each
// shown child frame without FRAME_FLAG_SCROLL_CHILD, recursively.
//
// FUN_FRAME_SET_SCROLLED — `void __thiscall(frame, int scrolled, int
// scrollChild)`, `ret 8` — sets or clears FRAME_FLAG_SCROLLED, sets or
// clears FRAME_FLAG_SCROLL_CHILD when `scrollChild` >= 0, marks the
// frame's five layers for a rebuild when scrolled (0x0076B530), and calls
// itself on each child frame with (scrolled, -1). Its only callers:
// SetScrollChild (0x00786CE0: the old child (0, 0), the new one (1, 1)),
// SetParent (0x0076ABCB: the new parent's FRAME_FLAG_SCROLLED bit, or 0
// with no parent, and -1) and its own recursion (0x0076A45F). So a value
// SetParent passes down reaches a scroll child and everything in it.
// 3.3.5's setter (0x00490F60) skips child frames that carry
// FRAME_FLAG_SCROLL_CHILD; `Frame::ScrollChildren` hooks this one to do
// the same.
FUN_FRAME_SET_SCROLLED = 0x0076A400,
OFF_FRAME_FLAGS = 0xB4,
FRAME_FLAG_SCROLLED = 0x2000,
FRAME_FLAG_SCROLL_CHILD = 0x4000,
// CSimpleFrame::SetFrameFlag — `void __thiscall(frame, uint32 mask, int
// on)`, `ret 8`: sets or clears `mask` in OFF_FRAME_FLAGS. Every write of
// the word goes through it (benilla-re ui/layoutcache). Its 14 callers
// pass only 0x1, 0x10, 0x100, 0x200, 0x1000, 0x2000 and 0x4000, so the
// 4.3.4 bits below are free in 1.12.
FUN_FRAME_SET_FRAME_FLAG = 0x0076A3C0,
// 4.3.4's disabled bit: CSimpleFrame::RunOnEnableScript sets it for a
// disabled Button or EditBox, and EditBox:IsEnabled reads it.
FRAME_FLAG_DISABLED = 0x400,
// 4.3.4's SetDontSavePosition bit: its layout-cache writer
// (PlacedFrameCallback) skips a frame that has it.
FRAME_FLAG_DONT_SAVE_POSITION = 0x80000,
// 4.3.4's SetPropagateKeyboardInput bit: a frame's key-down and character
// slots run the script and then answer "not handled", so the key goes on.
FRAME_FLAG_PROPAGATE_KEYBOARD = 0x200000,
// `int` — nonzero when the frame is shown (4.3.4's m_shown).
// Script_IsShown (0x00775990) pushes `[frame+0xD0] != 0`.
OFF_FRAME_SHOWN = 0xD0,
// The frame key slots — `int __thiscall(frame, const CKeyEvent *)`,
// `ret 4`, nonzero = the frame takes the input. CSimpleTop's character
// and key-down walks (0x00765DF0, 0x00765F10) stop at the first frame that
// answers nonzero and record it as the key's owner; the key-up and repeat
// handlers discard the slot's answer. Every frame vtable holds the base
// slots below except CGWorldFrame's and CSimpleEditBox's (vtable
// 0x0081C910: char 0x0077A900, key down 0x0077B160, key up 0x0077B7C0).
FUN_FRAME_ON_CHAR = 0x0076B760, // vtable+0x5C
// CSimpleFrame::OnFrameUpdate - `void __thiscall(frame, float elapsed)`,
// `ret 4`, vtable+0x38: runs OnUpdate (+0x128). The top's update pass
// (0x00765650) calls slot 0x38 on every frame of every level list - every
// shown frame - once per frame; each override (EditBox 0x0077A790,
// message frames 0x00788460, Model 0x0076D7F0, ...) calls it first. 4.3.4's
// CSimpleFrame::OnLayerUpdate runs OnUpdate, then the frame's animation
// groups, then its regions'.
FUN_FRAME_ON_UPDATE = 0x0076B2C0,
FUN_FRAME_ON_KEY_DOWN = 0x0076B7D0, // vtable+0x60
FUN_EDITBOX_ON_KEY_DOWN = 0x0077B160,
// Layout cache (layout-cache.txt). The writer 0x00490E10 calls this on
// each frame of the top's list: `void __fastcall(frame, file)`. It writes
// a record only for a named frame with the user-placed bit 0x1000 that is
// movable or resizable (benilla-re ui/layoutcache).
FUN_LAYOUT_CACHE_SAVE_FRAME = 0x00490E60,
// ScrollFrame: its scroll child (0x00786E30 reads it; SetScrollChild
// 0x00786CE0 stores it) and its class's Lua type id (read by Script
// UpdateScrollChildRect 0x007918B0, as VAR_FRAME_LUA_TYPE_ID is by the
// Frame methods).
OFF_SCROLLFRAME_SCROLL_CHILD = 0x318,
VAR_SCROLLFRAME_LUA_TYPE_ID = 0x00CF4F14,
FUN_SCRIPT_TEXTURE_SHOW = 0x0079B770,
FUN_SCRIPT_TEXTURE_HIDE = 0x0079B830,
FUN_SCRIPT_FONTSTRING_SHOW = 0x0079CDB0,
FUN_SCRIPT_FONTSTRING_HIDE = 0x0079CE70,
// ---- World map overlay data (WorldMapOverlay.dbc + WorldMapArea.dbc)
// Backs `C_Map.GetMapOverlays`. Instance VAs per docs/DBCs.md;
// schemas verified against the extracted DBCs AND the engine's own
// reader `Script_GetMapOverlayInfo` (0x004A8A00), which reads the
// same fields for its 7 returns.
//
// WorldMapArea.dbc record (8 fields, 0x20 bytes):
// {ID@+0, mapID@+4, areaID@+8 (AreaTable, 0 for continent rows),
// name@+0xC (char*, the map directory name GetMapInfo returns),
// locLeft/locRight/locTop/locBottom floats}
VAR_WORLDMAP_AREA_RECORDS = 0x00C0D5BC,
VAR_WORLDMAP_AREA_COUNT = 0x00C0D5C0,
OFF_WMA_MAP_ID = 0x04,
OFF_WMA_AREA_ID = 0x08,
OFF_WMA_NAME = 0x0C,
OFF_WMA_LOC_LEFT = 0x10, // world Y at the map's left edge (max Y)
OFF_WMA_LOC_RIGHT = 0x14, // world Y at the map's right edge (min Y)
OFF_WMA_LOC_TOP = 0x18, // world X at the map's top edge (max X)
OFF_WMA_LOC_BOTTOM = 0x1C, // world X at the map's bottom edge (min X)
// AreaTrigger.dbc record (10 fields, 0x28 bytes) — instance cataloged
// in docs/DBCs.md (records slot 0x00C0E034, count 0x00C0E038). The
// client loads it but exposes NO geometry to Lua, which is why map
// addons (pfQuest et al.) ship hand-scraped trigger tables. Schema:
// {ID@+0, mapID@+4 (Map.dbc — continent or instance),
// x@+8, y@+0xC, z@+0x10 (continent-space world coords),
// radius@+0x14 (sphere trigger; 0 => box trigger),
// boxLength@+0x18, boxWidth@+0x1C, boxHeight@+0x20, boxYaw@+0x24}
VAR_AREATRIGGER_RECORDS = 0x00C0E034,
VAR_AREATRIGGER_COUNT = 0x00C0E038,
OFF_AT_MAP_ID = 0x04,
OFF_AT_X = 0x08,
OFF_AT_Y = 0x0C,
OFF_AT_Z = 0x10,
OFF_AT_RADIUS = 0x14,
OFF_AT_BOX_LENGTH = 0x18,
OFF_AT_BOX_WIDTH = 0x1C,
OFF_AT_BOX_HEIGHT = 0x20,
OFF_AT_BOX_YAW = 0x24,
// WorldMapOverlay.dbc record (17 fields, 0x44 bytes):
// {ID@+0, worldMapAreaID@+4 (-> WorldMapArea row),
// areaID[4]@+8..+0x14 (AreaTable ids the overlay reveals),
// mapPointX@+0x18, mapPointY@+0x1C, textureName@+0x20 (char*,
// bare name), textureWidth@+0x24, textureHeight@+0x28,
// offsetX@+0x2C, offsetY@+0x30, hitRect@+0x34..+0x40}
// The engine's Lua surface only exposes EXPLORED overlays: the map
// rebuild FUN_004a67a0 keeps a row when one of its four areaIDs passes
// the exploration test (FUN_IS_AREA_EXPLORED below), into the list at
// 0x00B6E630 (count 0x00B6E6B4) that Script_GetMapOverlayInfo reads.
// Reading the DBC directly gives every overlay of a zone, explored or
// not. Verified: benilla-re ui/worldmap#the-overlays.
VAR_WORLDMAP_OVERLAY_RECORDS = 0x00C0D594,
VAR_WORLDMAP_OVERLAY_COUNT = 0x00C0D598,
OFF_WMO_WORLDMAP_AREA = 0x04,
OFF_WMO_AREA_ID = 0x08, // areaID[4] @ +0x08..+0x14 (AreaTable ids revealed)
OFF_WMO_MAP_POINT_X = 0x18,
OFF_WMO_MAP_POINT_Y = 0x1C,
OFF_WMO_TEXTURE_NAME = 0x20,
OFF_WMO_TEXTURE_WIDTH = 0x24,
OFF_WMO_TEXTURE_HEIGHT = 0x28,
OFF_WMO_OFFSET_X = 0x2C,
OFF_WMO_OFFSET_Y = 0x30,
OFF_WMO_HITRECT_TOP = 0x34, // hit rect in world-map canvas px (~1002x668):
OFF_WMO_HITRECT_LEFT = 0x38, // the tight clickable bounds of the landmass,
OFF_WMO_HITRECT_BOTTOM = 0x3C, // used for subzone-center placement (pfQuest's
OFF_WMO_HITRECT_RIGHT = 0x40, // pfDB["zones"] was scraped from these)
// Current world-map view selection — the globals the engine's
// current-map-name resolver (FUN_004a6cf0, behind GetMapInfo) reads:
// continent index, zone index (-1 = whole continent), the default
// WorldMapArea row used when no continent is selected, and the
// per-continent data blob (base ptr; stride 0x10024 per continent,
// continent's own WMA row at +0x04, per-zone WMA row array ptr at
// +0x10).
VAR_WORLDMAP_CONTINENT_INDEX = 0x0084506C,
VAR_WORLDMAP_ZONE_INDEX = 0x00845070,
VAR_WORLDMAP_DEFAULT_AREA_ROW = 0x00845074,
VAR_WORLDMAP_CONTINENT_DATA = 0x00B6E668,
WORLDMAP_CONTINENT_STRIDE = 0x10024,
// `Script_SetPoint` — the ONE SetPoint implementation, registered in
// the Region base table and inherited by every region type. Vanilla's
// parser accepts (point, region), (point, region, relPoint[, x, y]),
// (point, x, y), and even an explicit nil region — but NOT the bare
// one-arg form (`fs:SetPoint("RIGHT")`): a fully-omitted arg 3 is
// LUA_TNONE, which fails the string/table/number/nil check and raises
// the usage error. Modern clients accept it (anchor to parent at the
// same point, zero offsets). `Frame::Modern` co-hooks this and
// normalizes the one-arg call to (point, 0, 0) — the vanilla
// (point, x, y) form, which is parent-relative and thus exactly the
// modern semantic.
FUN_SCRIPT_REGION_SETPOINT = 0x007A2540,
// `CGUnit_C::OnAuraAdded` — `__thiscall void(CGUnit *unit, uint32_t
// slot, uint32_t spellId)` (i.e. `__fastcall(unit /*ecx*/, edx_unused,
// slot, spellId)`). Fires for EVERY aura that lands on a tracked unit,
// including proc/triggered auras that never produce an `SMSG_SPELL_GO`
// (Shadow Weaving, etc.). `Aura::Source` co-hooks it to stamp
// expiration for those — it carries no caster, so it fills timing only
// and never overwrites an entry `SpellGo` already owns. Per-aura-change
// frequency. nampower hooks the same function (its BUFF/DEBUFF events).
FUN_ON_AURA_ADDED = 0x006123F0,
// `CGUnit_C::OnAuraStacksChanged` — `__thiscall void(CGUnit *unit, int
// slot, uint8_t stackCount)` (`__fastcall(unit, edx_unused, slot,
// stackCount)`). Fires when an existing aura's stack count changes
// without a fresh add — e.g. Shadow Weaving climbing 2→3. The slot's
// spellID is read from the unit aura array (`OnAuraAdded` gets it as an
// arg; here only the slot is given). `Aura::Source` co-hooks it to
// re-stamp expiration so stacking-DoT refreshes are picked up.
FUN_ON_AURA_STACKS_CHANGED = 0x00612450,
// `CGUnit_C::OnAuraRemoved` — same ABI as `OnAuraAdded`
// (`__fastcall(unit /*ecx*/, edx_unused, slot, spellId)`; the disassembly
// of the diff dispatcher `FUN_00604d00` at the call site `0x00604dc4`
// shows `ECX = unit`, stack `[slot, spellId]`). The sibling of
// `OnAuraAdded`: `FUN_00604d00` fires this when a descriptor aura slot
// goes from occupied to empty — a genuine removal (fell off, dispelled,
// or replaced by a higher rank, which fires Removed(old)+Added(new)).
// `Aura::Source` co-hooks it to EVICT the cached entry so the
// `GetAuraDataByIndex` fallback can't resurrect a superseded/dispelled
// aura that's still inside its computed duration window.
FUN_ON_AURA_REMOVED = 0x00612320,
// Group-loot roll packet handlers (the inner display functions in
// LootRoll.cpp). Each is `__fastcall`; the deserialized 0x48-byte
// PendingLootRoll message struct is fully populated at entry and freed
// at exit, so read its fields BEFORE calling the original. The register
// the message arrives in differs per handler (matched in
// loot/History.cpp): ROLL passes it in ECX, WON / ALL_PASSED in EDX.
// Backs the C_LootHistory backport (loot/History.cpp) — 1.12 has no
// loot-history store, so we reconstruct one from these packets.
FUN_LOOT_ROLL_HANDLER = 0x0061C0B0, // SMSG_LOOT_ROLL (msg=ECX)
FUN_LOOT_ROLL_WON_HANDLER = 0x0061B9E0, // SMSG_LOOT_ROLL_WON (msg=EDX)
FUN_LOOT_ALL_PASSED_HANDLER = 0x0061B640, // SMSG_LOOT_ALL_PASSED (msg=EDX)
// SMSG_LOOT_START_ROLL (opcode 0x2A1) handler — `__fastcall(ECX = packet)`,
// RET 0, returns 1 (the dispatcher passes EAX up). The result packets
// (ROLL/WON/PASSED) carry 0 for the item's
// random suffix/seed; only START_ROLL does. It deserializes a fresh
// PendingLootRoll node (same 0x20/0x24 field offsets as the message) and
// publishes it as the store head at VAR_LOOTROLL_STORE_HEAD, so we read
// the suffix straight off that node right after the original runs.
FUN_LOOT_START_ROLL_HANDLER = 0x0061B310,
VAR_LOOTROLL_STORE_HEAD = 0x00C4DC00, // PendingLootRoll* — newest node
// PendingLootRoll message field offsets, derived from the SMSG_LOOT_ROLL
// deserializer FUN_0061BFA0 (reads GUID/u32/byte fields off the packet).
OFF_LOOTROLL_SOURCE_GUID = 0x10, // u64 looted-object GUID (roll identity)
OFF_LOOTROLL_SLOT = 0x18, // u32 loot slot
OFF_LOOTROLL_ITEM_ID = 0x1C, // u32 itemID
// Random-enchant fields for the item link `item:id:enchant:suffix:unique`.
// +0x20 is the suffix/random-property ID the engine's item-name builder
// FUN_005D8B00 uses (indexes the random-properties DBC for the "of the X"
// name); +0x24 is the paired seed/unique value.
OFF_LOOTROLL_ITEM_SUFFIX = 0x20, // i32 random suffix / property ID
OFF_LOOTROLL_ITEM_SEED = 0x24, // u32 random seed (link unique field)
OFF_LOOTROLL_ROLLER_GUID = 0x30, // u64 roller / winner GUID
// Roll byte + type, decoded as WriteRollLine (FUN_0061C0B0) does: a
// negative (signed) byte is a vote — greed for type 2, else pass; a
// non-negative byte with type 0 is a need vote; anything else is a dice
// result (the byte) of type 2 = greed, else need. SMSG_LOOT_ROLL_WON
// (FUN_0061B870) stores the winner's dice byte and type (1 / 2) here too.
OFF_LOOTROLL_ROLL_NUM = 0x38, // u8 roll byte (see above)
OFF_LOOTROLL_ROLL_TYPE = 0x40, // u32 roll type (see above)
// CGPlayer-side sub-struct, allocated for any player-controlled
// unit (local self, target, party, raid, inspect targets — all of
// them). Holds player-specific data that's *not* in the broadcast
// UpdateField descriptor:
//
// +0x08 uint32 PLAYER_FLAGS (AFK = bit 1, DND = bit 2,
// RESTING = bit 5)
// +0x118 + slot*0x30 visible-items table (slots 0..18,
// walked by FUN_UNIT_GET_VISIBLE_ITEM)
//
// Same offset works for any player; the visible-items helper and
// `UnitIsAFK`-style flag readers share the same `[unit + 0xE68]`
// pointer. NPCs / CGCreature_C objects have this slot
// *uninitialized* — reading without a `UNIT_FLAG_PLAYER_CONTROLLED`
// gate is a known crash path (helper does `garbage + 0x118 +
// slot*0x30` then derefs).
//
// Flag bits verified by:
// - `Script_IsResting` (`0x00516EA0`): `[CGPlayer + 0xE68] +
// 0x08`, `shr 5; test 1` → bit 5 = RESTING (0x20).
// - Nameplate AFK renderer (`0x005EC9E0`): `[unit + 0xE68] +
// 0x08`, `test [+8], 2` → bit 1 = AFK (0x02). Works for ANY
// unit, not just local player — confirmed by user testing
// `<AFK>` rendering above other players' heads on stock 1.12.
// - DND bit by symmetry with chat-flag protocol; confirmed in-game.
//
// PLAYER_FLAGS being out-of-band (in this sub-struct rather than a
// broadcast UpdateField) is a vanilla-only quirk — modern WoW
// (3.0+) added PLAYER_FLAGS as a UpdateField at descriptor +0x228.
// In 1.12, descriptor +0x228 is repurposed as UNIT_CHANNEL_SPELL
// (see OFF_UNIT_FIELD_CHANNEL_SPELL below); PLAYER_FLAGS only
// exists on the +0xE68 sub-struct here.
OFF_CGPLAYER_INFO = 0xE68,
// The engine's explored-area bit test (benilla `IsAreaExplored`):
// __thiscall(this = player + OFF_CGPLAYER_INFO, int areaBit) → nonzero
// when explored, ret 4. Reads `[this] + 0xE6C` (the 0x100-byte
// explored bitfield, PLAYER_EXPLORED_ZONES). The byte index is
// compared UNSIGNED against 0x100, so a bit number >= 2048 OR negative
// counts as explored. Callers test the AreaTable gate first
// (OFF_AREATABLE_EXPLORE_GATE). Disassembled 0x004A9A40.
FUN_IS_AREA_EXPLORED = 0x004A9A40,
// The engine's explored-bits watcher (benilla `OnExploredBitsChanged`):
// a descriptor-observer callback (ABI per FUN_DESC_OBSERVER_REGISTER,
// ret 0x10) on the player's 0x100 explored bytes (bank 4, field 0xE6C).
// Armed by ArmExploredWatcher 0x004A6430 from EnterWorldUI and cleared
// by ClearExploredWatcher 0x004A6490 from LeaveWorldUI (the pair shares
// the s_worldEntered latch, so it never stacks). The dispatcher calls it
// only when the bytes really changed; it re-selects the current map
// (FUN_004a67a0 → WORLD_MAP_UPDATE). Its only references are those two
// DATA xrefs. Map::Exploration co-hooks it for MAP_EXPLORATION_UPDATED.
FUN_EXPLORED_BITS_CHANGED = 0x004A6460,
// CGObject's `GetPosition` virtual — vtable slot 5 (offset 0x14).
// Signature: `__thiscall(this, float outBuf[3]) → float *position`.
// The returned float* may equal outBuf (the object filled it
// directly) or point at a cached position field on the object
// (CGPlayer keeps its own copy). Either way, dereference the
// pointer for x/y/z. Used by `Script_CheckInteractDistance` for
// its squared-distance compute; same vtable layout for CGUnit,
// CGPlayer, CGGameObject, etc. since they share the CGObject
// base. Bytes verified via the call-site disassembly at
// `0x0048BACF` / `0x0048BADC`.
OFF_CGOBJECT_VTBL_GET_POSITION = 0x14,
// CGUnit movement-block orientation (facing) in radians, 0..2*pi. Lives
// right after the {x,y,z} position block (at +0x9B8), i.e. pos+0xC. The
// `GetPosition` virtual copies only x/y/z into the caller's buffer, so
// read facing off the object directly. Backs `GetPlayerFacing`. Empirically
// located by probing the player object across a known 180-degree turn
// (value flipped by ~pi, stayed in range); mirrored at +0x9F8 / +0xC98
// (last-sent / render copies) — +0x9C4 is the authoritative one.
OFF_UNIT_FACING = 0x9C4,
// CGObject `m_objectType` field — 0 = (base) object, 1 = item,
// 2 = container, 3 = unit, 4 = player, 5 = gameobject, … Read as
// `*(int *)(obj + 0x14)`. (Distinct from GET_POSITION above, which
// is a *vtable* byte-offset that happens to also be 0x14.)
OFF_CGOBJECT_TYPE_ID = 0x14,
OBJECT_TYPE_UNIT = 3,
OBJECT_TYPE_PLAYER = 4,
// CGObject vtable slots (byte offsets): GetFacing `float __thiscall()`
// (slot 6, the tab collector's player facing), IsMouseoverable
// `int __thiscall()` (slot 21, the hover dispatch's gate at 0x482982).
OFF_CGOBJECT_VTBL_GET_FACING = 0x18,
OFF_CGOBJECT_VTBL_IS_MOUSEOVERABLE = 0x54,
// The selection circle (benilla-re objectlayer/unitdisplay.md, verified
// against the bytes of 0x608E00 / 0x614A90). The base per-frame step
// FUN_CGOBJECT_FRAME_UPDATE `void __thiscall(obj, int)` (every class's
// slot 14 runs it, inside DrawEntityModels' per-entity callback) draws the
// target's circle through vtable slot 12 when VAR_CVAR_OBJECT_SELECTION_CIRCLE
// is on. A unit's slot 12 (0x608E00): box = position -/+ (r, r, 2r) with
// r = OFF_CGUNIT_SELECTION_RADIUS x the descriptor scale; ARGB colour from
// slot 11 OFF_CGOBJECT_VTBL_SELECTION_COLOR `__thiscall(obj, uint32 *argb)`;
// FUN_BUILD_YAW_MATRIX `__thiscall(obj, float m[16], const float pt[3])`;
// then inside a Gx state push/pop FUN_SELECTION_CIRCLE_STATE
// `__thiscall(obj)` and FUN_DRAW_DECAL `__fastcall(const float box[6],
// const uint32 *argb, const float m[16], float, uint32 flags)` with
// (0.5, 0x200122). The decal's vertices carry the full ARGB, and the
// circle blends (source alpha, one), so the alpha byte is its brightness.
FUN_CGOBJECT_FRAME_UPDATE = 0x00614A90,
// CGObject_C::SetLight / ClearLight — `void __thiscall(obj, int bit)`.
// SetLight ORs the bit into the object's light bits (+0xB8) and gives the
// model the light state's emissive colour (+0x178..+0x17A / 255); ClearLight
// clears it and blacks the emissive only when no bit is left. The engine
// uses bit 0 for the target (SelectTarget 0x493701 / ReleaseTarget
// 0x4939A7) and bit 1 for the mouseover (PublishWorldMouseover 0x492890,
// which first requires a model: OFF_CGOBJECT_OVERRIDE_MODEL, else
// OFF_CGOBJECT_MODEL). Decompiled; benilla-re objectbase#highlight-light-bits.
FUN_CGOBJECT_SET_LIGHT = 0x00614550,
FUN_CGOBJECT_CLEAR_LIGHT = 0x006144F0,
OFF_CGOBJECT_MODEL = 0xD8,
OFF_CGOBJECT_OVERRIDE_MODEL = 0xDC,
OFF_CGOBJECT_VTBL_SELECTION_COLOR = 0x2C,
OFF_CGUNIT_SELECTION_RADIUS = 0xCF0,
OFF_OBJECT_FIELD_SCALE_X = 0x10, // in the block at OFF_UNIT_GUID_PTR
FUN_BUILD_YAW_MATRIX = 0x00615070,
FUN_SELECTION_CIRCLE_STATE = 0x00614E00,
FUN_DRAW_DECAL = 0x006D7330,
VAR_CVAR_OBJECT_SELECTION_CIRCLE = 0x00C4DAF8, // CVar* of ObjectSelectionCircle
// CGUnit vtable slot (byte offset): GetSpellCastingTime `int __thiscall(int
// spellId)`, the unit's cast time for the spell in ms. The combat log's
// cast-start line drops a spell it gives 0 (0x0062B460 pushes the
// record's id and calls [vtbl+0xB4]); 4.3.4's GetSpellCastingTime.
OFF_CGUNIT_VTBL_GET_SPELL_CASTING_TIME = 0xB4,
// OBJECT_FIELD_TYPE, the type word, in the block at OFF_UNIT_GUID_PTR
// (the GUID is its +0): the hover dispatch reads `[[obj+8]+8]`.
OFF_OBJECT_FIELD_TYPE = 0x08,
// OBJECT_FIELD_ENTRY in the same block (UpdateField table 0x0083DB64:
// index 3): an item's template id, read by the combat log namer as
// `[[obj+8]+0xC]`.
OFF_OBJECT_FIELD_ENTRY = 0x0C,
// World line-segment collision test (client-side LoS core):
// `char __fastcall(const Vec3 *start /*ecx*/, const Vec3 *end /*edx*/,
// int unused, Vec3 *hitOut, float *tOut, uint32 flags)`.
// Returns nonzero if the ray hit world geometry; `*tOut` is the hit
// fraction along start→end (t in [0,1] ⇒ hit lies between the two
// points ⇒ blocked; t outside [0,1] or no hit ⇒ clear). `flags`
// selects geometry: 0x100111 = terrain + WMO (the LoS combo;
// 0x100171 also tests M2 doodads but crashes in some dungeons per
// UnitXP_SP3). Thin `__fastcall` shim that tail-calls the real
// intersect `FUN_0069BFF0`; verified in-binary and cross-checked
// against UnitXP_SP3's `CWorld_Intersect` (same VA + flags).
FUN_CWORLD_INTERSECT = 0x00672170,
// Collision-box height of a unit, read from its CMovement sub-struct
// (`[unit + OFF_UNIT_MOVEMENT_INFO_PTR]`) at `+0xB4`. Used as the
// eye-height offset for LoS so foot-to-foot traces don't false-block
// on terrain. (CMovement pointer offset 0x118 = OFF_UNIT_MOVEMENT_INFO_PTR.)
OFF_CMOVEMENT_COLLISION_BOX_HEIGHT = 0xB4,
// Quest list array inside the `+0xE68` sub-struct. 20 fixed
// slots of 0xC (12) bytes each — `questID` at slot+0x00, and
// some flags/state in the remaining 8 bytes. Walked by
// `Script_IsUnitOnQuest` (`0x004DFE10`) which iterates by byte
// offset over `[0, 0xF0)` with `0xC` stride and compares each
// entry's `+0` against the target questID. The engine writes
// this from `SMSG_QUESTGIVER_QUEST_DETAILS` / quest sync packets,
// so it covers any synced player-controlled unit (self + nearby
// party / raid in sync range), not just the local player.
//
// **Crash hazard**: same as visible items at `+0x118` — for NPCs
// (CGCreature_C objects) the `+0xE68` slot is uninitialized.
// Callers MUST gate on `UNIT_FLAG_PLAYER_CONTROLLED` before
// dereferencing. The engine's `Script_IsUnitOnQuest` is protected
// because its GUID-by-type filter (`FUN_00468460(0x10, ...)`)
// rejects non-player GUIDs upstream; `FUN_RESOLVE_UNIT_TOKEN`
// doesn't have that filter, so we gate explicitly.
OFF_CGPLAYER_INFO_QUEST_LIST = 0x28,
CGPLAYER_INFO_QUEST_LIST_STRIDE = 0xC,
CGPLAYER_INFO_QUEST_LIST_MAX = 20,
// Per-slot state byte and its "objectives complete" bit. Read by
// `FUN_QUEST_SLOT_ANNOUNCE_OBSERVER`, which compares it between the live
// slot and the observer's old-values snapshot (same 0xC layout) to decide
// whether to re-announce a quest that went from complete back to
// incomplete: `(live[7] & 2) == 0 && (old[7] & 2) != 0`.
OFF_QUEST_SLOT_STATE = 0x07,
QUEST_SLOT_STATE_COMPLETE = 0x02,
OFF_PLAYER_INFO_FLAGS = 0x08,
PLAYER_FLAG_AFK = 0x02,
PLAYER_FLAG_DND = 0x04,
// Guild-key field on the CGPlayer sub-struct. Verified by
// disassembling `Script_GetGuildInfo` at `0x004C9330`: after
// resolving the unit and checking the GUID-is-player bit, the
// function reads `mov ecx, [edi+0xE68]; mov ecx, [ecx+0x0C]` —
// if the value is 0, returns nil; otherwise passes it as the
// first arg to the guild cache lookup at `0x00560D30`. Two
// players in the same guild end up with the same value here
// (the cache key uniquely identifies a guild record), so
// `UnitIsInMyGuild` can compare this field between `"player"`
// and the input unit when the data is loaded — sidestepping the
// roster fetch requirement entirely for visible units.
//
// Populated immediately for the local player on guild join, and
// for any other player-controlled unit whose `+0xE68` sub-struct
// the engine has synced (party members, raid members, the
// current target, etc.). For unsynced units it reads 0.
OFF_PLAYER_INFO_GUILD_KEY = 0x0C,
// Guild roster — the per-character cache populated by
// SMSG_GUILD_ROSTER. `[VAR_GUILD_ROSTER_PTR]` is `GuildMember **`
// (a heap-allocated array of pointers), indexed `[0..total-1]` where
// total = `[VAR_GUILD_ROSTER_TOTAL_COUNT]`. Includes offline
// members — the "show offline" UI toggle controls what
// `GetNumGuildMembers()` returns by default and how the roster
// panel renders, but the underlying array always holds every
// member the server sent. Entries can still be NULL for other
// reasons (e.g. pending refresh), so null-check per entry.
//
// Verified by disassembling `Script_GetGuildRosterInfo` at
// `0x004D1200`:
// mov ecx, [0x00B73118] ; count
// cmp eax, ecx; jae bail
// mov edx, [0x00B72704] ; roster base
// mov edi, [edx+eax*4] ; entry = roster[idx]
// test edi, edi; je bail
// lea edx, [edi+8]; call lua_pushstring ; name at +0x08 (inline char[])
//
// Other GuildMember fields the engine pushes from the same loop:
// +0x38 int level
// +0x3C int classIndex
// +0x44 int rankIndex
// (We don't read these, but they're verified in the same function.)
//
// The companion `[0x00B7311C]` global is the online-only count
// (returned by `GetNumGuildMembers()` when called with no args).
// The roster array spans the full total — both counts share the
// same backing storage; online vs. total only affects the iteration
// bound the Lua API uses, not the underlying array.
VAR_GUILD_ROSTER_PTR = 0x00B72704,
VAR_GUILD_ROSTER_TOTAL_COUNT = 0x00B73118,
OFF_GUILD_MEMBER_NAME = 0x08,
// PackBagSlot — __fastcall(L, void **outInvMgr, int *outLinearSlot, int *outIsBank) → bool.
// Reads bagID at Lua stack[1] and slot at stack[2], validates them, and
// returns the inventory manager + linear slot ready to feed into GetItemBySlot.
//
// The fourth out-param is NOT unused (it was labelled `outUnused`
// here until the bank-autostore work): it is set to 1 for a bank
// position — bagID -1 (main bank) and bagIDs 5..10 (bank bags) —
// and left 0 otherwise, keyring included. `Script_UseContainerItem`
// is what consumes it: a non-zero flag is what makes right-clicking
// a bank item send `CMSG_AUTOSTORE_BANK_ITEM` instead of using it.
// This is the engine's own definition of "is this a bank slot".
FUN_PACK_BAG_SLOT = 0x004F9820,
// Equipped-bag container-GUID getter — `uint64 __fastcall(uint bagIndex0)`
// where `bagIndex0` is 0-based (Lua bagID 1..4 → 0..3; 4..9 are bank bags,
// gated on the bank-open globals). Returns the CGContainer GUID of the bag
// equipped in that slot, or 0 if none. This is the internal PackBagSlot
// uses to resolve bags 1..4: get the bag GUID here, resolve the container
// via FUN_OBJECT_RESOLVE_BY_GUID(TYPEMASK_CONTAINER, guid), then call the
// container's vtable[+OFF_CONTAINER_GET_INVENTORY] to get the inventory
// object GetItemBySlot indexes. Lets us enumerate bag contents in pure C++
// without PackBagSlot's Lua-stack coupling. (Reads GUID arrays at
// 0x00BDD060 lo / 0x00BDD064 hi, stride 8.)
FUN_GET_EQUIPPED_BAG_GUID = 0x004F93E0,
// CGContainer vtable slot (byte offset into the vtable) whose method
// returns the container's inventory object — `void* __thiscall(container)`.
// The inventory object's slot count lives at its +0x00 (OFF_INVMGR_SLOT_COUNT).
OFF_CONTAINER_GET_INVENTORY = 0x10,
// Backpack (bagID 0) linear-slot base in the player invMgr GUID/item
// arrays: a 1-based backpack slot S maps to linear (S - 1) + 23. Matches
// PackBagSlot's `*param_3 += 0x17` for the backpack branch.
BACKPACK_LINEAR_BASE = 23,
// Player inventory manager layout — used for direct GUID-array reads
// that bypass `GetItemBySlot`'s bank gate at `0x006228C1`.
// +0x00 uint32 max slot count
// +0x04 uint64* pointer to a flat GUID array, indexed by linear slot
// (8 bytes per slot — low dword + high dword)
// +0x10 uint8 "bank-aware mode" flag (engine-internal; gates the
// slot-range checks in `GetItemBySlot`'s validation
// path)
// Slot ranges, matching `PackBagSlot`'s linearization:
// 0..22 equipment / paperdoll
// 23..38 backpack (16 slots)
// 39..62 main bank (24 slots)
// 63..68 bank bag SLOTS (the bag items themselves; the bag CONTENTS
// live in each equipped bag's own invMgr, reachable via the
// bag's vtable +0x10)
// 81+ keyring
//
// **Bank slots are populated from server data at login** (verified
// empirically on Turtle WoW: fresh login + cleared WDB folder shows
// bank GUIDs already populated in slots 39..62, with the gate at
// `VAR_BANK_GATE_GUID` = 0). The gate doesn't hide data missing —
// it hides data that's present from boot. Reading the GUID array
// directly recovers it without ever opening the bank window.
OFF_INVMGR_GUID_ARRAY = 0x04,
INVMGR_BACKPACK_FIRST_SLOT = 23,
INVMGR_BACKPACK_LAST_SLOT = 38,
INVMGR_BANK_MAIN_FIRST_SLOT = 39,
INVMGR_BANK_MAIN_LAST_SLOT = 62,
INVMGR_BANK_BAG_FIRST_SLOT = 63,
INVMGR_BANK_BAG_LAST_SLOT = 68,
// Keyring (Lua bagID -2). No LAST constant: the engine bounds this
// range against the invMgr's own slot count (OFF_INVMGR_SLOT_COUNT)
// rather than a fixed size, since keyring capacity grows with level.
// Base confirmed from FUN_PACK_BAG_SLOT, which maps Lua bagID -2 to
// `slot - 1 + 0x51`.
INVMGR_KEYRING_FIRST_SLOT = 81,
// Engine's `ObjectMgr::Get`-style resolver — given a type and GUID,
// returns the resolved CGObject pointer (or null). Same function the
// engine itself uses inside `GetItemBySlot` (called at `0x00622904`)
// and `PackBagSlot` (called at `0x004F98E2`). We invoke it directly
// for bank slots so we sidestep the banker-GUID gate that
// `GetItemBySlot` applies for slots 39..68 — the GUIDs in
// `invMgr+0x04` are populated at login, only the gate gets toggled
// by bank-window state.
//
// __fastcall(int type, const char *debugName, u32 guidLo,
// u32 guidHi, int priority) → void *
//
// Type values: 2 = item (returns CGItem*), 4 = container/bag
// (returns CGContainer*). Engine passes `"ItemMgr"` as debugName
// and `0x172` as priority for both call sites we've decoded. Some engine
// sites type it as `(u32 typeMask, void *unused, u64 guid, int)` —
// ABI-equivalent (the u64 occupies the same two stack dwords as
// guidLo/guidHi). All our callers go through `Object::ByGuid`
// (object/Resolve.h), which wraps this single address.
FUN_OBJECT_RESOLVE_BY_GUID = 0x00468460,
// The type arg is a bitmask of object-type bits (see the TYPEMASK_*
// block below), not an enum index.
// `CGObject::GetName` — returns the display-name `const char *` for
// a resolved CGObject (CGUnit / CGPlayer / CGCreature). Internally
// does a NameCache lookup for players and reads the creature-info
// cache for NPCs; falls back to `"UNKNOWNOBJECT"` / `"Unknown Being"`
// when neither resolves. The same path `FUN_00609370` (the wrapped
// "name + PvP-rank decoration" helper used by the SetUnit tooltip
// builder) calls internally.
//
// __thiscall const char *(void *obj, int *outFlags /* may be 0 */)
//
// Caller-owned `outFlags` receives metadata about the lookup; we
// pass `nullptr` since we just want the name.
FUN_OBJECT_GET_NAME = 0x00609210,
// `CGGameObject_C::GetName` — gameobject-specific name getter.
// Returns `*(obj+0x214)+0x08` (the cached GameObjectStats_C record's
// name field) if the record has loaded, or the engine's empty-string
// sentinel `DAT_00882748` otherwise. Used by the hover tooltip
// populator at FUN_0052AA20.
//
// __fastcall const char *(void *gameObject)
//
// The polymorphic `FUN_OBJECT_GET_NAME` above is unit-cache-only
// (routes through NameCache / creature cache) and returns the
// "UNKNOWNOBJECT" sentinel for gameobjects.
FUN_GAMEOBJECT_GET_NAME = 0x005F8100,
// Bank gate. The engine writes the active banker NPC's GUID here
// when the bank window opens (8-byte qword) and zeroes it on close.
// `GetItemBySlot` returns null for slots 39..68 if this GUID is zero,
// even though the slot data in `invMgr+0x04` remains populated.
// Bypassed in the direct-read bank path; informational only otherwise.
VAR_BANK_GATE_GUID = 0x00BDD038,
// `Script_UseContainerItem` Lua C function — `__fastcall(void *L)`.
// Reads bagID at Lua stack[1] and slot at stack[2], dispatches to the
// engine's item-use machinery (same path the secure
// `tooltip:Click()` / `UseContainerItem(...)` flow takes from
// Lua). We invoke this from `C_Container.UseHearthstone` after
// locating the hearthstone in bags.
FUN_SCRIPT_USE_CONTAINER_ITEM = 0x004FA0E0,
// Vanilla 1.12 hearthstone is always itemID 6948 and uses spell 8690
// ("Hearthstone" - 10-second cast, teleport to bind). Modern WoW
// recognizes many hearthstone-equivalent toys (Garrison, Dalaran,
// etc.) but those items don't exist in 1.12. Custom servers
// (Turtle WoW and similar) sometimes ship alternate hearthstone
// items that reuse spell 8690 as their on-use, so the hearthstone
// matcher OR's `itemID == HEARTHSTONE_ITEM_ID` against
// `OnUseSpellIDForItemID(itemID) == HEARTHSTONE_SPELL_ID` to catch
// both shapes.
HEARTHSTONE_ITEM_ID = 6948,
HEARTHSTONE_SPELL_ID = 8690,
// `Script_PickupContainerItem` Lua C function — `__fastcall(void *L)`.
// Reads bagID at Lua stack[1] and slot at stack[2]; if an item is
// present there, it goes onto the cursor (or, if cursor already holds
// an item, swaps with the bag slot). Used by `EquipItemByName` to
// pick up the source item before dispatching to the equip helpers.
FUN_SCRIPT_PICKUP_CONTAINER_ITEM = 0x004F9B30,
// Container-content cursor-pickup PRIMITIVE — the plain-pickup branch
// inside `Script_PickupContainerItem`'s state machine, called directly
// (no Lua stack, no state-machine modes).
// void __fastcall(uint linearSlot, int count, uint itemGuidLo,
// uint itemGuidHi, uint containerGuidLo,
// uint containerGuidHi, int flag)
// Self-resolves the player, sets the cursor-state globals
// (VAR_CURSOR_ITEM_GUID_*, cursor type = 1) and fires the cursor-update
// event itself. Does NOT apply the cursor-empty / item-lock guards the
// Script wrapper does — callers replicate those (Item::Cursor::PickupBagItem).
FUN_CURSOR_PICKUP_ITEM = 0x00494B60,
// `CGItem::UseItem` — the engine's actual "use this item" primitive.
// It's the fallback dispatch in `Script_UseContainerItem` (the call
// site at 0x004FA430 after every special-cursor-mode branch is
// skipped), and the function `Script_UseContainerItem` ends up at
// for normal hearthstone-style / potion / food / scroll use. We
// call it directly from `UseItemByName` so we don't pay a
// Lua-stack roundtrip just to re-find the item the engine already
// points us at.
//
// Internally dispatches by item flags / fields:
// - off-target-pickup items (flag 0x200) → FUN_005EDEA0/FUN_005EDD60
// - bind-on-pickup confirmation needed → FUN_004E32E0
// - food items (flag 0x4) → FUN_005EDC80
// - quiver/ammo (flag 0x2000) → FUN_005EEF40
// - default (potions, hearthstone, scrolls, …) → FUN_006E5A90
//
// __thiscall uint(CGItem *item, const uint64_t *targetGuid,
// int flag)
//
// `targetGuid` is a pointer to a 64-bit GUID — for self-use items
// the engine substitutes the player itself even if a different
// target is passed, so passing zero (no target) is fine for most
// items. `flag` is 0 in every Script_UseContainerItem call site.
FUN_ITEM_USE = 0x005D8D00,
// `CGPlayer::AutoEquipCursorItem` — `__thiscall(CGPlayer *this, int flag)`.
// The engine-internal helper that `Script_AutoEquipCursorItem`
// (`0x0048A040`) is a thin wrapper around: that wrapper just
// resolves the local player and calls this with `flag = 0`.
// Equips the cursor item to its natural slot (engine picks based
// on inventory type) and clears the cursor. No-op if cursor is
// empty.
FUN_AUTO_EQUIP_CURSOR_ITEM = 0x005E1480,
// Per-item descriptor block (object/item-field array) lives at this offset
// on the CGItem instance.
OFF_ITEM_DESCRIPTOR = 0x114,
// Within the descriptor, ITEM_FIELD_FLAGS is at +0x3C (a single dword).
// Bit 0 = soulbound. Confirmed empirically by dumping descriptor bytes
// for a worn-and-bound item.
OFF_DESCRIPTOR_FLAGS = 0x3C,
ITEM_FLAG_SOULBOUND = 0x01,
// Within the descriptor, the item's random-property index
// (ITEM_FIELD_RANDOM_PROPERTIES_ID) is at +0x98 — this is the live
// instance's suffix, indexing ItemRandomProperties.dbc the same way
// StatAccum::ApplyRandomSuffix expects. Derived from the item-tooltip
// builder's `[descriptor + 0x26*4]` read (FUN_0052B650 @ ~0x52b7xx),
// which feeds it straight into `ItemRandomProperties[idx]`.
OFF_DESCRIPTOR_RANDOM_PROPERTY = 0x98,
// Bit 2 — instance is "unlocked", i.e. the lock referenced by
// `ItemStats.LockID` has been opened (rogue Pick Lock, key item,
// etc.). For unlockable items, the engine gates the
// `<Right Click to Open>` tooltip on this bit: a fresh lockbox
// has it clear (priest sees no openable affordance), a picked
// lockbox has it set. Items with `LockID == 0` (clams, simple
// sacks) never need the bit.
ITEM_FLAG_UNLOCKED = 0x04,
// Bit 3 — instance is gift-wrapped. The tooltip builder pairs it with
// `ITEM_FLAG_WRAPPER` (`0x52E31D`) for `<Right Click to Open>`;
// GetInventoryItemBroken (`0x4C8628`) excludes it from "broken", and
// the auction-sell check (`0x4CE4B1`) rejects it.
ITEM_FLAG_WRAPPED = 0x08,
// Client-side "in-transaction" lock — set when the engine puts an
// item on the cursor / mail-attaches it / trade-attaches it, cleared
// when the SMSG_UPDATE_OBJECT post-processor (`FUN_005D8440`)
// confirms the transaction OR a cursor-cancel sweep
// (`FUN_00495460`) clears all locks.
//
// This is NOT in m_objectFields — it's a per-CGItem instance flag
// at byte offset 0x314, lowest bit (mask 0x01). Bit 1 of the same
// dword is a separate "cache-coherence" flag set by the SMSG
// post-processor. We only expose bit 0 here.
//
// The matching setter / clearer the engine uses:
// FUN_004953E0(guidLo, guidHi) — set: `[item+0x314] |= 1` + fire ITEM_LOCK_CHANGED
// FUN_00495420(guidLo, guidHi) — clear: `[item+0x314] &= ~1` + fire ITEM_LOCK_CHANGED
// FUN_00495460() — sweep: walk all bags/items, clear all locks
//
// Vanilla fires `ITEM_LOCK_CHANGED` (engine event 0xBC = 188) on
// every set / clear; no payload.
OFF_ITEM_CLIENT_LOCK = 0x314,
ITEM_CLIENT_LOCK_BIT = 0x01,
// `__stdcall(uint guidLo, int guidHi)` — sets bit 0 at `[item+0x314]`
// for the resolved item and fires ITEM_LOCK_CHANGED. Mirror of
// FUN_ITEM_UNLOCK_BY_GUID below. Engine's normal trigger is the
// optimistic-lock step inside pickup/equip/attach paths (cursor
// packets are sent immediately after).
FUN_ITEM_LOCK_BY_GUID = 0x004953E0,
// `__stdcall(uint guidLo, int guidHi)` — clears bit 0 at
// `[item+0x314]` for the resolved item and fires ITEM_LOCK_CHANGED.
// Resolves the item by GUID internally via FUN_00468460; safe to
// call with the GUID of an item that's already gone (event still
// fires but no-op on state). The engine's normal trigger for this
// is the SMSG_UPDATE_OBJECT post-processor (`FUN_005D8440`) when
// the server confirms a transaction.
FUN_ITEM_UNLOCK_BY_GUID = 0x00495420,
// `__cdecl()` — walks every CGItem the engine knows about (bag
// containers + their contents) and clears the lock bit on each.
// Fires a single ITEM_LOCK_CHANGED at the end. The engine itself
// only calls this from the PLAYER_LEAVING_WORLD cleanup path
// (`FUN_005FEF70` → fires event 0x112 right after); we expose it
// to addons as a stuck-lock recovery primitive.
FUN_ITEM_UNLOCK_ALL = 0x00495460,
// ITEM_FIELD_STACK_COUNT — single dword. Verified by decoding
// `Script_GetContainerItemInfo` (`0x004F9670`): after resolving the
// descriptor, `mov eax, [esi+0x114]; fild [eax+0x20]` is the count
// return. Field index 0x8 in 1.12's item-field layout, which puts
// STACK_COUNT *before* the contained/creator GUIDs (0x9..0xE) —
// different from the more common documented layout that places
// STACK_COUNT after them. Trust the binary, not external docs.
OFF_DESCRIPTOR_STACK_COUNT = 0x20,
// ITEM_FIELD_SPELL_CHARGES[0] — first of five signed dwords. Field
// indices 10..14 (fields 8..9 are STACK_COUNT and DURATION; field 15
// is FLAGS at +0x3C, which gives a tight sandwich around the
// SPELL_CHARGES range). Derived from the descriptor-field name table
// builder at `FUN_0047f840`, which consumes a list of `{ name_ptr,
// ?, count, ?, ? }` entries starting at `0x0083a328` (14 items) —
// summing the `count` field in declaration order gives each name's
// starting dword index. STACK_COUNT/FLAGS/DURABILITY/MAX_DURABILITY
// landing on their known offsets cross-checks the derivation. The
// tooltip "X Charges" text in `FUN_0052b650` reads from the
// *enchantment*-charges range at +0x48 (slot N + 0x8) which is a
// different field (ITEM_FIELD_ENCHANTMENT, fields 16..36).
//
// Value is signed: positive = rechargeable (wand recovers charges
// on use? no — they decrement; positive means "doesn't destroy on
// last use"). Negative = single-use, destroyed when count hits 0.
// `GetItemCount(includeUses=true)` uses abs() for the multiplier.
OFF_DESCRIPTOR_SPELL_CHARGES_0 = 0x28,
// ITEM_FIELD_ENCHANTMENT block (fields 16..36, per the +0x48
// enchant-charges note above) — 7 enchant slots, 3 dwords each
// `{enchantID, duration, charges}`. Slot 0 = permanent enchant,
// slot 1 = temporary (weapon oils / sharpening stones). The
// enchant ID indexes SpellItemEnchantment.dbc. Block base = field
// 16 = +0x40 (field 15 FLAGS at +0x3C precedes it); slot stride
// 0x0C, enchant ID at slot+0x00. Used by spell/BonusDamage.cpp to
// fold enchant-granted spell power into GetSpellBonusDamage, and by
// item/WeaponEnchant.cpp to read the temporary slot.
OFF_DESCRIPTOR_ENCHANTMENT_ID = 0x40,
DESCRIPTOR_ENCHANTMENT_SLOT_STRIDE = 0x0C,
// Within one slot, following the enchant ID at slot+0x00.
DESCRIPTOR_ENCHANTMENT_DURATION_DELTA = 0x04,
DESCRIPTOR_ENCHANTMENT_CHARGES_DELTA = 0x08,
// Slot 1 of the block — poisons, weapon oils, sharpening stones, the
// shaman imbues. The timed enchant `GetWeaponEnchantInfo` measures.
DESCRIPTOR_ENCHANTMENT_SLOT_TEMPORARY = 1,
// The CGItem's client-side enchantment expiry clock, set from
// SMSG_ITEM_ENCHANT_TIME_UPDATE: `uint32_t __thiscall(CGItem *item,
// int slot)` → ms left (`expiry − now` while positive, 0 for an unset or
// reached expiry, wrap-safe `sub; jns`). Expiries live at
// `item+0x324 + 4·slot`. Verified by disassembly. 1.12's own
// `Script_GetWeaponEnchantInfo` (`0x4c9790`) reads the time left here and
// uses the descriptor duration field only as a nil gate — the field is
// not a live countdown (4.3.4's `GetEnchantmentTimeLeft` is the same).
FUN_ITEM_ENCHANTMENT_TIME_LEFT = 0x005D9D00,
// ITEM_FIELD_DURABILITY (current) and ITEM_FIELD_MAXDURABILITY (max) live
// adjacent to each other in the descriptor as plain dwords. Verified in
// `Script_GetInventoryItemBroken` (`0x004C8590`): after resolving the
// descriptor, it reads `[ecx+0xA4]` for max and `[eax+0xA0]` for cur,
// and treats the item as broken when `max > 0 && cur == 0`. Items with
// no durability concept (consumables, materials) have both fields 0.
OFF_DESCRIPTOR_DURABILITY = 0xA0,
OFF_DESCRIPTOR_MAX_DURABILITY = 0xA4,
// Per-instance "readable text" id (letters / mail-scroll items carry a
// server-assigned text id here). Drives the `readable` return of
// `Script_GetContainerItemInfo` (`0x004F9670`): at `0x004F97C1` it reads
// `[descriptor+0x9C]` and, when non-zero, reports the slot as readable
// even when the static ItemStats page-text is 0. Field index 0x27.
OFF_DESCRIPTOR_READABLE_TEXT_ID = 0x9C,
// Per-item repair-cost helper used by Script_GameTooltip_SetInventoryItem
// (3rd return value). __fastcall(ecx = CGItem *) -> int copperCost.
// Returns 0 for null/broken/no-durability/fully-repaired items, otherwise
// the cost in copper, with the merchant discount applied IFF a merchant
// window is currently open.
//
// Internals: FUN_005DA330 is the raw calculator; FUN_004FAF30 is the
// discount wrapper that calls it. The raw side:
// 1. Look up the item's ItemStats record via DBCache_ItemStats_C_GetRecord
// (callback=NULL → returns NULL for uncached items).
// 2. Index DurabilityCosts.dbc by `subClass` to get the per-class row.
// 3. Branch on inventoryType: weapon (2) uses cols at row+4..row+0x54,
// armor (4) uses cols at row+0x58..row+0x78.
// 4. Multiply by DurabilityQuality.dbc's quality multiplier (indexed
// by `quality * 2 + 1`).
// 5. Round to nearest int; clamp 0 → 1 if there was any cost at all.
//
// The discount wrapper:
// - Resolves the local player object via FUN_00468550 (returns the
// player's GUID from [0x00B41414 + 0xC0]).
// - Resolves the current-merchant object via the GUID stored in
// DAT_00BDDFA0 / DAT_00BDDFA4. Those globals are set by
// FUN_004FACF0 on SMSG_LIST_INVENTORY (merchant frame opens) and
// zeroed by FUN_004FAC50 when the merchant frame closes.
// - If both lookups succeed, calls FUN_00612B80(merchant, player)
// to compute (factionDiscount + pvpRankDiscount). Faction
// contribution: 0% below Friendly, +base% (5%) at Friendly and
// above. PvP rank contribution: +5% for PvP rank > 5
// (Sergeant Major+), another +5% for rank > 7
// (Knight-Lieutenant+).
// - Otherwise (no merchant context) the multiplier stays at 1.0
// and the raw cost is returned undiscounted.
//
// So this helper produces the merchant's displayed cost ONLY when
// the player has a vendor open; called from anywhere else (HUD
// refresh, idle check) it returns the raw base cost.
FUN_ITEM_REPAIR_COST = 0x004FAF30,
// CGItem has TWO descriptor-like pointers and they hold different things:
// +0x114 = m_objectFields (the UpdateField array we read FLAGS from at
// +0x3C). For item instances, OBJECT_FIELD_ENTRY in this array
// is empirically 0 — don't try to read itemID from here.
// +0x08 = a separate identification block. Contains the item's GUID at
// +0x00 (qword) and the itemID at +0x0C (dword).
// The canonical "look up the cache record for this item" sequence is:
// item = GetItemBySlot(invMgr, slot)
// id = *(uint32_t *)(*(void **)(item + 0x08) + 0x0C)
// _GetRecord(cache, id, ...)
// Verified at 0x004C8B1F-2D (inventory→cache lookup right after a
// GetItemBySlot call). The same shape appears in many other inventory
// sites that call _GetRecord.
OFF_ITEM_INSTANCE_BLOCK = 0x08,
OFF_INSTANCE_BLOCK_ITEM_ID = 0x0C,
// Item stats cache (the client-side cache of ItemSparse-style records that
// gets populated by SMSG_ITEM_QUERY_SINGLE_RESPONSE). The cache instance
// lives directly at this VA — `_GetRecord`'s `this` argument is the literal
// address `0xC0E2A0`, not a pointer to it. See Script_GetItemInfo at
// 0x0048E070 which calls `mov ecx, 0xC0E2A0` before the call.
VAR_ITEMDB_CACHE = 0x00C0E2A0,
// `Script_GetItemInfo` Lua C function. We hook this to auto-warm the
// item cache on miss — vanilla 1.12's stock behavior is "return nil
// for uncached items and don't fire any query"; modern WoW (5.x+)
// auto-fires the load and emits `GET_ITEM_INFO_RECEIVED` when data
// arrives. The hook makes `GetItemInfo(uncached_id)` return nil
// first call but kick off the query, so subsequent calls work.
FUN_SCRIPT_GET_ITEM_INFO = 0x0048E070,
// ItemStats_C *(__thiscall *)(void *cache, uint32_t itemID,
// const uint64_t *guid /*may point to zero*/,
// void *callback, void *userData,
// bool requestIfMissing).
// With `requestIfMissing=false`, returns NULL if not in cache (no server
// round-trip) — exactly the "instant" semantics we want.
FUN_DBCACHE_ITEMSTATS_GET_RECORD = 0x0055BA30,
// Item-cache response handler — the function called from
// `0x00555140` (success path for `SMSG_ITEM_QUERY_SINGLE_RESPONSE`)
// and `0x00555160` (failure path). Parses one or more itemIDs out
// of the packet, looks up (or creates) the cache entry per ID,
// copies the item data block via `FUN_007c9640` to `entry+0x18`,
// sets `[entry+0x1F0]=1` (the loaded byte), then walks the entry's
// pending callback list at `[entry+0x1FC]` and invokes each with
// `(userData, success)`. High-bit-on itemID in the packet signals
// a per-item failure for the batch.
//
// We hook this to observe any item-cache fill the engine performs
// — covers the engine's natural inventory prefetch and any
// addon-triggered queries without having to register our own
// engine callbacks. Lets `RequestLoadItemData` be purely passive:
// we track itemIDs, the engine (or whoever) issues the query, we
// see the fill via this hook and fire `ITEM_DATA_LOAD_RESULT`.
//
// Signature: `__thiscall(void *cache, void *packetReader, int flag)`.
// `cache` is the same `VAR_ITEMDB_CACHE` we already use.
FUN_ITEMSTATS_CACHE_RESPONSE = 0x0055BDB0,
// DBCache<T> object fields (benilla-re dbcache#cache-objects-and-nodes,
// read by the query send in FUN_DBCACHE_ITEMSTATS_GET_RECORD at
// 0x0055BB18 / 0x0055BB49): the query opcode the cache sends for a miss
// (0x56 CMSG_ITEM_QUERY_SINGLE for the item cache), and the owner flag
// that appends the caller's GUID to that query.
OFF_DBCACHE_QUERY_OPCODE = 0x30,
OFF_DBCACHE_OWNER_FLAG = 0x38,
// ItemStats_C field offsets we read. Full struct layout in
// VanillaHelpers's `Game.h` (`struct ItemStats_C`); we only need these.
OFF_ITEMSTATS_CLASS = 0x00,
OFF_ITEMSTATS_SUBCLASS = 0x04,
// `char *m_name[4]` per VanillaHelpers's `struct ItemStats_C`. Only
// m_name[0] is the primary localized item name (e.g., "Linen Cloth");
// m_name[1..3] are random-property suffix slots that are typically
// null for non-randomized items. Used by `C_Item.IsEquippedItem`'s
// name-string match form.
OFF_ITEMSTATS_NAME = 0x08,
OFF_ITEMSTATS_DISPLAY_INFO_ID = 0x18,
OFF_ITEMSTATS_QUALITY = 0x1C, // u32 — 0=Poor … 5=Legendary
// Item-quality color-prefix table. Array of 7 `const char *`
// pointers, indexed by quality 0..6 (POOR..ARTIFACT); each
// points to a `"|cffRRGGBB"` markup string used by the engine's
// own link builder. Discovered via the inner color helper at
// `0x0052AD90` which does `(&table)[quality]` with a fallback
// to white (`"|cffffffff"`, the index-1 entry) for quality > 6.
// Quality 7 (Heirloom) doesn't exist in vanilla; consumers
// should mirror the engine's fallback for safety.
VAR_QUALITY_COLOR_TABLE = 0x00854124,
QUALITY_COLOR_TABLE_SIZE = 7,
// `m_flags` — item-class flags bitfield. Bits we read:
// `ITEMSTATS_FLAG_OPENABLE` (`0x4`, bit 2): freely right-click-
// openable container (sack, clam, simple chest, quest box).
// The tooltip line `<Right Click to Open>` (`ITEM_OPENABLE`
// string) renders for items with this bit set, gated on the
// instance's `ITEM_FLAG_UNLOCKED` bit when the item also
// carries a non-zero LockID.
// `ITEM_FLAG_WRAPPER` (`0x200`) is the tooltip's second openable
// arm, gated on the instance's `ITEM_FLAG_WRAPPED` bit.
// Other documented bits (`0x1` = BIND_ON_PICKUP, `0x2` = CONJURED,
// `0x10` = LOOTABLE, etc.) live in the same field.
// Reader at `0x0052E323` (the tooltip-builder's openable branch in
// `FUN_0052B650`) does `(ItemStats[+0x20] & 0x4)` against this
// field; verified by checking the field offset matches the
// 5-DWORD-per-row layout `puVar4[8]` resolves to in the decompile.
OFF_ITEMSTATS_FLAGS = 0x20,
ITEMSTATS_FLAG_OPENABLE = 0x4,
OFF_ITEMSTATS_SELL_PRICE = 0x28,
// `m_lockID` — references `Lock.dbc`. Zero means "no lock"; any
// nonzero value gates the openable interaction on the player
// successfully unlocking the item (instance flag bit 2 in
// `ITEM_FIELD_FLAGS`). Same field the tooltip builder reads as
// `ItemStats[+0x1AC]` (puVar4[0x6b]) when deciding whether the
// `<Right Click to Open>` line should require the lock to be
// picked first.
OFF_ITEMSTATS_LOCK_ID = 0x1AC,
OFF_ITEMSTATS_INVENTORY_TYPE = 0x2C,
OFF_ITEMSTATS_ITEM_LEVEL = 0x38, // u32 — base ilvl from ItemSparse
// `m_stackable` — max stack size for this item type (1 for non-
// stackable; 5/20/200/etc. for stackable). The instance-level
// current stack count is a different field (`OFF_DESCRIPTOR_STACK_COUNT`
// at +0x20 on the CGItem's m_objectFields descriptor).
OFF_ITEMSTATS_STACKABLE = 0x60,
// Bag-only fields. `m_containerSlots` (slot count) and `m_bagFamily`
// (the BagFamily bitfield — quiver=1, ammo pouch=2, soul bag=4 in
// vanilla) live deep in the record. Offsets derived from
// VanillaHelpers's `struct ItemStats_C` (full layout, sizeof =
// ~0x1D4); cross-check by counting fields up through `m_stackable`
// at +0x60 (which we already use) — `m_containerSlots` is the next
// u32 at +0x64. `m_bagFamily` is the last u32, at +0x1D0.
OFF_ITEMSTATS_CONTAINER_SLOTS = 0x64,
// `m_bagFamily` is a **raw 1-based ID** in 1.12, not the modern
// bitmask. Vanilla data: arrow=1, bullet=2, soul shard=3, herb=6,
// etc. Wrath flipped the encoding to `1 << (ID-1)` (so soul shard
// became 4, herb became 32, …) and addons from Wrath onward expect
// the bitmask form. Reader functions must convert via
// `bitmask = id ? (1 << (id - 1)) : 0` to maintain modern API
// parity. Verified empirically on Turtle WoW: Soul Shard (6265)
// returns raw 3 here, which is `1 << 2 = 0x4` in modern encoding.
//
// Field offset verified by decoding the engine's own
// `GetItemBagFamily(itemID)` helper at `0x005DA050` — calls
// `_GetRecord` (`0x0055BA30`) on the item cache (`0x00C0E2A0`),
// tests the result for null, then `mov eax, [eax+0x1D0]; ret`.
// (Found via xref scan for `mov reg, [reg+0x1D0]` in `.text`.)
OFF_ITEMSTATS_BAG_FAMILY = 0x1D0,
// `m_itemSet` — ItemSet.dbc row ID for items that belong to an
// armor / equipment set. 0 for items not part of any set.
// Position derived by counting fields up through `m_block` per
// VanillaHelpers's `ItemStats_C` (m_block at +0x1BC; m_itemSet
// is the next u32). Verified against `m_bagFamily` already
// confirmed at +0x1D0 — m_itemSet sits 16 bytes earlier with
// `m_maxDurability`, `m_area`, `m_map` between the two.
OFF_ITEMSTATS_ITEM_SET = 0x1C0,
// Item-spell tables — five parallel arrays starting at +0x11C in
// each `ItemStats_C` record. Each item has up to 5 spell slots
// (vanilla server data uses ≤2 for most items: e.g. Hearthstone
// 6948 uses slot 0 for spell 8690 with trigger 0 = `ON_USE`).
//
// Field offsets computed by summing struct members in
// VanillaHelpers's `ItemStats_C` definition; verified empirically
// against the Hearthstone case (spellID 8690, trigger 0).
//
// Trigger enum (CMaNGOS `ITEM_SPELLTRIGGER_*`):
// 0 = ON_USE (potions, trinkets, scrolls, hearthstone)
// 1 = ON_EQUIP (passive proc auras on equipped gear)
// 2 = CHANCE_ON_HIT (weapon proc effects)
// 4 = SOULSTONE (soulstone-style on-death effect)
// 5 = ON_USE_NO_DELAY
// 6 = LEARN_SPELL (recipe items)
//
// `GetItemSpell` matches modern WoW semantics — returns the
// ON_USE (trigger=0) entry only, ignoring ON_EQUIP procs / weapon
// procs / recipes. Walks all 5 slots since the ON_USE entry isn't
// always at index 0 (some Turtle WoW custom items put it later).
OFF_ITEMSTATS_SPELL_ID = 0x11C, // u32[5] — spell ID per slot
OFF_ITEMSTATS_SPELL_TRIGGER = 0x130, // u32[5] — trigger code per slot
OFF_ITEMSTATS_SPELL_CHARGES = 0x144, // i32[5] — charges per slot; negative = item is used up when they run out (ActionSlotIsConsumable 0x004E5250)
OFF_ITEMSTATS_SPELL_COOLDOWN = 0x158, // u32[5] — cooldown ms per slot
OFF_ITEMSTATS_SPELL_CATEGORY = 0x16C, // u32[5] — category (groups shared cooldowns)
OFF_ITEMSTATS_SPELL_CATEGORY_CD = 0x180, // u32[5] — category cooldown ms
ITEMSTATS_SPELL_SLOT_COUNT = 5,
ITEM_SPELLTRIGGER_ON_USE = 0,
// `ItemStats_C.m_maxCount` — max number of this item the player can
// hold in inventory at once. `0` = unlimited, `1` = unique, higher
// values are caps like "5x bandage type". Vanilla 1.12 doesn't have
// modern "unique-equipped category" semantics; this is the only
// uniqueness signal the client has. Derived by summing struct
// members in VanillaHelpers's `ItemStats_C` definition.
OFF_ITEMSTATS_MAX_COUNT = 0x5C,
// Remaining `ItemStats_C` fields used by `C_Item.GetItemData(ByID)`.
// Offsets derived from VanillaHelpers's `struct ItemStats_C`
// definition (`C:\Git\VanillaHelpers\src\Game.h`), sized to match
// the verified anchors above (`+0x60 m_stackable`, `+0x1D0
// m_bagFamily`, `+0x1AC m_lockID`, etc.). Block follows the same
// ordering as the struct so it's easy to cross-reference.
OFF_ITEMSTATS_BUY_PRICE = 0x24, // u32
OFF_ITEMSTATS_ALLOWABLE_CLASS = 0x30, // u32 — class bitmask, -1 = all
OFF_ITEMSTATS_ALLOWABLE_RACE = 0x34, // u32 — race bitmask, -1 = all
OFF_ITEMSTATS_REQUIRED_LEVEL = 0x3C, // u32
OFF_ITEMSTATS_REQUIRED_SKILL = 0x40, // u32 — SkillLine.dbc row
OFF_ITEMSTATS_REQUIRED_SKILL_RANK = 0x44, // u32
OFF_ITEMSTATS_REQUIRED_SPELL = 0x48, // u32 — Spell.dbc row
OFF_ITEMSTATS_REQUIRED_HONOR_RANK = 0x4C, // u32
OFF_ITEMSTATS_REQUIRED_CITY_RANK = 0x50, // u32
OFF_ITEMSTATS_REQUIRED_FACTION = 0x54, // u32 — Faction.dbc row
OFF_ITEMSTATS_REQUIRED_FACTION_RANK = 0x58, // u32 — Friendly/Honored/etc.
OFF_ITEMSTATS_STAT_TYPE = 0x68, // u32[10] — ItemModType enum per slot
OFF_ITEMSTATS_STAT_VALUE = 0x90, // i32[10] — magnitude per slot
ITEMSTATS_STAT_SLOT_COUNT = 10,
OFF_ITEMSTATS_DAMAGE_MIN = 0xB8, // f32[5]
OFF_ITEMSTATS_DAMAGE_MAX = 0xCC, // f32[5]
OFF_ITEMSTATS_DAMAGE_TYPE = 0xE0, // u32[5] — schools per damage slot
ITEMSTATS_DAMAGE_SLOT_COUNT = 5,
OFF_ITEMSTATS_ARMOR = 0xF4, // u32
OFF_ITEMSTATS_RES_HOLY = 0xF8, // u32 (six resists contiguous)
OFF_ITEMSTATS_RES_FIRE = 0xFC,
OFF_ITEMSTATS_RES_NATURE = 0x100,
OFF_ITEMSTATS_RES_FROST = 0x104,
OFF_ITEMSTATS_RES_SHADOW = 0x108,
OFF_ITEMSTATS_RES_ARCANE = 0x10C,
OFF_ITEMSTATS_DELAY = 0x110, // u32 — weapon swing time (ms)
OFF_ITEMSTATS_AMMO_TYPE = 0x114, // u32 — ammo subclass for ranged
OFF_ITEMSTATS_RANGED_MOD_RANGE = 0x118, // f32 — range modifier on bows/guns
OFF_ITEMSTATS_BONDING = 0x194, // u32 — 0=none, 1=BoP, 2=BoE, 3=BoU, 4=Quest
OFF_ITEMSTATS_DESCRIPTION = 0x198, // char * — flavor text (locale-applied)
OFF_ITEMSTATS_PAGE_TEXT = 0x19C, // u32 — PageText.dbc row (readable books)
OFF_ITEMSTATS_LANGUAGE_ID = 0x1A0, // u32 — language for book text
OFF_ITEMSTATS_PAGE_MATERIAL = 0x1A4, // u32 — book material
// u32 — the quest this item BEGINS (the tooltip's "This Item Begins
// a Quest" line), not one it is an objective for; 0 = starts nothing.
// Both of the binary's references to the `ITEM_STARTS_QUEST`
// global-string name at `0x0084e4fc` are in the tooltip builder
// `FUN_0052b650`, which reads the neighbouring `m_lockID` as
// `puVar4[0x6b]` (= +0x1AC) — so this field is `puVar4[0x6a]`.
// Read by `C_Container.GetContainerItemQuestInfo` as its `questID`.
OFF_ITEMSTATS_START_QUEST = 0x1A8,
OFF_ITEMSTATS_MATERIAL = 0x1B0, // i32 — material type
OFF_ITEMSTATS_SHEATH = 0x1B4, // u32 — weapon sheath style
OFF_ITEMSTATS_RANDOM_PROPERTY = 0x1B8, // i32 — random property template
OFF_ITEMSTATS_BLOCK = 0x1BC, // u32 — shield block value
OFF_ITEMSTATS_MAX_DURABILITY = 0x1C4, // u32
OFF_ITEMSTATS_AREA = 0x1C8, // u32 — bound area (AreaTable.dbc)
OFF_ITEMSTATS_MAP = 0x1CC, // u32 — bound map (Map.dbc)
// `m_flags` bits we surface as decoded booleans. WRAPPER (0x200) is
// verified by the tooltip-builder's openable test at 0x0052E312;
// the others are documented in the standard 1.12 protocol
// (CMaNGOS / TrinityCore `ITEM_FLAG_*`) and exposed as-is. Add
// verification anchors as consumers materialize.
ITEM_FLAG_CONJURED = 0x2,
ITEM_FLAG_LOOTABLE = 0x10,
ITEM_FLAG_WRAPPER = 0x200,
// `Spell.dbc` `Name[9]` field at record +0x1E0 (9-locale string
// array, indexed by `[VAR_LOCALE_INDEX]`). Used by `GetItemSpell`
// to push the spell name half of its return.
OFF_SPELL_NAMES = 0x1E0,
// First character-pane bag-slot index. INVSLOT_BAG1 = 20, BAG2 = 21,
// BAG3 = 22, BAG4 = 23. Used to map a Lua bagID (1..4) onto the
// equipment slot the bag occupies: `equipSlot = INVSLOT_BAG1 + bagID - 1`.
INVSLOT_BAG1 = 20,
BACKPACK_NUM_SLOTS = 16,
// ItemClass.dbc — standard 5-DWORD class shape. Records is an array of
// record pointers indexed directly by classID. Each record has a 9-slot
// localized name array at +0x0C (4 bytes per locale).
VAR_ITEMCLASS_RECORDS = 0x00C0DC24,
VAR_ITEMCLASS_COUNT = 0x00C0DC28,
OFF_ITEMCLASS_NAMES = 0x0C,
// ItemSubClass.dbc — class instance at 0x00C0DB90 has the standard 5-DWORD
// shape (records at +0x08, count at +0x0C, per the reset at 0x53B700), but
// the engine ALSO maintains a parallel (records, count) pair in the first
// two unused slots (+0x00, +0x04) for fast compound-key iteration.
// Script_GetItemInfo and three other callers all read from this parallel
// pair, NOT the standard slots — verified by greping every reader of
// 0xC0DB94. Records there is a flat array of 0x74-byte structs (not the
// standard array-of-pointers); linear scan keyed by (classID, subClassID)
// at record +0x00 / +0x04.
//
// Each record has TWO localized name string arrays:
// +0x28 short name (e.g. "Sword") — 9 locale ptrs, stride 4
// +0x4C verbose/display name (e.g. "One-Handed Swords") — same shape
// Engine pattern: try verbose first; if that locale's slot is empty,
// fall back to short. Many subclasses (e.g. Miscellaneous→Junk) only
// populate the short array, so the fallback matters.
VAR_ITEMSUBCLASS_RECORDS = 0x00C0DB90,
VAR_ITEMSUBCLASS_COUNT = 0x00C0DB94,
OFF_ITEMSUBCLASS_RECORD_STRIDE = 0x74,
OFF_ITEMSUBCLASS_NAME = 0x28,
OFF_ITEMSUBCLASS_DISPLAY_NAME = 0x4C,
// record +0x00 = classID, +0x04 = subClassID (the compound key the
// linear scan matches on). Flags field at +0x10; bit 0x200 marks the
// subclasses whose items display by inventory slot rather than by
// subclass name — set on exactly the armor material types (Misc / Cloth
// / Leather / Mail / Plate), clear on weapons, shields, librams, etc.
// This is `C_Item.GetItemSubClassInfo`'s `subClassUsesInvType` return.
// Derived by dumping ItemSubClass.dbc (see docs/DBCs.md dump oracle).
OFF_ITEMSUBCLASS_CLASS_ID = 0x00,
OFF_ITEMSUBCLASS_SUBCLASS_ID = 0x04,
OFF_ITEMSUBCLASS_FLAGS = 0x10,
ITEMSUBCLASS_FLAG_USES_INVTYPE = 0x200,
// ItemDisplayInfo.dbc — standard layout. Icon path char* at record +0x14
// (per the helper at 0x005D88B0 that Script_GetItemInfo uses).
VAR_ITEMDISPLAYINFO_RECORDS = 0x00C0DC10,
VAR_ITEMDISPLAYINFO_COUNT = 0x00C0DC14,
OFF_ITEMDISPLAYINFO_ICON = 0x14,
// ItemSet.dbc — armor/equipment set definitions referenced by
// `ItemStats_C::m_itemSet`. Standard 5-DWORD class shape at
// 0x00C0DBB8 (records-ptr at +0x08, count at +0x0C). 45 columns,
// 0xB4-byte record stride. Field layout derived from the per-
// record reader at `FUN_0057BBA0`:
//
// +0x00 (4) ID
// +0x04 (32) Name[8] — localized strings, 8 LOCALES (not 9
// like Spell.dbc / ChrRaces.dbc — clamp
// VAR_LOCALE_INDEX to 0..7 before reading)
// +0x24 (4) unused / flags
// +0x28 (68) ItemID[17] — items in the set (zero = empty slot)
// +0x6C (32) SetSpellID[8] — bonus spells granted by the set
// +0x8C (32) SetThreshold[8] — pieces needed for each SetSpellID
// (e.g. {2, 4, 6, 8, 0, 0, 0, 0})
// +0xAC (4) RequiredSkill — skill line ID, 0 for none
// +0xB0 (4) RequiredSkillRank
VAR_ITEMSET_RECORDS = 0x00C0DBC0,
VAR_ITEMSET_COUNT = 0x00C0DBC4,
OFF_ITEMSET_NAMES = 0x04,
OFF_ITEMSET_ITEM_IDS = 0x28,
OFF_ITEMSET_SPELL_IDS = 0x6C,
OFF_ITEMSET_THRESHOLDS = 0x8C,
OFF_ITEMSET_REQUIRED_SKILL = 0xAC,
OFF_ITEMSET_REQUIRED_SKILL_RANK = 0xB0,
ITEMSET_MAX_ITEMS = 17,
ITEMSET_MAX_BONUSES = 8,
ITEMSET_LOCALE_COUNT = 8,
// INVTYPE_* string table — array of char* indexed by m_inventoryType.
// Index 0 is empty (0=INVTYPE_NON_EQUIP), indices 1..28 are valid
// INVTYPE_HEAD..INVTYPE_RELIC, index 29 is empty (sentinel), and indices
// 30+ are unrelated combat-log strings (MISS/WOUND/DODGE/...). Always
// bound-check before indexing.
VAR_INVTYPE_STRING_TABLE = 0x0083DDB0,
INVTYPE_TABLE_MAX_INDEX = 28,
// Equipment-slot mask per `m_inventoryType` — uint32[29], same indexing
// as the string table above; bit n = 0-based equipment slot n (INVSLOT
// n + 1). Read by CGItem_C::FitsSlot (0x5DA1D0); values dumped from
// WoW.exe. Differs from the 3.3.5/4.3.4 copy: 2H (17) and main-hand-only
// (21) set only the main-hand bit, off-hand-only (22) only the off-hand.
VAR_INVTYPE_SLOT_MASKS = 0x00809200,
// The two `m_inventoryType` values that mean "consumed when used", so
// both the item-consumable test (`C_Item.IsConsumableItem`) and the
// action-slot one (`IsConsumableAction`) single them out. Indices into
// the table above: 24 = `INVTYPE_AMMO`, 25 = `INVTYPE_THROWN`.
INVTYPE_AMMO = 24,
INVTYPE_THROWN = 25,
// Faction "displayed list" — the engine maintains a sorted/visible list
// of factions the player has rep with. `Script_GetNumFactions` (at
// 0x004D64C0) returns `[VAR_FACTION_DISPLAY_COUNT]` (the primary list
// count). `Script_GetFactionInfo` (at 0x004D64F0) maps its 1-based
// index by calling the resolver below, which accepts a slightly wider
// 0-based range bounded by `[VAR_FACTION_VISIBLE_MAX_INDEX]`. The two
// ranges differ because the displayed list also exposes the "Inactive"
// / collapsed-category rows past the primary count.
//
// The resolver `FUN_RESOLVE_FACTION_INDEX` is __fastcall(ecx = 0-based
// index) → factionID (Faction.dbc record ID), or 0 for headers and
// empty entries. The internal bounds-check is `cmp ecx, [maxIdx]; jbe`
// — i.e., 0..maxIdx inclusive is valid. Out of range returns 0 too,
// so we must bound-check ourselves to distinguish "header" (0 in
// range) from "no such index" (out of range → nil).
//
// We re-use the resolver for `GetFactionIDByIndex` directly, and for
// `GetFactionInfoByID` we walk it to find the displayed-index of a
// given factionID, then replace Lua arg 1 and tail-call
// `Script_GetFactionInfo` to produce all 11 returns.
// ChrClasses.dbc — class metadata. Standard 5-DWORD class shape.
// Records is a flat array of record pointers indexed by classID
// (records[0] unused, records[1..count]).
FUN_RESOLVE_FACTION_INDEX = 0x004D5FA0,
FUN_SCRIPT_GET_FACTION_INFO = 0x004D64F0,
//
// Per-record fields used by `FillLocalizedClassList`, derived from
// `Script_GetSelectedClass` (`0x004716E0`):
// +0x14 char *Name[9] — localized class names (locale-indexed)
// +0x38 char *Filename — class token ("WARRIOR", "MAGE", etc.)
//
// Vanilla 1.12 has no separate female-name array — `Name[9]` is
// exactly the 36 bytes between `+0x14` and `+0x38`, so the
// `isFemale` arg of `FillLocalizedClassList` is a no-op for this
// client (and matches the male names that English/most locales
// use anyway).
VAR_CHRCLASSES_RECORDS = 0x00C0DEF4,
VAR_CHRCLASSES_COUNT = 0x00C0DEF8,
OFF_CHRCLASSES_NAMES = 0x14,
OFF_CHRCLASSES_FILENAME = 0x38,
// SpellFamilyName for the class — the gate the SpellMod system
// matches a spell's OFF_SPELL_RECORD_FAMILY_NAME against. Read by
// FUN_006e6ca0 (`DAT_00cecaac = ChrClasses[classID] + 0x3c`).
OFF_CHRCLASSES_SPELL_FAMILY = 0x3C,
// Non-zero when the class's slot-18 is a RELIC slot (Libram / Idol /
// Totem) rather than a ranged-weapon slot. The whole of
// Script_UnitHasRelicSlot's answer — 0x00519EAE-0x00519EC0:
// mov ecx, [0x00c0def4] ; records
// mov eax, [ecx + eax*4] ; records[classID]
// mov ecx, [eax + 0x40]
// test ecx, ecx / jz push_nil ; non-zero => true
// Last column (16) of the 17-field record; parsing the client's own
// ChrClasses.dbc gives 1 for PALADIN / SHAMAN / DRUID and 0 for the
// other six, which is exactly the relic-slot set.
OFF_CHRCLASSES_RELIC_SLOT = 0x40,
// ChrRaces.dbc — standard 5-DWORD class shape at 0x00C0DED8,
// records-pointer at +0x08, count at +0x0C. 29 columns,
// 0x74-byte record stride. Field offsets verified by decoding
// `Script_UnitRace` (registration entry at 0x00850580, function at
// 0x00518200): the function loads `[VAR_CHRRACES_RECORDS]` →
// `records[raceID]` → reads `+0x44 + locale*4` for the localized
// race name and `+0x3C` for the non-localized file string (e.g.
// `"Human"`, `"NightElf"`, `"Scourge"`), pushes both as Lua
// returns. The two offsets are what we mirror to populate
// `GetPlayerInfoByGUID`'s `localizedRace` / `englishRace` slots.
VAR_CHRRACES_RECORDS = 0x00C0DEE0,
VAR_CHRRACES_COUNT = 0x00C0DEE4,
OFF_CHRRACES_FILENAME = 0x3C,
OFF_CHRRACES_NAMES = 0x44,
// CreatureFamily.dbc — pet/beast family metadata. Standard 5-DWORD
// class shape (instance 0x00C0DE74; records 0x00C0DE7C, count
// 0x00C0DE80 — the same globals `Script_UnitCreatureFamily`
// (`0x0051A310`) bounds-checks/indexes). 72-byte stride, familyID-keyed
// and sparse (10/13/14/22/… are unused). Localized `Name[]` at +0x20
// (the engine reads `record + 0x20 + locale*4`), `IconFile` texture-path
// string at +0x44 (last field; empty for warlock-pet families). Backs
// `C_CreatureInfo.GetCreatureFamilyInfo` / `GetCreatureFamilyIDs`.
VAR_CREATUREFAMILY_RECORDS = 0x00C0DE7C,
VAR_CREATUREFAMILY_COUNT = 0x00C0DE80,
OFF_CREATUREFAMILY_NAMES = 0x20,
OFF_CREATUREFAMILY_ICON = 0x44,
// CreatureType.dbc — pet/NPC classification (1=Beast … 11=Totem;
// contiguous ids, 11 rows). Records 0x00C0DE2C, count 0x00C0DE30 (the
// globals `Script_UnitCreatureType` (`0x0051A280`) bounds-checks/indexes),
// localized `Name[]` at +0x04 (engine reads `record + 0x04 + locale*4`).
// Backs `C_CreatureInfo.GetCreatureTypeInfo` / `GetCreatureTypeIDs`;
// `UnitCreatureTypeID` returns the id `FUN_UNIT_CREATURE_TYPE` resolves.
VAR_CREATURETYPE_RECORDS = 0x00C0DE2C,
VAR_CREATURETYPE_COUNT = 0x00C0DE30,
OFF_CREATURETYPE_NAMES = 0x04,
// Flags, column 10. Bit 1 = never tab-targeted (set only on Critter in
// the extracted DBC); the tab search FUN_00494200 skips such units.
OFF_CREATURETYPE_FLAGS = 0x28,
CREATURETYPE_FLAG_NOT_TAB_TARGET = 0x1,
// CreatureDisplayInfo.dbc / CreatureModelData.dbc — the
// creatureDisplayID → model-file chain behind `Model:SetDisplayInfo`.
// Both standard pointer-array DBCs (records[id], sparse). Column offsets
// verified two independent ways: parsing the extracted 1.12 DBCs
// (C:\WoW\Octo\DBFilesClient) AND the engine's own unit-display resolver
// FUN_0060afb0, which reads displayID from `[descriptor+0x1F4]` →
// CreatureDisplayInfo[id] +0x04 ModelID → CreatureModelData[ModelID].
// CreatureDisplayInfo: +0x04 ModelID (col 1 → CreatureModelData id);
// +0x18/+0x1C/+0x20 TextureVariation[3] (cols 6/7/8 — creature skin,
// bare filenames applied as replaceable-texture MONSTER_1/2/3).
// CreatureModelData: +0x08 ModelPath (col 2, e.g. "Creature\Rat\Rat.mdx").
VAR_CREATUREDISPLAYINFO_RECORDS = 0x00C0DE90,
VAR_CREATUREDISPLAYINFO_COUNT = 0x00C0DE94,
OFF_CREATUREDISPLAYINFO_MODEL_ID = 0x04,
OFF_CREATUREDISPLAYINFO_TEXTURE_VARIATION = 0x18, // char*[3] @ +0x18/+0x1C/+0x20
VAR_CREATUREMODELDATA_RECORDS = 0x00C0DE68,
VAR_CREATUREMODELDATA_COUNT = 0x00C0DE6C,
OFF_CREATUREMODELDATA_MODEL_PATH = 0x08,
// CreatureDisplayInfo.extendedDisplayInfoID (col 3) — nonzero for a
// CHARACTER-based display (shared Character\Race\Sex base model). It indexes
// CreatureDisplayInfoExtra.dbc, whose LAST field (col 18 in the 19-col
// vanilla layout, +0x48) is the pre-composited body-skin filename. That
// texture lives under Textures\BakedNpcTextures\ and applies to the M2
// body-skin replaceable types (1/8) — NOT the monster slots, which a
// character model has no texture units for (hence "renders white" without
// this). The baked skin already carries the equipped body armor. Verified by
// parsing the extracted DBC; C:\Git\Inklab resolves the same chain.
OFF_CREATUREDISPLAYINFO_EXTENDED_ID = 0x0C,
VAR_CREATUREDISPLAYINFOEXTRA_RECORDS = 0x00C0DEA4,
VAR_CREATUREDISPLAYINFOEXTRA_COUNT = 0x00C0DEA8,
OFF_CREATUREDISPLAYINFOEXTRA_BAKE_NAME = 0x48, // col 18 (last), string
OFF_CREATUREDISPLAYINFOEXTRA_RACE = 0x04, // col 1 (ChrRaces id)
OFF_CREATUREDISPLAYINFOEXTRA_SEX = 0x08, // col 2 (0=male, 1=female)
OFF_CREATUREDISPLAYINFOEXTRA_HAIR_COLOR = 0x18, // col 6 (CharSections color)
// Cols 3/4/5/7 + the NPC equipment block — field order verified from
// CGUnit_C::UpdateCharacterCustomization (FUN_005fb200), which reads
// +0x04..+0x1C into the compositor info struct and walks +0x20..+0x44
// as 10 ItemDisplayInfo ids for FUN_CHARCOMP_SET_ITEM.
OFF_CREATUREDISPLAYINFOEXTRA_SKIN = 0x0C, // col 3
OFF_CREATUREDISPLAYINFOEXTRA_FACE = 0x10, // col 4
OFF_CREATUREDISPLAYINFOEXTRA_HAIR_STYLE = 0x14, // col 5
OFF_CREATUREDISPLAYINFOEXTRA_FACIAL_HAIR = 0x1C, // col 7
OFF_CREATUREDISPLAYINFOEXTRA_EQUIP = 0x20, // cols 8..17: u32[10] ItemDisplayInfo ids
// CharSections.dbc — per-race/sex character texture layers. Scanned by
// Model:SetDisplayInfo to resolve a character display's HAIR texture (applied
// to the M2 hair replaceable type 6, else the hair geoset renders white).
// Standard pointer-array DBC; match rows on race/sex/baseSection (3 = Hair) +
// color, then read the first texture column. Verified against the extracted
// DBC: Human Female (race 1, sex 1) hairColor 0 -> "Character\Human\Hair00_00.blp".
VAR_CHARSECTIONS_RECORDS = 0x00C0DF6C,
VAR_CHARSECTIONS_COUNT = 0x00C0DF70,
OFF_CHARSECTIONS_RACE = 0x04, // col 1
OFF_CHARSECTIONS_SEX = 0x08, // col 2
OFF_CHARSECTIONS_BASE_SECTION = 0x0C, // col 3 (3 = Hair)
OFF_CHARSECTIONS_COLOR = 0x14, // col 5
OFF_CHARSECTIONS_TEXTURE = 0x18, // col 6 (texture[0] path)
CHARSECTIONS_BASE_SECTION_HAIR = 3,
// Race → faction group, mirroring the player branch of
// `Script_UnitFactionGroup` (`0x00516630`) — backs
// `C_CreatureInfo.GetFactionInfo(raceID)`. Chain:
// ChrRaces[race] + 0x08 → FactionTemplate id
// FactionTemplate[id] + 0x0C → group mask (ourMask)
// scan FactionGroup for the row whose bit is set (and whose
// localized name is non-empty — that non-empty test is what
// skips the always-set "Player" bit and lands on Alliance/Horde)
// push { groupTag = row+0x08 (english), name = row+0x0C+locale*4 }
// FactionTemplate is a pointer-array DBC (records[id]); FactionGroup
// is stored CONTIGUOUSLY (records-base + i*stride, direct field reads,
// NOT a pointer array), so iterate it by hand rather than via DBC::Record.
// FactionTemplate globals match docs/DBCs.md; the FactionGroup
// records-base/count globals are the ones the engine actually
// dereferences per the disassembly (0x00C0DD5C / 0x00C0DD60), which
// differ from DBCs.md's standard-shape tabulation for this table.
// `Script_UnitFactionGroup` itself: slot 13 of the in-game registration
// table 0x00850438 (loop @ 0x0051BB74; docs/raw_globals.txt). Two branches
// pick the faction template: object in world (FUN_00468460 hit) → unit
// descriptor +0x74 (UNIT_FIELD_FACTIONTEMPLATE; corpses via 0x005D7120);
// object missing → name cache 0x00C0E228 entry +0x138 (race) → ChrRaces
// +0x08. Either way it pushes nil,nil and returns 2 on a miss. Co-hooked by
// unit/FactionGroup.cpp so "player" resolves while addons load.
FUN_SCRIPT_UNIT_FACTION_GROUP = 0x00516630,
OFF_CHRRACES_FACTION_TEMPLATE = 0x08,
VAR_FACTIONTEMPLATE_RECORDS = 0x00C0DD3C,
VAR_FACTIONTEMPLATE_COUNT = 0x00C0DD40,
OFF_FACTIONTEMPLATE_GROUP_MASK = 0x0C,
VAR_FACTIONGROUP_RECORDS = 0x00C0DD5C,
VAR_FACTIONGROUP_COUNT = 0x00C0DD60,
FACTIONGROUP_STRIDE = 0x30,
OFF_FACTIONGROUP_BIT = 0x04,
OFF_FACTIONGROUP_ENGLISH = 0x08,
OFF_FACTIONGROUP_NAMES = 0x0C,
// AreaTable.dbc — used by `Script_GetCharacterInfo` to resolve
// each character's last-known-area to a localized zone name.
// Same shape as the other DBCs (records pointer + count globals,
// 9-slot locale-string array at the per-record offset).
VAR_AREATABLE_RECORDS = 0x00C0E048,
VAR_AREATABLE_COUNT = 0x00C0E04C,
OFF_AREATABLE_NAMES = 0x2C,
// Parent AreaTable id @ +0x08 — a sub-area's enclosing zone (e.g. Goldshire
// → Elwynn Forest). GetFriendInfo resolves it to name the zone, not the
// sub-area. 0 for a top-level zone.
OFF_AREATABLE_PARENT_ID = 0x08,
// AreaBit @ +0x0C: the bit number FUN_IS_AREA_EXPLORED tests. Gate
// @ +0x28 (ExplorationLevel): when < 0 the area needs no exploration
// (always counts explored); when >= 0 the AreaBit test applies. Source:
// the overlay and landmark loops of FUN_004a67a0.
OFF_AREATABLE_AREA_BIT = 0x0C,
OFF_AREATABLE_EXPLORE_GATE = 0x28,
// Flags @ +0x10 (column 4). Bit 0x80 = arena: `Script_GetZonePVPInfo`
// (0x0048D540) pushes its isArena return from
// `*(char *)(rec + 0x10) < 0` on the current subzone. Set on the
// open-world free-for-all rings (Gurubashi, The Maul) and on the
// instanced arena maps' areas (Turtle: 4013, 4014).
OFF_AREATABLE_FLAGS = 0x10,
AREA_FLAG_ARENA = 0x80,
// TaxiNodes.dbc (16 fields, 0x40 bytes) — flight points. records/count
// per docs/DBCs.md. mapID @ +0x04 is the Map.dbc continent; x/y/z floats;
// Name[8] localized @ +0x14; the two MountCreatureID columns are
// [Horde @ +0x38, Alliance @ +0x3C] (0 = that faction has no flight
// master at this node — both 0 = a transport/system waypoint).
VAR_TAXINODES_RECORDS = 0x00C0D6C0,
VAR_TAXINODES_COUNT = 0x00C0D6C4,
OFF_TAXINODE_MAP_ID = 0x04,
OFF_TAXINODE_X = 0x08,
OFF_TAXINODE_Y = 0x0C,
OFF_TAXINODE_Z = 0x10,
OFF_TAXINODE_NAME = 0x14,
OFF_TAXINODE_HORDE_MOUNT = 0x38,
OFF_TAXINODE_ALLIANCE_MOUNT = 0x3C,
// Live taxi session — the open flight master's reachable node list,
// populated between TAXIMAP_OPENED/CLOSED (count 0 otherwise). Backs the
// legacy NumTaxiNodes/TaxiNodeName/TaxiNodePosition/TaxiNodeGetType Lua
// globals. Node slots are 0x20-stride records at VAR_TAXI_NODE_ARRAY:
// +0x00 = pointer to the node's TaxiNodes.dbc record (id @ +0, name @
// +0x14), +0x04 = flight-map x (0-1 float), +0x08 = y. Count at
// VAR_TAXI_NODE_COUNT. Derived from Script_TaxiNode* (FUN_004dc380 name,
// FUN_004dc3b0 position); the reachability type comes from
// FUN_TAXI_NODE_TYPE.
VAR_TAXI_NODE_COUNT = 0x00BB4AA8,
VAR_TAXI_NODE_ARRAY = 0x00BB4F10,
TAXI_NODE_STRIDE = 0x20,
OFF_TAXI_SLOT_RECORD = 0x00,
OFF_TAXI_SLOT_X = 0x04,
OFF_TAXI_SLOT_Y = 0x08,
// __fastcall(uint slot0Based) -> const char* ("CURRENT" / "REACHABLE" /
// "DISTANT" / other) — the node's reachability for the open session.
FUN_TAXI_NODE_TYPE = 0x004DC4E0,
// Per-slot computed route (the chain that TakeTaxiNode sends to the
// server). Derived from FUN_004dc8d0 (the TakeTaxiNode worker) and the
// route builder FUN_004dbce0:
// +0x0C (byte) nonzero when the multi-hop route array below is built
// +0x14 (int*) array of TaxiNodes.dbc IDs, current->dest in flight
// order, length at +0x18
// +0x18 (int) route length (node count; hops = count - 1)
// A direct hop (a TaxiPath edge exists current->dest) is flown as just
// {current, dest} and does NOT populate +0x14 — see VAR_TAXI_ADJACENCY.
OFF_TAXI_SLOT_MULTIHOP = 0x0C,
OFF_TAXI_SLOT_ROUTE = 0x14,
OFF_TAXI_SLOT_ROUTE_COUNT = 0x18,
// Pointer to the CURRENT flight master's TaxiNodes.dbc record (id @ +0);
// the origin of every route. Used by FUN_004dc8d0 / FUN_004dbce0.
VAR_TAXI_CURRENT_REC = 0x00BB4A80,
// Node x node -> pathID adjacency matrix (256-wide rows, int cells; cell
// [from*0x100 + to] is the direct TaxiPath id, or 0 if none). Backs the
// direct-hop test FUN_004dbad0. IDs are 1..256.
VAR_TAXI_ADJACENCY = 0x00B7365C,
TAXI_ADJACENCY_DIM = 0x100,
// TaxiPath.dbc (4 fields, 0x10 bytes): {id, fromNode@+0x04, toNode@+0x08,
// cost}. A real flight master is a node some flight path connects to;
// Northshire Abbey / spurious duplicate rows / standalone markers are not
// endpoints and so are filtered out of GetTaxiNodesForMap.
VAR_TAXIPATH_RECORDS = 0x00C0D698,
VAR_TAXIPATH_COUNT = 0x00C0D69C,
OFF_TAXIPATH_FROM = 0x04,
OFF_TAXIPATH_TO = 0x08,
OFF_TAXIPATH_COST = 0x0C,
// TaxiPathNode.dbc — the per-path flight waypoints. 1-based
// record-pointer array (records/count slots per docs/DBCs.md). Record
// (verified against the extracted DBC + the loading-screen spline
// reader FUN_004075A0, which reads mapID@+0xC, X@+0x10, Y@+0x14):
// {ID@+0, pathID@+4, nodeIndex@+8, mapID@+0xC,
// X@+0x10, Y@+0x14, Z@+0x18 (float), flags@+0x1C, delay@+0x20}
// Waypoints of a path share pathID and order by nodeIndex.
VAR_TAXIPATHNODE_RECORDS = 0x00C0D6AC,
VAR_TAXIPATHNODE_COUNT = 0x00C0D6B0,
OFF_TAXIPATHNODE_PATH_ID = 0x04,
OFF_TAXIPATHNODE_INDEX = 0x08,
OFF_TAXIPATHNODE_MAP = 0x0C,
OFF_TAXIPATHNODE_X = 0x10,
OFF_TAXIPATHNODE_Y = 0x14,
OFF_TAXIPATHNODE_Z = 0x18,
// Engine player-info cache — populated by the
// SMSG_NAME_QUERY_RESPONSE handler (opcode 0x51) at 0x005551A0,
// which reads (GUID, name[48], realm[256], race, sex, class) from
// the packet and writes them into an entry via the cache method
// at 0x0055F310. Used by chat, raid frames, guild events — any
// engine code that needs name/class/race for a GUID. NOT limited
// to visible objects (an earlier note in TODO #35 was wrong — the
// visible-only cache at 0x00CE870C is a different smaller one
// used for chat name resolution).
//
// Lookup primitive at `FUN_PLAYER_INFO_LOOKUP`:
// `__thiscall uint8_t *(this=cache, guid_lo, guid_hi, &cookie,
// callback, userData, retryFlag)`
//
// Returns:
// - `nullptr` if the GUID isn't loaded (cache miss, or pending
// response from a prior request).
// - Pointer to the entry's data block (= entry +0x20) if loaded.
//
// Side effect: if `callback != nullptr` AND the entry isn't yet
// allocated, the engine builds a CDataStore, writes the GUID, and
// calls `FUN_005AB630` to send CMSG_NAME_QUERY (opcode 0x50). The
// callback fires with `(userData, success)` when the response
// arrives (`__stdcall void(void *, int)`, same shape as the item
// cache callback).
//
// For pure cache reads (our `GetPlayerInfoByGUID`), pass
// `callback=nullptr, userData=nullptr, retryFlag=0` and a dummy
// 8-byte cookie buffer. We don't fire the request from the read
// path — addons that want to trigger one can layer a
// `C_PlayerInfo.RequestLoadPlayerByID`-style helper on top later.
VAR_PLAYER_NAME_CACHE = 0x00C0E228,
FUN_PLAYER_INFO_LOOKUP = 0x0055F080,
// Every node of the name cache sits on one Storm TSList at cache+0x04:
// the list's link offset at cache+0x04, its first node at cache+0x0C,
// each node's next at node + linkOffset + 4, ended by 0 or a low-bit-
// tagged pointer. A node keeps its 64-bit GUID key at +0x168 (pass it
// to FUN_PLAYER_INFO_LOOKUP for the record). Verified from the cache's
// own save walk, NameCacheSave 0x0055EC70 (next-link helper
// 0x0055EC50). The engine has no by-name lookup over this cache — this
// walk is the only way to search it.
OFF_NAME_CACHE_LINK_OFFSET = 0x04,
OFF_NAME_CACHE_FIRST_NODE = 0x0C,
OFF_NAME_CACHE_NODE_GUID = 0x168,
// NameCache write entry — `__thiscall(this = cache, packetData,
// guidLo, guidHi)` at 0x0055F310. Called once per
// SMSG_NAME_QUERY_RESPONSE after the engine's opcode handler
// builds a `packetData` buffer with the layout:
// +0x000 name[48]
// +0x030 realm[256]
// +0x130 unknown[8] (probably (charGuidLo, charGuidHi))
// +0x138 race (u32)
// +0x13C sex (u32, 0/1 wire)
// +0x140 class (u32)
// Writes that data into the cache entry and dispatches any
// pending callbacks. Decoded by Ghidra; field offsets verified
// against the `*(uint*)(param_2 + N)` reads in the function body.
//
// Hooking here gives us a single chokepoint covering every name-
// query response the engine processes — chat, group/raid sync,
// guild roster, visible-object resolution. The hook runs after
// the engine has settled the entry, so reading from the cache
// post-hook is safe.
FUN_PLAYER_INFO_CACHE_WRITE = 0x0055F310,
// Entry-data offsets. The lookup returns `entry + 0x20`, so these
// are relative to that pointer (not to the entry's hash-table
// header). Field layout verified by decoding the cache writer
// FUN_0055F310 at 0x0055F32D-0x0055F365:
// - copy 48 bytes from packet[+0] into entry+0x20 (name)
// - copy 256 bytes from packet[+0x30] into entry+0x50 (realm)
// - copy 4 bytes from packet[+0x138] into entry+0x158 (race)
// - copy 4 bytes from packet[+0x13C] into entry+0x15C (sex)
// - copy 4 bytes from packet[+0x140] into entry+0x160 (class)
OFF_PLAYER_INFO_NAME = 0x000, // 48-byte inline C string
OFF_PLAYER_INFO_REALM = 0x030, // 256-byte inline C string
OFF_PLAYER_INFO_RACE = 0x138, // u32 (race ID 1..8)
OFF_PLAYER_INFO_SEX = 0x13C, // u32 (0=male, 1=female on wire)
OFF_PLAYER_INFO_CLASS = 0x140, // u32 (class ID 1..11)
// Visible-object iterator. Walks the engine's linked list of
// currently-in-range CGObjects (the same list the minimap blip
// renderer uses). __fastcall(ecx = callback, edx = context).
// Callback signature: __fastcall(ecx = context, edx unused, [stack] = uint64_t guid).
// Callback returns 0 to stop iteration, 1 to continue.
// Verified by disassembling the iterator body at 0x00468380 —
// ECX/EDX preserved into ESI/EDI, ECX restored to context before
// each callback invocation, guidLo/guidHi pushed as 8 stack bytes.
FUN_CLNT_OBJ_MGR_ENUM_VISIBLE_OBJECTS = 0x00468380,
// Type-mask flags accepted by FUN_OBJECT_RESOLVE_BY_GUID (and the SetUnit
// path FUN_00529FE0, which passes ECX=8 for UNIT). A bitmask of
// object-type bits, not an enum index — single-bit flags OR together.
// PLAYER (0x10) is what the bag observer FUN_004F8DB0 passes; GAMEOBJECT
// (0x20) what the hover-tooltip populator FUN_0052AA20 passes.
TYPEMASK_OBJECT = 0x01,
TYPEMASK_ITEM = 0x02,
TYPEMASK_CONTAINER = 0x04,
TYPEMASK_UNIT = 0x08,
TYPEMASK_PLAYER = 0x10,
TYPEMASK_GAMEOBJECT = 0x20,
TYPEMASK_DYNAMICOBJECT = 0x40,
TYPEMASK_CORPSE = 0x80,
// CGUnit_C.m_objectFields slot. Different from CGItem's +0x114 —
// sibling classes use class-specific descriptor offsets. Inside the
// descriptor at +0x79 lives the class byte (UNIT_FIELD_BYTES_0
// field's second byte). Verified at 0x005183FE-0x00518404 in
// Script_UnitClass's general-unit-token path:
// mov edx, [eax + 0x110] ; descriptor
// movzx eax, byte [edx + 0x79] ; class
OFF_CGUNIT_OBJECT_FIELDS = 0x110,
// UNIT_FIELD_BYTES_0 packs race/class/sex/powerType into one dword
// at descriptor +0x78. Individual bytes:
OFF_UNIT_DESCRIPTOR_RACE_BYTE = 0x78,
OFF_UNIT_DESCRIPTOR_CLASS_BYTE = 0x79,
OFF_UNIT_DESCRIPTOR_SEX_BYTE = 0x7A,
// The local player's UNIT_FIELD_BYTES_0 race/class/sex bytes, mirrored
// into a login-time global that is populated at character-enter —
// BEFORE the in-world CGUnit/descriptor exists. Script_UnitClass
// (0x00518350) and Script_UnitRace special-case the literal "player"
// token to read these (Script_UnitClass calls FUN_005abde0 →
// `return DAT_00c27e81`), which is why UnitClass("player") resolves at
// addon-load while a descriptor read returns nil until the player
// object spawns. Getters: race FUN_005abdd0, class FUN_005abde0,
// sex FUN_005abdf0.
VAR_PLAYER_RACE_BYTE = 0x00C27E80,
VAR_PLAYER_CLASS_BYTE = 0x00C27E81,
VAR_PLAYER_SEX_BYTE = 0x00C27E82,
// SkillLineAbility.dbc — maps each (class, race) pair to its
// learnable spell list with skill-rank gating. Indexed by record
// ID; reads via the standard `records[id]` pattern. Used by
// `GetCurrentLevelSpells` to filter the global spell set down to
// entries our class/race can learn.
//
// Class instance VA `0x00C0D94C` per docs/DBCs.md. Standard 5-DWORD
// class shape so the records-array pointer slot sits at +0x08 and
// the count slot at +0x0C.
VAR_SKILL_LINE_ABILITY_RECORDS = 0x00C0D954,
VAR_SKILL_LINE_ABILITY_COUNT = 0x00C0D958,
// Record-internal offsets, vanilla 1.12 layout (CMaNGOS-canonical):
// +0x00 id
// +0x04 skillId (→ SkillLine.dbc; e.g. 44 = "Swords")
// +0x08 spellId (→ Spell.dbc — the spell taught by this entry)
// +0x0C raceMask (bit `1 << (race - 1)`; 0 = all races)
// +0x10 classMask (bit `1 << (class - 1)`; 0 = all classes)
// +0x14 excludeRace (bitmask of races this entry does NOT apply to)
// +0x18 excludeClass (bitmask of classes this entry does NOT apply to)
// +0x1C minSkillRank
// ... (more fields)
OFF_SLA_SKILL_ID = 0x04,
OFF_SLA_SPELL_ID = 0x08,
OFF_SLA_RACE_MASK = 0x0C,
OFF_SLA_CLASS_MASK = 0x10,
OFF_SLA_EXCLUDE_RACE = 0x14,
OFF_SLA_EXCLUDE_CLASS = 0x18,
// Field 8: the spellID of the NEXT rank that supersedes this row's
// spell (0 = none / not linked). Verified against the extracted DBC:
// Mortal Strike 12294 → 21551 → 21552, Kick 1766 → 1767. Populated
// for some ability chains (660 of 6812 rows) but NOT for every chain —
// Fireball 133's row and the ENTIRE Mind Flay chain (15407, 17311..
// 17314, 18807) hold 0 — so treat it as "known next rank", not as a
// complete rank graph. The engine's own rank-chain walk
// (CGUnit_C::KnowsHigherRank, 0x0060C8D0) reads this same field and has the same
// gap. `Talent::SpellSet` follows it to extend a talent's rank-1 spell
// to its trained higher ranks, then falls back to a shared spell name.
OFF_SLA_SUPERCEDED_BY_SPELL = 0x20,
// Skill-up threshold ranks (grey / green) at record fields 10/11.
// A row with either nonzero is a craftable recipe; profession
// rank-up / passive rows have both zero. Empirically: the
// Blacksmithing skill line has 343 SLA rows, 334 with a nonzero
// threshold — the 9 excluded are the Apprentice..Artisan rank
// spells and skill grants. This is the discriminator
// `TradeSkill::Link` uses to build the canonical recipe universe.
OFF_SLA_TRIVIAL_SKILL_HIGH = 0x28,
OFF_SLA_TRIVIAL_SKILL_LOW = 0x2C,
// The engine's (race, class, spellID) -> SkillLineAbility record lookup:
// `const uint8_t *__fastcall(char race /*ecx*/, char classId /*edx*/,
// uint32_t spellID /*stack*/)`, RET 4, NULL on a miss (disassembly).
// Reads the hash FUN_006dda50 builds once at boot from every ChrBaseInfo
// race/class pair crossed with every SLA row that passes the
// SkillRaceClassInfo and race/class-mask gates (FUN_006ddbe0). The
// trade-skill rebuild FUN_004fca20 calls it per recipe with the player's
// descriptor race/class bytes (+0x78/+0x79). The 1.12 twin of 3.3.5's
// SpellTableLookupAbility (0x00812410).
FUN_SKILL_LINE_ABILITY_LOOKUP = 0x006DE040,
// SkillLine.dbc — the skill/category each SLA row points into via
// its `skillId` field. Each record carries a 9-locale localized
// name array (the user-facing tab name in the spellbook, profession
// header, weapon-skill name, etc.) plus a SpellIcon ID at +0x54.
// Standard 5-DWORD class instance at `0x00C0D924`; records-array
// pointer at `0x00C0D92C`, count at `0x00C0D930`.
//
// Record layout (verified against `Script_GetSpellTabInfo` at
// `0x004B3CE0`):
// +0x00 id
// +0x0C `Name[9]` — locale string pointers, indexed via the
// global locale at `0x00C0E080` (read as
// `*(char **)(record + 0x0C + locale * 4)`)
// +0x54 SpellIcon.dbc ID (looked up via `SpellIcon` for the
// spellbook tab/profession icon)
VAR_SKILL_LINE_RECORDS = 0x00C0D92C,
VAR_SKILL_LINE_COUNT = 0x00C0D930,
OFF_SKILL_LINE_NAME = 0x0C,
// Player's known-skills table — separate from the DBC. Populated
// by the engine on login from server data; entries are pointers
// to per-skill records. Each record's `+0x00` is the
// `SkillLine.dbc` row (or `0` for header / category rows), and
// `+0x10` is the current skill rank (other rank/modifier fields
// follow). Source: `Script_GetSkillLineInfo` at `0x004D3610`,
// which walks this array indexed by the Lua arg.
VAR_PLAYER_SKILL_LIST = 0x00B7318C,
VAR_PLAYER_SKILL_COUNT = 0x00B731B8,
OFF_PLAYER_SKILL_LINE_ID = 0x00,
OFF_PLAYER_SKILL_RANK = 0x10,
// Live per-skill current/max rank. These are NOT in
// `VAR_PLAYER_SKILL_LIST` (that entry's `+0x10` is numTempPoints) —
// the real ranks live in the CGPlayer `+0xE68` sub-struct
// (`OFF_CGPLAYER_INFO`). `FUN_SKILL_LINE_TO_SLOT`
// (`__thiscall(player, skillLineID) -> slot`) maps a SkillLine.dbc
// row to its slot; the slot indexes a `SKILL_INFO_STRIDE`-byte
// record at `[player+0xE68] + OFF_SKILL_INFO_TABLE + slot*stride`:
// current `+0x0`, max `+0x2`, rank bonus `+0x6` (all u16 — add the
// bonus when the base value is nonzero). Source: `Script_GetTradeSkillLine`
// (`0x004FDD40`) / `Script_GetSkillLineInfo` (`0x004D3610`). Verified
// in-game vs. those functions (Tailoring 261/300, Enchanting 186/240).
FUN_SKILL_LINE_TO_SLOT = 0x005EA3F0,
OFF_SKILL_INFO_TABLE = 0x84C,
SKILL_INFO_STRIDE = 0xC,
OFF_SKILL_INFO_CUR = 0x0,
OFF_SKILL_INFO_MAX = 0x2,
OFF_SKILL_INFO_BONUS = 0x6,
// Per-itemClass proficiency bitmap maintained by the engine.
// 17 u32 entries (indexed by Item.dbc `m_class`, 0..16). Each
// entry is a bitmask where bit N is set if the player has
// proficiency in subclass N of that item class — i.e.
// `table[4] & (1 << 3)` = "can wear Mail" (armor=class 4,
// mail=subclass 3).
//
// Populated by SMSG_SET_PROFICIENCY's handler at
// `FUN_005E7B70`, which writes `table[itemClass] = mask`
// verbatim from the packet. Same source the engine itself uses
// for equip eligibility (the tooltip "Mail" red-text logic
// and the cursor-drop-on-paperdoll check both read this). Note:
// covers **weapons too** (class 2), making it strictly more
// general than walking the per-skill-line table for individual
// armor proficiencies.
VAR_PROFICIENCY_TABLE = 0x00C4D4A0,
// CGPlayer_C::CanUseItem — `__thiscall(player, ItemStats_C *record,
// uint32_t *error) -> int`, `ret 8`. Nonzero when the player meets the
// record's level, class/race masks, proficiency (VAR_PROFICIENCY_TABLE,
// mask 0 passes), required skill, required spell or a higher rank, honor
// rank, PvP medal bit and reputation. On refusal `error` is 0x17
// ERR_ITEM_NOT_FOUND (null record), 7 ERR_PROFICIENCY_NEEDED or 0x9C
// ERR_CANT_USE_ITEM. The engine's "can use" for loot, quest rewards,
// merchant, auction, mail and trade, and the Bind on Equip confirmation.
// 4.3.4: CGPlayer_C::CanUseItem (Player_C.cpp). Verified by decompile
// (benilla-re objectlayer/playercombat#using-an-item).
FUN_PLAYER_CAN_USE_ITEM = 0x005EA930,
// Spell.dbc `BaseLevel` — the level a spell becomes available
// (trainer offers it, quest reward grants it, etc.). Distinct
// from `SpellLevel` at +0x74 which is the effective level used
// for damage scaling and resistance math. Per CMaNGOS-canonical
// 1.12 Spell.dbc layout; cross-checked against known fields at
// ±a few offsets (PowerType at +0x7C is verified).
OFF_SPELL_RECORD_BASE_LEVEL = 0x70,
// `UNIT_BYTES_1` (CMaNGOS field 132 in the 1.12.1 layout). 32-bit
// composite field; the low byte is the standstate (standing /
// sitting / sleeping / kneeling / etc.), the upper bytes hold
// PetTalents / VisFlag / AnimTier per CMaNGOS docs (uncalibrated
// for 1.12). Broadcast field, so the standstate works for any
// synced unit (player, target, party/raid, inspect targets) —
// not local-only.
//
// Verified via the `IsAssistingRitual` development session by
// observing `0xEE00 → 0xEE05` on `/sit` over a chair (the medium-
// chair sit value 5).
//
// Byte 3 (the AnimTier / misc-flags byte, mask 0x02000000 on the
// u32) is the **stealth / sneak flag**: set while the unit is in
// the sneaking anim tier (Rogue Stealth, Druid Prowl, Shadowmeld),
// which is what drives the client's semi-transparent render of a
// stealthed unit. Verified via `_classicapi_DiffAll`: a Prowl
// toggle from a Cat-Form baseline flips byte 3 `0x00 → 0x02` while
// every other descriptor change is aura-array slot metadata — so
// this is the only standalone broadcast bit that means "stealthed".
// Read by `IsStealthed()`.
OFF_UNIT_FIELD_BYTES_1 = 0x210,
UNIT_BYTES_1_STEALTH_FLAG = 0x02000000,
// `__fastcall(void)` engine helper that refreshes the bonus
// action bar from the local player's current shapeshift form
// (byte 2 of `UNIT_BYTES_1`, descriptor `+0x212`). Reads the form
// byte, looks up SpellShapeshiftForm.dbc's `bonusActionBar`
// column, stores it into `DAT_00BC6E88`, and fires
// `UPDATE_BONUS_ACTIONBAR` (event id `0xD9`).
//
// Called from two sites: once during post-login init from
// `FUN_004908C0`, and on every relevant UNIT_BYTES_1 broadcast
// update (the unrooted call at `0x005DE01B`, inside the
// local-player UpdateField dispatch). Hooked to synthesize
// modern `UPDATE_SHAPESHIFT_FORM` — the cached-byte gate in our
// hook filters out the non-form recomputes (this fires for any
// UNIT_BYTES_1 update, not just form changes).
FUN_BONUS_ACTIONBAR_UPDATE = 0x004E4FC0,
// Inner watched-faction setter — `__fastcall(ecx = factionID) → void`.
// The engine's `Script_SetWatchedFactionIndex` (0x004D6B60) is a
// thin Lua-side wrapper that takes a 1-based displayed-list index,
// resolves it to a factionID via FUN_RESOLVE_FACTION_INDEX, and
// forwards to this. Going through the wrapper requires a round-
// trip through the resolver (and excludes unencountered factions),
// so for `C_Reputation.SetWatchedFactionByID` we call this
// directly with the user-supplied factionID. factionID == 0
// clears the watched faction (the engine handles 0 as "no
// watched"). Updates `[player+0xE68]+0x10C4` and persists the
// value via the engine's CVar / event machinery.
FUN_PLAYER_SET_WATCHED_FACTION = 0x004D6240,
VAR_FACTION_DISPLAY_COUNT = 0x00B73764,
VAR_FACTION_VISIBLE_MAX_INDEX = 0x00B73760,
// Reputation-pane selection. Stored as a FACTION ID, not a list
// index: `Script_SetSelectedFaction` (below) takes a 1-based
// displayed-list index but immediately resolves it through
// `FUN_RESOLVE_FACTION_INDEX` and stores the resulting factionID
// here, and `Script_GetSelectedFaction` (0x004D6C00) walks the
// displayed list to map it back to a 1-based index (0 when the
// stored id isn't currently listed). So selecting by ID is a
// direct write — no index round-trip. Verified by decompiling
// both accessors.
VAR_FACTION_SELECTED_ID = 0x00B73768,
// `Script_SetSelectedFaction` — the stock `SetSelectedFaction(index)`
// global. `int __fastcall(void *L)`, standard Lua C ABI, so it can be
// re-registered under a namespace table as-is.
FUN_SCRIPT_SET_SELECTED_FACTION = 0x004D6BB0,
// Faction.dbc — standard 5-DWORD class shape, records pointer at +0x08
// and count at +0x0C of the class instance at 0x00C0DD48. Records is an
// array of `FactionRec *` indexed directly by factionID (1-based;
// records[0] is unused). We read it on the slow path of
// `GetFactionInfoByID` for factions the player has never encountered
// (i.e. not in the displayed reputation list), where the engine's
// `Script_GetFactionInfo` can't help us.
//
// Record name/description offsets verified by disassembling
// `Script_GetFactionInfo` at 0x004D6562 / 0x004D6573:
// mov edx, [edi+ecx*4+0x4C] ; Name[locale]
// mov edx, [edi+edx*4+0x70] ; Description[locale]
// Each is a 9-entry array of locale string pointers, indexed by
// `[VAR_LOCALE_INDEX]` (0..8).
VAR_FACTION_DBC_RECORDS = 0x00C0DD50,
VAR_FACTION_DBC_COUNT = 0x00C0DD54,
// RepListIndex on the Faction.dbc record. Maps factionID to the
// 0..63 slot in `VAR_PLAYER_REP_SLOTS`. Read by the engine's
// factionID→repListID helper at `0x004D5600` (called by
// FUN_FACTION_GET_AT_WAR / GET_CAN_TOGGLE_AT_WAR / IS_WATCHED).
// -1 means the faction has no rep slot (it's a category header).
OFF_FACTION_REP_LIST_INDEX = 0x04,
OFF_FACTION_PARENT_ID = 0x48,
OFF_FACTION_NAMES = 0x4C,
OFF_FACTION_DESCRIPTIONS = 0x70,
// Displayed-list category headers. `VAR_FACTION_HEADER_LIST` is a
// flat int32 array of header factionIDs (max 32 — engine bounds
// it at `0x1f`). `VAR_FACTION_HEADER_COUNT` is the live count.
// Special sentinel factionIDs `0` (FACTION_OTHER) and `-1`
// (FACTION_INACTIVE) may appear in this list for the "Other" and
// "Inactive" pseudo-rows.
//
// `VAR_FACTION_COLLAPSED_BITMASK` is a 32-bit mask where bit `i`
// SET means the header at `VAR_FACTION_HEADER_LIST[i]` is
// **expanded** (NOT collapsed) — bit CLEAR = collapsed. Default
// state at login is all-clear (all categories collapsed).
VAR_FACTION_HEADER_LIST = 0x00B736C0,
VAR_FACTION_HEADER_COUNT = 0x00B736B0,
VAR_FACTION_COLLAPSED_BITMASK = 0x0084A0A4,
MAX_FACTION_HEADERS = 32,
// The social singleton (0x00C28168) — one object shared by the friend
// list, ignore list, and /who system. Layout: friend entries inline from
// offset 0 (stride 0x20, up to 50; each is {connected@+0x00, name char*
// @+0x04, GUID u64 @+0x08, level@+0x10, area@+0x14, class@+0x18}), the
// 25-entry ignore-GUID table at +0x650, and the who-query state. Read by
// GetNumFriends/GetFriendInfo, GetNumIgnores, and Script_SendWho.
//
// `Script_SendWho` (0x005AD3B0) is a 32-byte wrapper:
// - validate arg1 is a string via lua_isstring
// - load the singleton from `[VAR_SOCIAL_SYSTEM]`
// - if non-NULL, lua_tostring(L, 1) for the query string
// - tail-call `FUN_WHO_SYSTEM_SEND_QUERY` with
// `__thiscall(this = WhoSystem, queryStr)`
//
// The query string follows the engine's standard /who filter syntax
// (`"n-Bob"`, `"r-Alliance"`, `"c-Warlock"`, etc.); the inner
// function at `FUN_WHO_SYSTEM_SEND_QUERY` (~1.5KB) does the
// parse + CMSG_WHO build + network send.
//
// `Script_SetWhoToUI` (0x005AD870) is even smaller — 13 bytes that
// store arg1 (as int, default 0) to `[VAR_WHO_TO_UI_FLAG]`. The
// SMSG_WHO response handler at ~0x005ADF80 reads the flag at
// `0x005ADF9C` to decide whether the results buffer into the
// engine's WhoList (flag != 0 → list path, friends-frame fires
// WHO_LIST_UPDATE; flag == 0 → results go to chat as
// `"Found N players matching..."`).
//
// Server-side cooldown for CMSG_WHO is ~5 seconds — a faster
// client gets silent-dropped, so any client-side gating just
// matches that.
VAR_SOCIAL_SYSTEM = 0x00C28168,
VAR_WHO_TO_UI_FLAG = 0x00C2A12C,
FUN_WHO_SYSTEM_SEND_QUERY = 0x005AEBB0,
// Friend count: `__fastcall(socialSingleton) -> uint` — walks the inline
// entries and returns the number of populated friend slots. Backs
// GetNumFriends and C_FriendList.IsFriend.
FUN_FRIEND_LIST_COUNT = 0x005AE490,
// FriendList::IsFriend — `bool __thiscall(socialSingleton, uint64_t guid)`
// (RET 8): true when one of the 50 slots holds the GUID.
FUN_FRIEND_LIST_IS_FRIEND = 0x005AE810,
// FriendList::IsIgnored — `bool __thiscall(socialSingleton, uint64_t guid)`
// (RET 8): false for guid 0, else true when any of the 25 ignore slots at
// +0x650 holds the GUID. Scans all 25 (no stop at a zero slot): removing
// an ignore (0x005AF650) zeroes its slot and only re-sorts when no ignore
// name lookup is pending (+0x718 == 0), so the list can have holes.
FUN_FRIEND_LIST_IS_IGNORED = 0x005AE5A0,
// SMSG_WHO opcode handler — opcode 0x63 (99) per the registration
// in `FUN_005adc50`: `FUN_005ab650(99, FUN_005adf60, 0)`. Reads
// `VAR_WHO_TO_UI_FLAG` mid-function (at `0x005ADF9C`) to decide
// between WhoList + WHO_LIST_UPDATE vs the chat-count printer.
//
// We hook post-original to restore the flag after each response
// so the routing override only affects responses we initiated.
// Otherwise a user-typed `/who` inheriting our flag=1 stays
// silent (no chat-count message, no FriendsFrame popup) when the
// user actually wanted both.
FUN_SMSG_WHO_RESPONSE = 0x005ADF60,
// /who result list — the buffer `Script_GetWhoInfo` (0x005AD6E0) and
// `Script_GetNumWhoResults` (0x005AD690) read. An array of fixed-size
// entries at `VAR_WHO_RESULTS`, stride `WHO_RESULT_STRIDE`; the field
// offsets below are all relative to an entry. `name`/`guildName` are
// inline C strings; `race`/`class` index ChrRaces/ChrClasses.dbc and
// `zone` indexes AreaTable.dbc (own name, not parent-resolved).
// `VAR_WHO_RESULT_COUNT` is the displayed count (the first of the two
// values GetNumWhoResults returns; the second, total matches, is at +4).
// Verified by decompiling both accessors.
VAR_WHO_RESULTS = 0x00C281B8,
VAR_WHO_RESULT_COUNT = 0x00C2A120,
WHO_RESULT_STRIDE = 0xA0,
OFF_WHO_NAME = 0x00, // char[] inline
OFF_WHO_GUILD = 0x30, // char[] inline
OFF_WHO_LEVEL = 0x90, // i32
OFF_WHO_RACE = 0x94, // i32 → ChrRaces.dbc
OFF_WHO_CLASS = 0x98, // i32 → ChrClasses.dbc
OFF_WHO_ZONE = 0x9C, // i32 → AreaTable.dbc
// Per-faction current standing — `__fastcall(ecx = factionID) → int`.
// Returns `base + delta` where the two values are stored at
// `+0x08` / `+0x0C` of the player's rep slot (slot stride 0x10,
// 64 slots at `0x00B73290`). Returns 0 for factionIDs not in the
// player's reputation list (i.e. unencountered). Used by the
// FACTION_STANDING_CHANGED event firing to push the live total
// after the engine's setter has written the new delta.
FUN_REPUTATION_GET_STANDING = 0x004D6370,
// Reaction-band classifier — `__fastcall(ecx = factionID) → int`.
// Internally calls `FUN_REPUTATION_GET_STANDING` and maps the total
// through the 7-band threshold ladder (Hated..Exalted). Returns
// 0..7 (0=Hated, 7=Exalted); `Script_GetWatchedFactionInfo` pushes
// this `+ 1` to produce the 1..8 standingID Lua addons see.
FUN_REPUTATION_GET_REACTION_BAND = 0x004D63A0,
// Reputation-list slots — the player's 64-entry per-faction rep
// store. Stride `0x10`; layout per entry:
// +0x00 i32 factionID (0 if slot unused)
// +0x04 u8 flags (bit 1 = atWar, bit 4 = canToggleAtWar)
// +0x08 i32 base standing
// +0x0C i32 delta standing
// Slot index = RepListID = Faction.dbc record `+0x04`. Indexed by
// `FUN_004D5600(factionID) → repListID`. Reverse direction is
// `FUN_004D5620(repListID) → factionID`.
VAR_PLAYER_REP_SLOTS = 0x00B73290,
REP_SLOT_STRIDE = 0x10,
OFF_REP_SLOT_FACTION_ID = 0x00,
OFF_REP_SLOT_FLAGS = 0x04,
OFF_REP_SLOT_BASE_STANDING = 0x08,
OFF_REP_SLOT_DELTA_STANDING = 0x0C,
REP_SLOT_FLAG_AT_WAR = 0x02,
// "Peace forced" — when SET, the player CAN'T toggle this faction
// to/from at-war (e.g. your own home cities, certain quest
// factions). Decoded from `FUN_FACTION_GET_CAN_TOGGLE_AT_WAR` at
// `0x004D61E0`, which reads bit `0x10` of the flags byte and
// `Script_GetFactionInfo` pushes `canToggleAtWar=false` when set.
// Note: the bit's MEANING is "can't toggle" — `canToggleAtWar` is
// its inverse, NOT its value.
REP_SLOT_FLAG_PEACE_FORCED = 0x10,
// INACTIVE flag — set by `Script_SetFactionInactive` (the "Inactive"
// collapsible category in FactionFrame). Toggles via
// `FUN_FACTION_SET_INACTIVE`; same byte as AT_WAR and PEACE_FORCED.
REP_SLOT_FLAG_INACTIVE = 0x20,
MAX_REP_SLOTS = 64,
// Static reaction-band threshold tables, indexed by reaction band
// 0..7 (returned by `FUN_REPUTATION_GET_REACTION_BAND`). The pair
// gives the `[min, max)` standing range that defines each band —
// currentReactionThreshold / nextReactionThreshold for modern
// `C_Reputation.GetWatchedFactionData`-style table fields.
VAR_REACTION_MIN_TABLE = 0x0080928C,
VAR_REACTION_MAX_TABLE = 0x00809290,
// `[player +0xE68] + 0x10C4` — the RepListID (rep-slot index) of
// the faction currently being watched (the one shown above the XP
// bar). Written by `FUN_PLAYER_SET_WATCHED_FACTION` after
// translating the user-supplied factionID via
// `FUN_004D5600 → RepListID`. Negative or out-of-range means "no
// watched faction", which `Script_GetWatchedFactionInfo` checks
// against `FUN_004D5620(slot)`'s return.
OFF_CGPLAYER_INFO_WATCHED_REP_LIST_ID = 0x10C4,
// `FactionSetAtWar(factionID, newState)` — `__fastcall(ecx = factionID,
// edx = char newState)`. The sole worker behind
// `Script_FactionToggleAtWar` (`0x004D6950`); the script wrapper just
// reads the current at-war flag, negates it, and tail-calls here.
//
// Validates (only when turning OFF) that current standing ≥ -3000,
// resolves factionID → repListID, bails if the player is in a loot
// session (UNIT_FIELD_FLAGS bit `0x80000`, error code `0x1A1`),
// mutates the rep-slot flag byte (`AT_WAR` gated by `PEACE_FORCED`),
// and sends `CMSG_SET_FACTION_ATWAR` (opcode `0x125`).
//
// **Does NOT fire `UNIT_FACTION`** — a vanilla engine omission. 3.3.5
// added a `FUN_0071F8F0(player, 0)` call here, whose inner
// `FUN_0060BF10(playerGUID, UNIT_FACTION_id)` dispatches the event
// for every unit token referencing the player. We polyfill by
// hooking this function and firing `UNIT_FACTION("player")` post-
// original (see `src/faction/UnitFactionPolyfill.cpp`).
FUN_FACTION_SET_AT_WAR = 0x004D5FD0,
// `FactionGetAtWar(factionID)` — `uint __fastcall(ecx = factionID)`.
// Resolves factionID → repListID and returns the `AT_WAR` flag bit as
// 0/1; returns 0 when the faction has no rep slot. The read half of
// `Script_FactionToggleAtWar`'s read-negate-write pair.
FUN_FACTION_GET_AT_WAR = 0x004D61B0,
// `Script_FactionToggleAtWar` — the stock `FactionToggleAtWar(index)`
// global. Resolves its 1-based index through
// `FUN_RESOLVE_FACTION_INDEX`, then (for a non-zero factionID) calls
// GET_AT_WAR and hands the negated value to SET_AT_WAR. Standard Lua C
// ABI, so it re-registers under a namespace table as-is. Toggling by
// faction id is that same pair without the index resolve.
FUN_SCRIPT_FACTION_TOGGLE_AT_WAR = 0x004D6950,
// `FactionSetInactive(factionID, newState)` — `__fastcall(ecx = factionID,
// edx = char newState)`. Inner setter behind `Script_SetFactionInactive`
// (`0x004D69B0`, sets INACTIVE bit) and `Script_SetFactionActive`
// (`0x004D6A00`, clears it) — both script wrappers tail-call here.
//
// Resolves factionID → repListID via `FUN_004D5600`, mutates the
// rep-slot flag byte (sets/clears `INACTIVE` = `0x20`), writes via
// `FUN_004D5FC0`, sends `CMSG_SET_FACTION_INACTIVE` (opcode `0x317`),
// then calls `FUN_004D5C40` (recompute displayed-list, fire
// `UPDATE_FACTION` event `0x174`).
//
// **Does NOT fire `UNIT_FACTION`** — same engine omission as the at-
// war setter. Polyfilled in `src/faction/UnitFactionPolyfill.cpp`.
FUN_FACTION_SET_INACTIVE = 0x004D60F0,
// `Script_SetFactionInactive` / `Script_SetFactionActive` — the stock
// `SetFactionInactive(index)` / `SetFactionActive(index)` globals. Each
// resolves its 1-based index through `FUN_RESOLVE_FACTION_INDEX` and,
// for a non-zero factionID, calls SET_INACTIVE with 1 / 0 respectively.
// Standard Lua C ABI, so both re-register under a namespace table as-is.
// Setting by faction id is the same call without the index resolve.
FUN_SCRIPT_SET_FACTION_INACTIVE = 0x004D69B0,
FUN_SCRIPT_SET_FACTION_ACTIVE = 0x004D6A00,
// `Script_IsFactionInactive` — the stock `IsFactionInactive(index)`
// global (pushes 1 / nil, not a boolean). Its worker at `0x004D6210`
// takes the 0-based INDEX rather than a faction id — unlike the at-war
// getter — resolving index → factionID → repListID before reading the
// INACTIVE bit. Standard Lua C ABI, so it re-registers as-is.
FUN_SCRIPT_IS_FACTION_INACTIVE = 0x004D6AF0,
// SMSG_SET_FACTION_ATWAR handler — `__stdcall(uint32_t opcode,
// void *packet)`. Fires when the server force-changes the player's
// at-war state on a faction (e.g., a flag the player can't toggle
// changes server-side, or faction reset). Reads `(u32 repListID,
// u8 flags)`, mutates AT_WAR on the slot accordingly, writes via
// `FUN_004D5FC0`, then fires `UPDATE_FACTION` (event `0x174`).
//
// **Does NOT fire `UNIT_FACTION`** — 3.3.5 does (unconditionally
// after the byte write). Polyfilled in
// `src/faction/UnitFactionPolyfill.cpp`.
FUN_SMSG_SET_FACTION_ATWAR = 0x004D56B0,
// SMSG_INITIALIZE_FACTIONS handler — `__stdcall(uint32_t opcode,
// void *packet)`. Fires once at login from the SMSG dispatcher. Reads
// a count, then loops `(u8 flags, i32 standing)` pairs into the
// 64-entry rep slot array: `FUN_004D5FC0(slot, flags)` +
// `FUN_004D6330(slot, standing, 0 /*notify*/)`. Trailing
// `FUN_004D5430` rebuilds the displayed-list snapshot, then fires
// `UPDATE_FACTION` (event `0x174`).
//
// **Does NOT fire `UNIT_FACTION`** — modern WoW does. Addons that
// observe UNIT_FACTION miss the initial sync entirely in vanilla.
// Polyfilled in `src/faction/UnitFactionPolyfill.cpp`.
FUN_SMSG_INITIALIZE_FACTIONS = 0x004D5640,
// SMSG_SET_FACTION_STANDINGS handler — `__stdcall(uint32_t opcode,
// void *packet)`. Fires once per server-pushed rep change (kills,
// quest turn-ins, etc.). Reads count, loops `(flags, standing)`
// pairs, calling `FUN_004D6330(slot, standing, 1 /*notify*/)` which
// routes through `FUN_REPUTATION_FIRE_NOTIFY` for the
// `CHAT_MSG_COMBAT_FACTION_CHANGE` dispatch.
//
// Also mutates AT_WAR / VISIBLE flag bits as standing crosses
// thresholds (e.g., recovering to -2999 clears the force-set AT_WAR
// from "below Hated"). **Vanilla doesn't fire `UNIT_FACTION` for
// these side-effect flag flips**; modern 3.3.5 does. Polyfilled in
// `src/faction/UnitFactionPolyfill.cpp` — snapshots the 64-entry
// flag-byte array before/after and fires a single
// `UNIT_FACTION("player")` if any bit changed.
FUN_SMSG_SET_FACTION_STANDINGS = 0x004D5760,
// `__fastcall(ecx = factionID, edx = signedDelta)`. This is the
// engine's "reputation changed, fire the chat event" notify
// helper — it formats the localized chat message and dispatches
// `CHAT_MSG_COMBAT_FACTION_CHANGE`. Called from `FUN_004D6330`
// (the per-slot setter) at `0x004D635C`, only when:
// 1. The stored standing value actually changed for this slot.
// 2. The setter's `notify` arg was non-zero (i.e. the call
// came from the per-update SMSG handler, not the bulk init
// handler that runs at login).
// Hooking here matches modern WoW's `FACTION_STANDING_CHANGED`
// semantics: fires once per real reputation change, skipping the
// initial faction sync at login. ECX/EDX layout means the hook
// can read factionID + delta in registers; for the modern
// `(factionID, newStanding)` payload, call
// `FUN_REPUTATION_GET_STANDING(factionID)` from inside the hook
// (the setter has already written the new value by this point,
// so it returns the updated total).
FUN_REPUTATION_FIRE_NOTIFY = 0x0062C5F0,
// Quest static-info cache (the client-side cache of QUEST_QUERY_RESPONSE
// payloads — descriptions, objectives, reward text). Same five-arg
// `_GetRecord` shape as the item cache, keyed by questID. Verified by
// tracing `Script_GetQuestLogQuestText` (`0x004DFF20`):
// 1. `[VAR_QUEST_LOG_SELECTED_QUEST_ID]` is the *questID* of the
// selected entry (not a pointer) — populated from
// `mov eax, [esi + 0x00BB71C0]` which reads field +0 of a
// `VAR_QUEST_LOG_ENTRIES` row, i.e. the questID itself.
// 2. That value is passed as the `key` arg to `_GetRecord`, then
// hashed via `key & cache.mask` and matched with `cmp [bucket], key`.
//
// Cache-hit-already-loaded shortcut: if `[entry+0x18F8]` is set, the
// function returns `entry+0x18` immediately and does NOT invoke the
// queued callback. Modules that want a notification regardless of
// cache state must fire it themselves (see `Item::Data` for the same
// pattern).
//
// Callback shape verified at the dispatch sites near 0x00562EEB et al.:
// `mov ecx, [entry+0x18]; push 1; push ecx; call [entry+8]`
// → `__stdcall(void *userData, int success)` where `userData` is
// `arg4` we passed to `_GetRecord` (engine stores it at
// `entry+0x18` and replays it without dereferencing).
VAR_QUEST_CACHE = 0x00C0E1B0,
FUN_DBCACHE_QUEST_GET_RECORD = 0x00562A40,
// Quest-text substituter — `void __fastcall(const char *src /*ECX*/, char
// *dst /*EDX*/, uint32_t size, const uint64_t *playerGuid)`, callee-cleans
// its two stack args. Expands the `$N`/`$C`-style tokens (player name,
// class, ...) for the player the GUID names, as the quest log shows quest
// text. `Script_GetQuestLogQuestText` (0x004DFF20) runs it over the cached
// description (+0xA9C) and objectives (+0x29C) with a 0x400-byte buffer
// and the active player's GUID (FUN_00468550).
FUN_QUEST_TEXT_SUBSTITUTE = 0x00506F70,
VAR_QUEST_LOG_SELECTED_QUEST_ID = 0x00BB7480,
// Creature cache (creaturecache.wdb, SMSG_CREATURE_QUERY_RESPONSE).
// One instance of the generic client query-cache class; constructed
// by the cache factory (FUN_00554b40 -> FUN_00556060 with sig
// 'BOMW', "creaturecache.wdb", recordSize 0x60).
VAR_CREATURE_CACHE = 0x00C0E354,
// Creature-cache `_GetRecord` — `__thiscall(cache, id, const u64 *guid,
// void *callback, void *userData, char dedup)`. Returns the data
// block (entry+0x18) when loaded; with `callback==0` it only peeks
// (no query), with a non-null callback it fires the network query on
// a miss. Class-specific (reads the loaded flag at entry+0x50);
// gameobjects are a sibling class with a different layout and their
// own `_GetRecord` (FUN_GAMEOBJECT_GET_RECORD). Verified via
// FUN_00604600 (`FUN_00556aa0(creatureID, &guid, cb, 0, 0)`).
FUN_CREATURE_GET_RECORD = 0x00556AA0,
// Creature-cache response parser — `__thiscall(cache, packetReader,
// flag)`. Fills the entry data block, sets the loaded flag (entry+0x50),
// and walks the entry's pending-callback list. The creature SMSG
// handler `FUN_005550E0` calls it with ecx=the creature cache.
// `Cache::QueryLoad` hooks it to fire CREATURE_DATA_LOAD_RESULT. The
// item/quest caches have their own parsers, so it's conflict-free.
FUN_CREATURE_QUERY_RESPONSE = 0x00556E20,
// Creature-query record field offsets, within the data block returned
// by FUN_CREATURE_GET_RECORD. Anchored by rank@+0x20 (read by the
// classification helper FUN_00605620 as `[block+0x20]`) and the
// wire/WDB field order (Name[4], SubName, typeFlags, type, family,
// rank, unk, petSpellDataId, displayId), cross-checked against real
// creaturecache.wdb rows (Misthoof Stag 61332 -> type 1; Nordrassil
// Nymph 61582 -> type 7, rank 1). Strings are char* (the fixed 0x60
// block holds pointers, not the WDB's inline strings).
OFF_CREATURE_NAME = 0x00, // char *Name[4]; [0] is the primary name
OFF_CREATURE_SUBNAME = 0x10, // char *SubName (title); "" if none
OFF_CREATURE_TYPE = 0x18, // CreatureType (1=Beast, 7=Humanoid, ...)
OFF_CREATURE_FAMILY = 0x1C, // CreatureFamily
OFF_CREATURE_RANK = 0x20, // 0=normal,1=elite,2=rareelite,3=worldboss,4=rare
OFF_CREATURE_DISPLAYID = 0x2C, // creature model display ID
// GameObject cache (gameobjectcache.wdb, SMSG_GAMEOBJECT_QUERY_RESPONSE).
// Sibling cache class to creature (constructed by FUN_00554B90 ->
// FUN_00557bd0, sig 'BOGW', recordSize 0x5E) — same struct shape but a
// different vtable (0x0080913C) and a LARGER entry (loaded flag at
// entry+0x98, not +0x50), so it has its own `_GetRecord` and parser.
VAR_GAMEOBJECT_CACHE = 0x00C0E318,
// GO `_GetRecord`, same signature as the creature one. Verified via
// FUN_0062dc10 (`FUN_00558560(goEntry, &guid, 0,0,0)` then reads the
// GO name at `[block+0x08]`).
FUN_GAMEOBJECT_GET_RECORD = 0x00558560,
// GO response parser — `__thiscall(cache, packetReader, flag)`. The GO
// SMSG handler `FUN_00555100` calls it with ecx=the GO cache. Distinct
// from the creature parser (sets loaded flag at entry+0x98), so
// `Cache::QueryLoad` hooks it separately to fire GAMEOBJECT_DATA_LOAD_RESULT.
FUN_GAMEOBJECT_QUERY_RESPONSE = 0x005588E0,
// GO-query record field offsets, within the data block returned by
// FUN_GAMEOBJECT_GET_RECORD. Wire/WDB order: type, displayId, Name[4],
// then a 24-int data[] array. name@+0x08 verified (FUN_0062dc10 reads
// `[block+0x08]` as the name); type@+0x00 / displayId@+0x04 follow from
// the field order, cross-checked against real gameobjectcache.wdb rows
// (Windrunner type 15 displayId 7087; Mesa Elevator 47297 type 11
// displayId 360).
OFF_GAMEOBJECT_TYPE = 0x00, // GameObjectType (0=door,3=chest,…)
OFF_GAMEOBJECT_DISPLAYID = 0x04, // model display ID
OFF_GAMEOBJECT_NAME = 0x08, // char *Name[4]; [0] is the primary name
// Action bar slot table — `uint[120]` (max slot index `< 0x78`).
// Each entry is a packed action descriptor; top 4 bits are the type
// tag, low 28 bits are the payload. Tags:
//
// 0x00000000 spell action; payload = spellID
// 0x40000000 macro action (the server's ACTION_BUTTON_MACRO, 0x40);
// payload `entry & 0xBFFFFFFF` is a macroID. It names a
// live macro only while the macro-slot map at
// `VAR_MACRO_SLOT_MAP` holds it (the match's index is the
// macro slot); a miss is a button whose macro is gone,
// which every engine reader treats as nothing. There is no
// bag-item tag — items are 0x80000000 below.
// 0x80000000 item-by-ID action; payload (entry & 0x7FFFFFFF) IS
// the itemID. Queries the global item cache directly.
//
// `entry == 0` means empty. Engine bounds-checks `slot < 0x78` in
// every reader (verified at `Script_HasAction = 0x004E70D0`, helpers
// at `0x004E5A50`, `0x004E6A50`).
VAR_ACTION_TABLE = 0x00BC6980,
ACTION_TABLE_MAX_SLOTS = 0x78,
// Engine helper used by every action reader to extract the spellID
// associated with a slot (spells return directly; bag-items return
// their triggered spell; item-by-ID returns the first valid
// m_spells[N].SpellID from the item cache). Pet/spell discriminator
// returned via the second arg.
// __fastcall uint(uint slot0Based, uint *outPetFlag)
FUN_ACTION_SLOT_TO_SPELL = 0x004E5A50,
ACTION_TYPE_MASK = 0xF0000000,
ACTION_TYPE_SPELL = 0x00000000,
// 0x40000000 entries are macros — live only while `entry & 0xBFFFFFFF`
// is in the 36-entry macro-slot map. Engine helper `FUN_004F0EC0`
// (FUN_MACRO_ID_TO_SLOT) does the walk and returns slot-index or -1.
ACTION_TYPE_BAG_OR_MACRO = 0x40000000,
ACTION_TYPE_ITEM_BY_ID = 0x80000000,
// Equipment-set action; payload (entry & ~ACTION_TYPE_EQUIPMENT_SET) is
// the setID. 1.12 has no such type — the tag is 3.3.5's (`FUN_005a78f0`
// tests `(entry & 0xF0000000) == 0x20000000`, `FUN_005a7950` masks it
// off). Every 1.12 reader falls through harmlessly on it: the spell
// resolver answers 0, the texture resolver NULL, `HasAction` true.
// `EquipmentSet::Action` owns it. The server drops type 0x20 without
// saving it (tortoise-wow `HandleSetActionButtonOpcode` whitelists
// spell / macro / item), so the placement is kept client-side.
ACTION_TYPE_EQUIPMENT_SET = 0x20000000,
ACTION_PAYLOAD_MASK_BAG_OR_MACRO = 0xBFFFFFFF,
ACTION_PAYLOAD_MASK_ITEM_BY_ID = 0x7FFFFFFF,
// Engine "is this 0x40000000 slot a macro?" — `bool __fastcall(uint
// slot0)`: `FUN_MACRO_ID_TO_SLOT(entry & 0xBFFFFFFF) != 0xFFFFFFFF`.
// Every action reader's macro branch gates on it.
FUN_ACTION_IS_MACRO = 0x004E5030,
// Per-slot texture resolver behind `Script_GetActionTexture` (its sole
// caller) — `char *__fastcall(uint slot0)`, NULL for an empty slot.
// Branch order: attack → auto-repeat → item-by-ID (ItemStats display
// info → icon) → spell (SpellIcon path; the active icon `+0x1D8` when
// FUN_ACTION_SPELL_ICON_ACTIVE says so) → macro (FUN_MACRO_ICON_PATH
// into a static 0x104-byte buffer).
FUN_ACTION_SLOT_TEXTURE = 0x004E6A50,
// `int __fastcall(uint slot0)` — non-zero while the slot's spell is
// active (toggle / stance / auto-repeat up); the texture resolver then
// shows Spell.dbc's `activeIconID` (+0x1D8) instead of `iconID` (+0x1D4).
FUN_ACTION_SPELL_ICON_ACTIVE = 0x004E55F0,
// Per-slot cooldown — `void __fastcall(uint slot0, int *start, int
// *duration, uint *enable)`, ms ticks (the triple
// `Script_GetActionCooldown` scales by 0.001). Item-by-ID slots go through
// FUN_ITEM_QUERY_COOLDOWN; every other slot through FUN_ACTION_SLOT_TO_SPELL
// — so a macro slot's cooldown is its cached primary spell's.
FUN_ACTION_SLOT_COOLDOWN = 0x004E6CA0,
// The engine's own "this slot changed" notifier — `__fastcall(uint slot0
// /*ecx*/, int sendToServer /*edx*/, int quiet /*stack*/)`, RET 4.
// Recomputes the per-slot usable / noMana arrays (`0x00BC6B60` /
// `0x00BC67A0`) via the usable helper `FUN_004E5050` and, when `quiet ==
// 0`, fires EVENT_ACTIONBAR_SLOT_CHANGED with `slot0 + 1` — which
// FrameXML's `ActionButton_OnEvent` compares against `this.action`.
// Called by the engine at the end of every place / pickup. Pass
// `(slot0, 0, 0)` to repaint a slot without the CMSG_SET_ACTION_BUTTON
// packet (verified by disassembly: the packet build is the `edx != 0`
// branch, the event fire the `[esp+4] == 0` branch).
FUN_ACTION_SLOT_CHANGED_NOTIFY = 0x004E58E0,
// Single-slot clear — `__fastcall(uint slot0)`: writes
// `VAR_ACTION_TABLE[slot0] = 0` then FUN_ACTION_SLOT_CHANGED_NOTIFY(slot0,
// /*sendToServer=*/1, 0), so the removal goes out as CMSG_SET_ACTION_BUTTON
// and the server persists it.
FUN_ACTION_SLOT_CLEAR = 0x004E5DB0,
// Slot writer — `__fastcall(uint slot0, uint entry, int sendToServer,
// int quiet)`: `VAR_ACTION_TABLE[slot0] = entry` (+ the item-count cache
// for item-by-ID) then FUN_ACTION_SLOT_CHANGED_NOTIFY. The enter-world
// apply loop calls it `(slot, entry, 0, 1)` per buffered button.
FUN_ACTION_SLOT_SET = 0x004E5D60,
// Per-slot usable — `uint __fastcall(uint slot0, int *outNoMana)`,
// the value FUN_ACTION_SLOT_CHANGED_NOTIFY and the bulk recompute
// `FUN_004E5C00` (fires ACTIONBAR_UPDATE_USABLE) store into the uint[120]
// arrays at `0x00BC6B60` / `0x00BC67A0`, which `IsUsableAction` reads.
// Only those two callers; both are event-driven.
FUN_ACTION_SLOT_USABLE = 0x004E5050,
// The bulk recompute above — `void __cdecl()`: FUN_ACTION_SLOT_USABLE for
// slots 0..0x77, store any changed value into both arrays, and fire
// ACTIONBAR_UPDATE_USABLE (0xD7, via FUN_FIRE_EVENT_NO_ARGS) when one did.
// Disassembled; it is 4.3.4's `CGActionBar::UpdateUsable` line for line.
FUN_ACTION_UPDATE_USABLE = 0x004E5C00,
// Drop the cursor onto a slot — `__fastcall(uint slot0)`. Sole entry
// for `PlaceAction`, and the tail of both FUN_ACTION_PICKUP and
// nampower's detoured `CGActionBar_UseAction` (`0x004E5EE0`) when the
// cursor holds a spell / bag item / macro / type-7 action item. Gated
// on FUN_CURSOR_EDIT_ALLOWED(9); picks up whatever the slot held (the
// `FUN_CURSOR_PICKUP_*` for its type, or a plain cursor clear for a
// type it doesn't know), writes the new entry, and notifies with
// `sendToServer = 1`.
FUN_ACTION_PLACE = 0x004E62E0,
// FUN_ACTION_PLACE's spell arm: `call FUN_ACTION_SLOT_TO_SPELL` (ecx
// slot0, edx &[ebp-0x14]) whose result `0x004E63D0 cmp esi, eax` tests
// against the cursor spell, clearing the cursor on a match. E8 call,
// target checked against the exe.
CALL_ACTION_PLACE_SAME_SPELL = 0x004E63C8,
// Pick a slot up — `__fastcall(uint slot0)`. Sole entry for
// `PickupAction`. When the cursor already holds something the engine
// places (the gate in the note above) it tail-calls FUN_ACTION_PLACE;
// else it puts the slot's action on the cursor and FUN_ACTION_SLOT_CLEARs.
FUN_ACTION_PICKUP = 0x004E6130,
// `Script_UseAction(slot, checkCursor, onSelf)` — `__fastcall(L)`. Parses
// `slot - 1`, `checkCursor` = loose bool of arg 2, `onSelf` of arg 3, and
// calls `0x004E5EE0` — which nampower detours, so hook here, not there.
FUN_SCRIPT_USE_ACTION = 0x004E7140,
// `Script_GetActionText(slot)` — `__fastcall(L)`. Pushes the macro name
// for a macro slot, nil otherwise.
FUN_SCRIPT_GET_ACTION_TEXT = 0x004E7050,
// SMSG_ACTION_BUTTONS leaf — `__stdcall(?, CDataStore *)`, RET 8 (stack
// args at [ebp+8] / [ebp+0xC]; ECX/EDX unused). Reads 120 u32 into
// `VAR_ACTION_BUTTONS_PENDING`; the local-player enter-world init
// `FUN_005DEA50` then applies each through FUN_ACTION_SLOT_SET(slot,
// entry, 0, 1) — spells only when still known, every tagged entry
// unconditionally — and fires ACTIONBAR_SLOT_CHANGED(0).
FUN_SMSG_ACTION_BUTTONS = 0x005E6680,
VAR_ACTION_BUTTONS_PENDING = 0x00C4C2B4, // uint[120]
// The unlearn sweep — `__fastcall(uint spellID)`. Walks all
// ACTION_TABLE_MAX_SLOTS slots, resolves each through
// FUN_ACTION_SLOT_TO_SPELL, and FUN_ACTION_SLOT_CLEARs every slot whose
// spell equals `spellID`. Sole caller is the spell-removal handler
// FUN_005E9FE0, immediately after FUN_UNLEARN_SPELL (verified by
// disassembly + xrefs). Because the resolver is macro-aware — a macro slot
// answers with its primary-spell cache — a macro whose cache holds the
// unlearned spell is permanently removed from the action bar, which is why
// `Macro::ShowTooltip` co-hooks this to keep its DISPLAY resolution out of
// the comparison.
FUN_ACTION_BAR_PRUNE_SPELL = 0x004E5E20,
// Count of `itemID` the player carries, as `UseAction` caches per
// item-by-ID slot into VAR_ACTION_ITEM_COUNTS — `uint __fastcall(uint
// itemID)`. Charged items (ItemStats `SPELL_CHARGES[0]` not 0 / -1) sum
// charges via FUN_INVMGR_COUNT_CHARGES_BY_ID, everything else sums stacks
// via FUN_INVMGR_COUNT_STACKS_BY_ID. The inner GetActionCount
// (`0x004E6C70`) only reads the cached array, item-by-ID slots only.
FUN_ACTION_ITEM_COUNT = 0x004E6D20,
VAR_ACTION_ITEM_COUNTS = 0x00BC6390, // uint[120]
// Inventory-manager searches (3.3.5/4.3.4 `CGBag_C::FindItem` family) —
// `__thiscall(invMgr, uint itemID, uint flags)`. All drive the slot
// visitor `FUN_00622420`, which skips broken items (max durability set,
// durability 0, ITEM_FIELD_FLAGS 0x8 clear) and items with field flag
// 0x10 — there is no 3.3.5 `BAG_SEARCH_IGNORE_ITEM_STATE` (0x80) bypass.
// On the player inventory manager a `flags` with none of 0x47 set gets
// 0x47 ORed in: equipment (linear 0..18), bag slots (19..22), backpack
// (23..38), keyring (81..112), recursing into each bag — 3.3.5's
// `BAG_SEARCH_DEFAULT_LOCATIONS` minus currency. The bag items in 19..22
// reach the callback themselves before their contents.
FUN_INVMGR_FIND_ITEM_BY_ID = 0x00622270, // → CGItem *, first match
FUN_INVMGR_COUNT_STACKS_BY_ID = 0x00622130, // → summed ITEM_FIELD_STACK_COUNT (3.3.5 GetItemTypeCount)
FUN_INVMGR_COUNT_CHARGES_BY_ID = 0x00622180, // → summed abs(SPELL_CHARGES[0]) (3.3.5 GetItemTypeCharges)
// The walk with a caller callback — `CGItem *__thiscall(invMgr,
// int (__fastcall *cb)(CGItem *item, void *ctx), void *ctx, uint flags)`,
// returning the first item `cb` answered nonzero for (null = none).
// `cb` gets the item in ECX and `ctx` in EDX (`0x0062253C`).
FUN_INVMGR_WALK = 0x006223F0,
// `flags` bit adding the bank: main bank (39..62) and the bank-bag slots
// (63..68), recursing into each bag. Reads the GUID array directly, so
// unlike FUN_ITEMMGR_GET_ITEM_BY_SLOT it needs no open bank window.
INVMGR_SEARCH_BANK = 0x08,
// The registered action-bar Lua C functions that `Action::ItemState`
// re-registers in front of. Tail-call these with the untouched stack for
// every slot we don't own (they raise their own usage errors).
// `GetActionTexture` needs no override: its macro branch goes through the
// hooked FUN_MACRO_ICON_PATH.
FUN_SCRIPT_GET_ACTION_TEXTURE = 0x004E6E10,
FUN_SCRIPT_GET_ACTION_COOLDOWN = 0x004E6ED0,
FUN_SCRIPT_GET_ACTION_COUNT = 0x004E6E70,
FUN_SCRIPT_IS_CONSUMABLE_ACTION = 0x004E7470,
EVENT_ACTIONBAR_SLOT_CHANGED = 0xD5, // fmt "%d", 1-based slot
// Per-character macro-slot map (uint[36]). Entry N holds the macroID
// of the macro in slot N (0 = empty slot). The same memory is used
// to look up macros by hash in `FUN_004F0E40` (Script_GetMacroInfo)
// and by slot in `FUN_004F0EC0` (linear search for "is this entry
// value a known macro?").
VAR_MACRO_SLOT_MAP = 0x00BDCC60,
MACRO_SLOT_MAP_COUNT = 0x24,
// Macro slot → `MacroEntry *` resolver — `__fastcall(uint slot0Based)`.
// Returns the MacroEntry struct pointer for the given 0-based slot,
// or NULL when the slot is empty / out of range. Same accessor
// `Script_GetMacroInfo` uses; we call it directly to read the
// engine's cached primary-spell ID at `entry + OFF_MACRO_PRIMARY_SPELL`
// without re-parsing the body. See `Macro::Spell::Script_GetMacroSpell`.
FUN_MACRO_SLOT_TO_ENTRY = 0x004F0E40,
// `Script_GetMacroInfo` — `int __fastcall(void *L)`; pushes `(name,
// "Interface\Icons\<OFF_MACRO_ICON>", body, isLocal-or-nil)`, always 4
// returns (nils for an empty slot). Left alone deliberately: it is the read
// side of the icon `C_Macro.EditMacro` writes, and the Macro UI seeds its
// icon selector from that texture (`MacroFrame_Update` ->
// `MacroPopupFrame.selectedIconTexture`), so a resolved `#showtooltip`
// icon here would report a choice the player never made. The icon a macro
// SHOWS is `C_Macro.GetMacroIcon` (`Macro::IconPath`) instead.
// `Macro::ByName` co-hooks it for the argument only (a macro name becomes
// its index); the returns are untouched.
FUN_SCRIPT_GET_MACRO_INFO = 0x004F1760,
// The other index-only legacy macro functions — `int __fastcall(void *L)`,
// registered from the table at `0x0084C9A8`. Each gates on
// `lua_isnumber(L, 1)` ("Usage: DeleteMacro(index)" etc.), then turns
// `index - 1` into a macroID with the bounds-checked slot reader
// `0x004F0EB0` (`VAR_MACRO_SLOT_MAP[slot]`, 0 when `slot >= 36` or the
// slot is empty) and does nothing when that is 0 — so an out-of-range
// index is a silent no-op. Delete then calls the delete worker
// `0x004F1340(macroID)`, Pickup calls FUN_MACRO_PICKUP, and Edit goes on
// to its field writes. `Macro::ByName` co-hooks all three (plus
// FUN_SCRIPT_GET_MACRO_INFO) so a macro name works in place of the index.
FUN_SCRIPT_EDIT_MACRO = 0x004F18B0,
FUN_SCRIPT_DELETE_MACRO = 0x004F1850,
FUN_SCRIPT_PICKUP_MACRO = 0x004F1AE0,
// Macro create/edit workers — back `C_Macro.CreateMacro` /
// `C_Macro.EditMacro` (see [[src/macro/Edit.cpp]]). Both store the
// icon as a BARE basename at `entry + OFF_MACRO_ICON` (256 bytes,
// no validation); `Script_GetMacroInfo` re-prefixes it as
// `Interface\Icons\%s` on read, which is why any texture that lives
// under `Interface\Icons\` — including index-less `INV_*` item icons
// — round-trips even though vanilla's index-based UI can't pick it.
//
// Create — `__fastcall(char *name /*ECX*/, char *iconBasename /*EDX,
// may be null*/, char *body /*may be null*/, uint local, int
// perCharacter) -> uint macroID`. SStrCopys name→`+0x24` (0x40),
// icon→`+0x64` (0x100) when non-null, body via `FUN_004f1550`
// (`+0x164`), runs the primary-spell parser `FUN_004EFE00`, sets the
// dirty flag `DAT_00bdcbf8=1`, and refreshes the UI. Returns 0 on
// failure (empty name, or the 18-per-scope list is full). Pass
// `local=0` to match the legacy `CreateMacro` default.
FUN_MACRO_CREATE = 0x004F1010,
// Edit — `__fastcall(uint macroID, char *name, char *iconBasename,
// char *body, uint flag)`. Hash-finds the entry by macroID (no-op if
// absent); each of name/icon/body is written only when its pointer is
// non-null (so nil = leave that field unchanged), then reparse + dirty
// flag + UI refresh, exactly like the create worker. It ALWAYS writes
// `entry + OFF_MACRO_LOCAL_FLAG = flag`, so read the current flag and
// pass it back to leave it unchanged. Chosen over replicating the
// field writes because it also fires the action-button refresh
// (`FUN_004e5cc0`/`FUN_004e5c00`) that direct writes would miss.
FUN_MACRO_EDIT = 0x004F1280,
// macroID → 0-based slot (linear scan of VAR_MACRO_SLOT_MAP);
// `0xFFFFFFFF` on miss. `slot = FUN_MACRO_ID_TO_SLOT(macroID) + 1`
// is how the legacy `CreateMacro` wrapper turns the worker's return
// into the 1-based index it hands back to Lua.
FUN_MACRO_ID_TO_SLOT = 0x004F0EC0,
// Macro name → 0-based slot; `0xFFFFFFFF` on miss (the resolver
// behind `GetMacroIndexByName`). Feeding its miss value straight to
// `FUN_MACRO_SLOT_TO_ENTRY` yields NULL (bounds-rejected), so the
// by-name and by-index EditMacro paths share one validation.
FUN_MACRO_NAME_TO_SLOT = 0x004F0FA0,
// MacroEntry field offsets. Name/body are handled by the workers; the
// icon offset is documentation, and the local flag must be read to be
// preserved across an EditMacro that doesn't mean to change it.
OFF_MACRO_NAME = 0x24, // char[0x40] inline
OFF_MACRO_ICON = 0x64, // char[0x100] inline bare basename
OFF_MACRO_LOCAL_FLAG = 0x20, // uint32 `local` flag (echoed by GetMacroInfo)
// Which spellbook the cached primary spell (`OFF_MACRO_PRIMARY_SPELL`)
// came from: 0 = player, 1 = pet. Written alongside `+0x564` by the
// parser's name resolver (FUN_RESOLVE_SPELL_NAME_TO_BOOK_ID's out-param)
// and handed back as the pet flag by FUN_ACTION_SLOT_TO_SPELL.
OFF_MACRO_PRIMARY_SPELL_IS_PET = 0x568,
// macroID → `MacroEntry *` — `__fastcall(uint macroID)`. Walks the
// per-character macro hash (buckets at `[0x00BDCC54]`, mask at
// `[0x00BDCC5C]`; `entry+0x00` is the macroID key). The resolver behind
// every action-bar macro branch (slot→spell `FUN_004E5BA0`,
// FUN_GAMETOOLTIP_SET_MACRO, FUN_MACRO_RUN_BY_ID) — the action table
// stores macroIDs, not slots. NULL when the id isn't registered (deleted
// macro). (An earlier entry mislabeled this address as a per-spell
// "state cache" lookup with `+0x564 = usable` / `+0x568 = noMana`; those
// are the macro's primary spell and pet flag, and nothing read them
// through the mislabel.)
FUN_MACRO_ID_TO_ENTRY = 0x004F0F40,
// Macro icon path — `void __fastcall(uint macroID, char *out, uint
// size)`: sprintf("%s%s", "Interface\\Icons\\", entry+OFF_MACRO_ICON)
// into `out`, empty when the id is unknown. Exactly two callers (binary
// scan for `call 0x004F0FD0`): the per-slot texture resolver
// FUN_ACTION_SLOT_TEXTURE (`0x004E6C44`) and the macro cursor pickup
// FUN_MACRO_PICKUP (`0x00494F97`), so a co-hook here (`Macro::IconPath`)
// gives the `?`-icon rule to action buttons AND the drag cursor at once —
// the same place 3.3.5 keeps it (its getter `FUN_00566ac0`).
// `Script_GetMacroInfo` does NOT call it (it formats the path itself).
FUN_MACRO_ICON_PATH = 0x004F0FD0,
// Puts a macro on the cursor — `__fastcall(uint macroID)`; called from
// the UseAction core for macro slots when the cursor is in pickup mode
// (`FUN_004E62E0` / `FUN_004E6130`). Paints the cursor via
// FUN_MACRO_ICON_PATH. Doc-only.
FUN_MACRO_PICKUP = 0x00494F80,
// Macro body runner — `void __fastcall(MacroEntry *entry)`, null-safe.
// Tokenizes the body at `+OFF_MACRO_BODY` with FUN_STORM_STR_TOKENIZE
// (delimiters VAR_MACRO_LINE_DELIMS, 0x400-byte line buffer) and fires
// EVENT_EXECUTE_CHAT_LINE("%s", line) for every non-empty line;
// FrameXML's hidden `MacroEditBox` then pushes each line through
// `ChatEdit_SendText`. Sole caller FUN_MACRO_RUN_BY_ID (macroID → entry),
// itself called from the UseAction core `FUN_004E5EE0` for macro slots.
// Vanilla never skips `#` lines, so `#showtooltip` reached chat —
// `Macro::RunBody` co-hooks this to drop them.
FUN_MACRO_RUN_BODY = 0x004F14E0,
FUN_MACRO_RUN_BY_ID = 0x004F1460,
// The two engine re-parse passes that also rewrite `+0x564`/`+0x568`
// (both call FUN_MACRO_PARSE_PRIMARY_SPELL per macro): every macro
// (world-enter init `FUN_005DEA50` + macro file load `FUN_004F0600`), and
// only the unresolved ones (`+0x564 < 0` or `+0x568 != 0`) on spellbook
// update (`FUN_004BD990`).
FUN_MACRO_REPARSE_ALL = 0x004F0CA0,
FUN_MACRO_REPARSE_UNRESOLVED = 0x004F0CE0,
// Storm string tokenizer — `__stdcall(char **cursor, char *out, uint
// outSize, const char *delims, int *outQuoted)`, RET 0x14. Skips leading
// delimiters, copies the next token (honoring `"` quoting) NUL-terminated
// into `out` and advances `*cursor` past it. `outQuoted` may be NULL.
// Shared by the macro parser (0x100 buffer) and the body runner (0x400).
FUN_STORM_STR_TOKENIZE = 0x0064AE50,
VAR_MACRO_LINE_DELIMS = 0x0082EDFC, // "\r\n" — the macro line delimiter set (bytes 0D 0A 00 verified)
// The engine runner's own line buffer size (`SUB ESP, 0x404` plus the
// 0x400 it hands the tokenizer). Anything that tokenizes a macro body
// the way the runner does uses the same buffer, so a body line never
// truncates differently from the engine's.
MACRO_LINE_BUFFER_SIZE = 0x400,
EVENT_EXECUTE_CHAT_LINE = 0x188, // fmt "%s", one macro body line
// Macro-icon database. One flat array of basenames, built lazily and
// cached for the process. Each entry is the basename with its extension
// truncated (e.g. `"Ability_Kick"`); `Script_GetMacroIconInfo`
// (`0x004F1A30`) re-joins the `Interface\Icons\` prefix with
// `SStrPrintf("%s%s", …)` before pushing, and pushes the EMPTY STRING
// (not nil) for an out-of-range index. Only `Script_GetNumMacroIcons`
// (`0x004F19F0`) triggers the lazy build, gated on `count == 0`.
//
// `FUN_LOAD_MACRO_ICONS` runs three enumeration passes, then
// `qsort(array, count, 4, 0x004F05E0)` + an adjacent case-insensitive
// `SStrCmpI` dedup (freeing the dupe and memmove-compacting), then
// shrinks the allocation. Every pass appends with the SAME inlined
// grow-and-append code — there is no shared downstream helper, so the
// ONLY filtering is what each callback does itself:
//
// pass 1 FUN_MPQ_ENUM_FILES(6, "Interface\Icons\", cb, 0)
// -> FUN_MACRO_ICON_CB_MPQ: skips the prefix, keeps only
// `Ability_*` / `Spell_*` (SStrCmpI, length-bounded) with a
// `.blp` / `.tga` extension.
// pass 2 FUN_ADDON_SCAN_DISK_DIRS(<basePath>+"Interface\Icons\", "*", cb)
// -> FUN_MACRO_ICON_CB_DISK_PREFIXED: same prefix + extension
// test (plus a `.bz` sub-extension strip).
// pass 3 FUN_ADDON_SCAN_DISK_DIRS("Interface\Icons\", "*", cb)
// -> FUN_MACRO_ICON_CB_DISK_ANY: extension test ONLY.
//
// So the engine's list is all `Ability_*`/`Spell_*`
// (`GetNumMacroIcons() == 746`) for one reason: passes 1-2 prefix-filter,
// and pass 3 — the only one that doesn't — is a DISK walk over a folder
// that is empty on a stock install (every icon ships inside the MPQs).
// A loose `INV_*.blp` dropped into `Interface\Icons\` DOES enter the list,
// through pass 3 alone. (An earlier note here guessed a filter inside the
// `SStrDup`/array-append helpers downstream of all three callbacks; that
// was wrong — the append is inlined per callback and nothing runs between
// the filter and the array write.) `Macro::Icons` also co-hooks the
// loader itself to seed `INV_Misc_QuestionMark` and move it to index 0,
// mirroring 3.3.5's loader (so `#showtooltip` macros can pick the `?`).
//
// `Macro::Icons` hooks all three at ENTRY, before each filter, so it sees
// every filename the engine walks — including the ~5,226 archive `INV_*`
// names pass 1 rejects — and sorts them into (loose|mpq) x (spell|item)
// buckets for the four modern `Get*MacroI*Icons` mutators. The bucket a
// callback feeds is therefore decided by WHICH WALKER the loader passed
// it to, which is what these names record.
VAR_MACRO_ICON_COUNT = 0x00BDCC1C, // uint32 count of loaded icons
VAR_MACRO_ICON_ARRAY = 0x00BDCC20, // char ** — flat array of icon-name C strings (4-byte stride)
FUN_LOAD_MACRO_ICONS = 0x004F0090, // `__cdecl()` lazy populate; no-op once count != 0
FUN_MACRO_ICON_CB_MPQ = 0x004F0220, // pass 1, ARCHIVE walk — `__fastcall(const char *archivePath)`, prefix + extension filtered; returns 1 to continue
FUN_MACRO_ICON_CB_DISK_PREFIXED = 0x004F0350, // pass 2, DISK walk — `__fastcall(FindRecord *r)` (dir bit `r[4] & 0x10`, inline name at `r+8`), prefix + extension filtered
FUN_MACRO_ICON_CB_DISK_ANY = 0x004F04F0, // pass 3, DISK walk — same record shape, EXTENSION ONLY (the sole route for a non-`Ability_`/`Spell_` icon)
// Quest log: 16-byte-stride entry array and active count.
// Field +0 of each entry is the questID for real quests (a category index
// for headers); field +8 is the header indicator: non-NULL = header,
// NULL = real quest. Verified by Script_GetQuestLogTitle's isHeader push
// at 0x004DF9A9 and by the helper at 0x004DF150 used by IsUnitOnQuest.
VAR_QUEST_LOG_ENTRIES = 0x00BB71C0,
VAR_QUEST_LOG_ENTRY_COUNT = 0x00BB7478,
OFF_QUEST_LOG_ENTRY_STRIDE = 0x10,
OFF_QUEST_LOG_ENTRY_QUEST_ID = 0x0,
OFF_QUEST_LOG_ENTRY_HEADER_PTR = 0x8,
// Script_GetQuestLogTitle — `int __fastcall(lua_State *L)`, the Lua entry
// itself. Reads L[1] (1-based index into the FULL entry array above) and
// pushes 6: title, level, questTag, isHeader (1/nil), isCollapsed
// (1/nil — header whose category bit in 0x00BB748C is clear), isComplete
// (1 = objectives done, -1 = failed, nil otherwise). Verified by decompile.
FUN_SCRIPT_GET_QUEST_LOG_TITLE = 0x004DF930,
// The single chokepoint that rebuilds the quest log from the
// player's authoritative quest-slot data at `[CGPlayer + 0xE68 +
// 0x28]` (a 0xF0-byte block holding the engine's quest sync state).
// Called by the engine after every quest state change that needs
// the Lua-visible log refreshed — accept, abandon, completion,
// objective updates, login bulk sync. Signature:
//
// __fastcall void FUN_QUEST_LOG_REBUILD(int param_1)
//
// If `param_1 == 0`, the function just fires QUEST_LOG_UPDATE
// (event ID 0x134) via `FUN_00703E50` and returns — a no-op
// rebuild signal. If non-zero, it `memset`s the entry array,
// walks the player's slot data, repopulates `VAR_QUEST_LOG_ENTRIES`
// / `VAR_QUEST_LOG_ENTRY_COUNT`, then fires QUEST_LOG_UPDATE.
//
// Hooked by `Quest::LogEvents` to snapshot the log pre-/post-rebuild
// and fire `QUEST_ACCEPTED(logIndex, questID)` / `QUEST_REMOVED(questID)`
// for the diff. Single quiet target in the `0x004DExxx` quest region —
// no known DLL collisions.
FUN_QUEST_LOG_REBUILD = 0x004DE510,
// The engine's per-quest-slot player-descriptor observer, registered 20
// times by FUN_005DD8A0 (once per slot, at OFF_DESC_PLAYER_QUEST_LOG_FIRST
// + N * DESC_PLAYER_QUEST_LOG_SLOT_SIZE, size DESC_PLAYER_QUEST_LOG_SLOT_SIZE).
// Standard observer callback ABI; resolves the player from the GUID it is
// handed via FUN_OBJECT_RESOLVE_BY_GUID(TYPEMASK_PLAYER, …) and returns 1.
//
// This is the engine's own accept/remove decision point. On a slot taking
// a quest — `new != 0 && (old == 0 || (new == old && !complete(new) &&
// complete(old)))` — it announces "Quest accepted: <name>" via
// `FUN_00496720(0x89, title)`, the game-message table at 0x00B4B498
// (stride 0x14), row 137 = { "ERR_QUEST_ACCEPTED_S", channel 0, sound
// "QUESTADDED" }. On `old != 0 && new != old` it drops the old quest
// (FUN_004DF0E0). The title comes from the QUEST CACHE, never from the
// quest log, so it can announce a quest the Lua-visible log hasn't picked
// up yet; on a cache miss it announces nothing and queues the deferred
// twin at 0x005DDEB0, which re-reads the cache once the query response
// lands. Hooked by `Quest::LogEvents` — see that file.
FUN_QUEST_SLOT_ANNOUNCE_OBSERVER = 0x005DDD80,
// Player and pet spellbooks — flat int32 arrays indexed by 0-based slot.
// Each entry is a spellID (0 for unused slots). Engine bounds-checks
// each slot against an absolute max of `SPELLBOOK_MAX_SLOTS = 0x400`
// before indexing (see `Script_GetSpellName` at `0x004B3FE0` and the
// `cmp eax, 0x400; jb` guard at `0x004B4018`); the actual populated
// count is much smaller, but slots past the populated range simply
// hold 0, which we surface to Lua as nil.
//
// Used by `Spell::Lookup::SpellbookSlotToID` to support the
// `GetSpellInfo(slot, bookType)` overload.
VAR_PLAYER_SPELLBOOK = 0x00B700F0,
VAR_PET_SPELLBOOK = 0x00B6F098,
SPELLBOOK_MAX_SLOTS = 0x400,
// Populated-slot count of the player array above. The learn writer
// `FUN_LEARN_SPELL` appends a newly learned spell at
// `VAR_PLAYER_SPELLBOOK[count++]` (0x004B2B37: `mov [ecx*4 + B700F0],
// spellID; inc [B7116C]`), so a before/after read of this count is the
// exact "was it added to the book" gate the engine itself uses before
// firing LEARNED_SPELL_IN_TAB. Read by `Spell::Learn`.
VAR_PLAYER_SPELLBOOK_COUNT = 0x00B7116C,
// The player's pet GUID as a u64 (lo @ +0, hi @ +4). Verified three
// ways: `Script_HasPetUI` (0x004BE670) resolves it with TYPEMASK_UNIT
// through FUN_OBJECT_RESOLVE_BY_GUID, FUN_PET_ACTIONS_USABLE compares it
// against the CGPlayer pet field (`[player+0xE68]+0x830`), and the pet
// branch of the action-usability recompute `FUN_004E5050` resolves the
// pet from it before reading the pet's power.
VAR_PET_GUID = 0x00B714A0,
// "The pet can act" — the core of `Script_GetPetActionsUsable`
// (0x004BE0B0), `int()` with no args. True when the player isn't
// charmed, the CGPlayer pet field matches VAR_PET_GUID, the pet
// resolves, its charmer / summoner is the player, it's not stunned /
// fleeing / confused, and the pet-state flag `[0x00B71468] & 0x8000000`
// is clear. The pet branch of `FUN_004E5050` gates on it before the
// pet power check; `Spell::Usable` mirrors that branch for pet-book
// spells.
FUN_PET_ACTIONS_USABLE = 0x004BCF70,
// Spellbook TABS — what `GetNumSpellTabs` / `GetSpellTabInfo` read.
// `[VAR_SPELL_TAB_ENTRIES]` is a `SpellTab **` (heap array of pointers,
// grown by `FUN_LEARN_SPELL` as new skill lines appear); `[VAR_SPELL_TAB_
// COUNT]` is the live tab count. Each 8-byte `SpellTab` is
// `{ skillLineID @+0, numSpells @+4 }` — verified from
// `Script_GetSpellTabInfo` (0x004B3CE0), which reads `entry[0]` as the
// SkillLine.dbc ID (0 = the "General" tab, name from the GENERAL global
// string + `Interface\Icons\Ability_Kick`; else name `SkillLine+0x0C`
// localized, icon via `SkillLine+0x54` → SpellIcon.dbc) and pushes
// `entry[1]` as numSpells. Tabs partition the player spellbook array in
// order: tab i covers slots `[offset(i), offset(i) + numSpells)` where
// `offset` is `FUN_SPELL_TAB_SLOT_OFFSET`. The skillLineID per tab is
// never surfaced to Lua by the stock API — `Spell::Tabs` exposes it as
// `C_SpellBook.GetSkillLineIndexByID` / `GetSpellBookItemSkillLineIndex`.
VAR_SPELL_TAB_ENTRIES = 0x00B71160,
VAR_SPELL_TAB_COUNT = 0x00B71170,
OFF_SPELL_TAB_SKILL_LINE_ID = 0x00,
OFF_SPELL_TAB_NUM_SPELLS = 0x04,
// `int __fastcall(uint tabIndex0)` — sum of `numSpells` over tabs
// `[0, tabIndex0)`, i.e. the 0-based first slot of that tab (the `offset`
// return of `GetSpellTabInfo`). Returns 0 for tab 0 and for OOR input.
FUN_SPELL_TAB_SLOT_OFFSET = 0x004B2580,
// The engine's own `Script_GetSpellTabInfo(index)` Lua C function
// (`int __fastcall(void *L)`; reads `L[1]`, pushes `name, texture,
// offset, numSpells`). `C_SpellBook.GetSpellBookSkillLineInfo` reshapes
// the stack and calls it directly so the GENERAL-tab localization and the
// SkillLine → SpellIcon chain stay the engine's.
FUN_SCRIPT_GET_SPELL_TAB_INFO = 0x004B3CE0,
// Active minimap-tracking spell ID (0 = none). Vanilla tracks exactly
// one active tracker as a plain int here, derived from the player's
// active Track Creatures/Resources/Stealthed aura by `FUN_004E4170`
// (an aura-descriptor observer registered by `FUN_004E4100`). Read by
// `Script_GetTrackingTexture` (`0x004E4A20`), `Script_CancelTrackingBuff`
// (`0x004E4A80`), and `GameTooltip:SetTrackingSpell` (`0x00532C50`);
// `Spell::Tracking::GetTrackingInfo` reads it to report `active`.
VAR_ACTIVE_TRACKING_SPELL = 0x00BC6378,
// Player-spell-knowledge bitmap — `[VAR_PLAYER_SPELL_BITMAP]` is a
// pointer to a dword bitmap covering all spellIDs the player has
// learned, including talent passives, racials, profession recipes,
// and anything else granted via SMSG_LEARNED_SPELL / set in
// SMSG_INITIAL_SPELLS. One bit per spellID:
//
// bit set ⟺ player knows this spellID
// bitmap[spellID >> 5] & (1 << (spellID & 31))
//
// Verified by decoding the engine helper at `0x0060C740` (called
// from `Script_GetTalentInfo`'s currentRank-derivation loop). Matches
// the same bitmap pattern 5.4.8 uses for its `IsPlayerSpell`
// (instance moved to `[0x011C25D8]` in that build).
//
// Bitmap covers spellIDs 0..VAR_SPELL_RECORD_COUNT inclusive — the
// size matches Spell.dbc's row count. Pre-login the slot is NULL.
VAR_PLAYER_SPELL_BITMAP = 0x00B710FC,
// Player spell-knowledge writers — the two functions that mutate the
// bitmap above. Learn (`FUN_004b25b0`) sets the bit, rebuilds the
// spellbook arrays, and fires SPELLS_CHANGED; unlearn (`FUN_004b2c50`)
// clears the bit and removes the spell. Both `__fastcall`: learn is
// (uint spellID, int notify, uint replacedSpellID), unlearn is
// (uint spellID, int). Co-hooked (spell/Learn.cpp) to bump
// Player::StatSignal so a talent respec invalidates GetSpellBonusHealing's
// talent-conversion cache, and to fire LEARNED_SPELL_IN_SKILL_LINE. They
// fire at login (SMSG_INITIAL_SPELLS) and on each learn/unlearn — never
// per-frame, so cool hook targets.
//
// Learn's own event gate (decompiled): it fires LEARNED_SPELL_IN_TAB
// (event 0x1FE, fmt "%d" at 0x00835154) only when `notify != 0` AND the
// spell was appended to the player spellbook array (non-trade, non-
// hidden spells; passives included). Shapeshift-form spells additionally
// hit the form list + UPDATE_SHAPESHIFT_FORMS; trade spells only get the
// "learned how to create" chat line (0x39). There is NO action-bar
// auto-placement anywhere in it — 1.12 never pushes a learned spell to a
// bar, so SPELL_PUSHED_TO_ACTIONBAR has no engine source.
FUN_LEARN_SPELL = 0x004B25B0,
FUN_UNLEARN_SPELL = 0x004B2C50,
// Per-spell cooldown query. `__fastcall(int spellID, int pet,
// int *outDuration, int *outStart, int *outEnable)`. Same path
// `Script_GetSpellCooldown` (`0x004B40A0`) uses internally after
// resolving the (slot, bookType) Lua args to a spellID. `pet` picks the
// spell history: 0 = the player's (`0xCECAEC`), 1 = the pet's
// (`0xCECB04`) — 4.3.4's by-ID `GetSpellCooldown` picks 1 when the spell
// is in the pet's book. `outDuration > 0` means the spell is currently
// on cooldown.
//
// **Argument order**: verified via `Script_C_Spell_GetSpellCooldown`
// round-trip test (Blink, spellID 1953) — the third arg receives
// the cooldown duration (e.g. 15000 ms for Blink), the fourth
// receives the engine tick count at start (`FUN_OS_TICKCOUNT_MS`).
// Both are 0 when no cooldown is active. The CMaNGOS-leaning
// documentation in other emulator projects has these reversed —
// don't trust it for this entry.
FUN_SPELL_QUERY_COOLDOWN = 0x006E2EA0,
// Per-item cooldown query — `bool __fastcall(uint itemID,
// int *outDuration, int *outStart, uint *outEnable)`. Looks up
// the item's `ItemStats_C` record via the cache, finds the slot
// with trigger = ON_USE (`OFF_ITEMSTATS_SPELL_TRIGGER[i] == 0`),
// and queries that spell's cooldown via the shared
// `FUN_006E13E0` against the player-spell manager
// (`DAT_00CECAEC`). Returns `true` when a cooldown is active.
//
// Same `(*outDuration, *outStart, *outEnable)` order as
// `FUN_SPELL_QUERY_COOLDOWN`, so the unit conversion is
// identical: multiply both by 0.001 to convert engine ms →
// `GetTime()`-compatible seconds.
//
// **Calling convention gotcha**: the Ghidra decomp labels the
// first arg `uint *` because the ItemStats cache lookup uses
// it both as a hash key and as the cached-entry field-0 match
// target (a `uint *` typed slot). The actual fastcall value is
// the itemID integer itself, NOT a pointer to it — passing
// `&itemID` makes ItemStats interpret the stack address as the
// itemID and the lookup silently fails.
FUN_ITEM_QUERY_COOLDOWN = 0x006E2ED0,
// Spell.dbc reagent fields. Reagent[8] (itemIDs) at +0xA8;
// ReagentCount[8] (counts) at +0xC8. Verified empirically by
// decompiling `BuildSpellTooltip` at 0x0052E610 — its reagent-
// loop iterates `localSpellRec + 0x2A` (dword arithmetic, byte
// +0xA8) as itemIDs and indexes `[+8]` (dword 0x32, byte +0xC8)
// for counts. Walked by both the tradeskill / craft scraper's
// `Spell::Lookup::NthRecipeReagentItemID` and `IsUsableSpell`'s
// reagent gate.
//
// **Don't trust CMaNGOS for these offsets.** A prior version of
// this entry placed reagents at +0x110 / +0x130 per CMaNGOS
// vanilla `SpellEntry`, but 1.12.1's actual record layout
// diverges from CMaNGOS for reagent fields — those offsets read
// unrelated data that's always 0 for normal spells, so
// IsUsableSpell's reagent check silently passed every spell.
// The "verified previously" PowerType=+0x7C / ManaCost=+0x80
// CMaNGOS alignment held for earlier fields but breaks before
// the reagent block.
OFF_SPELL_REAGENT_ID = 0xA8,
OFF_SPELL_REAGENT_COUNT = 0xC8,
SPELL_MAX_REAGENTS = 8,
// (`0x004F0F40` used to be listed here as a per-spell "state cache"
// lookup with `+0x564 = usable` / `+0x568 = noMana`. Decompiled, it is
// the macroID → MacroEntry resolver — see FUN_MACRO_ID_TO_ENTRY — and the
// two fields are the macro's cached primary spell and its pet flag
// (OFF_MACRO_PRIMARY_SPELL / OFF_MACRO_PRIMARY_SPELL_IS_PET). The
// action-bar path `0x004E5BA0` that reads them is the macro branch of
// FUN_ACTION_SLOT_TO_SPELL. `IsUsableSpell` never read the mislabel.)
// Spell description format helper. Reads the locale-resolved description
// string from `record[+0x228 + locale*4]` and walks it character-by-
// character substituting `$s1`/`$d`/`$o`/etc. placeholders with values
// computed from the spell record. Engine has 8 callers (the spell
// tooltip builder at 0x52F717, the talent UI, the trainer, ...). The
// global cursor at `0x00BE0B80` is the helper's parser state; it sets
// and walks it internally, so callers don't manage it.
//
// Calling convention (verified at 0x52F717 et al.):
// void __fastcall(
// void *spellRecord, // ecx — Spell.dbc record ptr
// char *outputBuffer, // edx — caller-provided, null-terminated on return
// int bufLen, // [ebp+0x08]
// int contextFlag, // [ebp+0x0C] — small int the talent/trainer paths
// // compute from a UI-state global; 0 is the safe
// // "no scaling context" default
// int reserved3, // [ebp+0x10] — always 0 across the 8 callers
// int useToolTipText, // [ebp+0x14] — 0=description (+0x228),
// // non-zero=ToolTip (+0x24C with fallback to +0x228)
// int reserved5, // [ebp+0x18] — always 1 across the 8 callers
// int reserved6 // [ebp+0x1C] — always 0 across the 8 callers
// );
FUN_FORMAT_SPELL_DESCRIPTION = 0x005075F0,
// The currently-auto-repeating spellID (0 when nothing is
// auto-repeating). Same dword backs Shoot/Wand/Auto-Shot — no
// per-class branching. Written by the cast-start path at
// `FUN_006E54F0` (line `DAT_00ceac30 = *piVar5;` where `piVar5` is
// the Spell.dbc record) and cleared on logout/world unload. Read by
// `Script_IsAutoRepeatAction`'s inner helper at `0x004E55B0` and
// exposed as a 1-line getter at `0x006E9FD0`.
VAR_ACTIVE_AUTO_REPEAT_SPELL = 0x00CEAC30,
// StopAutoRepeatSpell — `void __cdecl(void)`. With an auto-repeat spell
// set: sends CMSG_CANCEL_AUTO_REPEAT_SPELL (0x26D), ends the ranged
// pose, clears VAR_ACTIVE_AUTO_REPEAT_SPELL and fires
// STOP_AUTOREPEAT_SPELL; nothing without one (decompiled; 4.3.4's
// Spell_C_CancelAutoRepeat(true)).
FUN_STOP_AUTO_REPEAT_SPELL = 0x006EA080,
// Currently-casting spellID. Written by the cast-start helper at
// `FUN_006E4AD0` (`__fastcall(spellID, targetState)`) — when a
// new cast begins, the function pushes the previous active
// spellID into `VAR_QUEUED_CAST_SPELL` and writes the new one
// here. Read by `Script_SpellStopCasting` via its
// `is-currently-casting` predicate at `FUN_006E3D30` (returns
// `DAT_00CECA88 != 0`) and the spellID-returning getter at
// `FUN_006E3D10`. Non-zero means "the cast bar is showing this
// spell"; cleared to 0 when the cast finishes or is cancelled.
VAR_CURRENT_CAST_SPELL = 0x00CECA88,
// Ground/reticle-targeting flags — non-zero while a spell is awaiting a
// target click (the AoE reticle / target cursor). `SpellIsTargeting()`
// (`0x006E6CD0`) returns true iff this != 0 (via its predicate
// `FUN_006E48A0`, `return DAT_00CECAC0 != 0`); `Spell_C_TargetSpell`
// (`0x006E5250`) sets the flag bits from the spell's target type, and the
// clear helper `FUN_006E4900` (from `SpellStopTargeting`) / a ground
// placement zeroes it. Polled by `Spell::CastEvents::PollReticle` to fire
// UNIT_SPELLCAST_RETICLE_TARGET / _CLEAR.
VAR_SPELL_TARGETING_FLAGS = 0x00CECAC0,
// The pending cast spellID — written by `Spell_C_CastSpell` (`0x006E4B60`)
// to the spell being cast, and used elsewhere as a `Spell.dbc` index (e.g.
// `CancelSpell`'s `records[this]`). While `VAR_SPELL_TARGETING_FLAGS` is
// set it's the spell whose reticle is up, so the RETICLE events read the
// spellID from here.
VAR_PENDING_CAST_SPELL = 0x00CEAC58,
// The cast-start state writer — `__fastcall(int spellID, int
// targetState)`. Sets `VAR_CURRENT_CAST_SPELL` (pushing any current
// spell into `VAR_QUEUED_CAST_SPELL`; `spellID == 0` restores the queued
// one). `Spell::Cast` co-hooks it for lag-free, client-side detection of
// NORMAL player casts (stamps from the spellID arg before the original).
// It does NOT fire for a chained same-spell recast: the caller
// `Spell_C_CastSpell` (`0x006E4B60`) short-circuits at `spellID ==
// VAR_CURRENT_CAST_SPELL` *before* reaching here, so those never run the
// client cast path — they're caught by the `SMSG_SPELL_START` backstop
// instead. nampower hooks the higher Spell_C_CastSpell, not this inner
// writer, so contention is low.
FUN_CAST_START_SET = 0x006E4AD0,
// Previous / queued cast — holds the spellID that was active
// before the latest one superseded it (mid-GCD queueing in
// vanilla). When the current cast ends, `FUN_006E4AD0(0, ...)`
// restores this into `VAR_CURRENT_CAST_SPELL`. Modern
// `C_Spell.IsCurrentSpell` covers both "casting now" and "queued
// to cast next", so we check this slot too.
VAR_QUEUED_CAST_SPELL = 0x00CECAA8,
// Spell-placement state bitmask. Non-zero when the engine is
// waiting on user input for an in-progress cast — the AoE reticle,
// unit-target cursor, trade-target cursor, etc. Bits encode what
// kind of input is needed; the engine's click handlers read this
// to decide whether a click was relevant. Read by
// `Script_SpellIsTargeting` via `FUN_006E48A0` (returns
// `state != 0`). Bits the engine OR-sets via `FUN_006E5250` when
// entering placement (subset relevant to us):
// - `0x20` source world location needed
// - `0x40` dest world location needed
// The `0x60` mask therefore identifies "ground-target placement"
// (vs. unit-target, trade-target, etc.). See `Spell::Placement`.
VAR_SPELL_PLACEMENT_STATE = 0x00CECAC0,
SPELL_PLACEMENT_GROUND_MASK = 0x60,
// `FUN_006E60F0(float *xyz)` — commits the in-flight ground-target
// placement at the given world position. Reads three contiguous
// floats from `xyz`; checks the placement-state mask
// (`VAR_SPELL_PLACEMENT_STATE`) to decide whether this is a
// source-coord (`0x20`) or dest-coord (`0x40`) commit; clears the
// matching bit and stores the coords into engine globals which the
// cast-finalize path then reads. Self-gates when neither bit is
// set — safe no-op for unit-target placement. Called by the engine
// itself when a player left-clicks ground while the reticle is up.
FUN_COMMIT_PLACEMENT_COORDS = 0x006E60F0,
// `FUN_006E4900()` — cancels in-flight placement mode. Internally
// checks `VAR_SPELL_PLACEMENT_STATE != 0` and, if so, fires the
// cast-cancel path via `FUN_006E4940(0x1C)`. Safe to call when no
// placement is active (no-ops). Wraps the action behind
// `Script_SpellStopTargeting`.
FUN_STOP_PLACEMENT = 0x006E4900,
// `*VAR_WORLDFRAME_CLICK_INFO` is a pointer to the engine's
// CWorldFrame "click info" struct — the data block where the input
// dispatcher stashes "what is the cursor pointed at right now"
// after every mouse motion. Allocated at world enter, populated
// continuously by the rendering pipeline (viewport bounds and
// camera position at fixed offsets) and the OS message pump
// (cursor screen pos). NULL when not in world.
// - `+0x350` (uint32) click type after last raycast:
// `0` = no hit
// `1` = world / terrain hit
// `2` = unit / object hit
// - `+0x360..+0x368` (3 floats) hit world position (when type == 1)
VAR_WORLDFRAME_CLICK_INFO = 0x00B4B2BC,
OFF_CLICK_INFO_TYPE = 0x350,
OFF_CLICK_INFO_COORDS = 0x360,
// `FUN_00481F00(void *clickInfo)` — refreshes the cursor's "what
// am I pointed at?" state on demand. Internally reads cursor
// screen pos from input state at `[clickInfo+0xA0]+0x1118/+0x111C`,
// calls the screen→world ray builder at `FUN_004813B0` (uses
// viewport bounds at `[clickInfo+0x390..+0x39C]` plus camera
// position at `[clickInfo+0x65B8]+8/+0xC/+0x10`), then raycasts
// via `FUN_0069BFF0` (terrain + WMO intersection). Writes click
// type to `[clickInfo+0x350]` and hit coords to
// `[clickInfo+0x360..+0x368]`. Safe to call from arbitrary code
// as long as the player is in-world.
FUN_REFRESH_CURSOR_RAYCAST = 0x00481F00,
// `Script_CastSpellByName` — engine's Lua wrapper for the
// `CastSpellByName(name [, onSelf])` global. `int __fastcall(void *L)`
// — standard Lua C function ABI. Reads `name` from stack[1] (string)
// and `onSelf` from stack[2] (boolean), resolves the name (with
// optional `(Rank N)` suffix) through `FUN_004B3950`, then dispatches
// to the engine's cast path at `FUN_004B3300`. Returns 0 (no Lua
// results). Callable directly from C++ — push args on stack, call.
FUN_SCRIPT_CAST_SPELL_BY_NAME = 0x004B4AB0,
// `Script_CastSpell` — engine's Lua wrapper for the slot-based
// `CastSpell(spellbookSlot, bookType)` global. `int __fastcall(void *L)`.
// Parses (slot, bookType) from stack[1]/[2] via `FUN_004B3EC0`, then
// dispatches through `FUN_SPELL_CAST_DISPATCH` with the current target
// (or self). Raises "Invalid spell slot in CastSpell" for a bad slot.
// Callable from C++ by preparing the stack and tail-calling it (the
// `Spell::Tracking::SetTracking` "select = cast" path does this).
FUN_SCRIPT_CAST_SPELL = 0x004B42F0,
// Inner spell-cast dispatcher — `__fastcall(slot, bookType, targetGuidLo,
// targetGuidHi)`. `Script_CastSpellByName` calls this after resolving
// the spell name to a spellbook slot. For ground-target spells, the
// engine enters placement mode (sets `VAR_SPELL_PLACEMENT_STATE`)
// and returns; placement is resolved later by mouse-click or
// programmatically via `FUN_COMMIT_PLACEMENT_COORDS`. Passing (0, 0)
// for the GUID is the "no implicit target" form — engine falls back
// to the player's current selected target.
FUN_SPELL_CAST_DISPATCH = 0x004B3300,
// Macro "primary spell" parser — `__fastcall(MacroEntry *entry)`.
// Walks the macro body (stored at `entry + OFF_MACRO_BODY`) line
// by line, looking for `/cast <name>`, `/castsequence <name>`,
// etc. (via the engine's `SLASH_CAST%d` registry) and the
// `CastSpellByName("<name>")` Lua pattern. On first hit, resolves
// the name to a spellID via `FUN_004B3BC0` and writes it to
// `entry + OFF_MACRO_PRIMARY_SPELL`. Writes `0xFFFFFFFF` when a
// pattern matched but the name didn't resolve (unknown spell);
// writes `0` when no line matched any pattern. Called from macro
// create/edit/refresh paths.
//
// Hooked by `Spell::CastNoToggle` to teach the engine to recognize
// `CastSpellNoToggle("<name>")` as a primary-spell pattern, so
// macros using it get tagged in the spell-state cache the same
// way `CastSpellByName` macros do. Without this, `IsAutoRepeatAction`
// returns false for macro slots whose only cast is via our function
// (the engine's parser doesn't know to look for our identifier),
// breaking action-bar highlighting in pfUI etc.
FUN_MACRO_PARSE_PRIMARY_SPELL = 0x004EFE00,
// Engine's "spell name → spellbook-resolved spellID" helper.
// `__fastcall(const char *name, int *outIsPet)`. Internally calls
// `FUN_004B3950` (the rank-stripping name-with-`(Rank N)` parser)
// to get a spellbook slot, then returns
// `[VAR_PLAYER_SPELLBOOK][slot]` or `[VAR_PET_SPELLBOOK][slot]` and
// WRITES which book matched to `*outIsPet` (0 player, 1 pet — an
// output; initialize it to 0). The macro parser passes
// `&entry->OFF_MACRO_PRIMARY_SPELL_IS_PET` here. Returns 0 if the name
// doesn't resolve to a known spellbook entry. This is the resolver the
// engine's macro parser uses — name → spellID lookup that respects
// the player's known spell list.
FUN_RESOLVE_SPELL_NAME_TO_BOOK_ID = 0x004B3BC0,
// The single name → spellbook-slot resolver underneath everything
// spell-cast related. `__fastcall(const char *name, void *out) ->
// int slot` (or `-1`). Strips a trailing `(Rank N)` suffix, then
// calls `FUN_004B3A10` for the actual lookup. Called by
// `Script_CastSpellByName` (every Lua cast) AND by
// `FUN_RESOLVE_SPELL_NAME_TO_BOOK_ID` (which the macro parser
// uses). Hooking here makes one change to both the runtime cast
// path AND the macro-tagging path — `Spell::NameResolve` owns that
// hook and uses it for the two macro name forms the engine never
// learned: a numeric spellID (`/cast 5019`) and the `!Name` prefix.
FUN_RESOLVE_SPELL_NAME_TO_SLOT = 0x004B3950,
// `__fastcall(uint slot, int bookType) -> int isActive`. Returns 1
// if the spell at the given (slot, bookType) is currently producing
// an active aura on the player (bookType=0) or pet (bookType=1).
// Walks the unit descriptor's aura-spellID array at `+0xA4` (48
// slots) and checks the active-bit at `+0x164`. The engine's
// toggle-aware cast path (`FUN_004B3300`) consults this to decide
// whether `/cast Shoot` should send CMSG_CAST_SPELL or
// CMSG_CANCEL_AURA. Used by `Spell::CastNoToggle` to suppress the
// toggle-off side of `CastSpellNoToggle` on shapeshift / aspect /
// stance forms — anything that creates a self-aura.
FUN_SPELL_IS_TOGGLE_AURA_ACTIVE = 0x004B36F0,
// MacroEntry struct offsets (verified by tracing FUN_004EFE00).
// The macro body is an inline null-terminated string at `+0x164`;
// line breaks are `\r\n` / `\n` (VAR_MACRO_LINE_DELIMS). The
// primary-spell cache is at `+0x564` (its spellbook flag at
// OFF_MACRO_PRIMARY_SPELL_IS_PET); FUN_ACTION_SLOT_TO_SPELL returns it
// for every macro slot, so cooldown / usable / range / current /
// auto-repeat all follow it — and `Macro::ShowTooltip` writes the
// `#showtooltip`-resolved spell into it for exactly that reason.
OFF_MACRO_BODY = 0x164,
OFF_MACRO_PRIMARY_SPELL = 0x564,
// Spell.dbc and friends. Pointer-to-records-array + record-count pairs.
// Used by Script_GetSpellName/Texture and BuildSpellTooltip.
VAR_SPELL_RECORDS = 0x00C0D788, // SpellRecord *records[spellID]
VAR_SPELL_RECORD_COUNT = 0x00C0D78C, // max spellID
// SpellMechanic.dbc — maps a SpellMechanic ID to its localized
// name. Standard 5-DWORD DBC instance at 0x00C0D7BC; records ptr at
// +0x08, count at +0x0C (see docs/DBCs.md). Records are 1-based
// (records[mechanicID]); the engine only ever uses the table for
// existence/bounds checks (FUN_006e9ca0, FUN_00612df0, FUN_006e8eb0
// case 0x8d all do `records[id] != 0`), never reading the name — so
// the name offset below follows the canonical 2-column
// (ID + localized Name) DBC schema rather than an engine-reader anchor.
VAR_SPELLMECHANIC_RECORDS = 0x00C0D7C4, // SpellMechanicRecord *records[mechanicID]
VAR_SPELLMECHANIC_COUNT = 0x00C0D7C8, // max mechanic ID
OFF_SPELLMECHANIC_NAME = 0x04, // char *name[9], locale-indexed
// SpellItemEnchantment.dbc — the table a weapon/item enchant ID
// (e.g. the enchantID from `C_Item.GetWeaponEnchantInfo`) indexes.
// Records-ptr at instance +0x08, count at +0x0C (instance 0x00C0D7D0).
// 24-DWORD records (recordSize 0x60). Layout fully verified by
// parsing the on-disk SpellItemEnchantment.dbc against known records
// (Crusader 1900: Type[0]=1, Arg[0]=20007 "Holy Strength";
// Sharpened+3 id 13: Type[0]=2, Amount[0]=3; Reinforced Armor+8 id 15:
// Type[0]=4, Amount[0]=8). OFF_..._NAME (+0x34) is cross-confirmed by
// two engine readers (FUN_00496170 / FUN_00495d60) that push
// `[rec + 0x34 + VAR_LOCALE_INDEX*4]` as the display name.
// Type[i] : ITEM_ENCHANTMENT_TYPE — 1=combat-proc spell,
// 2=damage, 3=equip spell, 4=resistance, 5=stat,
// 6=totem, 7=use spell. 0 = empty slot.
// Amount[i] : magnitude for damage/resist/stat types (min; vanilla
// min==max). 0 for spell types (value lives in the spell).
// Arg[i] : spellID for spell types (1/3/7); stat index for STAT.
VAR_SPELLITEMENCHANT_RECORDS = 0x00C0D7D8, // SpellItemEnchantmentRecord *records[enchantID]
VAR_SPELLITEMENCHANT_COUNT = 0x00C0D7DC, // max enchant ID
OFF_SPELLITEMENCHANT_TYPE = 0x04, // int Type[3]
OFF_SPELLITEMENCHANT_AMOUNT = 0x10, // int Amount[3] (EffectPointsMin)
OFF_SPELLITEMENCHANT_ARG = 0x28, // int EffectArg[3]
OFF_SPELLITEMENCHANT_NAME = 0x34, // char *name[8], locale-indexed
// ItemRandomProperties.dbc — the table a random-suffix ID (the third
// field of an `item:id:enchant:suffix:unique` link) indexes to get
// the SpellItemEnchantment IDs that apply the "of the Bear"-style
// bonus. Standard 5-DWORD DBC instance at 0x00C0DBCC; records-ptr at
// +0x08, count at +0x0C (see docs/DBCs.md). Verified by parsing the
// on-disk ItemRandomProperties.dbc: 16-field / 0x40 records, field 0
// = ID, field 1 = internal name string, and the enchant IDs occupy
// fields 2..6 (offset +0x08, five contiguous u32 slots — only the
// first few are used; the rest are 0). Field 7 duplicates the name
// string offset, so it is NOT an enchant slot — do not read past
// slot 5.
VAR_ITEMRANDOMPROP_RECORDS = 0x00C0DBD4, // ItemRandomPropertiesRecord *records[suffixID]
VAR_ITEMRANDOMPROP_COUNT = 0x00C0DBD8, // max suffix ID
OFF_ITEMRANDOMPROP_ENCHANT = 0x08, // u32 Enchantment[5]
ITEMRANDOMPROP_ENCHANT_SLOT_COUNT = 5,
// Spell.dbc School field — 0-based integer at record +0x04.
// Verified empirically against Fireball (133) → School=2 (Fire)
// and Frostbolt (116) → School=4 (Frost) on Octo 1.12.1. Vanilla
// doesn't use the multi-bit SchoolMask form (TBC+); a spell
// belongs to exactly one school. Mapping:
// 0 = Physical 1 = Holy 2 = Fire 3 = Nature
// 4 = Frost 5 = Shadow 6 = Arcane
OFF_SPELL_SCHOOL = 0x04,
SPELL_SCHOOL_COUNT = 7,
// Spell.dbc DispelType field — u32 at record +0x10, indexes into
// `SpellDispelType.dbc` (`VAR_SPELLDISPEL_RECORDS` below). 0 =
// not dispellable. Verified by decompiling `Script_UnitDebuff`,
// which reads `*(int*)(spellRecord + 0x10)` and feeds it into
// the DispelType DBC to produce the third return value (the
// dispel-type name string).
OFF_SPELL_DISPEL_TYPE = 0x10,
VAR_SPELL_RANGE_RECORDS = 0x00C0D79C, // SpellRange.dbc
VAR_SPELL_RANGE_COUNT = 0x00C0D7A0,
OFF_SPELLRANGE_RECORD_MIN = 0x04, // float min range (column 1)
OFF_SPELLRANGE_RECORD_MAX = 0x08, // float max range (column 2)
VAR_SPELL_ICON_RECORDS = 0x00C0D7EC, // SpellIcon.dbc
VAR_SPELL_ICON_COUNT = 0x00C0D7F0,
VAR_SPELL_CAST_TIMES_RECORDS = 0x00C0D878, // SpellCastTimes.dbc
VAR_SPELL_CAST_TIMES_COUNT = 0x00C0D87C,
// SpellRadius.dbc — AOE radius records, indexed by a spell's
// EffectRadiusIndex (see OFF_SPELL_RECORD_EFFECT_RADIUS_INDEX). Record
// shape: { id@+0, radius@+4 (f32), radiusPerLevel@+8 (f32), ... }.
// Verified by decompiling FUN_006e6350 (the engine's effective-radius
// helper), which reads `radiusRec[+4]` as the base radius and
// `radiusRec[+8] * casterLevel` as the per-level term. Read by
// GetSpellRadius (base radius only — no level scaling).
VAR_SPELL_RADIUS_RECORDS = 0x00C0D7B0,
VAR_SPELL_RADIUS_COUNT = 0x00C0D7B4,
OFF_SPELL_RADIUS_VALUE = 0x04, // base radius, f32
// SpellMod (talent / item) accumulators for the LOCAL PLAYER. Two
// parallel tables of int32, indexed [familyFlagBit][op]: flat adds at
// VAR_SPELLMOD_FLAT_TABLE, percent adds at VAR_SPELLMOD_PCT_TABLE.
// Per-bit stride is 0x74 (29 ops); the op is the dword index (op*4
// within a slot). A spell's per-effect value is modified by summing,
// over the bits set in its SpellFamilyFlags, flat[bit][op] and
// pct[bit][op], then `value = (value + flat) * (100 + pct) * 0.01`.
// Gated on the spell's SpellFamilyName matching the player's class
// family. Decompiled from FUN_006e6b30 / FUN_006e6bf0 (the engine's
// ApplySpellMod), which the radius helper FUN_006e6350 invokes with
// op 6. These are single global instances = the local player's mods
// (vanilla only tracks spell mods for the local player).
VAR_SPELLMOD_FLAT_TABLE = 0x00CEAD60,
VAR_SPELLMOD_PCT_TABLE = 0x00CECB30,
SPELLMOD_SLOT_STRIDE = 0x74, // bytes per familyFlagBit row
SPELLMOD_SLOT_COUNT = 64, // SpellFamilyFlags is 64-bit
SPELLMOD_OP_RADIUS = 6, // op index for spell radius
SPELLMOD_OP_DURATION = 1, // op index for aura duration
// SpellDispelType.dbc — maps dispel-type IDs (1..N) to localized
// names like "Magic", "Curse", "Disease", "Poison". Used by
// `Script_UnitDebuff` to fill its third return value. Standard
// 5-DWORD class instance shape; records array at +0x08, count at
// +0x0C of the instance. Records themselves have a "has-name"
// gate at +0x28 (non-zero means the name slot is populated) and
// the locale-applied string pointer at +0x2C. The engine's
// accessor does the locale lookup before exposing the pointer
// here, so we get a ready-to-use string with no further indexing.
VAR_SPELLDISPEL_RECORDS = 0x00C0D83C,
VAR_SPELLDISPEL_COUNT = 0x00C0D840,
OFF_SPELLDISPEL_HAS_NAME = 0x28,
OFF_SPELLDISPEL_NAME = 0x2C,
// Map.dbc — instance/zone metadata. Standard 5-DWORD class instance
// shape; records and count are catalogued in `docs/DBCs.md`. Record
// schema (vanilla, derived from `FUN_00495c90` IsInInstance helper
// and `FUN_0049e1c0` raid-instance warning handler):
// +0x08 uint32 instance type (0=world, 1=dungeon, 2=raid, 3=BG)
// +0x10..+0x30 9 locale-string ptrs (localized display name)
// No max-players column in vanilla — that data was added in TBC via
// MapDifficulty.dbc.
VAR_MAP_RECORDS = 0x00C0DAA8,
VAR_MAP_COUNT = 0x00C0DAAC,
OFF_MAP_INSTANCE_TYPE = 0x08,
OFF_MAP_NAME = 0x10,
// Currently-loaded map ID (the Map.dbc ID for the zone/instance the
// player is in). Written by the map-transition handler
// `FUN_00495d10`; read by `FUN_00495c90` (the helper backing
// `Script_IsInInstance`).
VAR_CURRENT_MAP_ID = 0x00B4E378,
// "World is live" flag — 1 while the player is fully in the world, 0 during
// any loading screen (initial login, zone/instance transition, logout to
// glue). Set to 1 by the enter-world init `FUN_004908C0` (guarded
// `if (==0){=1;...}`) and back to 0 by the world-teardown `FUN_00490A80`
// (`if(!=0){=0;...}`) that runs at the start of every transition. Byte flag.
// The clean pollable gate for "can this happen in the world right now" —
// e.g. suppressing server resync packets that arrive behind a loading
// screen. Verified via the enter/leave pair in Ghidra.
//
// (NOTE: 0x00B4E37C is NOT this flag — an earlier note wrongly claimed it
// was. That address is instance grace-period state, read only by the
// "recently left an instance" 90-second check in `FUN_00495c90`.)
VAR_IN_WORLD = 0x00B4B424,
// Local player's current AreaTable.dbc ZONE ID (u32 storage; only
// the low 16 bits are used — the value is broadcast over the wire
// as a u16 in `SMSG_PARTY_MEMBER_STATS`). Written by the zone-change
// handler `FUN_00494780(zoneID, subzoneID, zoneName, subzone,
// realZone, eventID)`; read by `Script_GetRealZoneText` and the
// outbound party-stats builder `FUN_005f0880`.
VAR_PLAYER_AREA_ID = 0x00B4E314,
// Local player's current SUBZONE AreaTable.dbc ID, 0 when the area
// under the player is itself a top-level zone. Second arg of the same
// handler: its sole caller `FUN_0067e510` resolves the area at the
// player's position and passes (zone, area) when the area has a parent,
// else (area, 0). `Script_GetZonePVPInfo` reads the arena flag here.
VAR_PLAYER_SUBZONE_AREA_ID = 0x00B4E318,
// Unified party/raid member stats lookup —
// `__fastcall(GUID *guidPair) -> uint8_t *`. Returns a pointer to
// the member's stats data on hit, NULL on miss. Tail-jumps from
// party storage (`FUN_004e8820`, 4 slots at `0x00BC70B0`) to raid
// storage (`FUN_004bb0f0`, 40-slot pointer array at `0x00B712A8`).
// Both sub-calls return pointers where the field at `+0x14` is the
// u16 areaID (AreaTable.dbc ID) — for party that's at struct +0x14
// directly, for raid it's at `*raidArr[i] + 0x10 + 0x14`. Caller
// doesn't need to distinguish the two cases.
//
// Within the returned stats block: `+0x08` status flags, `+0x09`
// powerType, `+0x0A..+0x10` HP/maxHP/power/maxPower, `+0x12` level,
// `+0x14` u16 areaID, `+0x16/+0x18` position. Verified from the
// outbound stats builder `FUN_005f0880` (mirrors inbound packet
// shape from SMSG_PARTY_MEMBER_STATS_FULL).
FUN_GROUP_MEMBER_STATS_LOOKUP = 0x00496400,
OFF_GROUP_MEMBER_AREA_ID = 0x14,
// `+0x08` status-flags byte of the stats block (see field map above);
// bit 0 is the online flag `Script_UnitIsConnected` tests. Sibling
// `FUN_GROUP_MEMBER_SLOT_LOOKUP` (`0x00496420`, `__fastcall(u64 *guid)
// → member slot*`) is the presence fallback UnitIsConnected consults
// when no stats block exists — a non-null slot means the member is
// present (and thus connected). Both take a pointer to the 64-bit GUID.
OFF_GROUP_MEMBER_STATUS_FLAGS = 0x08,
GROUP_MEMBER_STATUS_ONLINE = 0x1,
// Bit 1: flagged for PvP — Script_UnitIsPVP's test (0x00516502) for a
// token with no unit object.
GROUP_MEMBER_STATUS_PVP = 0x2,
FUN_GROUP_MEMBER_SLOT_LOOKUP = 0x00496420,
// Inline member name in the slot record — `Script_UnitName` (0x00517020)
// pushes `slot + 8` for a GUID with no live object, as does the unit
// tooltip builder's no-object branch (0x00529FE0). This is why
// `UnitName("partyN")` answers for an offline member.
OFF_GROUP_MEMBER_SLOT_NAME = 0x08,
// Health/power fields within the two group-member blocks — the
// out-of-range fallback the engine's UnitHealth/UnitMana (and their Max
// variants) use when a groupmate has no live CGUnit (different map / out
// of range), sourced from SMSG_PARTY_MEMBER_STATS. The two blocks have
// DIFFERENT layouts (all u16):
//
// Stats block (FUN_GROUP_MEMBER_STATS_LOOKUP): statusFlags@+8,
// powerType@+9, health@+0xa, maxHealth@+0xc, power@+0xe, maxPower@+0x10,
// level@+0x12, areaId@+0x14. The full record.
// Raid slot (FUN_GROUP_MEMBER_SLOT_LOOKUP): powerType@+0x58,
// health@+0x5c, maxHealth@+0x5e, power@+0x60, maxPower@+0x62. Leaner —
// no level/area/flags.
//
// Power values are raw (divide by the power divisor for display). Verified
// from Script_UnitHealth (0x005174d0) / Script_UnitHealthMax (0x005175b0)
// / Script_UnitMana (0x00517670) / Script_UnitManaMax (0x005177e0).
OFF_GROUP_MEMBER_STATS_HEALTH = 0xa,
OFF_GROUP_MEMBER_STATS_MAX_HEALTH = 0xc,
OFF_GROUP_MEMBER_STATS_POWER_TYPE = 0x9,
OFF_GROUP_MEMBER_STATS_POWER = 0xe,
OFF_GROUP_MEMBER_STATS_MAX_POWER = 0x10,
OFF_GROUP_MEMBER_STATS_LEVEL = 0x12,
OFF_RAID_SLOT_POWER_TYPE = 0x58,
OFF_RAID_SLOT_HEALTH = 0x5c,
OFF_RAID_SLOT_MAX_HEALTH = 0x5e,
OFF_RAID_SLOT_POWER = 0x60,
OFF_RAID_SLOT_MAX_POWER = 0x62,
// Remaining raid-member-struct fields, mapped from Script_GetRaidRosterInfo
// (0x004bb560). Same struct FUN_GROUP_MEMBER_SLOT_LOOKUP returns; all
// object-independent (readable for out-of-range raiders). Name + class are
// NOT here — GetRaidRosterInfo reads those from the NameCache by GUID.
OFF_RAID_SLOT_SUBGROUP = 0x08, // u32, 0-based (roster UI shows +1)
OFF_RAID_SLOT_RANK = 0x0c, // u32
OFF_RAID_SLOT_FLAGS = 0x18, // u32
OFF_RAID_SLOT_LEVEL = 0x22, // u16
OFF_RAID_SLOT_AREA_ID = 0x24, // u16 -> AreaTable.dbc
RAID_SLOT_FLAG_ONLINE = 0x1,
RAID_SLOT_FLAG_DEAD = 0x4,
// Group-member aura spell-ID arrays — the out-of-range fallback the
// engine's Script_UnitBuff (0x00519500) / Script_UnitDebuff (0x005198f0)
// read when a groupmate has no live CGUnit. The server transmits a
// member's current auras (spell IDs only — no caster/duration/stacks) in
// SMSG_PARTY_MEMBER_STATS via GROUP_UPDATE_FLAG_AURAS (buffs, slots 0..31)
// + GROUP_UPDATE_FLAG_AURAS_NEGATIVE (debuffs, slots 32..47); the client
// keeps them in the two group-member blocks. Both arrays are 48 u16
// entries (UNIT_AURA_TOTAL) indexed by the same absolute slot the
// descriptor uses. Spell IDs are truncated to u16 on the wire, so custom
// IDs > 65535 come through wrong (same limitation as the built-in
// UnitBuff/UnitDebuff). Read the party array only when the member's online
// flag (OFF_GROUP_MEMBER_STATUS_FLAGS bit 0) is set — the engine does.
OFF_GROUP_MEMBER_STATS_AURAS = 0x1a, // party stats block (FUN_00496400)
OFF_RAID_SLOT_AURAS = 0x64, // raid slot (FUN_00496420)
// Per-slot GUID tables — used to map party/raid token strings
// ("party1", "raid17") to GUIDs without going through
// `FUN_RESOLVE_UNIT_TOKEN`, which only resolves to a local CGUnit
// and returns NULL for group members in other zones.
//
// Party: 4 entries × 8 bytes (lo + hi). `guids[i]` corresponds to
// "partyN" where N = i+1.
//
// Raid: 40 entries × 4 bytes — each is a `RaidMember *`. GUID is
// at `*member + 0` (lo) and `*member + 4` (hi). Verified from
// `FUN_004bb0f0`. Slot may be NULL (empty / offline raid member).
VAR_PARTY_MEMBER_GUIDS = 0x00BC6F48,
VAR_RAID_MEMBER_PTRS = 0x00B712A8,
// Raid-target-marker GUID table — 8 contiguous `uint64` slots, one
// per raid icon (slot 0 = mark1/star … slot 7 = mark8/skull), `0`
// when that marker is unassigned. Written by the
// `SMSG_RAID_TARGET_UPDATE` handler cluster (`FUN_004ba0b0` /
// `FUN_004ba220` / `FUN_004ba550`); the reverse lookup
// `FUN_004bb190(guidLo, guidHi)` walks it as `(&table)[i*2]` for
// `i` in 0..7 and returns the mark index or 8. `Unit::RaidTarget`
// reads it to resolve the `markN` token and to drive the per-mark
// unit-event observers. Matches nampower's `CGRaidInfo_m_raidtargets`.
VAR_RAID_TARGET_GUIDS = 0x00B71368,
VAR_LOCALE_INDEX = 0x00C0E080, // 0..8, picks one of the 9 localized strings
// Locale-name string table — a parallel `const char *[8]` indexed by
// VAR_LOCALE_INDEX, holding the exact codes `GetLocale()` returns:
// enUS / koKR / frFR / deDE / zhCN / zhTW / esES / xxYY. This is the
// source `Script_GetLocale` (FUN_0048d8b0) reads:
// lua_pushstring(L, (&PTR_DAT_008558a4)[DAT_00c0e080]);
// Verified by resolving all 8 entries from the binary. Index range is
// 0..7 (VAR_LOCALE_INDEX is documented 0..8, but slot 8 overreads into
// the string pool — clamp to 0..7 before reading). Used by the TOC
// `[TextLocale]` / `[AllowLoadTextLocale]` directives (AddOns::TocRewrite).
VAR_LOCALE_NAME_TABLE = 0x008558A4,
LUA_IS_NUMBER = 0x6F34D0,
LUA_IS_STRING = 0x6F3510,
LUA_TO_NUMBER = 0x6F3620,
LUA_TO_BOOLEAN = 0x6F3660,
LUA_TO_STRING = 0x6F3690,
LUA_PUSH_NUMBER = 0x6F3810,
LUA_PUSH_NIL = 0x6F37F0,
LUA_PUSH_BOOLEAN = 0x6F39F0,
LUA_PUSH_STRING = 0x6F3890,
// `lua_pushlstring(L, ptr, len)` — binary-safe push. Same TValue
// tag as `pushstring` but takes an explicit length so the string
// can contain NULs.
LUA_PUSH_LSTRING = 0x6F3840,
// `lua_strlen(L, idx)` — returns the byte length of the string
// value at `idx`. Pairs with `lua_tostring` for binary-safe
// string reads.
LUA_STR_LEN = 0x6F36E0,
// Verified empirically via `_classicapi_PushValueProbe` —
// pushes a number then dups via PushValue, checks GetTop tracks.
// **Doc note:** `docs/LuaCAPI.md` reports `0x6F30D0` as lua_pushvalue
// and `0x6F32B0` as lua_remove; both are wrong. `0x6F30D0` is
// actually `lua_remove` (has the shift-down loop and `decr_top`),
// and `0x6F3350` is `lua_pushvalue` (index-resolve → TValue copy
// to L->top → `add [ecx+8], 0x10` incr_top). `0x6F32B0` is
// `lua_replace` (single TValue copy + decr_top).
LUA_PUSH_VALUE = 0x6F3350,
// `luaL_ref(L, t)` — pops the top, stores it in the table at `t`
// at a freshly-allocated integer key, returns the key. Use with
// `LUA_REGISTRY_INDEX` to stash Lua values across C-side scopes;
// pair with `LUA_REF_UNREF` to release. Verified by decompiling
// `FUN_006f5310`: classic luaL_ref shape — nil-top early-out
// returning `LUA_REFNIL = -1`, FREELIST_REF chain pop (pushvalue +
// tonumber on table[0]), else objlen-based new slot, finally
// table[ref] = popped value.
LUA_REF_REF = 0x6F5310,
// `luaL_unref(L, t, ref)` — releases a ref previously returned
// by `luaL_ref`, freeing the slot for future allocations. Verified
// by decompiling `FUN_006f5400`: `ref >= 0` guard (skips
// `LUA_NOREF = -2` / `LUA_REFNIL = -1`), reads current FREELIST_REF
// head, writes it to `table[ref]`, then updates FREELIST_REF = ref
// — the canonical freelist-link operation.
LUA_REF_UNREF = 0x6F5400,
LUA_PUSH_CCLOSURE = 0x6F3920,
LUA_NEW_TABLE = 0x6F3C90,
LUA_GET_TABLE = 0x6F3A40, // (was 0x6F3EA0, which is lua_rawset)
LUA_RAW_GET = 0x6F3B00,
// `lua_rawgeti(L, idx, n)` — pushes `table_at_idx[n]` without invoking
// metamethods. __fastcall(L /*ecx*/, idx /*edx*/, n /*stack*/). The
// frame-script runner uses it with `idx = REGISTRY` to push a value
// stored under an integer ref (handler, frame object, message handler,
// and luaL_ref'd saved globals). Note it also carries the WoW
// frame-script exec-context stamp (the `DAT_00ceeac0` dance) for pushed
// CObjects — which is exactly why the engine pushes handler/frame
// through it rather than a plain rawget.
LUA_RAWGETI = 0x6F3BC0,
// `luaA_indexAcceptable(L, idx)` — the API's index walk: stack, pseudo
// (registry / globals) or upvalue index → TObject*, or NULL for a
// positive index at or past the top. __fastcall(L /*ecx*/, idx /*edx*/),
// plain RET; pushes nothing (disassembled 0x006F3410; lua_type calls it).
LUA_INDEX_ACCEPTABLE = 0x6F3410,
// `luaH_getnum(Table *t, int key)` — raw integer-key read: the array part
// for 1..sizearray (`[t+0x0C] + key*16 - 16`), else the node chain by
// hashnum. __fastcall(t /*ecx*/, key /*edx*/), plain RET; returns const
// TObject* (&nilobject 0x00811BC0 on a miss). No metamethods, no
// allocation, no stack traffic (disassembled 0x006FA700).
FUN_LUAH_GETNUM = 0x6FA700,
// `lua_getmetatable(L, objindex)` — pushes the metatable of the value at
// objindex and returns 1, or pushes nothing and returns 0 when it has none.
// Verified in docs/LuaCAPI.md and by the getfenv/getmetatable base-lib
// functions that call it. Used by the `__environment` env-protection hook.
// __fastcall(L, idx) -> int. Body: index2adr; table/userdata → mt at
// `value+0x08`, rejected when it is the default sentinel `*(L+0x10)+
// 0x48`; pushes `{tt=5, ctx=[VAR_FRAMESCRIPT_EXEC_CONTEXT], mt}` at
// L->top (`L+0x08`) and adds 0x10. Every other type returns 0. Engine
// callers: luaL_checkudata 0x006F4A90, luaL_getmetafield 0x006F4D00
// (→ luaL_callmeta 0x006F4D60 → `tostring` 0x00702F40 for __tostring),
// luaB_getmetatable 0x007029F0. Co-hooked by LuaSyntax::StringMethods
// to return strings' 5.1 shared metatable.
LUA_GET_METATABLE = 0x6F3CF0,
// `lua_setmetatable(L, objindex)` — pops the table at the top of the
// stack and installs it as the metatable of the value at objindex;
// returns 1. Catalogued (★-verified) in docs/LuaCAPI.md. Used by
// Table::Length to build its weak-keyed mark table from C.
LUA_SET_METATABLE = 0x6F4020,
// `lua_getfenv(L, idx)` — pushes the environment table of the function
// (or userdata/thread) at `idx`. The getfenv/setfenv base-lib code calls
// it to read a function's environment before the protection check.
LUA_GET_FENV = 0x6F3D50,
LUA_SET_TABLE = 0x6F3E20,
LUA_RAW_SET = 0x6F3EA0,
LUA_INSERT = 0x6F31A0,
LUA_REMOVE = 0x6F30D0, // (was 0x6F32B0, which is lua_replace)
LUA_REPLACE = 0x6F32B0,
LUA_TYPE = 0x6F3400,
// `lua_typename(L, type)` — `const char *__fastcall`; indexes the name
// array at 0x00811CD0, `-1` → "no value" (0x00871624).
LUA_TYPE_NAME = 0x6F3480,
LUA_GET_TOP = 0x6F3070,
LUA_SET_TOP = 0x6F3080,
LUA_CALL = 0x6F4180,
LUA_PCALL = 0x6F41A0,
// `lua_next(L, idx)` — pops a key, pushes (newKey, value) for the
// next pair in the table at `idx`. Returns 0 when iteration is
// done. Documented in `docs/LuaCAPI.md`; calls `luaH_next` at
// `0x006FA2A0` internally.
LUA_NEXT = 0x6F4450,
// Despite the name, `luaL_error(L, fmt, ...)` (__cdecl): luaL_where(L, 1)
// (0x006F48E0), pushvfstring, concat 2 (0x006F44E0), then LUA_RAW_ERROR.
LUA_ERROR = 0x6F4940,
// `lua_error(L)` proper — __fastcall(L), raises the value on top of the
// stack as is (luaG_errormsg 0x006FC780), so a non-string error object
// survives. The tail of LUA_ERROR.
LUA_RAW_ERROR = 0x6F4440,
// `lua_xmove(from, to, n)` — moves the top `n` TValues from one
// thread to another. Decrements `from->top` by `n*16`, copies each
// 16-byte TValue, increments `to->top`. Needed by the `coroutine.*`
// trampolines to shuttle args/returns between the main state and a
// suspended coroutine.
LUA_X_MOVE = 0x6F2F80,
// `lua_newthread(L)` — does GC check, calls inner `luaE_newthread`
// at `0x006F6B10` to allocate a new state, pushes it onto L's stack
// with type tag 8 (LUA_TTHREAD). Ghidra reports the return as
// `void` (decompiler limitation — the inner call's eax flows
// through), so callers should retrieve the new state via
// `ToPointer(L, -1)` rather than relying on the return value.
LUA_NEW_THREAD = 0x6F3030,
// `lua_resume(L_co, nargs)` — runs a coroutine. Zero internal
// callers in the engine (coroutine library was stripped from the
// standard-library registration tables at build time); linker
// kept the symbol so it's callable from C. Goes through
// `luaD_rawrunprotected` at `0x006F5DAC` for setjmp/longjmp
// safety; inner static `resume` helper lives at `0x006F67B0`.
LUA_RESUME = 0x6F6620,
// `lua_yield(L, nresults)` — flags the current CallInfo to yield
// and returns -1. Sets a `0x10` bit on the CI->state field rather
// than writing `L->status` directly in this build. Zero internal
// callers (same reason as `lua_resume`). Errors with
// "attempt to yield across metamethod/C-call boundary" or
// "cannot yield a C function" when called from the wrong context.
LUA_YIELD = 0x6F6860,
// `lua_topointer(L, idx)` — returns the pointer value of a
// pointer-valued TValue: type 5 (table), 6 (function), 8 (thread)
// return `tvalue[2]` directly; type 2 (lightuserdata) returns its
// value; type 7 (userdata) returns the userdata payload (record +
// 0x10). Returns 0 for anything else. We use it as `lua_tothread`
// — for a known-thread TValue, returns the embedded `lua_State *`.
LUA_TO_POINTER = 0x6F3790,
// `luaL_argerror(L, narg, msg)` — formats "bad argument #%d to
// '%s' (%s)" (or "calling '%s' on bad self (%s)" for method-style
// calls) and calls `lua_error`. Doesn't return.
LUAL_ARG_ERROR = 0x6F4810,
// `luaL_setn(L, t, n)` — Lua 5.0 auxlib table-length setter
// (verified: `FUN_006f4ea0`, __fastcall L/ecx, t/edx, n/stack,
// RET 4). Matches 5.0.2 `luaL_setn`: sets `t.n = n` if a numeric
// `n` field exists, else `sizes[t] = n` in the registry's weak
// LUA_SIZES table. Found via `table.insert` (`FUN_007fb6b0`), which
// calls it to record the new length; `luaL_getn` is `FUN_006f5050`.
// Needed by `table.wipe` to reset the length after clearing keys —
// the length is out-of-band from the keys, so a `lua_next` +
// `rawset(nil)` clear leaves it stale and subsequent `table.insert`
// appends past the wiped slots.
LUAL_SETN = 0x6F4EA0,
// `luaL_getn(L, tableIndex)` — Lua 5.0 auxlib table-length getter,
// `int __fastcall(L /*ecx*/, idx /*edx*/)`, plain RET (no stack
// args), length in eax. Verified by disassembly: a negative idx is
// normalized via lua_gettop; tries the `t.n` field (rawget "n"),
// then the registry LUA_SIZES path, then falls back to a linear
// rawgeti scan for the first nil. Counterpart of LUAL_SETN above
// (named there since the table.insert trace). Used by the 5.1
// `unpack(list, i, j)` upgrade for the default range end.
LUAL_GETN = 0x6F5050,
// `table.insert` (5.0 `luaB_tinsert`), `int __fastcall(L)`. Found two
// independent ways: the table-lib luaL_reg pair in .data (entry
// {name 0x008821B4 "insert", func} at 0x00822D70) and the LUAL_SETN
// caller trace above. Decompile matches 5.0.2 tinsert exactly:
// lua_gettop → luaL_checktype(1, TABLE) → n = luaL_getn(1)+1 →
// optional-pos shift-up loop (rawgeti/rawseti) → luaL_setn(1, n) →
// lua_pushvalue(value) → lua_rawseti(1, pos). Its ONLY xref is that
// luaL_reg entry — no engine C code calls it — and exactly two Lua
// values hold it: `table.insert` (lib open) and the global `tinsert`,
// bound by the engine's embedded compat snippet (`tinsert = tab.insert`,
// .data 0x008722E8, run by FUN_00703b80 right before
// FUN_LOAD_SCRIPT_FUNCTIONS). Table::Length registers its marking
// `table.insert` OVER both names (no hook) and calls this address
// directly for the engine behavior (#36/#39).
FUN_LUA_TABLE_INSERT = 0x7FB6B0,
// `luaV_gettable(L, t, key, loop)` — the VM's generic index resolver.
// __fastcall(L /*ecx*/, t /*edx*/, key /*stack*/, loop /*stack*/),
// RET 8. Returns the result TValue* in eax (Ghidra types it void; the
// table-hit path demonstrably reaches the epilogue with eax =
// luaH_get's return — `CALL 0x006fa7a0; CMP [EAX],0; JNZ epilogue` at
// 0x006F7D1D..25). Table case: luaH_get (0x006FA7A0); nil result →
// the metatable continuation FUN_006F7D60, which reads the TABLE'S
// OWN metatable (hvalue+0x08, fast-TM flag byte hvalue+0x06 — 5.0
// fasttm) and returns &nilobject (0x00811BC0) when there is none
// (miss = nil, never an error). Non-table case → the continuation
// below, loop+1. Depth-guarded at 100 ("loop in gettable").
FUN_LUA_V_GETTABLE = 0x006F7CF0,
// The non-table branch of luaV_gettable — stock Lua 5.0's "index a
// non-table value" continuation. Same convention/return as
// FUN_LUA_V_GETTABLE (result TValue* in eax, RET 8). Body: __index
// tag method via luaT_gettmbyobj (0x006F7BD0 — which HARDCODES
// &nilobject for anything but table/userdata; stock 5.0, nothing
// stripped); nil → luaG_typeerror "attempt to index" (0x006FC620);
// function TM → call it; table TM → recurse FUN_LUA_V_GETTABLE with
// `loop` passed through UNCHANGED (0x006F7F23). Exactly 3 call
// sites: luaV_gettable's else-branch + luaV_execute's OP_GETTABLE /
// OP_SELF non-table fallbacks (0x006F8A14 / 0x006F8C17 in
// FUN_006F8720) — so it fires ONLY when code indexes a non-table,
// which in stock 5.0 is always about to raise "attempt to index"
// (table `__index` dispatch goes through FUN_006F7D60's fasttm and
// never lands here). Not hooked: string methods ride
// FUN_LUAT_GETTMBYOBJ below, which this continuation calls.
FUN_LUA_INDEX_NONTABLE = 0x006F7EE0,
// `luaT_gettmbyobj(L, o, event)` — the tag-method lookup for a value
// that has no fasttm path. __fastcall(L /*ecx*/, const TValue *o
// /*edx*/, int event /*stack*/), RET 4, returns const TValue* (eax;
// &nilobject 0x00811BC0 on a miss). Reads the event name from
// `G(L)->tmname` at `*(L+0x10) + 0x80 + event*4`, then for a table or
// userdata calls FUN_LUAH_GETSTR on its metatable (`hvalue+0x08`, no
// null check — 5.0's default-metatable sentinel is never NULL). Every
// other type hardcodes &nilobject: this is the ONE line where 5.1
// reads the per-type slot `G(L)->mt[ttype(o)]` instead. Callers (7):
// luaD_tryfuncTM 0x006F6370, index/newindex non-table continuations
// 0x006F7EE0 / 0x006F7F40, call_binTM 0x006F8670 (x2), call_orderTM
// 0x006F8210 (x2) — all fallbacks for values with no native
// operation, so cold. Prologue PUSH EBP / MOV EBP,ESP / MOV ECX,[ECX+
// 0x10] — MinHook-relocatable. Co-hooked by LuaSyntax::StringMethods
// to give strings 5.1's shared metatable.
FUN_LUAT_GETTMBYOBJ = 0x006F7BD0,
// `luaH_getstr(Table *t, TString *key)` — raw hash lookup of an
// interned string key. __fastcall(t /*ecx*/, key /*edx*/), returns
// const TValue* (eax; &nilobject on a miss). Node stride 0x28, key tt
// at +0, key ptr at +8, value at +0x10, next at +0x20. Called by
// FUN_LUAT_GETTMBYOBJ.
FUN_LUAH_GETSTR = 0x006FA760,
// `luaL_loadbuffer(L, buff, size, chunkname)` — compiles a source
// buffer into a Lua function on the stack (does NOT run it). Returns
// an int status (0 = ok) in eax; Ghidra types it void because the
// status flows through `lua_load`. __fastcall(L /*ecx*/, buff /*edx*/,
// size /*stack*/, chunkname /*stack*/); strips a leading UTF-8 BOM.
// This is the UNIVERSAL Lua compile chokepoint — every path that turns
// source text into bytecode funnels through it: `luaL_loadstring`
// (0x006F57C0, backs the `loadstring` global) and the three FrameScript
// execute/load funnels (0x00704AE0 / 0x00704C70 / 0x00703280, backing
// `RunScript`, XML `<OnLoad>`/`<OnClick>` handlers, and file-loaded
// addon chunks). Verified via xrefs to `lua_load` (0x006F4320) and its
// two callers (this = loadbuffer, 0x006F5490 = loadfile). Hooking here
// lets a source-level transform see every chunk before the 5.0 parser.
FUN_LUAL_LOADBUFFER = 0x006F5690,
// Return address of the `call luaL_loadbuffer` inside the compile-AND-run
// funnel FUN_00704AE0 (the CALL is at 0x00704B0C; next instruction, and so
// the pushed return address, is 0x00704B11). FUN_00704AE0 compiles a buffer
// then IMMEDIATELY `lua_pcall`s it (0x00704B42) — it is the funnel every
// addon/FrameXML FILE load reaches (FUN_006ede10 -> FUN_00704bc0 -> here)
// AND what `RunScript` runs through. LuaSyntax's `luaL_loadbuffer` hook
// reads `_ReturnAddress()` and arms the addon-args grant ONLY when the
// caller is THIS site — i.e. a chunk that will be run before anything else,
// so its preamble consumes the grant immediately. `loadstring` (0x00703280,
// returns to 0x007032B5) compiles WITHOUT running and takes a
// caller-forgeable chunkname, so it must NOT arm; the call-site check
// excludes it even when nested inside a RunScript body.
RET_LUA_FILE_COMPILE = 0x00704B11,
// Return address of the `call luaL_loadbuffer` inside the XML script
// compile funnel FUN_00704C70 (the CALL is at 0x00704C87, so the pushed
// return address is 0x00704C8C). That funnel compiles an XML handler body
// (<OnLoad>, <OnClick>, ...) into the function the frame stores, under an
// engine-built chunkname "<FrameName>:<ScriptName>". Found by scanning
// FUN_00704C70 for an `E8 rel32` whose target is FUN_LUAL_LOADBUFFER; the
// same scan reproduces RET_LUA_FILE_COMPILE (0x00704B11) for FUN_00704AE0
// and 0x007032B5 for loadstring's FUN_00703280. LuaSyntax uses it to give
// XML handler bodies their modern implicit parameters (self, elapsed, ...).
RET_LUA_SCRIPT_COMPILE = 0x00704C8C,
// That funnel itself: `int __fastcall(const char *source, uint32_t size,
// const char *chunkName, void *errCtx)`, returning 1 when the chunk both
// compiled and ran and 0 otherwise. It resolves the Lua state through
// FUN_007040D0 rather than taking one, so a single call site reaches
// whichever state is current -- the glue state during glue boot, the in-game
// state afterwards. It also pushes the FrameScript error handler
// (DAT_008722C8) as the pcall's errfunc, so a runtime error is reported the
// way any script error is even when `errCtx` is null; `errCtx`, when given,
// is an object whose vtable +0xC receives the message instead. `chunkName`
// follows the usual Lua convention: `@name` is shown as a filename, `=name`
// verbatim. This is what `RunScript` runs through.
FUN_LUA_RUN_STRING = 0x00704AE0,
// --- Lua 5.0 parser internals: the upvalue limit --------------------------
// Stock lparser.c compiled as-is (the `lua\src\lparser.c` path string is
// still in .rdata). The 32-upvalue limit is NOT just the `PUSH 0x20`
// immediate in indexupvalue: it is the size of a fixed `expdesc
// upvalues[32]` array inside the parser's FuncState, and the array ends
// exactly where the next field begins — 0x38 + 32 × 0x14 = 0x2B8 =
// OFF_LUA_FUNCSTATE_ACTVAR, the declared-variable stack. Raising the
// immediate alone makes the 33rd upvalue overwrite actvar[0] and miscompile.
// In 5.0 the array has exactly two readers, both below; everything past the
// parser is dynamic (nups and LClosure.nupvalues are bytes, OP_GETUPVAL's B
// field is 9 bits, closures are sized per instance, the debug-name array
// grows with luaM_growaux). LuaSyntax::Upvalues co-hooks the two readers and
// spills entries 33+ into side storage, raising the limit to Lua 5.1's 60.
// The structural ceiling is the byte, 255, if it is ever wanted.
//
// indexupvalue(fs, name, v) -> index. `__fastcall(ecx = FuncState*, edx =
// TString *name, [stack] expdesc *v)`, RET 4. Scans fs->upvalues for
// {k, info} equal to v's, else checklimit(nups+1, 32, "upvalues"), grows
// f->upvalues (names) via luaM_growaux(L, block, &f->sizeupvalues, 4,
// 0x7FFFFFFD, ""), stores the name and the expdesc, returns nups++.
FUN_LUA_PARSER_INDEXUPVALUE = 0x006FDF80,
// pushclosure(ls, func, v). `__fastcall(ecx = LexState*, edx = FuncState
// *func, [stack] expdesc *v)`, RET 4. Grows f->p via luaM_growaux(L, f->p,
// &f->sizep, 4, 0x3FFFF, "constant table overflow"), stores func->f at
// f->p[np++], emits OP_CLOSURE (0x22) with luaK_codeABx(fs, op, 0, np-1),
// init_exp(v, VRELOCABLE = 10, pc), then one luaK_codeABC(fs, k == VLOCAL
// (5) ? OP_MOVE (0) : OP_GETUPVAL (4), 0, info, 0) per func->upvalues[i].
FUN_LUA_PARSER_PUSHCLOSURE = 0x006FD980,
// luaY_checklimit(ls, value, limit, what). `__fastcall(ecx = LexState*,
// edx = value, [stack] limit, what)`, RET 8. Raises "too many %s (limit=%d)"
// through luaO_pushfstring(ls->L, …) when limit < value; never returns then.
// NOTE: takes the LexState in this build, not the FuncState stock 5.0 passes.
FUN_LUA_PARSER_CHECKLIMIT = 0x006FF440,
// init_exp(v, k, info): `__fastcall(ecx = expdesc*, edx = k, [stack] info)`.
FUN_LUA_PARSER_INIT_EXP = 0x006FD3E0,
// luaM_growaux(L, block, &size, elemSize, limit, errMsg) -> new block.
// `__fastcall(ecx = L, edx = block, [stack] int *size, elemSize, limit,
// msg)`, RET 0x10.
FUN_LUA_M_GROWAUX = 0x006FC900,
// luaK_codeABx(fs, op, A, Bx) -> pc and luaK_codeABC(fs, op, A, B, C) -> pc.
// `__fastcall(ecx = fs, edx = op, [stack] …)`; RET 8 / RET 0xC.
FUN_LUA_K_CODEABX = 0x00701910,
FUN_LUA_K_CODEABC = 0x007018E0,
// FuncState (lparser.h), verified from indexupvalue / pushclosure /
// new_localvar: f@+0, ls@+0xC, L@+0x10, np@+0x2C, nactvar@+0x34, then the
// fixed expdesc upvalues[32]@+0x38 (stride 0x14) running into
// actvar[200]@+0x2B8.
OFF_LUA_FUNCSTATE_F = 0x00,
OFF_LUA_FUNCSTATE_LS = 0x0C,
OFF_LUA_FUNCSTATE_L = 0x10,
OFF_LUA_FUNCSTATE_NP = 0x2C,
OFF_LUA_FUNCSTATE_UPVALUES = 0x38,
OFF_LUA_FUNCSTATE_ACTVAR = 0x2B8,
LUA_PARSER_NATIVE_UPVALUE_SLOTS = 32, // sizeof(fs->upvalues) / sizeof(expdesc)
SIZEOF_LUA_EXPDESC = 0x14, // { k, info, aux, t, f }
// LexState: fs@+0x30, L@+0x34 (new_localvar reads both; checklimit reads L).
OFF_LUA_LEXSTATE_FS = 0x30,
OFF_LUA_LEXSTATE_L = 0x34,
// Proto (lobject.h). p/sizep and upvalues/sizeupvalues from pushclosure and
// indexupvalue; the four packed bytes at +0x44 are nups, numparams,
// is_vararg, maxstacksize — numparams/is_vararg were verified separately by
// Frame::ScriptArgs, which reads them to decide whether a handler declares
// parameters, and they pin nups to the byte before them.
OFF_LUA_PROTO_P = 0x10,
OFF_LUA_PROTO_UPVALUES = 0x1C, // TString **, the debug names
OFF_LUA_PROTO_SIZEUPVALUES = 0x24,
OFF_LUA_PROTO_SIZEP = 0x34,
OFF_LUA_PROTO_NUPS = 0x44,
OFF_LUA_PROTO_NUMPARAMS = 0x45,
OFF_LUA_PROTO_IS_VARARG = 0x46,
// TObject (16 bytes): type tag at +0 (`TYPE_*`), payload at +8 (a
// Table* / TString* / double). luaH_getnum's node walk reads both
// (`CMP [ECX],3` / `FLD [ECX+8]` at 0x006FA736 / 0x006FA73B).
OFF_LUA_TVALUE_TT = 0x00,
OFF_LUA_TVALUE_VALUE = 0x08,
// Table: array size (int). luaH_getnum's array-part bound test
// `CMP EDX,[ECX+0x1C]` at 0x006FA70E (array pointer at +0x0C).
OFF_LUA_TABLE_SIZEARRAY = 0x1C,
// --- Lua 5.0 GC object lifecycle (Lua::GcHooks) ---------------------------
// Every collectable object is created through one of three functions and
// freed through one. Proven by xrefs: luaC_link's six callers are luaH_new,
// luaF_newCclosure, luaF_newLclosure, luaF_newproto, luaF_close (a closed
// upvalue, tt 10) and luaE_newthread (tt 8); newlstr's only caller is
// luaS_newlstr; luaS_newudata's only caller is lua_newuserdata. freeobj's
// only caller is sweeplist (0x006F7210, from luaC_sweep twice and
// sweepstrings), and each per-type free function's only caller is freeobj.
// `__fastcall(L, o)` + `tt` on the stack, RET 4: next = rootgc, rootgc = o,
// marked = 0, tt = arg.
FUN_LUA_C_LINK = 0x006F7B20,
// `__fastcall(L, str)` + `len, hash` on the stack, RET 8 → TString*.
// Allocates len+0x11, links into strt.hash[hash & (size-1)].
FUN_LUA_S_NEWLSTR = 0x006F9D90,
// `__fastcall(L, size)` → Udata*. Allocates size+0x10, tt 7, metatable
// [G+0x48], links into rootudata [G+0x14].
FUN_LUA_S_NEWUDATA = 0x006F9E30,
// `__fastcall(L, o)`. Switch on tt-4 through the jump table at 0x006F72D0.
FUN_LUA_C_FREEOBJ = 0x006F7260,
// lua_State: the global state (luaC_link reads `[ecx+0x10]`).
OFF_LUA_STATE_G = 0x10,
// global_State: string table {hash@+4, nuse@+8, size@+0xC} (newlstr's
// bucket insert), rootgc / rootudata (luaC_link, luaS_newudata,
// luaC_sweep), nblocks = bytes in use (lua_newtable's GC threshold test
// `cmp [G+0x28],[G+0x24]`; what gcinfo reports).
OFF_LUA_G_STRT_HASH = 0x04,
OFF_LUA_G_STRT_SIZE = 0x0C,
OFF_LUA_G_ROOTGC = 0x10,
OFF_LUA_G_ROOTUDATA = 0x14,
OFF_LUA_G_NBLOCKS = 0x28,
// GCheader: next@+0, tt@+4 (luaC_link writes both; freeobj switches on tt).
OFF_LUA_GCHEADER_NEXT = 0x00,
OFF_LUA_GCHEADER_TT = 0x04,
// GC type tags past TYPE_THREAD, from freeobj's jump table.
LUA_TT_PROTO = 9,
LUA_TT_UPVAL = 10,
// Object sizes, read from the sizes freeobj and its per-type free
// functions pass to luaM_irealloc (so they match the engine's own
// accounting exactly):
// string len@+0xC + 0x11 (freeobj 0x006F729B)
// udata len@+0xC + 0x10 (freeobj 0x006F72B4)
// upval 0x20 (freeobj 0x006F727D)
// table 0x20 + 16*sizearray@+0x1C + (lsizenode@+7 ? 40 << lsizenode : 0)
// (luaH_free 0x006FA690; a 0 lsizenode is the shared dummy node)
// closure isC@+6 ? (nupvalues@+7 + 1)*16 : nupvalues*4 + 0x24
// (luaF_freeclosure 0x006FA110)
// proto 0x48 + 4*sizecode@+0x2C + 4*sizep@+0x34 + 16*sizek@+0x28 +
// 4*sizelineinfo@+0x30 + 12*sizelocvars@+0x38 + 4*sizeupvalues@+0x24
// (luaF_freeproto 0x006FA050)
// thread 0x68 + 16*stacksize@+0x20 + 24*size_ci(u16)@+0x2C
// (luaE_freethread 0x006F6C90 → 0x006F6CE0 stack/ci, 0x006F6CC0 state)
OFF_LUA_TSTRING_LEN = 0x0C,
OFF_LUA_UDATA_LEN = 0x0C,
OFF_LUA_TABLE_LSIZENODE = 0x07,
OFF_LUA_CLOSURE_ISC = 0x06,
OFF_LUA_CLOSURE_NUPVALUES = 0x07,
OFF_LUA_PROTO_SIZEK = 0x28,
OFF_LUA_PROTO_SIZECODE = 0x2C,
OFF_LUA_PROTO_SIZELINEINFO = 0x30,
OFF_LUA_PROTO_SIZELOCVARS = 0x38,
OFF_LUA_STATE_STACKSIZE = 0x20,
OFF_LUA_STATE_SIZE_CI = 0x2C,
SIZEOF_LUA_TSTRING_HEADER = 0x11, // header + the terminating NUL
SIZEOF_LUA_UDATA_HEADER = 0x10,
SIZEOF_LUA_UPVAL = 0x20,
SIZEOF_LUA_TABLE = 0x20,
SIZEOF_LUA_TVALUE = 0x10,
SIZEOF_LUA_NODE = 0x28,
SIZEOF_LUA_LCLOSURE_BASE = 0x24,
SIZEOF_LUA_PROTO = 0x48,
SIZEOF_LUA_LOCVAR = 0x0C,
SIZEOF_LUA_STATE = 0x68,
SIZEOF_LUA_CALLINFO = 0x18,
// --- Lua 5.0 debug hooks (Profile::Cpu) -----------------------------------
// `lua_sethook(L, func, mask, count)` — `__fastcall`, mask/count on the
// stack, RET 8: stores count at +0x34/+0x38, mask byte +0x30, func +0x3C,
// clears the inited byte +0x32; an empty func or mask clears both. The
// engine never calls it and no other loaded DLL references it.
// Hooks are per lua_State and NOT inherited: luaE_newthread's preinit
// (0x006F6C40) zeroes them (and sets allowhook +0x31 = 1).
LUA_SET_HOOK = 0x006FBA40,
// luaD_callhook (0x006F5F80) calls the hook `__fastcall(L, ar)` when it is
// set and allowhook is 1. CALL (event 0) fires for a C function in
// luaD_precall (0x006F6191) and for a Lua function at the VM's call entry
// 0x006F8730, which OP_CALL (0x006F975C) and OP_TAILCALL (0x006F9827) jump
// back to; RET (1) and TAILRET (4) come from callrethooks (0x006F6540),
// which luaD_poscall runs before popping the record. `ar` (lua_Debug):
// event @+0, the call record's index @+0x5C (0 for TAILRET).
LUA_HOOK_CALL = 0,
LUA_HOOK_RET = 1,
LUA_MASK_CALL = 1,
LUA_MASK_RET = 2,
OFF_LUA_DEBUG_EVENT = 0x00,
OFF_LUA_DEBUG_I_CI = 0x5C,
// lua_State: base_ci (luaD_callhook's index = (ci - [L+0x28]) / 24).
OFF_LUA_STATE_BASE_CI = 0x28,
// CallInfo: base @+0 (luaD_precall stores func + 0x10, so the called
// function's TValue is base - 0x10); tailcalls @+0x14 — luaD_precall
// zeroes it for a Lua call (0x006F60FB), OP_TAILCALL increments the
// replaced record's (`inc [ci-4]` at 0x006F9809) before re-entering.
OFF_LUA_CALLINFO_BASE = 0x00,
OFF_LUA_CALLINFO_TAILCALLS = 0x14,
// --- Lua 5.0 parser internals: `for` loop scoping -------------------------
// forbody(ls, base, line, nvars, isnum) -- stock 5.0.2, decompiled:
// adjustlocalvars(nvars); check(TK_DO); enterblock(&bl, 1); prep =
// getlabel; block(ls); patchtohere(prep - 1); endfor = isnum ?
// codeABx(OP_FORLOOP, base, NO_JUMP) : codeABC(OP_TFORLOOP, base, 0,
// nvars - 3); fixline(line); patchlist(isnum ? endfor : jump(), prep);
// leaveblock. `__fastcall(ecx = LexState*, edx = base, [stack] line, nvars,
// isnum)`, RET 0xC. Sole callers: fornum 0x006FE380 and forlist 0x006FE540,
// both called from forstat 0x006FE300, which wraps the whole statement in
// its own non-breakable BlockCnt -- the one a captured loop variable marks.
// LuaSyntax::ForScopes replaces it.
FUN_LUA_PARSER_FORBODY = 0x006FE480,
// Helpers forbody calls, all `__fastcall`, register args only unless noted.
FUN_LUA_PARSER_ADJUSTLOCALVARS = 0x006FD870, // (ls, nvars)
FUN_LUA_PARSER_CHECK = 0x006FD140, // (ls, token); raises on mismatch
FUN_LUA_PARSER_ENTERBLOCK = 0x006FCF50, // (fs, BlockCnt*, [stack] isbreakable), RET 4
FUN_LUA_PARSER_BLOCK = 0x006FCF20, // (ls)
FUN_LUA_PARSER_LEAVEBLOCK = 0x006FCF80, // (fs); emits OP_CLOSE when bl->upval
FUN_LUA_K_GETLABEL = 0x00700850, // (fs) -> pc; lasttarget = pc
FUN_LUA_K_PATCHTOHERE = 0x007009E0, // (fs, list)
FUN_LUA_K_FIXLINE = 0x00701810, // (fs, line)
FUN_LUA_K_JUMP = 0x00700810, // (fs) -> pc
FUN_LUA_K_PATCHLIST = 0x00700860, // (fs, list, [stack] target), RET 4
// markupval 0x006FE080 walks fs->bl while bl->nactvar > level, then sets
// bl->upval = 1 (stock).
OFF_LUA_FUNCSTATE_BL = 0x14,
// BlockCnt (lparser.c), from enterblock / leaveblock: previous@+0,
// breaklist@+4, nactvar@+8, upval@+0xC (int), isbreakable@+0x10.
OFF_LUA_BLOCKCNT_PREVIOUS = 0x00,
OFF_LUA_BLOCKCNT_UPVAL = 0x0C,
SIZEOF_LUA_BLOCKCNT = 0x14,
LUA_TK_DO = 0x103, // the token forbody checks
// 5.0 opcodes, from forbody (0x1C/0x1D), forlist (TFORPREP 0x1E), leaveblock
// (OP_CLOSE 0x21) and pushclosure (OP_CLOSURE 0x22).
LUA_OP_FORLOOP = 0x1C,
LUA_OP_TFORLOOP = 0x1D,
LUA_OP_CLOSE = 0x21,
LUA_NO_JUMP_SBX = 0x1FFFE, // NO_JUMP (-1) biased by MAXARG_sBx
// Shared environment-protection predicate for `getfenv`/`setfenv`
// (`bool __fastcall(L /*ecx*/)`). Pushes the function-at-top's environment
// via `lua_getfenv(L, -1)`, then pushes the protection marker
// `env["__fenv"]` (a RAW field on the env table) and returns whether it is
// non-nil — net stack effect +2 (env, marker). Its only callers (Ghidra
// xrefs) are `getfenv` (`0x00702AC0`), which returns the marker in place
// of the real env when set, and `setfenv` (`FUN_SCRIPT_SETFENV`), which
// raises "cannot change a protected environment". LuaEnv::Fenv replaces it
// with the 5.1 `luaL_getmetafield(env, "__environment")` read.
FUN_LUA_ENV_PROTECT_PREDICATE = 0x00702BA0,
// The base library's `getfunc(L)` (`void __fastcall(L /*ecx*/)`): pushes
// arg 1 when it is a function, else the function at level
// `luaL_optnumber(L, 1, 1)` — erroring "level must be non-negative",
// "invalid level", or "no function environment for tail call at level
// %d" (bytes at 0x00702AF0..0x00702B97).
FUN_LUA_BASE_GETFUNC = 0x00702AF0,
// `setfenv` (`int __fastcall(L)`): luaL_checktype(2, table), getfunc,
// the protection predicate, then `lua_replace(GLOBALSINDEX)` for level 0
// or `lua_setfenv(-2)`; returns 0 (bytes at 0x00702BE0..0x00702C83).
FUN_SCRIPT_SETFENV = 0x00702BE0,
// `lua_setfenv(L, idx)` — `int __fastcall`; pops the table at the top
// into the environment of the Lua function at idx and returns 1; for any
// other value (C functions included, `isC` byte at closure+6) it still
// pops and returns 0 (decompiled 0x006F40D0).
LUA_SET_FENV = 0x006F40D0,
// `luaL_checktype(L, narg, t)` — `void __fastcall(L /*ecx*/, narg /*edx*/,
// t /*stack, callee-popped*/)`; tag_error unless lua_type(narg) == t
// (decompiled 0x006F4B50; setfenv pushes 5 then calls it with no esp fixup).
LUAL_CHECK_TYPE = 0x006F4B50,
// `lua_checkstack(L, n)` — `int __fastcall(L /*ecx*/, n /*edx*/)`.
// Ensures room for `n` more stack values, growing if needed; returns 0
// (without growing) when `(top-base)/16 + n` would exceed LUA_MAXCSTACK
// (0x800 = 2048), 1 otherwise. Verified by the `cmp reg, 0x800` overflow
// test at 0x006F2F43. Needed by any C function that pushes an unbounded
// number of results (e.g. `strsplit`) — pushing past the ~20-slot
// C-call guarantee without growing corrupts the stack.
LUA_CHECK_STACK = 0x006F2F30,
// `str_find` — the Lua 5.0 string-library `string.find` C function
// (`int __fastcall(void *L)`), entry in the strlib luaL_reg table at
// `0x00822dd0`. Returns `1` (nil pushed, no match), `2` (start, end),
// or `2 + ncaptures`. `string.match` (a Lua 5.1 addition, missing here)
// shares the exact same pattern engine — it's `find` that yields the
// captures / whole match instead of the indices — so `BaseLib::StringLib`
// calls this and transforms the result rather than reimplementing the
// matcher. Verified by decoding the function at this address.
FUN_LUA_STR_FIND = 0x007FC3B0,
// `str_gfind` — the Lua 5.0 `string.gfind` C function (strlib entry at
// `0x00822dd8`). 5.1 renamed it to `string.gmatch` with identical
// behaviour (returns a stateful iterator closure over the matches), so
// `BaseLib::StringLib` registers `string.gmatch` as a direct alias of
// this function pointer — no wrapper.
FUN_LUA_STR_GFIND = 0x007FCFA0,
// `str_gsub` — the Lua 5.0 `string.gsub` C function (strlib entry
// at `0x00822DE0`, name string "gsub" at `0x00882230` — the last
// entry before the registration table's NULL terminator, matching
// stock 5.0 order). Verified by decode: args (s, pat, repl, maxN),
// `^` anchor pre-strip, and the luaL_argerror(3) "string or
// function expected" gate. Its add_value helper (`FUN_007fd2a0`)
// matches stock 5.0: a FUNCTION replacement's non-string result is
// popped and NOTHING is appended (match → empty) — 5.1 instead
// keeps the original match for nil/false. That difference is why
// `BaseLib::StringLib`'s 5.1 table-replacement shim wraps the
// pattern in an outer capture (arg 1 = whole match) so its adapter
// closure can hand the match back for missing keys.
FUN_LUA_STR_GSUB = 0x007FD0E0,
// `str_format` — the Lua 5.0 `string.format` C function (`int
// __fastcall(void *L)`), strlib entry at `0x00822dc0`. Verified by decode:
// reads the format at arg 1, handles `%%`, `%d/i/c`, `%e/E/f/g/G`,
// `%o/u/x/X`, `%s`, `%q`, with the "invalid option to 'format'" / "invalid
// format (width or precision too long)" errors. Frame::FormattedText
// pushes THIS directly and pcalls it, rather than resolving `_G.string.format`
// — so an addon replacing `string.format` cannot hijack or break it (matches
// retail, whose SetFormattedText formats in C).
FUN_LUA_STR_FORMAT = 0x007FD3D0,
// `math_fmod` — the Lua 5.0 `math.mod` C function (mathlib entry at
// `0x00822cb0`): `luaL_checknumber(1/2)` → `fmod(x, y)` → `lua_pushnumber`.
// 5.1 renamed the Lua-facing name to `math.fmod` with the identical C
// implementation, so `BaseLib::MathLib` registers `math.fmod` as a direct
// alias of this function pointer — no wrapper. Verified by decode.
FUN_LUA_MATH_FMOD = 0x007FAFD0,
// `lua_iscfunction(L, idx)` — returns 1 if value is a function
// closure with the `isC` byte set (`Closure.c.isC == 1`), 0
// otherwise. Used by `coroutine.create` to reject C functions
// (Lua 5.0 only allows Lua-defined functions as coroutine bodies).
LUA_IS_C_FUNCTION = 0x6F34A0,
// `lua_tothread(L, idx)` — returns the embedded `lua_State *` for
// type-8 (LUA_TTHREAD) TValues, NULL for anything else. Used by
// the `coroutine` library to extract the coroutine pointer from a
// stack slot.
LUA_TO_THREAD = 0x6F3770,
// Global `lua_State *`. The engine keeps one main thread state here; we
// read it on demand in helpers that run outside a Lua callback (e.g.
// RegisterTableFunction during LoadScriptFunctions).
VAR_LUA_STATE = 0x00CEEF74,
// `FrameScript_GetContext` — `mov eax,[VAR_LUA_STATE]; ret`.
FUN_FRAMESCRIPT_GET_CONTEXT = 0x007040D0,
// FUN_FIRE_EVENT's `call FUN_FRAMESCRIPT_GET_CONTEXT` (E8, 5 bytes), right
// after its empty-listener early-out — once per signal that has a
// listener. ECX/EDX are dead across it (both reloaded after). Profile::
// ScriptTime counts signals here rather than MinHooking FUN_FIRE_EVENT,
// which nampower and SuperWoWhook also target (a co-hook there crashed).
CALL_FIRE_EVENT_GET_CONTEXT = 0x00703F78,
// zlib 1.2.2, statically linked into WoW.exe (version string at
// `0x008745F0`, copyright banners at `0x00815528`/`0x00815608`).
//
// One-shot helpers (always Zlib-format with adler32 trailer):
// int compress2(dest, *destLen, source, sourceLen, level)
// int uncompress(dest, *destLen, source, sourceLen)
//
// Lower-level streaming API — needed for Gzip and raw Deflate
// formats since the one-shots only do Zlib format. The `Init2_`
// variants take an explicit `windowBits` which selects format:
// +15 = Zlib (default)
// +15 + 16 = Gzip
// -15 = raw Deflate (no header, no checksum)
// +15 + 32 = auto-detect (decode only; Zlib or Gzip)
//
// Call signatures (all `__fastcall`, callee cleans the stack):
// int deflateInit2_(strm[ECX], level[EDX],
// stack: method, windowBits, memLevel,
// strategy, version, stream_size)
// int deflate(strm[ECX], flush[EDX])
// int deflateEnd(strm[ECX])
// int inflateInit2_(strm[ECX], windowBits[EDX],
// stack: version, stream_size)
// int inflate(strm[ECX], flush[EDX])
// int inflateEnd(strm[ECX])
//
// Return codes match zlib's: 0 = Z_OK, 1 = Z_STREAM_END,
// -3 = Z_DATA_ERROR, -4 = Z_MEM_ERROR, -5 = Z_BUF_ERROR.
FUN_ZLIB_COMPRESS2 = 0x00730BC0,
FUN_ZLIB_UNCOMPRESS = 0x00734810,
FUN_ZLIB_DEFLATE_INIT2 = 0x00732A70,
FUN_ZLIB_DEFLATE = 0x00733040,
FUN_ZLIB_DEFLATE_END = 0x00733650,
FUN_ZLIB_INFLATE_INIT2 = 0x00730D60,
FUN_ZLIB_INFLATE = 0x00730EA0,
FUN_ZLIB_INFLATE_END = 0x00732320,
// The version string deflateInit2_/inflateInit2_ checks against
// (compile-time mismatch returns Z_VERSION_ERROR). Same string the
// one-shot helpers pass through.
VAR_ZLIB_VERSION_STRING = 0x008745F0,
ZLIB_STREAM_SIZE = 0x38, // sizeof(z_stream) in 1.2.2 build
// Static event-name "table" at runtime VA `0x00BE11D8` — this is what
// `C_EventUtils.IsEventValid` walks. It is NOT the structure that
// `frame:RegisterEvent` and the dispatcher actually use; that lives at
// `[VAR_EVENT_TABLE_BASE_PTR]` (see below) with 16-byte entries. The
// table at 0x00BE11D8 is sufficient for an existence check, but firing
// or registering custom events requires the real structure.
VAR_EVENT_NAME_TABLE = 0x00BE11D8,
EVENT_NAME_TABLE_MAX_SLOTS = 1024,
// The REAL event registration data structure used by the engine. An
// `EventEntry` array, 16 bytes per entry:
// +0x00 char *name event name string ptr
// +0x04 ? used by the chain allocator at 0x7052D0
// +0x08 ?
// +0x0C SubscriberNode *head head of the subscribed-frames chain
// Allocated/populated at engine boot. `[VAR_EVENT_TABLE_BASE_PTR]`
// dereferences to the array base; `[VAR_EVENT_TABLE_COUNT]` is the
// entry count. `Frame::RegisterEvent` at 0x00702140 case-insensitively
// strcmps the input event name against each entry's `+0x00` and inserts
// the frame into the matching entry's chain.
VAR_EVENT_TABLE_BASE_PTR = 0x00CEEF68,
VAR_EVENT_TABLE_COUNT = 0x00CEEF64,
// The FrameScript_EventObject is a `{cap@+0, count@+4, data@+8}` at
// 0x00CEEF60, so COUNT/BASE above are its +4/+8. `Event::Custom::Grow`
// writes all three (base, cap, count) when it enlarges the table.
VAR_EVENT_TABLE_CAP = 0x00CEEF60,
EVENT_ENTRY_STRIDE = 0x10,
OFF_EVENT_ENTRY_NAME = 0x00,
OFF_EVENT_ENTRY_HEAD = 0x0C,
// Subscriber-chain node layout — the linked list hanging off each
// entry's +0x0C head, derived from Frame::RegisterEvent
// (FUN_00702140): each node is `{ ?, next@+0x04, frame@+0x08 }`, where
// `frame` is the CFrameScriptObject* subscriber. A node value with its
// low bit set (or null) is the end/empty sentinel. Walked by
// GetFramesRegisteredForEvent and the custom-event listener check.
OFF_EVENT_NODE_NEXT = 0x04,
OFF_EVENT_NODE_FRAME = 0x08,
// `Frame::RegisterEvent` — the C++ helper called by the Lua
// `frame:RegisterEvent(eventName)` method (`Script_RegisterEvent` at
// `0x00774A40` = FUN_SCRIPT_FRAME_REGISTEREVENT). `__thiscall` with
// `(this=frame, eventName)`. Walks the entry array at
// `[VAR_EVENT_TABLE_BASE_PTR]`, case-insensitively strcmps against each
// entry's name, appends `frame` to the matching entry's chain, and appends
// the event index to the frame's own registered-event list (`+0x14` cap,
// `+0x18` count, `+0x1C` int[]). Returns 1 when the frame was ALREADY on
// that chain (no-op), 0 after appending.
FUN_FRAME_REGISTER_EVENT = 0x00702140,
// The script object's own registered-event list — the event-table
// indices it listens to, appended by RegisterEvent (0x00702140) and
// RegisterAllEvents (0x007023E0), walked backwards by UnregisterEvent
// (0x00702280) to find a name, emptied by UnregisterAllEvents. Indices
// survive `Event::Custom::Grow` (entries keep their positions). Verified
// from the decomps + benilla-re systems/ui/script.md "The script object".
OFF_SCRIPTOBJECT_EVENT_COUNT = 0x18, // u32
OFF_SCRIPTOBJECT_EVENT_INDICES = 0x1C, // u32 *
// `Frame::UnregisterEvent` — `__thiscall(this=frame, eventName)`. Walks
// the frame's registered-event list backwards for the entry whose name
// matches (SStrCmpI), unlinks + frees the frame's `__AUEVENTLISTENERNODE__`
// from that chain, and compacts the list. Sole caller is the Lua wrapper
// `Script_UnregisterEvent` (0x00774B30). `Frame::UnitEvent` co-hooks it to
// drop the (frame, event) unit filter exactly when the engine drops the
// node — mirroring 5.4.8, where the filter LIVES on the node.
FUN_FRAME_UNREGISTER_EVENT = 0x00702280,
// `Frame::UnregisterAllEvents` — `__fastcall(frame)`. Unlinks the frame's
// node from every chain in its registered-event list, frees the list, and
// zeroes `+0x14/+0x18/+0x1C`. Callers: the Lua wrapper
// `Script_UnregisterAllEvents` (0x00774CF0) and the CScriptObject
// destructor FUN_00701B40 — so a hook here also sees frame destruction.
// `Frame::UnitEvent` co-hooks it to drop all of the frame's unit filters.
FUN_FRAME_UNREGISTER_ALL_EVENTS = 0x007024F0,
// `RebuildEventTable` — the engine's bulk event-table population
// routine. `__fastcall(const char **names, int count) -> void`
// (ECX = names array, EDX = count). Tears down any existing table
// (calling the per-entry teardown helper at 0x00701A40 + freeing
// the base pointer via SMemFree), allocates a fresh table of size
// `count * 16`, then loops `names[0..count-1]` and for each
// non-empty entry calls `SStrDup(name, file, line)` to allocate
// an engine-owned copy at `entry+0x00`.
//
// Called twice during boot (with two different name arrays — 26
// entries at 0x00B41E70, then 549 entries at 0x00BE1198) and once
// per `/reload`. We **don't hook this** — third-party DLLs
// (SuperWoWhook, transmogfix, nampower, etc.) all hook here too, and
// chaining their modifications to the `(names, count)` args makes the
// final table size unreliable (crashes seen with count → buffer-size
// mismatch). Instead, `Event::Custom` claims NULL slots from the live
// table after the rebuild settles. Kept for reference.
FUN_REBUILD_EVENT_TABLE = 0x00703D90,
// Event-table allocator — `__thiscall(EventObject *this, uint32 count)`.
// Called by `RebuildEventTable` to (re)size the entry array. SuperWoW and
// nampower co-hook it to destructively clamp the FrameXML count (`> 200`;
// glue is smaller) to 700. We deliberately DON'T hook it: our default is
// claim-NULL into the engine's ~200 low gaps (which always suffices), and
// when a grow IS needed `Event::Custom::Grow` reallocates the buffer +
// swaps the globals directly (bypassing this clamp) rather than routing a
// size through here. Also documents the empty-entry init the grow mirrors
// ({name=0, +4=0, +8=&self, +0xC=(&self)|1}). Kept for reference.
FUN_FRAMESCRIPT_SET_EVENT_COUNT = 0x007053B0,
// `FireEvent` — the engine's event dispatcher. 149 callers in the
// binary. `__cdecl void(int eventID, const char *format, ...)`.
// Indexes into `[VAR_EVENT_TABLE_BASE_PTR] + eventID * 0x10` and walks
// the subscriber chain at `+0x0C`. Format codes match printf:
// %s = const char *
// %d = int
// %u = unsigned int
// %f = float (promoted to double on the stack)
// No `%b` for boolean — pass `%d` with 0/1; the engine has no native
// bool concept here. No bounds check on eventID; pass valid indices.
FUN_FIRE_EVENT = 0x00703F50,
// Per-token unit-event broadcast. Fires unit event `eventCode` for every
// unit token currently mapping to `*guid` (player / pet / target / party /
// raid / npc / mouseover), via the engine's own GUID->token reverse map
// FUN_UNIT_TOKENS_FROM_GUID -- the same path the descriptor-field
// observers drive on a real field change. nampower REPLACES this function
// (SendUnitSignal, a hadesmem detour that never calls the original; it
// fires for its own token list from GetUnitNames, gated by its settings)
// — do not co-hook it: the last DLL to patch wins. A co-hook here that
// re-fired with "focus" never ran (pfUI's focus frame lost UNIT_HEALTH).
// SuperWoW patches the map itself. What no other DLL touches is the
// callers' CALL/JMP instructions: 37 `E8` and one tail `E9` (in the
// UNIT_NAME_UPDATE fire FUN_00491a00, at 0x00491A3C), matching Ghidra's
// xref list. Unit::TokenEvents points each at its own function, which
// calls this address (running whatever is installed there) and then
// fires the event for the unit's ClassicAPI tokens. Scanned all loaded
// DLLs for absolute references near the sites: none.
// `void __fastcall(uint64_t *guid, uint32_t eventCode)`;
// verified against nampower's SendUnitSignal (0x00515e50). `eventCode` is
// the unit field index, which doubles as the event id (see
// UNIT_EVENT_UNIT_AURA).
FUN_UNIT_EVENT_BROADCAST = 0x00515E50,
UNIT_EVENT_BROADCAST_CALL_SITES = 38,
// Event name strings live in `.data` (mostly clustered around
// 0x00851000..0x00855000); event-name string pointers also reach into
// `.rdata` (starts at 0x007FF000) for some entries. Bound the dereference
// range conservatively to "static-data section" — addresses outside this
// window cannot be valid string pointers in this binary, so we treat
// them as NULL during the walk.
EVENT_TABLE_VALID_PTR_LO = 0x007FF000,
EVENT_TABLE_VALID_PTR_HI = 0x00C00000,
// Storm allocator — Blizzard's internal C utility library. `SMemAlloc`
// wraps every block with bookkeeping (header magic + size + caller
// file:line, footer magic, plus a global registered-block list); the
// matching `SMemFree` validates against all of that and panics with
// `ERROR #124 SMem3: Pointer does not refer to a valid allocated block
// of memory` if the pointer didn't come from `SMemAlloc`.
//
// Both are `__stdcall`, 4 args, `ret 0x10`. Verified via disassembly
// at the function bodies (push order matches arg order; `ret 0x10`
// pops the 4 stack args). The Storm allocator instance both wrap is
// the singleton at `0x00C51C58`.
//
// void *__stdcall SMemAlloc(size_t size, const char *file, int line,
// int flags); // flags: bit 3 (0x08) = zero-fill
// int __stdcall SMemFree (void *ptr, const char *file, int line,
// int flags); // returns 1
//
// We use `SMemAlloc` for event-name storage in `Event::Custom` so the
// engine's reload teardown loop (which `SMemFree`s every event entry's
// name) doesn't trip its safety check on our injected pointers.
FUN_STORM_SMEM_ALLOC = 0x006462E0,
FUN_STORM_SMEM_FREE = 0x00646430,
// Engine's main file-content reader. Used by the TOC parser at
// `FUN_TOC_PARSER` to slurp addon `.toc` files and by the addon
// load pass for `.lua` source. Allocates a Storm buffer via
// `FUN_STORM_SMEM_ALLOC`, writes the file content + `extraBytes`
// trailing zeros, hands the buffer to the caller. Caller frees
// via `FUN_STORM_SMEM_FREE`.
//
// __stdcall int FileRead( // callee cleans 28 bytes (RET 0x1C);
// // NOT __cdecl — see src/addons/Embedded.cpp
// int archive, // 0 = merged VFS; or an archive
// // handle to read from one MPQ
// // (e.g. FUN_00648FB0 reads its
// // "(listfile)" this way)
// const char *path, // "Interface\AddOns\X\Y.lua"
// void **outBuf, // Storm-allocated content
// size_t *outSize, // optional, may be NULL
// size_t extraBytes, // trailing zero-fill (1 for nul-term)
// int flag1, // always 1 from TOC parser
// int flag2); // 0
// Returns 1 on success, 0 on failure.
//
// We hook this to redirect reads of `Interface\AddOns\!!!ClassicAPI\*`
// to embedded buffers (see src/addons/Embedded.cpp). Allocating via
// the same Storm allocator the engine uses means the caller's
// normal `SMemFree` works without us tracking lifetime.
FUN_FILE_READ = 0x00648620,
// ---- BLP2 reader (benilla-re image/blp, verified) -------------------
// The engine's synchronous BLP reader, as GetPortraitAlphaMask
// (0x005258A0) drives it: a 0x4B4-byte record on the stack, initialised
// to zero except magic 'BLP2' @+0x04, version 1 @+0x08, alpha type 2
// @+0x0E and 100 @+0x4A4 (its meaning is unread; mirrored as the
// engine stores it), then Open → DecodeLevel → FreeScratch → Reset.
// Open reads the whole file (patch MPQs honoured) into ONE module-static
// buffer, so only the record opened last is valid — decode before the
// next open. All __thiscall.
// Open(this, path, flag=1) → nonzero on success (ret 8)
// DecodeLevel(this, gxFmt, level, void **out, uint32_t *size)
// → nonzero; *out is the level in gxFmt (ret 0x10)
// FreeScratch(this, level) — frees DecodeLevel's buffer (ret 4)
// Reset(this) — drops the file pointer and the chain
// Header fields sit at file offset + 4: width @+0x10, height @+0x14.
FUN_BLP_OPEN = 0x005A7B40,
FUN_BLP_DECODE_LEVEL = 0x005A7F00,
FUN_BLP_FREE_SCRATCH = 0x005A8100,
FUN_BLP_RESET = 0x005A7AA0,
BLP_RECORD_SIZE = 0x4B4,
OFF_BLP_MAGIC = 0x04,
OFF_BLP_VERSION = 0x08,
OFF_BLP_ALPHA_TYPE = 0x0E,
OFF_BLP_WIDTH = 0x10,
OFF_BLP_HEIGHT = 0x14,
OFF_BLP_INIT_4A4 = 0x4A4,
// GxTex format 2: BGRA8888, four bytes per texel, alpha in byte 3
// (palette expansion keeps the palette dword's alpha byte there;
// benilla image/convert#palette-to-bgra). GetPortraitAlphaMask decodes
// to this format.
GX_TEX_FORMAT_BGRA8888 = 2,
// MPQ file enumerator — walks every mounted archive's `(listfile)`
// and invokes a callback for each entry whose path begins with a
// given prefix. This is the engine's flat, recursive name walk (the
// `SFileEnumFiles` analog), NOT a per-directory find. It's the
// function the macro-icon loader `FUN_LOAD_MACRO_ICONS` uses to
// surface MPQ-baked icons under `Interface\Icons\`.
//
// void __fastcall MpqEnumFiles(
// int archiveSelector, // ecx — archive-set selector;
// // the loader passes 6.
// // Covers the primary
// // mounted archives plus
// // one selected extra.
// const char *pathPrefix, // edx — e.g. "Interface\" —
// // only listfile entries
// // under this prefix are
// // reported.
// FileCb callback, // per-file callback (below)
// void *userParam); // loader passes 0
//
// The callback is `int __fastcall(const char *fullPath /*ecx*/)`;
// `fullPath` is the entry's full archive-relative path (e.g.
// "Interface\FrameXML\Foo.lua"). Returning 0 STOPS enumeration —
// return non-zero to keep going (note: the OPPOSITE of the disk
// find at `FindFirstFileW`). The continue/stop sense is verified in
// the per-archive walker `FUN_00648FB0`, whose loop does
// `if (... && callback() == 0) break;`.
//
// Internally: `FUN_00401470` loops the archive-handle array
// (`DAT_008826BC`, count `DAT_00882740`) calling the per-archive
// listfile walker `FUN_00648FB0`, which reads each archive's
// `(listfile)` via `FUN_FILE_READ`, splits on CR/LF, prefix-filters
// via a trampoline, and dispatches the callback. Used by
// `Interface::Export` (`ExportInterfaceFiles`).
//
// NB: the sibling `FUN_0042AD10` is a DISK-only walker (it resolves
// to kernel32 `FindFirstFileW` and never sees MPQ contents) — don't
// confuse the two. The macro `Icons.cpp` callback labels have the
// disk/MPQ roles swapped; this entry is the authoritative note.
FUN_MPQ_ENUM_FILES = 0x00401470,
// ...and the `archiveSelector` is NOT "an archive set" — it is an INDEX
// into a fixed 10-entry table of secondary archives. `FUN_00401470`
// walks the primary archives (`[0, DAT_00882740)`: the Data\patch-*.MPQ
// set plus speech2 sub-archives) and then exactly ONE more, at
// `archives[DAT_00882744 + selector]`. The mount function
// `FUN_00403740` builds that group from the name table at
// `0x0082E12C`, looping `uVar9 < 0x28` over 4-byte entries — so ten,
// in this order:
//
// 0 model 1 texture 2 terrain 3 wmo 4 sound
// 5 misc 6 interface 7 fonts 8 speech 9 dbc
//
// `DAT_00882740 == DAT_00882744` (both assigned the primary count), so
// the selector indexes that table directly and 0..9 are all in range;
// a failed open leaves a null the enumerator already skips.
//
// This bit us: passing 6 (copied from the macro-icon loader, which
// wants interface.MPQ) made `ExportInterfaceFiles` complete by
// coincidence while `ExportSoundFiles` saw neither sound.MPQ nor
// speech.MPQ — 6,561 of 9,535 listed sound files, silently. Anything
// enumerating content must sweep all ten selectors rather than guess
// which archive holds what; `Interface::Export::EnumAllArchives` does.
MPQ_SECONDARY_ARCHIVE_COUNT = 10,
// SoundEntries.dbc — the client's sound-file table, and the second
// source `ExportSoundFiles` enumerates from.
//
// The reason it needs one: an MPQ resolves a read by HASHING the
// path, so `(listfile)` is only an optional index, and this client's
// sound archives index a small fraction of what they hold. Measured
// on the 1.18.1 build: the listfile walk yields 3,184 files under
// `Sound\` while SoundEntries alone names 13,696 — including core
// entries like `Sound\Spells\DivineShield.wav` that demonstrably
// play. The two sets each carry files the other lacks (162 listfile
// files are in no SoundEntries row: doodad/model-referenced audio),
// so the export unions them, exactly as `ExportDBCFiles` unions the
// listfile with its `.text` path-getter scan.
//
// Standard 5-DWORD class instance at `0x00C0D8D4`; records-array
// pointer at `+0x08`, count at `+0x0C` (docs/DBCs.md). 29 fields,
// 116-byte records; string fields are fixed up to `char *` at load.
// Record layout (the columns we read; verified by parsing the
// extracted .dbc and rebuilding paths that match the exported tree):
// +0x00 id
// +0x08 Name
// +0x0C `File[10]` — bare file names, NULL for unused slots
// +0x5C DirectoryBase — e.g. "Sound\Spells"; one row in this
// build has a stray leading backslash
// ("\Sound\Creature\Ashbringer\"), so trim
// separators off both halves before
// joining them with a single '\'.
VAR_SOUND_ENTRIES_RECORDS = 0x00C0D8DC,
VAR_SOUND_ENTRIES_COUNT = 0x00C0D8E0,
OFF_SOUND_ENTRY_FILES = 0x0C,
OFF_SOUND_ENTRY_DIRECTORY = 0x5C,
SOUND_ENTRY_FILE_COUNT = 10,
// ---- Sound playback ------------------------------------------------
//
// Every sound in this client is an FMOD stream opened by path (the
// binary links only FSOUND_Stream_*), and every open ends in one of
// TWO engine functions (benilla-re sound/engine, xrefs confirmed in
// Ghidra):
// Sound::Play `int *__fastcall(int bus, const char *path,
// uint mode, char held, uint flags)`, RET 0xC.
// Reached only from Play2D (`FUN_SOUND_PLAY_2D`)
// and Play3D (`0x007A5490`, every positional sound:
// creature voices, spell impacts, server sounds).
// Sound::PlayLooped `int *__fastcall(int bus, const char *path,
// int loopCount, uint mode, char held, uint flags)`,
// RET 0x10. Ambience, emitters, 2D/3D loops.
// Both return the Sound record, or NULL when nothing started — the
// engine's own "didn't play" answer (Play2D/Play3D also return NULL
// from their pre-play gate `0x007A66A0`: the bus cap, and the by-path
// duplicate check when `flags & 1`), which every caller handles. That
// is what makes muting expressible: return NULL and nothing else
// changes. Play2D alone is NOT a funnel — it misses every 3D and
// looped sound.
//
// `flags` low byte picks the volume category: 0x2 Music (also exempt
// from the sound-effects switch), 0x8 Ambience, 0x10 Master only,
// otherwise Sound. `bus` is one of 13 concurrency buses (caps at
// `0x0087CE60`: 2^31-1, 1, 2, 2, 1, 1, 2, 2, 1, 6, 4, 1, 2); bus 3 is
// the one Script_PlaySoundFile (`0x00458780`) uses.
FUN_SOUND_OPEN = 0x007A5290,
FUN_SOUND_OPEN_LOOPED = 0x007A54D0,
// Sound::Play2D — `int *__fastcall(int bus, const char *path, uint
// flags, char held)`, RET 0x8: the pre-play gate, then FUN_SOUND_OPEN
// with mode 0x82000.
FUN_SOUND_PLAY_2D = 0x007A5450,
SOUND_BUS_PLAY_SOUND_FILE = 3,
SOUND_FLAG_MUSIC = 0x02,
SOUND_FLAG_AMBIENCE = 0x08,
SOUND_FLAG_NO_CATEGORY = 0x10,
// Sound::Stop2 — `void __thiscall(Sound *, float seconds)`, RET 0x4.
// Fades the sound out and releases it at silence, or releases it at
// once below 0.1 s (benilla-re sound/engine#fades). Releasing frees
// the record, so only a sound no engine slot holds may be stopped.
FUN_SOUND_STOP = 0x007A5A10,
// Interface-sound suppression count: `PlaySound(name)`
// (SndInterfacePlayInterfaceSound `0x00458030`) plays nothing while it
// is above 0. The UI load and the world enter/leave paths raise it
// around themselves (`0x00458F50` / `0x00458F60`).
VAR_INTERFACE_SOUND_SUPPRESS = 0x00B05FA0,
// Sound definition (`FUN_SOUND_ENTRY_FOR_ID`'s result) flags, copied
// from the SoundEntries row. Bit 0x20 asks the play for the by-path
// duplicate check (`0x00458F40`: `([def+0x7C] >> 5) & 1`).
OFF_SOUND_DEFINITION_FLAGS = 0x7C,
SOUND_DEFINITION_FLAG_NO_DUPLICATES = 0x20,
// SoundEntries player (InternalPlaySound) — `void *__fastcall(char keep
// /*ecx, flag 0x4*/, char noCategory /*edx, flag 0x10*/, int bus, int
// soundEntryID, int variantIndex, int music /*flag 0x2*/)`, RET 0x10,
// returning the Sound record or NULL. Resolves the definition
// (`FUN_0045CDA0`), picks one of its up-to-10 file variants
// (`FUN_0045BB70`; `variantIndex = -1` takes the weighted random pick
// the engine uses), then calls FUN_SOUND_PLAY_2D with the definition's
// duplicate bit as flag 0x1.
//
// ABI verified by disassembly, NOT the decompile — Ghidra maps the
// arguments inconsistently against the call site. `FUN_00458850`, the
// tail of `PlaySound(name)`, calls it as `(0, 0, 0, id, -1, 0)` and
// coerces the result to a bool, which is exactly a by-ID play: the
// engine has always played by SoundEntries ID internally, it simply
// never exposed that to Lua (`PlaySound` takes only the row's name).
FUN_SOUND_PLAY_ENTRY = 0x0045CE60,
// Head of the live stream list, walked by `FUN_007A66A0`'s dedup pass:
// an intrusive list with `next` at `+0x04` and the Storm tagged-pointer
// sentinel (low bit set, or null, ends it). Membership is how
// `C_Sound.IsPlaying` validates a handle — a stream object is freed
// when it finishes, so the handle must never be dereferenced directly.
VAR_SOUND_STREAM_LIST_HEAD = 0x00CF557C,
OFF_SOUND_STREAM_NEXT = 0x04,
// VocalUISounds.dbc — the player's spoken error lines ("my bags are
// full"), one row per (error, race), each naming a male and a female
// recording. Standard 5-DWORD class instance at `0x00C0D604`.
//
// Record layout, verified by resolving a row's sound ids to their
// SoundEntries names: row `{9, 0, 1, 1875, 1999, 626, 626}` is error 0
// for race 1, whose normal sounds are `HumanMale_InventoryFull` and
// `HumanFemale_InventoryFull`.
// +0x00 id
// +0x04 vocal error enum — matches the modern
// `Enum.Vocalerrorsounds` values, and this build carries ALL
// 68 of them (0..67) for 11 races
// +0x08 ChrRaces id
// +0x0C normal sound id [male, female] (-1 where unrecorded)
// +0x14 "pissed" sound id [male, female] — the escalated take; many
// of these ids name no SoundEntries row, so they are not used
//
// NOTE the engine loads this table and never reads it: the only xrefs
// to the records/count globals are the loader's own writes. So the
// row lookup has no engine function to borrow, and `Sound::VocalError`
// does it directly — the play itself still goes through the engine's
// by-id player.
VAR_VOCAL_UI_SOUNDS_RECORDS = 0x00C0D60C,
VAR_VOCAL_UI_SOUNDS_COUNT = 0x00C0D610,
OFF_VOCAL_UI_ENUM = 0x04,
OFF_VOCAL_UI_RACE = 0x08,
OFF_VOCAL_UI_NORMAL_SOUND = 0x0C, // int[2], indexed by sex (0 male)
// SoundEntries row resolver — `void *__fastcall(uint soundEntryID)`,
// null for an id with no row. The by-id player calls it first; we need
// it too because the volume applicator below is a method ON the row.
FUN_SOUND_ENTRY_FOR_ID = 0x0045CDA0,
// Row volume applicator — `void __thiscall(void *row, void *stream,
// float scale)`. Computes the row's own volume times `scale`
// (`FUN_00458C60`) and stores it on the stream via `FUN_007A5DC0`,
// which writes `stream + OFF_SOUND_STREAM_VOLUME` and pushes it to
// FMOD. The by-id player already calls this with a scale of 1.0
// immediately after starting a sound, so calling it again with another
// scale REPLACES the volume rather than compounding — which is what
// makes a volume override expressible without touching FMOD directly.
// (It also re-rolls the random pitch for rows flagged 0x400 at
// `row + 0x7C`, exactly as the engine's own call does.)
FUN_SOUND_APPLY_ROW_VOLUME = 0x00458DA0,
// The stream's current volume, as written by `FUN_007A5DC0` — i.e. the
// row's volume after scaling, which is what "scaled volume" names.
OFF_SOUND_STREAM_VOLUME = 0x74,
// Hash of the path the stream was opened with, stamped at creation
// (`FUN_007A51D0`: `obj[0x20] = FUN_0064AF90(path)`) and compared by
// the dedup pass. Stream objects come from a pool and their addresses
// are reused, so this is what tells one instance from another at the
// same address — see `Sound::Play`'s finish tracking.
OFF_SOUND_STREAM_PATH_HASH = 0x80,
// Per-frame sound update, main thread: drains finished streams
// (`FUN_007A4B60`), updates the 3D listener, then calls FSOUND_Update.
// The drain matters for anything reporting completion: FMOD's own end
// callback (`FUN_007A53C0`) runs on the STREAMER thread and only moves
// the stream onto a deferred list under a critical section
// (`0x00CF55B4`) — so a finished sound must never be reported from
// there. `FUN_007A4B60` is where the engine reclaims those, on the main
// thread, which is the only safe side to notice completion from.
FUN_SOUND_UPDATE_FRAME = 0x007A4AD0,
// `Script_PlaySound` — the engine's `PlaySound(soundName)`: hashes the
// name to a SoundEntries row and calls `FUN_00458850`, whose tail is
// `FUN_SOUND_PLAY_ENTRY(0, 0, 0, id, -1, 0)`. `Sound::Play`
// re-registers `PlaySound` over it to also accept a SoundKitID, and
// tail-calls this with the stack untouched for every other argument
// shape. Contention checked before re-registering: no sibling DLL
// references it (UnitXP_SP3's "PlaySound" string is the winmm
// `PlaySoundW` import), and the one addon that reassigns the global
// (unitscan) does a temporary `PlaySound = pass` / restore around its
// own target calls, capturing whatever is registered at addon load.
FUN_SCRIPT_PLAY_SOUND = 0x004586D0,
// Item-sound player — `void __fastcall(int soundType /*ecx*/,
// int displayInfoID /*edx*/)`, the whole of `C_Sound.PlayItemSound`
// below the Lua edge. Bounds-checks the display id against
// ItemDisplayInfo (`[0x00C0DC10]` records, `[0x00C0DC14]` count), reads
// that row's ItemGroupSounds id at `+0x2C`, bounds-checks THAT against
// ItemGroupSounds (`[0x00C0DBFC]` / `[0x00C0DC00]`), and plays the
// SoundEntries id at `row + 0x04 + soundType * 4` via `FUN_00458850`.
//
// So an ItemGroupSounds row is four sound ids, and their column order
// is the modern `Enum.ItemSoundType` order — 0 Pickup, 1 Drop, 2 Use,
// 3 Close. Every bounds failure falls through silently, which is the
// behavior an unknown item should have at the Lua edge too.
//
// Note the key is the item's DISPLAY id (`OFF_ITEMSTATS_DISPLAY_INFO_ID`),
// not its itemID: items that share a display share a sound.
FUN_SOUND_PLAY_ITEM = 0x00457FF0,
// Console-command registrar — the vanilla equivalent of 4.3.4's
// `FUN_00654c90`. Registers a developer-console command (the `~`
// console you get when launching with `-console`).
//
// int __fastcall RegisterConsoleCommand(
// const char *name, // ecx — command name; stored BY
// // POINTER (no copy), so must
// // have static lifetime
// Handler handler, // edx — see below
// int category, // help-grouping category id
// const char *description);// help text, or NULL
// Returns 1 on success, 0 if a command with that name already
// exists (dedup-safe — repeat calls are harmless no-ops). The
// command node is never freed for a static-literal name, so we
// don't need SStrDup the way the event table does.
//
// The handler is `int __fastcall(const char *command /*ecx*/, const
// char *args /*edx*/)` — 4.3.4's COMMANDHANDLER. `command` is the
// invoked name (the shared CVar handler FUN_CONSOLE_CVAR_COMMAND_HANDLER
// looks its CVar up by it); `args` is the text after the name
// (`*args == '\0'` when invoked bare). Return 1. The category is
// 4.3.4's CATEGORY enum (see VAR_CONSOLE_CATEGORY_TABLE); cosmetic,
// only `help` grouping reads it, and the registrar doesn't validate it.
//
// The node layout is 4.3.4's CONSOLECOMMAND up to +0x20. 4.3.4 adds a
// +0x24 argument-completion callback this registrar has no slot for —
// and no 4.3.4 command fills it (every registration passes NULL).
//
// Self-initializes the command hash table on first use, so it is
// safe to call any time after the engine's own console subsystem
// boots (well before our glue / load-script hooks fire). Verified
// via the bulk graphics registrar `FUN_0066F6C0` and the `help`
// command's own registration in `FUN_006400E0`.
FUN_CONSOLE_COMMAND_REGISTER = 0x0063F9E0,
// The registry that registrar fills: a Storm intrusive list plus a by-name
// hash. `Console::Commands` walks the list to back `C_Console.GetAllCommands`,
// mirroring the `help` handler (`FUN_0063FDC0`) exactly — it prints each
// command whose `+0x20` matches the requested category, stepping with
// `next = *(uint32_t *)(node + LINK_OFFSET + 4)` and stopping on a null or
// low-bit-tagged sentinel, the same tagged-pointer idiom as the addon
// registry. LINK_OFFSET is a value, not a pointer.
VAR_CONSOLE_COMMAND_LIST_HEAD = 0x00C4F854,
VAR_CONSOLE_COMMAND_LINK_OFFSET = 0x00C4F84C,
// Node fields, from the registrar's stores (`node[5..8]`) cross-checked
// against the help handler's reads. The registrar keeps `name` and `help`
// BY POINTER — it copies neither — so both outlive it only because every
// caller passes a literal.
OFF_CONSOLE_COMMAND_NAME = 0x14,
OFF_CONSOLE_COMMAND_HANDLER = 0x18,
OFF_CONSOLE_COMMAND_HELP = 0x1C, // may be null
OFF_CONSOLE_COMMAND_CATEGORY = 0x20,
// Every CVar is ALSO a console command: the CVar registrar's last act is
// `FUN_CONSOLE_COMMAND_REGISTER(cvar->name, 0x0063DDE0, categoryId, help)`,
// with this shared get/set handler. So the command list already contains
// every CVar — walking the CVar list too would double-count — and the
// handler pointer is an exact test for which kind a node is.
FUN_CONSOLE_CVAR_COMMAND_HANDLER = 0x0063DDE0,
// `{ int id; char name[0x14]; }` x 9, read by the bare `help` command to
// list the categories. Ids 0..8 are debug, graphics, console, combat, game,
// default, net, sound, gm, in that order — which is Enum.ConsoleCategory's
// own 0..8, so a category read off a command node needs no translation.
// This table is where that claim was checked; `Console::Commands` states
// the enum in full rather than deriving it, because the enum also carries
// Reveal (9) and None (10), which this client has no categories for.
VAR_CONSOLE_CATEGORY_TABLE = 0x008653A0,
CONSOLE_CATEGORY_COUNT = 9,
SIZEOF_CONSOLE_CATEGORY_ENTRY = 0x18,
// --- The rest of the console surface --------------------------------------
// Run a command line: `__fastcall(const char *line, int addToHistory)`. Skips
// leading spaces, resolves the name, and calls the node's +0x18 handler —
// the same field ConsoleGetAllCommands reports. Prints "Unknown command"
// when nothing matches. This is what replays each `SET` line of Config.wtf.
FUN_CONSOLE_EXEC = 0x0063CE00,
// `__fastcall(int keyCode)`, the whole body being a store to
// VAR_CONSOLE_TOGGLE_KEY.
FUN_CONSOLE_SET_KEY = 0x0063CB00,
// Console font init: reads VAR_CONSOLE_FONT_HEIGHT, releases the old font
// handle, creates `Fonts\ARIALN.ttf` at that size, and re-seeds
// VAR_CONSOLE_COLORS to its defaults.
//
// DO NOT CALL IT. It has no code callers — its single reference is one
// table entry at 0x0080E170 — so it runs exactly once at startup, before a
// console line exists. The null-check-and-free of the previous handle looks
// like re-entrancy but is not: every existing line holds a cached,
// font-dependent draw object at +0x20, and this frees the font without
// touching them, so the NEXT console render walks freed data and faults in
// the texture manager. The console's own shutdown frees the font and those
// per-line objects together, which is what the pairing is for. Verified by
// crashing this way; see console/Shell.cpp for why there is no font-height
// setter.
FUN_CONSOLE_FONT_INIT = 0x00639100,
// Toggled by the console key in the key handler FUN_0063C860, which acts
// only when VAR_CONSOLE_ENABLED is set: `visible = (visible == 0)`.
VAR_CONSOLE_VISIBLE = 0x00C4EAC8,
// Set at startup from the `-console` command-line switch (FUN_00419C10(0x22)
// in ConsoleDeviceInitialize). Without it the toggle key does nothing, so
// the console can never open.
VAR_CONSOLE_ENABLED = 0x00C4EC20,
VAR_CONSOLE_TOGGLE_KEY = 0x00864554,
// Nine ARGB uint32 colours indexed by a line's colour type — the second
// argument to FUN_CONSOLE_WRITE, stored per line at +0x1C and used to pick
// the colour at draw time. Seeded by FUN_00638A60 / FUN_CONSOLE_FONT_INIT
// (white, white, grey, red, yellow, white, white, half-alpha white, black),
// and the engine's own setter bounds the index with `< 9`. `help` writes
// type 4, "Unknown command" type 0.
VAR_CONSOLE_COLORS = 0x00C4EAD8,
CONSOLE_COLOR_COUNT = 9,
// Console font height as a fraction of screen height, 0.02 by default.
VAR_CONSOLE_FONT_HEIGHT = 0x0086455C,
// --- Console input: key handling and Tab completion -----------------------
// EventRegisterEx — `void __fastcall(int eventId /*ecx*/, Handler handler
// /*edx*/, void *param, float priority)`, into the current event context.
// Handlers are `int __fastcall(const void *data, void *param)`; returning 0
// stops the dispatch. The list is kept in DESCENDING priority, and a new
// handler is linked in front of the first one whose priority is <= its own
// (FUN_00424F00, 4.3.4's IEvtQueueRegister) — so a handler registered
// later at an EQUAL priority runs first. Does not dedup.
FUN_EVENT_REGISTER_EX = 0x0041FCA0,
// Event id of a key press. The console's RegisterHandlers (FUN_0063BC90)
// registers ids 1, 5, 8, 9, 10, 11, 14, 12 in 4.3.4's order CHAR, IDLE,
// KEYDOWN, KEYUP, KEYDOWN_REPEATING, MOUSEDOWN, MOUSEUP, MOUSEMOVE; id 8's
// handler FUN_CONSOLE_ON_KEY_DOWN is the one with the Tab/Enter/Escape
// switch. Its data is 4.3.4's EVENT_DATA_KEY: `{ int key; uint32_t meta; }`.
EVENT_ID_KEYDOWN = 8,
// Key release, and a key-down for a key already on the held-key list
// (the dispatch turns 8 into 0xA before any handler runs — so pressing
// the second side of a held merged modifier arrives as 0xA). Same
// EVENT_DATA_KEY payload (benilla-re core/events "Held keys and repeats").
EVENT_ID_KEYUP = 9,
EVENT_ID_KEYDOWN_REPEATING = 0xA,
// Every console input handler is registered at priority 7.0 (stored here
// as the integer; the registrar takes it as a float).
CONSOLE_EVENT_PRIORITY = 7,
FUN_CONSOLE_ON_KEY_DOWN = 0x0063C480,
// Mouse button press / release event ids, sent by PostMouseDownEvent
// (0x00423DB0, `mov edx,0xb`) and PostMouseUpEvent (0x004240B0, 0xe). The
// payload is nine dwords: mouse mode, the button's bit, the held mask
// after the change, modifiers, flags (+1 for a synthetic release on lost
// capture), x, y, wheel delta, time (benilla-re core/input "Payloads").
// The button bits are left 1, middle 2, right 4, X1 8, X2 0x10 — the same
// masks as VAR_BUTTON_NAME_*.
// Window activation change, sent by PostActivateEvent (0x00423CB0, `mov
// edx,2`) for every WM_ACTIVATE, either direction; payload `{ uint32_t
// active; }`. Before any handler runs, the dispatch (0x004245B0 →
// 0x00424790) empties the context's held-key list, so EventIsKeyDown
// answers 0 for every key until its next key-down (benilla-re
// core/events "Held keys and repeats").
EVENT_ID_ACTIVATE = 2,
EVENT_ID_MOUSEDOWN = 0xB,
EVENT_ID_MOUSEUP = 0xE,
OFF_MOUSE_EVENT_BUTTON = 0x04,
// The engine's held-button mask, same bits. PostMouseDownEvent ORs the
// button in (`0x00423DB6`..`0x00423DCF`), PostMouseUpEvent clears it, every
// activation change clears it whole (ClearInputMasks 0x00423900 from
// PostActivateEvent), and a lost capture releases every
// held button through PostMouseUpEvent.
VAR_HELD_MOUSE_BUTTONS = 0x00883F40,
// `Input::GlobalMouse`'s handler priority: above the interface's mouse
// handlers (1.0, CSimpleTop's registrar 0x00765BF0) so it sees clicks a
// frame takes; below the console (CONSOLE_EVENT_PRIORITY) and the
// loading-screen and screen-fade vetoes (8.0, 0x004069E0 / 0x004C0E00).
GLOBAL_MOUSE_EVENT_PRIORITY = 2,
// 4.3.4's KEY enum, unchanged in 1.12: the console's switch tests 0x200
// Escape, 0x201 Enter, 0x203 Tab.
KEY_TAB = 0x203,
// The key event's modifier mask is 4.3.4's `1 << key` over the meta keys,
// but 1.12 has three merged meta keys (KEY 0 SHIFT, 1 CTRL, 2 ALT — the
// FUN_GAMEUI_IS_KEY_DOWN codes) where 4.3.4 has six per-side ones. So:
// SHIFT 1, CTRL 2, ALT 4. Read off the binding-prefix builder FUN_004B6630
// (bit 0 "SHIFT-", 1 "CTRL-", 2 "ALT-"), and consistent with the console
// handler's own tests (`meta == 1` reverses Tab completion, `meta == 2` is
// Ctrl+C / Ctrl+V).
EVENT_META_SHIFT = 0x1,
EVENT_META_CTRL = 0x2,
// The line being typed — 4.3.4's GetInputLine; makes one if the head line
// is not an input line. `CONSOLELINE *__fastcall()`.
FUN_CONSOLE_GET_INPUT_LINE = 0x0063BAA0,
// 4.3.4's MakeCommandCurrent: `void __fastcall(CONSOLELINE *line, const
// char *text)` — replaces the typed text (from m_inputstart) with `text`,
// growing the buffer as needed, and leaves the caret at its end.
FUN_CONSOLE_MAKE_COMMAND_CURRENT = 0x00638E40,
// 4.3.4's SetInputString: `void __fastcall(const char *wholeLine)` —
// rebuilds the drawn input string. The key handler calls it with the
// line's whole buffer after every edit.
FUN_CONSOLE_SET_INPUT_STRING = 0x00638D10,
// 4.3.4's s_completionMode: set by the first Tab of a completion run, and
// cleared by the key handler on any key but Tab, Shift (KEY 0), Alt (KEY
// 2) or a Ctrl chord — 4.3.4's exact rule with merged meta keys. Read by
// Console::Completion to tell when a run has ended.
VAR_CONSOLE_COMPLETION_MODE = 0x00C4EC28,
// 4.3.4's CONSOLELINE (0x24 bytes, allocated as "CONSOLELINE"): link at
// +0, m_buffer +0x08, m_chars +0x0C, m_inputpos +0x14, m_inputstart +0x18,
// m_colorType +0x1C. Matches the key handler's and ConsoleWrite's reads.
OFF_CONSOLE_LINE_BUFFER = 0x08,
OFF_CONSOLE_LINE_INPUT_POS = 0x14,
OFF_CONSOLE_LINE_INPUT_START = 0x18,
// The output lines (4.3.4's s_linelist): newest first, the same tagged
// Storm list as the command registry — link offset, then the head's
// `next` pointer. A head with a non-zero m_inputpos is the line being
// typed. ConsoleWrite (FUN_CONSOLE_WRITE) holds the critical section at
// VAR_CONSOLE_LINE_LOCK while it links a line in.
VAR_CONSOLE_LINE_LIST_LINK_OFFSET = 0x00C4E9A4,
VAR_CONSOLE_LINE_LIST_HEAD = 0x00C4E9AC,
VAR_CONSOLE_LINE_LOCK = 0x00C4E64C,
// `ConsoleWrite(const char *line /*ecx*/, int colorFlag /*edx*/)` —
// appends a line to the developer console's output buffer. No-ops
// cleanly when the console isn't active (gated on the console-init
// globals `DAT_00C4EC1C` / `DAT_00C4EC34`), so it's safe to call
// unconditionally from a console-command handler. `colorFlag` 0 =
// default. Used by `Interface::Export` for "wrote N files" feedback.
FUN_CONSOLE_WRITE = 0x0063CB50,
// `void __cdecl ConsolePrintf(const char *format, ...)` — formats via
// Storm's vsnprintf (FUN_0064A8B0) into a 1024-byte stack buffer and
// passes it to FUN_CONSOLE_WRITE in colour 0. Gated on DAT_00C4EC1C (the
// console being initialised). The shared CVar handler prints
// `CVar "%s" is "%s"` through it. Matches 4.3.4's ConsolePrintf.
FUN_CONSOLE_PRINTF = 0x0063CD50,
// TOC parser — `__fastcall(this=addonName)`. Already documented in
// CLAUDE.md under "AddOn registry & hot-reload". Dedup-safe: if
// the addon is already in the hash table, returns immediately
// without re-parsing. Reads the TOC file via `FUN_FILE_READ`. We
// call this from the `FUN_ADDON_SCAN_FULL` pre-hook to register the
// embedded `!!!ClassicAPI` addon — the dedup behavior makes the
// scan's own call a no-op when the user has the addon on disk.
FUN_TOC_PARSER = 0x0051C9B0,
// Client interface version — `__cdecl() -> uint32` (no args), a bare
// `return 0x2BC0` (11200). The addon loadability resolver `FUN_0051e780`
// compares an addon's parsed `## Interface:` number (entry+0x1C) against
// this; a mismatch is the OUT_OF_DATE reason (code 7) that blocks loading
// while the `checkAddonVersion` cvar is on. `AddOns::TocRewrite` calls it
// to recognize the client version inside a multi-flavor comma-list.
FUN_ADDON_CLIENT_INTERFACE_VERSION = 0x0051D7D0,
// Per-addon file loader — `__fastcall(char *tocPath, int *bindingsCtx,
// int *progress) -> uint32`. `FUN_0051f240` calls it once per addon with
// `Interface\AddOns\<Name>\<Name>.toc`; it reads the TOC and runs each
// referenced Lua/XML file. Vanilla runs it BEFORE the addon's
// SavedVariables are loaded (files execute with SV nil), so
// `Addons::SavedVarsFirst` co-hooks it to honor `## LoadSavedVariablesFirst`
// by loading the SV first for flagged addons.
FUN_ADDON_LOAD_FILES = 0x006EDB90,
// Read + run a Lua file — `__fastcall(const char *path, void *checksumOut,
// void *errCtx) -> uint32`. Reads via `FUN_FILE_READ`, then compiles +
// pcalls; returns 0 (and fires errCtx's callback only when errCtx != null)
// if the file is missing, so it is safe to call on an absent path. How the
// engine loads each SavedVariables `.lua` (and how addon files run).
// Hooked once, by Script::LoadFile, which fans out to path rewriters
// (Xml::ScriptPath) and suppressors (AddOns::SavedVarsFirst).
FUN_LUA_LOAD_FILE = 0x00704BC0,
// XML file processor - `__fastcall(const char *path, void *ctx, void
// *status)` (RET 4); walks an XML file's top-level elements. Called by
// FUN_ADDON_LOAD_FILES for each .xml TOC line (0x006EDD51) and by itself
// for <Include> (0x006EE00D). <Include file> is always joined onto the
// including file's directory (0x006EDFBA..0x006EE00D); <Script file> only
// when the value contains no backslash (strchr(file, '\') at 0x006EE06E,
// jne 0x006EE0C7 on a hit), otherwise it is loaded as given, from the game
// root, through FUN_LUA_LOAD_FILE at 0x006EE0D4. The function first
// collapses each `\..\` in `path` into a local copy and joins onto that.
// Co-hooked by xml/ScriptPath.cpp to track the file being processed.
FUN_XML_LOAD_FILE = 0x006EDE10,
// Return address of that <Script file> call into FUN_LUA_LOAD_FILE.
RET_XML_SCRIPT_FILE_LOAD = 0x006EE0D9,
// File-exists probe — `__stdcall(const char *path, int mode)` (RET 8);
// nonzero when the file exists. `mode = 1` on the addon / SavedVariables
// paths. Used to mirror the engine's SV path fallback (prefer the
// realm-scoped per-character file, else the realm-less one). Hooked
// once, by `Addons::Embedded`, which answers for the embedded addon's
// files and chains `AddOns::FlavorBindings::TryExists`.
FUN_FILE_EXISTS = 0x00648A30,
// `realmName` CVar value reader — no-arg, `-> const char *` (last-connected
// realm's display name; lazily registers the cvar). The realm segment of
// the per-character SavedVariables path. (The character segment is
// FUN_GET_LOGIN_ACCOUNT_NAME, whose label is a misnomer — it returns the
// 0x00C27D88 buffer, NULL until a character is logged in.)
FUN_GET_REALM_NAME = 0x005AB7D0,
// AddOn scan — `void __cdecl()`, no args, plain RET (benilla-re
// `ScanAddOns`). Registers the archives' listfile addons, then the
// loose folders, then links every `## LoadWith:` list. Its one caller
// is the login init `LoadAddOnsForAccount` (`0x0051C740`, call at
// `0x0051C74E`), right after the registry reset `FUN_0051FA40` and the
// account-name store, so the registry is empty on entry. Records join
// the list at its tail, and the load pass walks it in that order.
// `Addons::Embedded` pre-hooks it to register `!!!ClassicAPI` first.
FUN_ADDON_SCAN_FULL = 0x0051C760,
// Addon-registry intrusive-list control. Layout
// (`__thiscall`-friendly, generic across all intrusive lists in the
// binary):
// +0x00 (= `0x00BE1B64`) — `int` next-pointer offset within each
// entry (= `0xC` at runtime; entries
// store their next-link at
// `entry+0xC..0x10`).
// +0x04 (= `0x00BE1B68`) — sentinel `next` field
// (points back into &sentinel+1 when
// the list is empty).
// +0x08 (= `0x00BE1B6C`) — list head (alias for sentinel `prev`
// when treated as circular).
//
// `VAR_ADDON_LIST_CTRL` is just the address of the control struct
// (i.e., `0x00BE1B64`). `VAR_ADDON_LIST_HEAD` is the
// control's +0x08 head slot; walk entries via
// `next = *(entry + [VAR_ADDON_LIST_CTRL] + 4)` (= `entry+0x10`),
// stopping on a low-bit-1 sentinel or NULL.
VAR_ADDON_LIST_CTRL = 0x00BE1B64,
VAR_ADDON_LIST_HEAD = 0x00BE1B6C,
// `SStrDup(const char *src, const char *file, int line)`. `__stdcall`.
// Storm's string-copy wrapper around `SMemAlloc` — used by the engine
// itself to populate event entry names. We use it from `Event::Custom`
// so the engine's reload-teardown `SMemFree` sees blocks that came
// from `SMemAlloc` (which it requires).
FUN_STORM_SSTRDUP = 0x0064A620,
// Talent system — per-player talent state populated at login from
// (class, race) + Talent.dbc / TalentTab.dbc. The engine maintains
// one `TabInfo *` per talent tab in the array at
// `[VAR_TALENT_TAB_INFO_ARRAY]`, with the count at
// `[VAR_TALENT_TAB_COUNT]` (= 3 for all vanilla classes).
// Verified by `Script_GetTalentTabInfo` (`0x004F3040`),
// `Script_GetNumTalents` (`0x004F3160`), and `Script_GetTalentInfo`
// (`0x004F3200`) — all three read the same pair of globals.
//
// TabInfo struct:
// +0x00 int TalentTab.dbc rowID
// +0x04 int pointsSpent
// +0x08 int numTalents (in this tab)
// +0x0C TalentEntry * talents (array, 0-indexed)
//
// TalentEntry, stride 0x54:
// +0x00 uint32 talentID (Talent.dbc primary key)
// +0x04..+0x0F other fields (tier, column, ...)
// +0x10..+0x33 uint32 SpellRank[9] (rank-N spellID at index N-1)
// +0x34..+0x53 prereqs / flags / other
//
// Vanilla 1.12 talents have at most 5 ranks, so SpellRank[5..8] are
// always zero; engine reserves 9 slots, we expose the same range.
//
// SpellRank offset verified by tracing the engine's currentRank-
// derivation loop in `Script_GetTalentInfo`: it `lea edx, [ebx+0x30]`
// (cur = highest slot) then walks **downward** with `sub ecx, 4`
// (visible at 0x004F3305) for 9 iterations, ending at +0x10. So
// SpellRank[0] (rank 1's spellID) is at +0x10, SpellRank[8] (rank 9
// sentinel) at +0x30. Confirmed empirically: a debug build reading
// `[entry+0x30]` returned 0 for Inner Focus (rank 1, 14751); the
// value is at `[entry+0x10]`.
VAR_TALENT_TAB_COUNT = 0x00BDCD24,
VAR_TALENT_TAB_INFO_ARRAY = 0x00BDCD28,
OFF_TABINFO_NUM_TALENTS = 0x08,
OFF_TABINFO_TALENT_ARRAY = 0x0C,
OFF_TALENT_SPELL_RANK = 0x10,
TALENT_ENTRY_STRIDE = 0x54,
TALENT_MAX_RANKS = 9,
// Talent.dbc — standard 5-DWORD class shape, records pointer at
// `+0x08` and count at `+0x0C` of the class instance at
// `0x00C0D6E0`. Records is an array of `TalentRec *` indexed
// directly by talentID (sparse — many slots NULL since talent IDs
// skip across classes). Used by `GameTooltip:SetTalentByID` to
// resolve cross-class talents that aren't in the local player's
// loaded TabInfo arrays.
//
// Record layout (verified standard vanilla Talent.dbc schema):
// +0x00 uint32 ID
// +0x04 uint32 TabID
// +0x08 uint32 TierID (row, 0-based)
// +0x0C uint32 ColumnIndex (0-based)
// +0x10 uint32 SpellRank[0..8] — rank-1 spellID at +0x10
//
// The per-player `TalentEntry` (in `TabInfo->talents[]`) shares
// the same SpellRank offset, which is why we can reuse
// `OFF_TALENT_SPELL_RANK` here without redefining it.
VAR_TALENT_DBC_RECORDS = 0x00C0D6E8,
VAR_TALENT_DBC_COUNT = 0x00C0D6EC,
// Flat (row-order) DBC arrays used by the talent-tree builder
// `FUN_004f2c00` — DISTINCT from the sparse by-ID index above. The builder
// walks TalentTab.dbc in row order, filtering each tab by
// `FUN_004f2e50(race, class, raceMask@+0x2c, classMask@+0x30)` (a plain
// bitmask test; mask 0 = all), then walks Talent.dbc in row order grouping
// contiguous TabID runs — so `GetTalentInfo(tab, idx)` ordering IS just
// "TalentTab rows for the class in row order" × "Talent.dbc rows for that
// TabID in row order". Reading these arrays with the same walk (but an
// arbitrary class-mask) reproduces the engine's ordering for any class,
// which is how `GetTalentIDByIndex`'s optional classID arg works.
//
// Each global holds a base POINTER (deref) to the contiguous record array;
// the sibling +4 holds the record count. Strides match the by-ID records:
// TalentTab 0x3c, Talent 0x54 (TALENT_ENTRY_STRIDE).
// TalentTab record: ID@+0x00, raceMask@+0x2c, classMask@+0x30
// Talent record: ID@+0x00, TabID@+0x04 (rest per the by-ID layout)
VAR_TALENTTAB_DBC_FLAT_RECORDS = 0x00C0D6CC,
VAR_TALENTTAB_DBC_FLAT_COUNT = 0x00C0D6D0,
TALENTTAB_ENTRY_STRIDE = 0x3c,
OFF_TALENTTAB_ID = 0x00,
OFF_TALENTTAB_CLASS_MASK = 0x30,
VAR_TALENT_DBC_FLAT_RECORDS = 0x00C0D6E0,
VAR_TALENT_DBC_FLAT_COUNT = 0x00C0D6E4,
OFF_TALENT_DBC_TAB_ID = 0x04,
// Engine's `Script_GetTalentInfo` Lua C function. We call it from
// `GetTalentSpellID` to derive the player's currentRank without
// re-implementing the spell-knowledge checks at `0x0060C740` /
// `0x0060C8D0`. Signature: `int __fastcall(void *L)` — reads tab and
// talent index from Lua stack[1] and stack[2], pushes 6 returns
// (name, icon, tier, column, currentRank, maxRank). Errors (calls
// lua_error) on invalid input or pre-login state, so callers must
// pre-validate.
FUN_SCRIPT_GET_TALENT_INFO = 0x004F3200,
// Game-time struct populated by SMSG_LOGIN_VERIFY_WORLD /
// SMSG_LOGIN_SETTIMESPEED. The engine maintains it as the current
// server clock, advanced by an internal tick handler. `Script_GetGameTime`
// (`0x00515EE0`) reads `[+0x04]` and `[+0x00]` directly via `fild`,
// and the engine's "to days-since-epoch" helper at `0x00642320`
// builds a `struct tm` from `[+0x0C..+0x14]` and calls `_mkgmtime`,
// confirming the field layout.
//
// +0x00 int minute 0..59
// +0x04 int hour 0..23
// +0x08 ? (uncertain — possibly seconds, treated as
// 0 by the engine's known consumers)
// +0x0C int day 0-based; engine `inc`s before storing as
// tm_mday (which is 1-based)
// +0x10 int month 0-based (0=Jan, matches tm_mon directly)
// +0x14 int year full year (e.g. 2026), engine normalizes
// via `(year % 100) + 100` for tm_year
//
// Pre-login the struct is BSS-zero; year=0 is the "uninitialized"
// sentinel we check for.
VAR_GAMETIME_STRUCT = 0x00CE8538,
OFF_GAMETIME_MINUTE = 0x00,
OFF_GAMETIME_HOUR = 0x04,
OFF_GAMETIME_DAY = 0x0C,
OFF_GAMETIME_MONTH = 0x10,
OFF_GAMETIME_YEAR = 0x14,
// Server-clock skew, the engine's own `CMSG_QUERY_TIME` sync — and a
// strictly better server clock than `VAR_GAMETIME_STRUCT` above, which
// carries minute granularity, no timezone, and (on realms that set a
// per-map time offset) the ZONE clock rather than the server's.
//
// `FUN_004DE430` (quest-log enter-world setup) sends `CMSG_QUERY_TIME`
// (opcode `0x1CE`) unconditionally on every enter-world. The response
// handler `FUN_004DE400`, registered for `SMSG_QUERY_TIME_RESPONSE`
// (`0x1CF`) by `FUN_004DE390`, reads the body's single u32 — a raw
// `time(nullptr)` server-side — and `FUN_004DEEF0` stores the skew:
//
// VAR_SERVER_TIME_DELTA = FUN_SERVER_TIME_LOCAL_SECONDS() - serverEpoch
// [0x00BB749C] = FUN_SERVER_TIME_LOCAL_SECONDS() + 0xE10
//
// so `serverEpoch = FUN_SERVER_TIME_LOCAL_SECONDS() - delta`. That
// direction is confirmed by the engine's own use of it: the timed-quest
// expiry check in `FUN_004DE510` tests
// `(questEndTime + delta) - localNow - 1 < 0`, i.e. it converts a
// server timestamp into local-clock space by ADDING the delta.
//
// The second global is a re-query deadline (`0xE10` = 3600 s); the
// quest-log rebuild re-sends `CMSG_QUERY_TIME` once it passes. Both are
// zeroed by `FUN_004DE390`, and the handler substitutes 1 for a
// computed 0 — so **0 is the engine's own "never synced" sentinel** and
// must be checked before use.
VAR_SERVER_TIME_DELTA = 0x00BB7494,
// Local Unix epoch in seconds — the CRT `time(nullptr)`
// (`FUN_0073F049`) behind a 500 ms cache in an interlocked 64-bit slot
// at `DAT_00884048`. `__fastcall void → uint32_t`. This is the clock
// `VAR_SERVER_TIME_DELTA` is measured against, so the two must always
// be read together.
FUN_SERVER_TIME_LOCAL_SECONDS = 0x00429580,
// AddOn registry. The engine keeps a flat 4-byte-stride array of
// addon NAME POINTERS at `[VAR_ADDON_ARRAY]` — each element is an
// entry's `[entry + OFF_ADDON_ENTRY_NAME_PTR]` (the display-array
// builder copies that field; `FUN_ADDON_GET_BY_INDEX` returns the
// element) — with the in-use count at `[VAR_ADDON_COUNT]`. Being the
// name string itself, an element can be passed directly to
// `lua_pushstring` (which is exactly what `Script_GetAddOnInfo` does for
// ret1). It is NOT the entry: `entry + 0` is the name hash (the loader's
// bucket compare `cmp [ebx],esi` at 0x0051F2A1). It is also the exact
// pointer the loader installs as the context word, so it is the addon's
// memory/CPU tag.
//
// Per-field accessors (all `__fastcall(ecx=name) → char* or NULL`):
// each one looks up the addon by name in the engine's hash table,
// then reads a single hardcoded field from the addon's metadata
// hash table and returns its string value (NULL if the addon
// doesn't exist or the field is missing).
//
// We use these directly in the `C_AddOns.*` wrappers to avoid
// dispatching to `Script_GetAddOnInfo` (which pushes a 7-tuple
// when we only want one field, and worse, errors via `lua_error`
// for out-of-range numeric indices).
FUN_ADDON_GET_BY_INDEX = 0x0051DF00, // (idx0Based) → name pointer or NULL
FUN_ADDON_GET_COUNT = 0x0051DEF0, // () → [VAR_ADDON_COUNT]; the engine's GetNumAddOns read
// `"AddOn index must be in the range of 1 to %d"` — the luaL_error
// format stock `Script_GetAddOnDependencies` (`0x0048E5E0`) raises with
// `FUN_ADDON_GET_COUNT()` on an out-of-range numeric index.
VAR_ADDON_INDEX_RANGE_ERROR_FMT = 0x00837D70,
FUN_ADDON_GET_TITLE_BY_NAME = 0x0051DF20, // (name) → title string or NULL
FUN_ADDON_GET_NOTES_BY_NAME = 0x0051E050, // (name) → notes string or NULL
// `__fastcall(const char *name) → AddOnEntry*+0x48 or NULL`.
// Hash-table lookup by name (a `FUN_ADDON_GET_BY_INDEX` result works
// because it IS a name pointer), returning a pointer to the
// matched record's RequiredDeps descriptor (`record + 0x48`), or
// NULL on a miss. Stock `Script_GetAddOnDependencies` (`0x0048E5E0`)
// calls this then reads count@+4 / data@+8 off the return to walk
// the required deps. We reuse it only to recover the record base for
// string input: `record = resolve(name) - OFF_ADDON_REQDEPS_DESC`.
FUN_ADDON_RESOLVE_REQ_DEPS = 0x0051E350,
// AddOnEntry dependency-array descriptors are `{cap, count, data,
// quantum}` (each field 4 bytes) laid out 0x10 apart, parsed by the
// TOC parser `FUN_0051c9b0`:
// OptionalDeps desc@+0x38 (count@+0x3C, data@+0x40)
// RequiredDeps desc@+0x48 (count@+0x4C, data@+0x50) ← stock walks
// LoadWith desc@+0x58
// Optional offsets verified against the parser's append site at
// `0x0051CDBA` (`mov esi,[rec+0x3C]` count, `lea edi,[rec+0x38]`);
// required desc@+0x48 confirmed by `FUN_ADDON_RESOLVE_REQ_DEPS`'s
// `lea eax,[rec+0x48]` return.
OFF_ADDON_REQDEPS_DESC = 0x48,
// `## Interface:` value (uint32, the parser's first-number atoi).
// Verified in `FUN_ADDON_CAN_LOAD`: `rec[7] != FUN_0051d7d0()` → status
// 7 (INTERFACE_VERSION), on the same record whose name is `rec[5]`
// (+0x14) and required-dep count `rec[0x13]` (+0x4C).
OFF_ADDON_INTERFACE_VERSION = 0x1C,
OFF_ADDON_OPTIONALDEPS_COUNT = 0x3C,
OFF_ADDON_OPTIONALDEPS_ARRAY = 0x40,
// Per-field accessors `Script_GetAddOnInfo` calls internally for
// returns 5 (loadable), 6 (reason string), 7 (security category).
// We dispatch to these directly so the wrappers don't need to
// bounce through `Script_GetAddOnInfo` and unwind 7 returns.
//
// IS_LOADED `__fastcall(entry) → byte`
// Hash-table lookup in the addon registry. Returns the byte
// at `entry+0x18`, which the addon loader (`FUN_0051F240`)
// writes `1` to when the addon has finished loading. Non-zero
// ⇒ the addon is loaded.
//
// CAN_LOAD `__fastcall(entry, char fullCheck=1, int *outStatus,
// int *outDepHandle, const char *accountName) → byte`
// Recursive load-check that resolves all forward `## Dependencies`.
// On `0` return, writes one of 8 status codes into `*outStatus`
// (see `VAR_ADDON_LOADABLE_REASON_TABLE` for the index→string
// mapping). `outDepHandle` carries a dep-pointer when status is 0
// ("DEP: %s" path), unused otherwise. We pass `&zeroDep` for
// `outDepHandle` — we don't render the dep-name into the reason
// since the modern API gives just the status enum.
//
// GET_REASON_STRING `__thiscall(int statusCode, char *buf, uint cap)`
// Copies the status-code's static string into `buf`, or formats
// `"DEP: <name>"` when `this == 0`. We bypass this entirely and
// index the table directly (see `VAR_ADDON_LOADABLE_REASON_TABLE`).
//
// GET_SECURITY_INDEX `__fastcall(entry) → uint`
// Hash-table lookup that returns the security category index
// (0=SECURE, 1=INSECURE, 2=BANNED). Defaults to `1` (INSECURE)
// when the entry isn't in the override table.
FUN_ADDON_IS_LOADED = 0x0051E6F0,
// The per-addon loader — `uint __fastcall(const char *name, char flag,
// void *progressCtx)`. Returns non-zero (low byte) once the addon is
// loaded, including the early-out when it already was.
//
// **It sets the entry's loaded byte (`+0x18`) BEFORE running anything**,
// then loads LoadWith + required deps (clearing the byte again if a
// required dep fails), runs the TOC files, `Bindings.xml` and the
// SavedVariables, fires `ADDON_LOADED`, and finally loads the entries
// that name this one in their LoadWith. So the byte means "load has
// begun", i.e. `loadedOrLoading` — NOT "load has finished". The window
// is observable from Lua, because the addon's own files (and every
// dependency pulled in during them) execute inside it.
// `AddOns::LoadState` co-hooks this to tell the two states apart.
FUN_ADDON_LOAD_ONE = 0x0051F240,
// The loader's context window — 3.3.5's `LoadAddOn` brackets the same
// span with `lua_gctag = addonName`. After the dependency loop it saves
// the context word, sets it to `[entry+0x24] ? [entry+0x14] : 0`, runs
// the TOC files, Bindings.xml and both SavedVariables files, restores the
// word, and only then fires ADDON_LOADED (0x0051F5AD). EBX = the entry
// throughout. Both sites are reached on every path through the window
// (the context write before the open is conditional; these are not) and
// no jump lands inside either:
// OPEN `33 C0 8D 4D E8` (xor eax,eax; lea ecx,[ebp-0x18]), 5 bytes
// CLOSE `A1 C4 EA CE 00` (mov eax,[0x00CEEAC4]), 5 bytes; also the
// target of the digest skip `jnz` at 0x0051F553
SITE_ADDON_LOAD_WINDOW_OPEN = 0x0051F38D,
SITE_ADDON_LOAD_WINDOW_CLOSE = 0x0051F576,
// `Script_LoadAddOn` — the stock `LoadAddOn(index or name)` global.
// Pushes two values either way: `(1, nil)` on success, or
// `(nil, "REASON")` with a locale-independent reason token
// ("DISABLED", "MISSING", … / "UNKNOWN_ERROR") on failure — already the
// modern `loaded, value` shape apart from `1` standing in for `true`.
// Standard Lua C ABI, so it re-registers under a namespace table as-is.
FUN_SCRIPT_LOAD_ADDON = 0x0048E980,
FUN_ADDON_CAN_LOAD = 0x0051E780,
FUN_ADDON_GET_SECURITY_INDEX = 0x0051E990,
// Per-character enable-state resolver — the inner check
// `FUN_ADDON_CAN_LOAD` (`0x0051E780`) consults to decide whether an
// addon is enabled: `__fastcall(const char *name /*ecx*/,
// const char *account /*edx*/, char resolveAll /*stack*/) -> uint`.
// Returns 0 = disabled (load pass then skips the addon, reason
// DISABLED), non-zero = enabled (2 = "enabled for all"). Walks the
// per-character override list at `0x00BE1BD8`; with no override it
// falls back to the entry's DefaultState byte (`+0x2b`):
// `-(uint)(entry[+0x2b] != 0) & 2`. `Addons::Embedded` co-hooks this
// to force-enable the embedded `!!!ClassicAPI` unconditionally — so a
// stale WTF disable-override (from back when the addon was still
// shown in the character-select list) can't leave it hidden AND
// unloaded. Cold: runs only during the login/reload load pass, once
// per addon.
FUN_ADDON_ENABLE_RESOLVE = 0x0051E470,
// Returns a pointer to the inline-stored login account name buffer
// at `0x00C27D88`, or NULL if no character is logged in yet.
// `Script_GetAddOnInfo` feeds this into the loadable + enabled
// checks; same convention.
FUN_GET_LOGIN_ACCOUNT_NAME = 0x005ABDC0,
// Two parallel `const char *[]` tables in `.data` covering every
// string `Script_GetAddOnInfo`'s returns 6 + 7 can produce.
//
// LOADABLE_REASON_TABLE — 8 entries indexed by the status code
// `FUN_ADDON_CAN_LOAD` writes:
// 0 LOADABLE (only emitted for the DEP fallback)
// 1 MISSING
// 2 DISABLED
// 3 BANNED
// 4 CORRUPT
// 5 INSECURE
// 6 NOT_DEMAND_LOADED
// 7 INTERFACE_VERSION
//
// SECURITY_TABLE — 3 entries indexed by the value
// `FUN_ADDON_GET_SECURITY_INDEX` returns. Lives at
// `LOADABLE_REASON_TABLE + 8 * sizeof(char *)` — the two
// tables are physically contiguous in the binary.
// 0 SECURE
// 1 INSECURE
// 2 BANNED
VAR_ADDON_LOADABLE_REASON_TABLE = 0x0085365C,
VAR_ADDON_SECURITY_TABLE = 0x0085367C,
VAR_ADDON_ARRAY = 0x00BE1B94,
VAR_ADDON_COUNT = 0x00BE1B90,
// AddOnEntry fields shared by `Addons::Embedded` and `Addons::Rescan`
// (the full per-field derivation lives in CLAUDE.md's AddOn registry
// section):
// +0x14 — canonical name pointer (what the load pass passes to the
// by-name loader `FUN_0051F240`).
// +0x29 — filter-out byte; the flat display-array builder skips
// entries where it's non-zero (how `!!!ClassicAPI` hides).
// LoadWith desc@+0x58 (count@+0x5C, data@+0x60) — `## LoadWith:`
// names, parsed by `FUN_TOC_PARSER` (append site writes
// rec[0x16..0x19]).
// reverse-LoadWith desc@+0x88 (count@+0x8C, data@+0x90,
// quantum@+0x94) — `AddOnEntry *`s of every addon that
// declared `## LoadWith: <this>`; built by the scan
// `FUN_0051C760`'s tail loop (rec[0x22..0x25]), consumed by
// the loader's post-ADDON_LOADED loop.
OFF_ADDON_ENTRY_NAME_PTR = 0x14,
OFF_ADDON_ENTRY_FILTER_OUT = 0x29,
OFF_ADDON_LOADWITH_COUNT = 0x5C,
OFF_ADDON_LOADWITH_ARRAY = 0x60,
OFF_ADDON_REVLOADWITH_DESC = 0x88,
// `## Secure:` flag byte. Parser write site verified in
// `FUN_TOC_PARSER`'s decompile (`*(bool *)(entry_dwords + 10)` =
// `+0x28`); also set by the SMSG_ADDON_INFO secure path at login.
// Entries with this set are SMSG-managed (Blizzard addons on stock
// clients) — never evict/re-register them: the parser cannot restore
// packet-delivered state (and their MPQ TOCs never change anyway).
OFF_ADDON_ENTRY_SECURE = 0x28,
// Signature status (dword) — 3.3.5's `UIADDON::m_status`. Nonzero = an
// insecure (user) addon. `FUN_ADDON_LOAD_ONE` runs the addon's files under
// the context word `[+0x24] ? [+0x14] : 0` (0x0051F37E..0x0051F387) and
// checks the TOC digest only when it is 0 (0x0051F54E).
OFF_ADDON_ENTRY_STATUS = 0x24,
// Complete single-`AddOnEntry` destructor — vtable slot 0 of the
// registry's node factory (`[0x00BE1B60]` = `&PTR_FUN_00808c7c`,
// installed by the boot init `FUN_0051C360`; the login teardown
// `FUN_0051FA40` dispatches per entry through it).
// `__stdcall(AddOnEntry *)`, RET 4 (arg read from `[EBP+8]`,
// verified by disassembly). Body (`FUN_005200A0` → field cleanup
// `FUN_005200D0`, both decompiled):
// - frees EVERY owned allocation: name (+0x14), the +0x30 string,
// all five dep/SV string arrays AND their buffers
// (+0x38/+0x48/+0x58/+0x68/+0x78), the reverse-LoadWith buffer
// (+0x88), and the per-entry `##` metadata hash table (+0x98 —
// the Title/Notes/Author/X-* nodes `GetAddOnMetadata` reads);
// - SELF-UNLINKS from both registry structures: the intrusive
// list (link node +0xC via `FUN_00520A60`, which neighbor-
// patches from the node alone and no-ops when already unlinked)
// and the hash bucket chain (+0x4);
// - frees the entry struct itself (`__AUUIADDON__` tag).
// What it does NOT clean: THIS entry's pointer inside OTHER
// entries' reverse-LoadWith lists — the caller must scrub those
// first (`Addons::Rescan`), or the loader's post-ADDON_LOADED loop
// (`FUN_0051F240` tail: reads +0x8C/+0x90, derefs each entry's
// +0x14) reads freed memory.
FUN_ADDON_ENTRY_DESTROY = 0x005200A0,
// `u8` set to 1 by `LoadAddOnsForAccount` (`0x0051C740`) after the login
// scan completes,
// cleared by the registry teardown `FUN_0051FA40`. Gates anything
// that touches the registry outside the login path.
VAR_ADDON_INITIALIZED = 0x00BE1C08,
// ── The loose-file index ───────────────────────────────────────────
//
// Every relative-path file open resolves through `FUN_00647E60`
// (callers: the open dispatcher `FUN_006477C0` and the exists-check
// `FUN_FILE_EXISTS`), which consults a HASH TABLE OF LOOSE FILES.
// `FUN_00646EA0` builds it lazily on the first lookup after the
// "built" latch `0x00C5251C` is 0: it walks the whole game directory
// tree (`FUN_00646910`), keying each file by its base-relative path
// and storing the joined on-disk path. Index hits open the mapped
// path LIVE from disk (edits to existing files take effect on
// /reload); index misses fall through to the MPQ search ONLY — the
// archive layer's live disk probe (`FUN_00654DD0` →
// GetFileAttributesA) is dead code at runtime because its enable
// global `DAT_00865B44` (ships as 1 in the image) is unconditionally
// cleared by early boot (`FUN_00402210` → `FUN_00648C20`). So a file
// created after the index was built is invisible until it is rebuilt.
//
// `FUN_VFS_INDEX_CLEAR` — `void __cdecl()`, no args. Frees every index
// node and zeroes the latch, so the NEXT lookup rebuilds the index
// from disk exactly as boot does — new files appear, deleted files
// drop out. The analog of 3.3.5's `SFile::RebuildHash`. The engine
// calls it mid-session itself, after creating or deleting a file it
// will later read back (decompiled):
// - `FUN_0051F650` — the /reload/logout SavedVariables unload pass,
// when it created or deleted any SV file;
// - `FUN_0051EF20` — the AddOns.txt writer, when it created the file;
// - `FUN_00491730` — another WTF writer, when it created its file;
// - `FUN_0051FB50` — after renaming loose GlueXML/FrameXML to `.old`.
// So a freshly written SavedVariables file IS readable on the same
// /reload — the engine handles that itself. Neither the clear, the
// builder, nor the lookup takes a lock (unlike 3.3.5); the engine runs
// all of them on the main thread.
FUN_VFS_INDEX_CLEAR = 0x00646FC0,
// ── Login scan walk #2 (loose-addon discovery) — replayed per /reload
//
// `FUN_ADDON_SCAN_DISK_DIRS` — generic disk directory walker
// (resolves to kernel32 FindFirstFileW; the DISK sibling of
// `FUN_MPQ_ENUM_FILES`):
// int __fastcall ScanDiskDirs(
// const char *basePath, // ecx — e.g. "Interface\AddOns\"
// const char *pattern, // edx — appended to basePath; the
// // scan passes the "*" at
// // VAR_ADDON_SCAN_PATTERN
// Callback cb, // stack — see below
// void *userParam, // stack — passed to cb in edx
// int includeHidden); // stack — 0 skips hidden files
// RET 0xC. Callback: `int __fastcall(FindInfo * /*ecx*/,
// void *userParam /*edx*/)` with FindInfo `{+0x4 attrs (0x10 =
// directory), +0x8 char name[]}`; returning nonzero STOPS the walk
// (note: OPPOSITE of `FUN_MPQ_ENUM_FILES`' convention).
//
// `FUN_ADDON_DISK_DIR_CB` — the engine's own per-entry callback for
// this walk (defined + verified in Ghidra): for every directory not
// starting with '.', calls `FUN_TOC_PARSER` on the name; returns 0.
// `Addons::Rescan` replays the scan's exact call —
// `ScanDiskDirs(VAR_ADDON_PATH_PREFIX, VAR_ADDON_SCAN_PATTERN,
// FUN_ADDON_DISK_DIR_CB, 0, 0)` — so new-folder discovery is 100%
// engine code; the parser's dedup guard makes it a no-op per
// already-registered addon.
FUN_ADDON_SCAN_DISK_DIRS = 0x0042AD10,
FUN_ADDON_DISK_DIR_CB = 0x0051D7B0,
VAR_ADDON_SCAN_PATTERN = 0x00833180, // "*" (walker config block)
VAR_ADDON_PATH_PREFIX = 0x00853724, // "Interface\AddOns\"
// ── Flat display array + descriptor grow helpers ──────────────────
//
// The `GetNumAddOns`/`GetAddOnInfo(i)` array (`VAR_ADDON_ARRAY` /
// `VAR_ADDON_COUNT` above) is a full `{cap, count, data, quantum}`
// descriptor at `VAR_ADDON_ARRAY_CAP` (cap@0x00BE1B8C,
// count@0x00BE1B90, data@0x00BE1B94, quantum@0x00BE1B98) holding
// NAME POINTERS (entry+0x14), rebuilt from scratch and qsorted by
// `FUN_0051DA70` phase 2 whenever SMSG_ADDON_INFO lands.
// `Addons::Rescan` mirrors that phase (never calls `FUN_0051DA70`
// itself — its phase 1 consumes the packet) so newly appended
// registry entries show up in the by-index Lua surface.
//
// Grow helpers (one template instantiation per desc — use each at
// its verified site): `__thiscall(desc /*ecx*/, uint newCap)`,
// RET 4 — Storm-reallocs `desc->data` to newCap*4 and writes
// `desc->cap = newCap`.
// FUN_ADDON_ARRAY_GROW — flat display array (used by
// `FUN_0051DA70` phase 2)
// FUN_ADDON_REVLOADWITH_GROW — reverse-LoadWith descs (used by the
// scan tail loop)
// `FUN_DESC_QUANTUM_CALC` — `__thiscall(desc /*ecx*/, uint needed)`,
// RET 4: returns the append-rounding quantum (highest power of two
// ≤ needed, min 1; ≥ 0x40 caps at 0x40 and stores desc->quantum).
// `FUN_CRT_QSORT` — the CRT `qsort` (`__cdecl(base, num, width,
// cmp)`); `FUN_ADDON_NAME_COMPARE` is the engine's `__cdecl`
// name-pointer comparator `FUN_0051DA70` sorts the array with.
VAR_ADDON_ARRAY_CAP = 0x00BE1B8C,
VAR_ADDON_ARRAY_QUANTUM = 0x00BE1B98,
FUN_ADDON_ARRAY_GROW = 0x004755F0,
FUN_ADDON_REVLOADWITH_GROW = 0x005213C0,
FUN_DESC_QUANTUM_CALC = 0x00521C50,
FUN_CRT_QSORT = 0x0073F727,
FUN_ADDON_NAME_COMPARE = 0x0051DEB0,
// NOTE: an earlier revision defined OFF_PLAYER_FIELD_VIS_BYTES /
// PLAYER_VIS_BIT_STEALTH here at 0x17C, believing bit 0x02 was a
// "stealth bit". That was wrong: 0x17C is UNIT_FIELD_AURALEVELS
// (per-slot caster-level bytes; see OFF_UNIT_FIELD_AURALEVELS above),
// and the old read only appeared to work by coincidence (a caster-
// level byte that happened to have bit 0x02 set on the test char;
// at level 60 = 0x3C it doesn't, so it read false). The real stealth
// flag is UNIT_FIELD_BYTES_1 byte 3 (UNIT_BYTES_1_STEALTH_FLAG); see
// that field above. IsStealthed reads it.
// Mount display ID — the creature display ID the engine renders
// under the mounted player. Zero when not mounted, non-zero
// (typically a 4-digit creature display ID like 0x4306) when
// mounted. Broadcast in UpdateFields, so works for any unit's
// descriptor — though we only expose `IsMounted()` for the
// player to match modern API semantics.
OFF_UNIT_FIELD_MOUNTDISPLAYID = 0x1FC,
// Local player movement-flags u32. Lives directly on the
// CGPlayer object (not the broadcast descriptor) — this is
// client-side state the engine maintains for outbound
// MSG_MOVE_* packets, never visible for remote units. Found
// empirically by diffing _classicapi_PlayerLog snapshots
// (standing/swimming/falling).
//
// Bit values match vanilla MOVEFLAG_* protocol constants —
// verified by matching observed values to the documented
// 1.12 movement-flag set:
// 0x0001 FORWARD 0x2000 FALLING (in-air, moving down)
// 0x4000 FALLING_FAR (extended fall)
// 0x8000 PENDING_STOP
// 0x200000 SWIMMING
// 0x1000000 FLYING (no flying mounts in vanilla, but the bit
// exists for druid Flight Form etc.)
OFF_PLAYER_MOVEMENT_FLAGS = 0x9E8,
MOVEFLAG_FORWARD = 0x1,
MOVEFLAG_BACKWARD = 0x2,
MOVEFLAG_STRAFE_LEFT = 0x4,
MOVEFLAG_STRAFE_RIGHT = 0x8,
// 0x10 / 0x20 are TURN_LEFT / TURN_RIGHT — turn-in-place, not
// translational movement. Excluded from "moving" semantics
// because modern `PLAYER_STARTED_MOVING` doesn't fire for them.
MOVEFLAG_JUMPING = 0x1000,
MOVEFLAG_FALLING = 0x2000,
MOVEFLAG_FALLING_FAR = 0x4000,
MOVEFLAG_SWIMMING = 0x200000,
// The player-movement bits that drop an in-progress cast — the exact mask
// the engine's CheckCast (FUN_006094f0) tests (0x200f). Spell::Cast uses it
// to tell a spurious movement drop of a movement-immune cast (grenades)
// from a real cancel/interrupt, which happens with the player stationary.
MOVEFLAG_MASK_CAST_DROP = MOVEFLAG_FORWARD | MOVEFLAG_BACKWARD |
MOVEFLAG_STRAFE_LEFT | MOVEFLAG_STRAFE_RIGHT |
MOVEFLAG_FALLING, // = 0x200f
// CGPlayer-local pointer to the GameObject the current spell cast
// is targeting. Holds a heap pointer (high bits in the user-mode
// range, e.g. `0x42908708` / `0x52FA1A08`) while the player is
// casting/channeling onto a GameObject; cleared on cast end or
// movement break. Local-only — does NOT broadcast.
//
// Empirically distinct from UNIT_FIELD_CHANNEL_OBJECT — the engine
// uses one or the other depending on the cast shape:
//
// - **Set** during: clicking a warlock summoning portal (channel-
// spell that doesn't populate UNIT_CHANNEL_OBJECT); mining
// (regular spell cast on an ore node).
// - **0** during: warlock channeling a spell (no GO target);
// fishing (uses UNIT_CHANNEL_OBJECT for the bobber GUID);
// herb gathering (no spell, pure GO-loot mechanism); mailbox /
// gossip / sit / NPC interaction (instant, no animation).
//
// Used together with UNIT_FIELD_CHANNEL_SPELL to detect ritual
// participation — see `IsAssistingRitual()` in `unit/State.cpp`.
// The combined check `channelSpell != 0 && castGameObject != 0`
// uniquely identifies the portal-clicker state in 1.12 (mining
// fails `channelSpell != 0`; warlock/fishing fail
// `castGameObject != 0`).
OFF_CGPLAYER_CAST_GAMEOBJECT_PTR = 0xB4,
// Indoor/outdoor query for a unit — backs `IsIndoors()` / `IsOutdoors()`
// (`unit/State.cpp`). `__fastcall(unit) -> uint` where **nonzero =
// outdoors**, 0 = indoors. A 2-instruction thunk: reads the unit's
// world/collision-context pointer at `unit + 0xE0` and tail-jumps to the
// WMO query `FUN_006706f0`. That query is fully null-safe — null context
// or a unit not inside a WMO group returns 1 (outdoors); otherwise it
// resolves the current WMO group via `FUN_0069d4f0` and returns bit 15
// (`0x8000`) of the group's runtime flags word (the OUTDOOR bit).
//
// Derived from SuperWoW 2.2's `IsIndoors` handler (which does exactly
// `unit = ObjMgr(0x10, PlayerGUID()); push (query(unit)==0)`), then
// confirmed against the vanilla binary. Vanilla ships no Lua binding for
// this; the 3.3.5 client's `IsIndoors` (`0x00612300`) uses the identical
// shape (`unit + 0xB8` → WMO group flag test), so the semantics are
// cross-checked across both clients.
FUN_UNIT_IS_OUTDOORS = 0x00612cc0,
// No `MOVEFLAG_FLYING` constant intentionally. Vanilla 1.12
// doesn't flip a flying bit during taxi flights (verified
// empirically: `IsFlying()` checking 0x01000000 stayed false
// throughout a flightpath on which `UnitOnTaxi("player")`
// correctly returned 1). Server-driven splines drive taxi
// animation directly without touching the local movement-
// flags word. Use `UnitOnTaxi` for taxi detection.
// Equipment-slot index for the off-hand. Slots 1..19 are the
// character-pane equipment slots (1=head … 19=tabard); 17 is
// the off-hand slot the engine uses when looking up shields,
// off-hand weapons, and held items via `ItemMgr::GetItemBySlot`.
INVSLOT_OFFHAND = 17,
INVSLOT_MAINHAND = 16,
// INVTYPE values that count as "weapon" for `OffhandHasWeapon`.
// INVTYPE_WEAPON (13) covers any one-handed weapon equippable in
// either hand (sword, axe, mace, dagger, fist). INVTYPE_WEAPONOFFHAND
// (22) covers weapons that can ONLY go in the off-hand. Shields
// (14), Holdables (23 — tomes/orbs), and empty slots all return
// false. INVTYPE_2HWEAPON (17) is excluded because two-handers
// occupy the main-hand slot exclusively.
INVTYPE_WEAPON = 13,
INVTYPE_WEAPONOFFHAND = 22,
INVTYPE_2HWEAPON = 17,
// Character-pane equipment slot range: 1..19 (head=1, neck=2, …,
// tabard=19). Used by `C_Item.IsEquippedItem` to walk every slot
// looking for a matching item.
EQUIPMENT_SLOT_FIRST = 1,
EQUIPMENT_SLOT_LAST = 19,
// CGItem instance block GUID — qword at +0x00 of the instance block
// (which sits behind the pointer at CGItem +0x08). Sibling of
// OFF_INSTANCE_BLOCK_ITEM_ID at +0x0C in the same block.
OFF_INSTANCE_BLOCK_GUID = 0x00,
// `Script_ClearCursor` / `Script_PickupInventoryItem` Lua C
// functions — both `__fastcall(void *L)`. ClearCursor takes no
// args, drops anything held on the cursor. PickupInventoryItem
// reads a 1-based character-pane slot at Lua stack[1] and lifts
// that equipped item onto the cursor (or swaps with the existing
// cursor contents). Used by `C_EquipmentSet.UseEquipmentSet` to
// assemble the pickup→equip chain for each set item.
FUN_SCRIPT_CLEAR_CURSOR = 0x004895B0,
FUN_SCRIPT_PICKUP_INVENTORY_ITEM = 0x004C8DA0,
// Equipment/bag-slot pickup PRIMITIVE behind Script_PickupInventoryItem
// (`FUN_004C8DA0` is just `FUN_004C7300(arg - 1)`). Called directly:
// void __fastcall(uint slot0Based)
// Self-contained — resolves the player, applies its own cursor/lock
// guards, and handles the drop case (slot == 0xFFFFFFFF). Covers the
// 0-based equipment (0..18) and equipped-bag (19..22) slots; container
// contents go through FUN_CURSOR_PICKUP_ITEM instead. Modern
// `equipmentSlotIndex` is 1-based, so pass `equipmentSlotIndex - 1`.
FUN_PICKUP_INVENTORY_SLOT = 0x004C7300,
// The engine's three BAG_UPDATE emitters (names from benilla-re
// systems/ui/bags.md). A pattern search finds exactly three fire
// sites for event 0x148 (BAG_UPDATE) in .text, one in each.
// `Bag::UpdateDelayed` hooks all three to drive BAG_UPDATE_DELAYED.
//
// FUN_RAISE_BAG_EVENTS — `RaiseBagEvents`, __cdecl `void()`, plain
// RET. Compares player slots 19..22 (bags 1..4) and 63..68 (bank
// bags) with the cached container GUIDs at `0x00BDD060` and fires
// BAG_CLOSED / BAG_UPDATE for each changed slot. Callers: the
// bag-slot field watcher `OnBagSlotChanged` (0x004F8EC0) and
// `RegisterBagWatchers` (0x004F8CC0) at login.
//
// FUN_RAISE_BAG_UPDATE — `RaiseBagUpdate`, __stdcall
// `void(int guidLo, int guidHi)`, RET 8. The argument is a
// CONTAINER GUID: fires BAG_UPDATE(0) for the player, BAG_UPDATE(N)
// for cached container N, and returns silently for any other
// container. Callers: `OnBackpackSlotChanged`,
// `OnContainerSlotChanged` (0x004F90D0) and the item-field watcher
// 0x004F9480, which passes the item's ITEM_FIELD_CONTAINED (the
// player for worn gear).
//
// FUN_ON_BACKPACK_SLOT_CHANGED — `OnBackpackSlotChanged`, the field
// watcher on player slots 23..38 (backpack) and 81..112 (keyring).
// Watcher ABI `__fastcall(offset, unused, guidLo, guidHi,
// previous*, user)`, RET 0x10 — four stack args; declaring three
// leaks 4 bytes of stack per call and crashes after a few updates.
// Slot = (offset - 0x4A8) >> 3. Keyring slots fire BAG_UPDATE
// directly; backpack slots call `RaiseBagUpdate(player)`.
FUN_RAISE_BAG_EVENTS = 0x004F91A0,
FUN_RAISE_BAG_UPDATE = 0x004F9370,
FUN_ON_BACKPACK_SLOT_CHANGED = 0x004F8DB0,
// World-subsystem per-frame update — runs exactly once per frame
// as part of the main world tick (`FUN_00482EA0`). Only one caller
// in the entire binary; deep in the rendering/world pipeline,
// nowhere near the chat/cast/transmog code regions that other
// DLLs (SuperWoWhook / nampower / transmogfix) hook. We hook the
// tail of this function to drain `BAG_UPDATE_DELAYED`'s pending
// flag — exact per-frame coalescing matching modern WoW.
//
// Calling convention: `__fastcall(int ecx, int edx, int stackArg)`,
// `RET 0x4` (callee cleans the one stack arg).
FUN_WORLD_TICK = 0x0066FD50,
// UI render root — the CSimpleTop singleton's (`DAT_00cf0bd8`) per-frame
// render callback. Registered at priority 1.0 into the global HLAYER list
// (`FUN_00442800`) and drained every frame by the master scene-render pump
// `FUN_00442350`; body is just `FUN_00765650(root, elapsed)` (the UI layout
// pass, which hands `elapsed` to every frame's vtable +0x38 per-frame update
// — the value OnUpdate receives as `%f`) then `FUN_007657d0(root)` (the
// strata walk that draws every UI frame). Unlike FUN_WORLD_TICK this fires
// in BOTH glue and world: the root ctor `FUN_00764180` runs from the
// world-init path (`FUN_0048FBF0`) AND the glue-boot path (`FUN_0046A7B0`),
// so the UI renders — and this callback fires — on the login/character-
// select screens too. This is the tick to drive UI-object upkeep that must
// also run on glue (inline-texture icon regions), where FUN_WORLD_TICK is
// silent.
//
// ABI: `__stdcall(const float *bounds, float elapsed)`, `RET 0x8`. The drain
// calls every layer as `cb(layer + 0x18 /*rect*/, DAT_00885608)` and
// discards the return value. `DAT_00885608` is the frame delta: stored by
// the setter at 0x00442330, zeroed by the drain at 0x004426C3 once every
// layer has run. This callback never reads `bounds` ([EBP+8] is not
// loaded) and never reads ECX on entry, so it is not a `__thiscall` in
// disguise. Clean PUSH EBP / MOV EBP,ESP prologue (MinHook-safe). Single
// caller (the HLAYER drain), quiet render region — not a known collision
// target for the other Octo DLLs.
FUN_UI_RENDER_ROOT = 0x00764330,
// SMSG_PLAYERBOUND. Handled inline by the shared player packet handler
// FUN_005E38C0 (registered for ~40 opcodes at 0x005E3013..; opcode in
// EDX, jump table at 0x005E3BEA covers 0x155..0x16E): its 0x158 case
// (0x005E3D3F) reads u64 binder GUID + u32 areaID, plays sound 0x475
// and prints game message 0x138 ("<area> is now your home."). Both
// tortoise-wow and vmangos send it ONLY from the bind spell effect,
// right after the SMSG_BINDPOINTUPDATE (0x155) carrying the new bind —
// never on the login / map-change resync. `Player::HearthstoneBound`.
SMSG_PLAYERBOUND = 0x158,
// SMSG_QUESTGIVER_QUEST_COMPLETE handler (opcode 0x191). Server
// sends this after the client claims a quest reward via CMSG_QUESTGIVER_CHOOSE_REWARD
// (opcode 0x18E, sent from `Script_GetQuestReward` → `FUN_005EADC0`).
// Packet body, read in order via `FUN_PACKET_READ_UINT32`:
// [0] questID
// [1] unknown / flags
// [2] xpReward
// [3] moneyReward
// [4] numItems (plus per-item itemID/count for each)
//
// __thiscall(void *player, void *packetStream)
//
// Registered via `FUN_005AB650(0x191, ...)` alongside 8 other quest
// opcodes that all dispatch through `FUN_005E59B0`'s switch — we
// hook the per-opcode handler directly to keep our gate narrow.
// Hooked by `Quest::TurnedIn` to fire `QUEST_TURNED_IN(questID, xp, money)`.
FUN_QUEST_GIVER_QUEST_COMPLETE_HANDLER = 0x005DC400,
// The two tests that keep "<quest> completed." out of chat for a quest in
// the middle of a chain. The handler above looks the quest up in the quest
// cache (FUN_00562A40 on 0x00C0E1B0; a record holds SMSG_QUEST_QUERY_
// RESPONSE's fields in packet order, so +0x24 is NextQuestInChain and +0x9C
// the title — questcache.wdb's records for 954/955/983/1001 hold
// 955/956/1001/1002 there). For a cached quest it runs `mov ecx,[eax+0x24];
// test ecx,ecx; jne` (`75 13`, at the address below) past `push title;
// push 0x8A; call FUN_00496720`. A quest not yet cached leaves callback
// 0x005DC710, which makes the same test when the record arrives (`75 14`).
// FUN_00496720 shows game message 0x8A from its 20-byte table at
// 0x00B4B498 (entry 0x00B4BF60, filled at 0x00485F4F): format
// ERR_QUEST_COMPLETE_S, display type 0 (chat), sound igQuestListComplete,
// chat type 0x0A, which FUN_0049B0B0 fires as event 238, CHAT_MSG_SYSTEM
// (name stored at 0x00BE1550 = 0x00BE1198 + 238 * 4). `Quest::
// CompleteMessage` NOPs both jumps.
PATCH_QUEST_COMPLETE_MSG_CHAIN_SKIP = 0x005DC4DC,
PATCH_QUEST_COMPLETE_MSG_CHAIN_SKIP_LATE = 0x005DC756,
// Engine session globals used by `EquipmentSet::Storage` to build
// the per-character WTF path. Same layout VanillaMinimapTracking
// uses for its own persistence file. Account is the value WoW
// writes the per-character WTF directory under — NOT the saved-
// credentials CVAR. Character name is an inline buffer (NUL byte
// at index 0 means "no active character yet"). Realm name lives
// inside a struct one indirection in.
VAR_ACCOUNT_NAME_PTR = 0x00BE1C0C,
VAR_CHARACTER_NAME = 0x00C27D88,
VAR_REALM_INFO_PTR = 0x00C28130,
OFF_REALM_INFO_NAME = 0x20,
// Player body yaw (orientation in radians, 0..2π) — the
// character's facing direction in the world. Inline float on
// CGPlayer; mirrored at `+0x9F8` (current vs last-broadcast).
// Verified empirically: a clean 180° RMB-drag swings this by
// ~π rad, and LMB-only camera orbits leave it untouched.
// Used by `PLAYER_STARTED_TURNING` to detect actual character
// rotation (vs the mouselook button merely being held).
OFF_PLAYER_BODY_YAW = 0x9C4,
// Camera object pointer chain. The game-state singleton lives
// at `*0x00B4B2BC`; the camera object hangs off it at `+0x65B8`.
// Verified via `Script_CameraZoomIn` (`0x0050B400`) which loads
// this chain to call `FUN_0050FC60` on the camera. Returns the
// camera struct or `nullptr` if the game state isn't yet
// initialized (pre-login).
VAR_GAME_STATE_PTR = 0x00B4B2BC,
OFF_GAME_STATE_CAMERA_PTR = 0x65B8,
// Camera yaw, relative to the character (radians). `0` =
// camera-behind-character default. Accumulates as the user
// LMB-orbits; stays at `0` during RMB-mouselook (camera rotates
// *with* the character, so relative offset doesn't change).
// Verified empirically: clean 180° LMB orbit moves this from
// `0` to `~π`. Mirrored at `+0x210` and `+0x214` (smoothing /
// last-applied buffers); we read the primary at `+0xF0`.
OFF_CAMERA_RELATIVE_YAW = 0xF0,
// Camera pitch clamp, radians: +/-1.55334306 (89 degrees). 4.3.4's
// MAX_PITCH_ANGLE / MIN_PITCH_ANGLE, which its `pitchLimit` console
// command writes. In 1.12 they are the same two floats but sit in
// .rdata, so writing them needs the page unprotected. Every one of their
// 31 readers is camera code (0x0050B380..0x005115B8) — the pitch clamps,
// the smooth-pitch target clamp, and FUN_0050B380, the cameraPitch CVar
// range check that 4.3.4 calls ValidateCameraPitch — so no unrelated
// constant shares the slot.
VAR_CAMERA_MAX_PITCH = 0x008089D8,
VAR_CAMERA_MIN_PITCH = 0x008089DC,
// UI input controller — heap-allocated struct holding the
// engine's master input-state bitfield (mouselook / free-look /
// turn-key / autorun / strafe-modifier / etc.). The slot at
// `0x00BE1148` is a pointer; deref it to reach the controller,
// which lives until the client tears down (rare in practice).
// NULL during pre-login.
VAR_UI_INPUT_CONTROLLER = 0x00BE1148,
// Master input flags. Single u32 at `+0x04` of the controller,
// touched by the engine's button-press/release handlers
// (`FUN_00514840` / `FUN_00514B70`) on every mouse-button or
// input-key transition.
OFF_UI_INPUT_FLAGS = 0x04,
// Bit 0 — `Script_IsMouselooking` checks this. Set when the
// user is in mouselook mode (RMB-drag, or `MouselookStart`
// called from Lua). Turning the character follows mouselook.
INPUT_FLAG_MOUSELOOK = 0x01,
// Bit 1 — set when the user is in free-look mode (LMB-drag).
// Camera-only rotation; character doesn't turn.
INPUT_FLAG_FREE_LOOK = 0x02,
// Bits 4-7 — WASD movement-key state. Each `MoveForwardStart`
// / `StrafeLeftStart` / etc. pushes one of these as the bit
// mask into the engine's button-press handler. Bit `0x1000` is
// the autorun-active flag (set by `ToggleAutoRun`).
// `INPUT_FLAGS_MOVING_ANY` is the engine's own "is the user
// currently inputting translational movement via keys/autorun"
// mask, used to drive `PLAYER_STARTED_MOVING` — matches modern's
// "STOPPED fires on key release, even mid-air" semantics because
// no physics/airborne bit is involved.
//
// NOTE: the "hold both mouse buttons to run forward" gesture is
// NOT in this mask. The button handler (`FUN_00514840`) drives
// that forward move directly via `FUN_005103e0` and explicitly
// *clears* the autorun bit when both buttons go down. Detect it
// from `INPUT_FLAG_MOUSELOOK & INPUT_FLAG_FREE_LOOK` both held
// instead — see `Player::InputEvents`.
INPUT_FLAG_MOVE_FORWARD = 0x10,
INPUT_FLAG_MOVE_BACKWARD = 0x20,
INPUT_FLAG_STRAFE_LEFT = 0x40,
INPUT_FLAG_STRAFE_RIGHT = 0x80,
INPUT_FLAG_AUTORUN = 0x1000,
INPUT_FLAGS_MOVING_ANY =
INPUT_FLAG_MOVE_FORWARD | INPUT_FLAG_MOVE_BACKWARD |
INPUT_FLAG_STRAFE_LEFT | INPUT_FLAG_STRAFE_RIGHT |
INPUT_FLAG_AUTORUN,
// CGUnit -> MovementInfo pointer. Holds the unit's per-instance
// position / orientation / movement-flags / per-direction-speed
// block. Both the local player and synced remote units carry
// valid pointers here (NPCs included, when they exist as
// CGUnits). Verified at multiple call sites that pass
// `[unit + 0x118]` to `FUN_MOVEMENT_GET_EFFECTIVE_SPEED` — e.g.
// `0x00511920` (sprint-jump motion calculator).
OFF_UNIT_MOVEMENT_INFO_PTR = 0x118,
// Inside the MovementInfo block:
OFF_MOVEMENT_FLAGS = 0x40, // u32 — engine's MOVEFLAG_* bits
OFF_MOVEMENT_WALK_SPEED = 0x88,
OFF_MOVEMENT_RUN_SPEED = 0x8C,
OFF_MOVEMENT_RUN_BACK_SPEED = 0x90,
OFF_MOVEMENT_SWIM_SPEED = 0x94,
OFF_MOVEMENT_SWIM_BACK_SPEED = 0x98,
// Effective-speed selector. `__thiscall float(this = MovementInfo,
// int forceWalk) → float`. Returns the speed the engine would
// apply to this frame's movement step — accounts for movement
// flags (walking, swimming, backward), taxi paths, and the
// walk/run/swim selection. Returns 0 when the unit isn't
// moving (movement-flag bits 0..3 all clear). Used by 1.12's
// movement-prediction loop; we call it to provide modern's
// `currentSpeed` first return from `GetUnitSpeed`.
FUN_MOVEMENT_GET_EFFECTIVE_SPEED = 0x007C4C90,
// ------------------------------------------------------------------
// Get*ItemID companions to the engine's Get*ItemLink functions.
// Each offset block is the data path the corresponding
// `Script_Get*ItemLink` reads from before calling
// `FUN_DBCACHE_ITEMSTATS_GET_RECORD` — same source, just stop at
// the itemID instead of building the link string.
// ------------------------------------------------------------------
// Loot rolls: an intrusive linked list of in-progress group loot
// rolls. `FUN_LOOT_ROLL_FROM_ID(rollID) → entry *` walks it.
// `Script_GetLootRollItemLink` reads the itemID at `entry+0x1C`.
FUN_LOOT_ROLL_FROM_ID = 0x0061B2E0,
OFF_LOOT_ROLL_ITEM_ID = 0x1C,
// Loot slots: flat array indexed by `slot-1`, 0x1C-byte stride.
// `LOOTABLE_FLAG` mirrors the engine's `[VAR_LOOT_LOOTABLE]` test
// that drives whether slot indices are 1-based or 0-based; we
// match the engine's `dec` behavior. itemID is at `entry+0`.
VAR_LOOT_SLOTS = 0x00B7196C,
VAR_LOOT_GUID_LO = 0x00B71B48,
VAR_LOOT_GUID_HI = 0x00B71B4C,
VAR_LOOT_LOOTABLE = 0x00B71BA0,
LOOT_SLOT_STRIDE = 0x1C,
LOOT_MAX_SLOTS = 0x10,
// Per-slot field offsets within a `VAR_LOOT_SLOTS + slot * 0x1C`
// entry. Decoded from `Script_GetLootSlotInfo` and the populator
// at `FUN_004C1CB0`:
// +0x00 itemID (Script_GetLootSlotInfo's first push)
// +0x04 displayInfoID (icon lookup via DBC index)
// +0x08 count (FUN_004C22E0 reads `[base+0x8]`)
// +0x0C ?
// +0x10 ?
// +0x14 wire-slot byte (the server-side slot index — what
// `CMSG_LOOT_ITEM` expects; differs from the local
// densely-packed index when the response had gaps)
OFF_LOOT_SLOT_COUNT = 0x08,
OFF_LOOT_SLOT_WIRE_INDEX = 0x14,
// `__fastcall(uint userFacingSlot, char *outBuf, int bufSize) →
// const char *outBuf` — builds the loot-slot hyperlink string
// (e.g. `|cff1eff00|Hitem:12345:0:0:0|h[Item Name]|h|r`) and
// copies it into `outBuf`. Returns the buffer pointer on success,
// `NULL` if no loot window is open, the slot is empty, or the
// item's cache record isn't loaded yet. Used by
// `Script_GetLootSlotLink` at `0x004C2D20`.
//
// `userFacingSlot` is the post-`__ftol`-decrement slot index — the
// same shape Lua's `LootSlot(slot)` produces internally after
// `dec eax`:
// - When coin is present (`VAR_LOOT_LOOTABLE != 0`), input `0`
// is the coin slot itself and returns NULL; subsequent
// internal items live at `userFacingSlot = internal_slot + 1`
// (the function dec's again inside).
// - When no coin, `userFacingSlot = internal_slot` directly.
// The internal `_GetRecord` call inside uses `callback = NULL`, so
// the link is a pure cache hit — no network request gets queued
// when the cache is cold, just a NULL return.
FUN_LOOT_SLOT_LINK_BUILDER = 0x004C2670,
// `__stdcall(uint8_t slotByte)` — sends `CMSG_LOOT_ITEM` (opcode
// `0x108`) carrying the wire-protocol slot byte for the currently-
// open loot window. Built directly from the engine's packet
// primitives — bypasses the `Script_LootSlot` Lua wrapper at
// `FUN_004C2790`, which routes through a `param_2 != 0`
// BoP-confirm-after-dialog branch that's of no use to us. The
// server cheerfully takes whatever slot you send for the current
// loot session; no client-side BoP confirmation gate.
//
// **Calling convention matters.** The callee reads its arg from
// `[ebp+8]` (stack) and ends with `ret 4`. Mis-typedef'ing as
// `__fastcall` produces a stack-corrupting caller — symptoms are
// delayed crashes on unrelated vtable reads.
FUN_CMSG_LOOT_ITEM = 0x005E1AD0,
// `__fastcall(player)` — sends `CMSG_LOOT_MONEY` (the coin/money
// request) for the player's currently-open loot window. Vanilla has
// no `LootMoney` Lua global; coin is virtual loot slot 0 and the Lua
// `LootSlot` handler `FUN_004C2790` routes the coin slot here (its
// `param_1 == 0 && VAR_LOOT_LOOTABLE != 0` branch calls this with the
// resolved local player). Guards internally on the player's active
// loot GUID at `[player + 0x1D28]` — which `FUN_CMSG_LOOT_UNIT` writes
// when it sends the loot request — so it silently no-ops if no window
// is open. Pass the SAME player pointer used for `FUN_CMSG_LOOT_UNIT`
// so the `+0x1D28` guard it just wrote is the one read here.
// `Loot::Scan`'s `LootAllCorpses` path uses it to grab coin alongside
// the per-slot `CMSG_LOOT_ITEM` sends.
FUN_CMSG_LOOT_MONEY = 0x005EA8C0,
// UNIT_DYNAMIC_FLAGS within `m_objectFields`. Standard
// server-driven dynamic-state bitmask. Empirically verified by
// cross-referencing three `Script_*` accessors that all read
// bytes at `[m_objectFields + 0x224]`:
// - `Script_UnitIsTapped` (`0x00519C90`): `test [eax+0x224], 0x04`
// - `Script_UnitIsTappedByPlayer` (`0x00519D00`): `test [eax+0x224], 0x08`
// - `Script_UnitIsDead` (`0x00517AC0`): `[eax+0x224] >> 5 & 1`
// Bit values match CMaNGOS conventions: 0x01 LOOTABLE,
// 0x02 TRACK_UNIT, 0x04 TAPPED, 0x08 TAPPED_BY_PLAYER,
// 0x10 SPECIALINFO, 0x20 DEAD, 0x40 REFER_A_FRIEND_LINKED,
// 0x80 ZONE_OUT. The +0x224 offset is significantly later than
// CMaNGOS-doc'd vanilla (which puts DYNAMIC_FLAGS at field 0x46
// = +0x118) — yet another non-uniform shift in 1.12.1's actual
// UNIT_FIELD layout. Direct empirical read is the authority.
OFF_UNIT_FIELD_DYNAMIC_FLAGS = 0x224,
UNIT_DYNFLAG_LOOTABLE = 0x01,
UNIT_DYNFLAG_DEAD = 0x20,
// UNIT_FIELD_BOUNDINGRADIUS within m_objectFields — single
// float, the unit's interact-radius in world yards. Both
// `FUN_005EC110` (interact-state check) and `FUN_005DF130`
// (CMSG_LOOT sender) compute the interaction-range threshold
// as `target_radius + player_radius + INTERACT_REACH`, clamped
// to a floor of `MIN_INTERACT_RANGE`. Verified at `0x005EC1A4`
// where the function reads
// `[(target_m_objectFields) + 0x1F0]`.
OFF_UNIT_FIELD_BOUNDING_RADIUS = 0x1F0,
// `__thiscall(player, target, useDistanceCheck)` — engine's
// CMSG_LOOT sender for **dead mobs** (CGCreature_C with
// DYNFLAG_LOOTABLE set). Pre-checks: `FUN_005EC110` interact
// validity + `FUN_006003A0` lootability (target dead + bit 0 of
// `m_objectFields[+0x224]` set) + local player not in a state
// that forbids interaction. Releases any open loot window before
// sending the new request.
//
// `useDistanceCheck` is the auto-walk gate:
// - `1` (engine default): if target out of range, start
// walking toward it and *don't* send CMSG_LOOT. If in range,
// send normally.
// - `0`: skip the range check; send immediately. The server
// enforces server-side range, so OOR sends silently fail
// rather than walking the player toward distant corpses —
// the right pick for AoE-loot-style callers.
//
// Engine callsite at `FUN_0060FA20` (right-click world handler)
// resolves the target via
// `ClntObjMgrObjectPtr(TYPEMASK_UNIT, ..., guid)` first, same as
// we do.
//
// Distinct from the sibling sender at `0x005DF130`, which gates
// on `FUN_CGCORPSE_IS_LOOTABLE` (player corpses only) instead of
// the mob path. The CGCorpse helper is documented immediately
// below.
FUN_CMSG_LOOT_UNIT = 0x005DF2A0,
// `__fastcall(int loot_response_struct, undefined4 coin, int unk)`
// — master loot-window state controller. Called by the
// `SMSG_LOOT_RESPONSE` handler tail (via `FUN_0048F3A0`) and by
// `CloseLoot`-inner (via `FUN_0048F200(0, 0, 0)`). Two phases:
// - **Close prior**: if `VAR_LOOT_GUID_LO/HI != 0`, clears
// them, releases item-cache callbacks for the prior slots,
// fires `LOOT_CLOSED` (event id `0x10D`).
// - **Open new**: if `param_1 != 0`, copies the GUID from
// `[param_1 + 8]` into `VAR_LOOT_GUID_LO/HI`, zeroes
// `VAR_LOOT_SLOTS`, walks 16 slots populating itemID via
// `FUN_005EBC90(slot)` and sibling helpers, sets
// `VAR_LOOT_LOOTABLE = param_2` (coin), then fires
// `LOOT_OPENED` (event id `0x10B`).
// Both event fires go through `FUN_FIRE_EVENT_NO_ARGS` —
// intercepting that function lets a caller swallow the events
// without touching this one.
FUN_LOOT_CONTROLLER = 0x004C1CB0,
// `__fastcall(int eventID)` — engine's no-args event dispatcher,
// the lighter-weight sibling of `FUN_FIRE_EVENT` (variadic).
// Called from ~100 sites across the engine, including the
// `LOOT_OPENED` / `LOOT_CLOSED` fires inside
// `FUN_LOOT_CONTROLLER`. Hooking it lets us conditionally swallow
// specific event ids while leaving the rest untouched — the
// mechanism we use to do silent scan loops without flickering
// the `LootFrame`. Fan-in is wide but call frequency is
// event-driven (state changes only), not per-frame, so per-call
// overhead from a hooked predicate is negligible.
FUN_FIRE_EVENT_NO_ARGS = 0x00703E50,
// `__fastcall(int sendRelease, char earlyReturnOnGameObject,
// char showError)` — engine's "close the current loot window"
// inner. Behavior keyed off args:
// - `sendRelease` (ECX): if non-zero, builds and sends
// `CMSG_LOOT_RELEASE` (opcode `0x15F`) for the current loot
// target before clearing client state.
// - `earlyReturnOnGameObject` (EDX): if non-zero, bails early
// when the loot target is a game object that's been
// interacted with in a particular way (fishing-style?).
// - `showError` (stack): if non-zero, calls `FUN_00496720(0x87)`
// to display a "cannot close loot" error.
// Side effects: clears `[player + 0x1D28/+0x1D2C]` (the player's
// prior-interact GUID slots), then calls `FUN_004C1CB0(0, 0, 0)`
// which clears `VAR_LOOT_GUID_LO/HI`, zeroes `VAR_LOOT_SLOTS`,
// and fires the `LOOT_CLOSED` event (`0x10D`). Use
// `(1, 0, 0)` for a clean release + clear.
FUN_CLOSE_LOOT_INNER = 0x0048F200,
// `CGCorpse::IsLootable(this)` — `__fastcall(corpse) → uint`,
// tests bit 0 of `[corpse_m_objectFields + 0x78]`. Specific to
// `TYPEMASK_CORPSE` (player corpses) — `+0x78` of a CGCorpse_C's
// m_objectFields holds dynamic flags with bit 0 = LOOTABLE. The
// same offset in CGUnit_C / CGPlayer_C's m_objectFields holds
// BYTES_0 (race / class / gender / power type), so this helper
// returns nonsense for live units (e.g. it returns 1 for Human
// players because race=1 has bit 0 = 1). Used by the engine's
// right-click-on-corpse handler at `FUN_005D6BF0` to gate
// CMSG_LOOT for player corpses, and from `FUN_005DF130` (one of
// two CMSG_LOOT senders) for the same corpse path. Don't reuse
// for live-unit lootability — use `OFF_UNIT_FIELD_DYNAMIC_FLAGS`
// bit 0 against a CGUnit instead.
FUN_CGCORPSE_IS_LOOTABLE = 0x005D6E20,
// Merchant inventory: flat array at `0xBDD118`, stride 0x1C,
// itemID at `entry+4`. The "flag" globals are actually the
// merchant NPC's 64-bit GUID lo/hi — both zero when no merchant
// is open, which is the engine's gate (`mov a, [LO]; or a, [HI];
// jz no_merchant`). Same globals also drive whether the buyback
// slots are populated.
VAR_MERCHANT_ITEMS = 0x00BDD118,
VAR_MERCHANT_NPC_GUID_LO = 0x00BDDFA0,
VAR_MERCHANT_NPC_GUID_HI = 0x00BDDFA4,
VAR_MERCHANT_COUNT = 0x00BDDFA8,
MERCHANT_STRIDE = 0x1C,
OFF_MERCHANT_ITEM_ID = 0x04,
// Additional 28-byte-entry offsets decoded from
// `Script_GetMerchantItemInfo` at `0x004FB150`:
// +0x0C uint32 numAvailable (-1 = unlimited stock)
// +0x10 uint32 price in copper
// +0x18 uint32 stack quantity per purchase
OFF_MERCHANT_NUM_AVAILABLE = 0x0C,
OFF_MERCHANT_PRICE = 0x10,
OFF_MERCHANT_STACK_COUNT = 0x18,
// Buyback storage. `VAR_BUYBACK_SLOTS` is a 4-byte-stride array
// of inventory-slot indices into the player's invMgr GUID array
// (the engine keeps sold items alive in a per-character buyback
// pool indexed through normal inventory storage). 12 fixed slots
// in vanilla; `VAR_BUYBACK_COUNT` is the live count of populated
// entries. Same merchant-open gate as `VAR_MERCHANT_NPC_GUID_*`.
VAR_BUYBACK_SLOTS = 0x00BDDF24,
VAR_BUYBACK_COUNT = 0x00BDDFAC,
// CMSG_SELL_ITEM dispatcher. Engine's
// `Script_UseContainerItem` merchant branch reaches it with this
// shape; calling it directly bypasses the use-vs-sell dispatch
// and any addon hooks on `UseContainerItem`.
//
// __fastcall(count[ECX],
// merchantGuidLo, merchantGuidHi,
// itemGuidLo, itemGuidHi)
//
// `count = 0` sells the whole stack — same as what
// `Script_UseContainerItem` passes. Callee cleans (`ret 0x10`).
FUN_MERCHANT_SELL_ITEM = 0x005E1D50,
// Quest item resolver — used by `GetQuestItem`. Walks the active
// quest-offer "reward"/"choice" arrays. Returns itemID directly
// (no follow-up cache lookup needed by the caller).
// `__fastcall(ECX = const char *type, EDX = int index0) → itemID`.
// Returns 0 on bad type, OOR index, or empty slot.
FUN_QUEST_ITEM_RESOLVER = 0x00501920,
// Quest log record fields (within the data block returned by
// `Quest::Cache::Lookup`). Reward and choice arrays each hold up
// to N inline itemIDs (4 bytes per entry).
OFF_QUEST_RECORD_REWARD_ITEMS = 0x3C, // 4 entries (0..3)
OFF_QUEST_RECORD_CHOICE_ITEMS = 0x5C, // 6 entries (0..5)
QUEST_RECORD_REWARD_COUNT = 4,
QUEST_RECORD_CHOICE_COUNT = 6,
// Trade window — local "player" side and remote "target" side.
// Player side is a flat int32 array (just itemIDs). Target side
// is a flat `{?, itemID}` array (8-byte stride). Both cap at 7
// slots (vanilla's 6 trade slots + 1 non-tradeable slot).
VAR_TRADE_PLAYER_SLOTS = 0x00B714F4,
VAR_TRADE_TARGET_SLOTS = 0x00B716D0,
TRADE_TARGET_STRIDE = 0x08,
OFF_TRADE_TARGET_ITEM_ID = 0x04,
TRADE_MAX_SLOTS = 7,
// Auction house — three independent arrays of entry-pointers
// covering the three views (list / owner / bidder). Each entry
// carries the itemID at `+0x08`.
VAR_AUCTION_LIST_ENTRIES = 0x00B72278,
VAR_AUCTION_LIST_COUNT = 0x00B7261C,
VAR_AUCTION_OWNER_ENTRIES = 0x00B72340,
VAR_AUCTION_OWNER_COUNT = 0x00B72624,
VAR_AUCTION_BIDDER_ENTRIES = 0x00B72470,
VAR_AUCTION_BIDDER_COUNT = 0x00B7262C,
OFF_AUCTION_ENTRY_ITEM_ID = 0x08,
// Auction sell slot — holds a single CGItem GUID for the item
// currently sitting in the "sell" frame. Engine resolves it via
// a typed object lookup; pass `OBJECT_TYPE_ITEM` and the GUID.
// `Script_StartAuction` posts whatever GUID is here, so writing an
// arbitrary bag item's GUID + calling it posts that item — no cursor,
// no ClickAuctionSellItemButton. Used by `AuctionHouse::PostItem`.
VAR_AUCTION_SELL_GUID_LO = 0x00B72608,
VAR_AUCTION_SELL_GUID_HI = 0x00B7260C,
// Auctioneer NPC GUID — set while an auction house window is open;
// `Script_StartAuction` writes it as the packet target and bails if
// it's zero (so this doubles as an "AH is open" probe).
VAR_AUCTION_AUCTIONEER_GUID_LO = 0x00B725F8,
VAR_AUCTION_AUCTIONEER_GUID_HI = 0x00B725FC,
// `Script_StartAuction` (`0x004CE770`) — `int __fastcall(void *L)`;
// reads (minBid, buyout, runTime) from L[1..3], validates the sell
// slot + auctioneer + runTime, and sends CMSG_AUCTION_SELL_ITEM
// (opcode 0x256 = { auctioneerGuid, sellItemGuid, bid, buyout,
// runTime }). Reused verbatim by `AuctionHouse::PostItem` per stack.
FUN_SCRIPT_START_AUCTION = 0x004CE770,
// Valid `runTime` values `Script_StartAuction` accepts, in minutes:
// {120, 480, 1440} = 2h / 8h / 24h (vanilla's three durations). The
// modern `duration` arg (1/2/3) indexes this table.
VAR_AUCTION_DURATION_TABLE = 0x00807028,
AUCTION_DURATION_TABLE_COUNT = 3,
// `__fastcall(ECX = typeCode, EDX = unused, [stack] = guidLo,
// [stack] = guidHi, [stack] = anyInt) → CGObject *`.
// Returns NULL when no object matches or the type doesn't match.
// The third stack arg (originally a `__FILE__/__LINE__` debug
// hint) is read by debug paths only — anything works at runtime.
FUN_GET_OBJECT_BY_GUID = 0x00468460,
OBJECT_TYPE_ITEM = 2,
// Melee auto-attack primitives (back StartAttack / StopAttack). 1.12
// exposes only the toggling AttackTarget (0x00489B50 -> FUN_006131A0);
// these are the non-toggling start/stop it calls internally.
// START: __thiscall(player, const uint64_t *targetGuid). Validates
// CanAttack on the target, sends CMSG_ATTACKSWING (opcode 0x141), and
// stamps the victim GUID at [player+0xC48]. Idempotent / switch-aware
// on a valid target (never stops an in-progress attack); an
// unattackable target while attacking routes to STOP.
// STOP: __fastcall(player). Clears the attack state; self-guards on the
// attack flag, so it is a no-op (safe) when not attacking.
// RESOLVE_TARGET: __thiscall(player, uint64_t *outGuid) -> int. Validates
// the player's CURRENT target (charm/fear/confuse redirect + CanAttack)
// and writes its GUID; returns 0 (and posts the UI error) if invalid.
FUN_ATTACK_START = 0x005ECB70,
FUN_ATTACK_STOP = 0x005ECAC0,
FUN_ATTACK_RESOLVE_TARGET = 0x00612DF0,
// How RESOLVE_TARGET settles the GUID (Ghidra, CGUnit_C::CanStartMeleeAttack):
// after the state ladder, an empty in-GUID takes the selection (0x0061306B);
// a friendly one (reaction >= 4) or none tab-targets via TargetNearest(0, 1)
// (0x006130BC); any other is selected through FUN_SET_SELECTION_BY_GUID at
// this call, and the GUID is then READ BACK from VAR_CURRENT_SELECTION_GUID_LO
// (0x006130C1) before the final alive / CanAttack test.
CALL_ATTACK_RESOLVE_SELECT = 0x00613100,
// FUN_ATTACK_TOGGLE (0x006131A0, CGUnit_C::StartAttack, behind 1.12's
// AttackTarget): `__thiscall(player, uint64_t guid)`, `ret 8`. Its call to
// RESOLVE_TARGET with &guid; then stop when attacking, else START.
CALL_ATTACK_TOGGLE_RESOLVE = 0x006131AA,
// FUN_ATTACK_START's own select of the victim (CGPlayer_C::StartMeleeAttack
// selects it through FUN_SET_SELECTION_BY_GUID before CMSG_ATTACKSWING).
CALL_ATTACK_START_SELECT = 0x005ECCAA,
// HAS_ATTACK_TARGET: __fastcall(unit) -> int. Nonzero while the
// melee-victim GUID at [unit+0xC48] is set: the engine's own "is
// attacking" test (the cast request's auto-attack start and STOP's
// guard both call it). CGUnit_C::HasAttackTarget, verified in Ghidra.
FUN_UNIT_HAS_ATTACK_TARGET = 0x0060ECB0,
// Inbox — array of mail-entry pointers behind a slot indirection.
// The address itself holds a heap pointer (`MOV ECX, [imm32]` in
// the engine), so reading the array requires one extra deref
// beyond plain `(uint8_t **)`. itemID inline on each entry at
// `+0x120`. (The engine's `Script_GetInboxItem` passes a per-
// entry completion callback at `0x004AF0A0` to GetRecord; for
// ID-only retrieval we skip the callback.)
//
// Entries also carry per-instance modifiers at `+0x12C`
// (enchantID), `+0x134` (suffix factor), `+0x138` (random
// property ID), etc. — `Script_GameTooltip_SetInboxItem` at
// `0x005354C0` copies them onto the tooltip object to render a
// fully-decorated tooltip. We don't expose them in
// `GetInboxItemLink` because 3.3.5's same function only emits
// basic itemID-only links (`FUN_0061E290(itemID)`); per-instance
// data only fully manifests when the player takes the item and
// the engine spawns a real CGItem.
VAR_INBOX_ENTRIES = 0x00B6EF54,
VAR_INBOX_COUNT = 0x00B6EFC0,
OFF_INBOX_ENTRY_ITEM_ID = 0x120,
// SendMail attached item — the engine stores the attached item's
// 64-bit GUID at these globals when the player drops an item onto
// the SendMail slot (`SetSendMailItem` / `ClickSendMailItemButton`).
// Cleared to zero by `ClearSendMail` and on `MAIL_CLOSED`. Vanilla
// allows exactly one attachment per outgoing mail (modern WoW lifted
// this to 12+; we ignore the modern `attachmentIndex` arg since only
// index 1 is meaningful).
//
// The attached item still exists as a live CGItem in the player's
// inventory until the mail is actually sent, so the GUID resolves
// via `FUN_GET_OBJECT_BY_GUID(OBJECT_TYPE_ITEM, ...)`. That lets
// `GetSendMailItemLink` return the full per-instance link (enchant
// / random suffix preserved) by feeding the resolved CGItem to
// `Item::Link::FromCGItem`.
VAR_SEND_MAIL_ITEM_GUID_LO = 0x00B6EF90,
VAR_SEND_MAIL_ITEM_GUID_HI = 0x00B6EF94,
// Craft window (engineering, alchemy, etc. before the "trade
// skill" overhaul). Same slot-indirection shape as inbox: the
// address holds a pointer to the heap-allocated entry-pointer
// array, NOT the array itself. Each entry's `+0x00` is a
// spellID (the recipe spell); the recipe's reagent list lives
// on the spell record at `+0xA8`.
VAR_CRAFT_ENTRIES = 0x00BDCF78,
VAR_CRAFT_COUNT = 0x00BDCFC0,
OFF_CRAFT_ENTRY_SPELL_ID = 0x00,
// Trade skill window — different storage from craft, same shape
// (slot-indirected entry-ptr array with a spellID inside). The
// recipe's created item lives on the spell record at `+0x19C`
// (the "produced item" field), and reagents at `+0xA8` (shared
// with craft).
VAR_TRADESKILL_ENTRIES = 0x00BDDFC0,
VAR_TRADESKILL_COUNT = 0x00BDE04C,
// SkillLine.dbc row ID of the currently-open trade skill window
// (the profession the player has open). Bounds-checked against
// `VAR_SKILL_LINE_COUNT` and used as `records[id]` by
// `Script_GetTradeSkillLine` (`0x004FDD40`). <= 0 / stale when no
// window is open. `FUN_004FC870` zeroes it on close (and fires
// event `0x13B`), so `> 0` reliably means "trade window open".
VAR_CURRENT_TRADESKILL_LINE = 0x00BDE040,
// Craft window (Enchanting, pet training) open-state flag — nonzero
// (3 for the enchanting-style craft) while open; `FUN_004F5FE0`
// zeroes it on close (fires event `0x169`). The Craft window has no
// skill-line-ID global — `TradeSkill::Link` derives the skill line
// from the first craft recipe — so this is the "craft open" gate.
VAR_CRAFT_WINDOW_STATE = 0x00BDCFB8,
// Spell.dbc "produced item" field for crafting recipes — the
// itemID this spell creates when cast. Reagent itemIDs and
// counts live at `OFF_SPELL_REAGENT_ID` / `OFF_SPELL_REAGENT_COUNT`
// above (shared with all spells that consume reagents, not just
// recipes).
OFF_SPELL_RECORD_CREATED_ITEM = 0x19C,
SPELL_RECIPE_MAX_REAGENTS = 8,
// Spell.dbc effect arrays — three effects per spell. Derived
// from `Script_CastShapeshiftForm` (`0x004B4810`): the form-toggle
// check reads `spellRec[+0x16C + i*4]` for the per-effect aura
// type, and `spellRec[+0x1A8 + i*4]` for that effect's misc
// value. Cross-checked against 3.3.5's `FUN_00726CE0`
// (`Script_CancelShapeshiftForm`'s inner), which does the same
// pair of reads against `0x24` (= `SPELL_AURA_MOD_SHAPESHIFT`)
// and a form-id compare.
//
// `EffectApplyAuraName[i]` is the SPELL_AURA_* code (0 = none /
// not an aura effect); `EffectMiscValue[i]` is effect-specific
// (form ID for shapeshift, channel index for periodic, etc.).
OFF_SPELL_RECORD_EFFECT_APPLY_AURA_NAME = 0x16C, // int32[3]
OFF_SPELL_RECORD_EFFECT_MISC_VALUE = 0x1A8, // int32[3]
// Per-effect SpellMechanic ids (EffectMechanic[3]). One int32[3] (0xC)
// after EffectBasePoints (0x130); cross-checked against EffectRadiusIndex
// (0x160) and EffectApplyAuraName (0x16C). Vanilla often stores a spell's
// mechanic on an effect rather than the spell-level Mechanic (0x14), so
// bleed / DoT detection needs this array in addition to that field.
OFF_SPELL_RECORD_EFFECT_MECHANIC = 0x13C, // int32[3]
// EffectItemType[3] (column 103): the item a CREATE_ITEM effect makes.
// Verified on recipes 2660 / 3275 / 2963 → items 2862 / 1251 / 2996.
OFF_SPELL_RECORD_EFFECT_ITEM_TYPE = 0x19C, // int32[3]
SPELL_RECORD_EFFECT_COUNT = 3,
// SPELL_EFFECT_* id array (`Effect[3]`) — five arrays before
// EffectBasePoints (`+0x130`), so `0x130 - 5*0xC`. Used to tell craft
// recipes from profession abilities (Disenchant etc.) that also carry
// skill-up thresholds. Recipe-producing effects: CREATE_ITEM (items),
// ENCHANT_ITEM / _TEMPORARY (enchants), and LEARN_SPELL (Turtle's custom
// recipes, e.g. "Steel Plate Boots" = effect 36).
OFF_SPELL_RECORD_EFFECT = 0xF4, // int32[3]
SPELL_EFFECT_SCHOOL_DAMAGE = 2, // direct damage (verified vs server SpellDefines.h)
SPELL_EFFECT_APPLY_AURA = 6, // EffectApplyAuraName[i] then names the aura type
SPELL_EFFECT_PERSISTENT_AREA_AURA = 27, // vmangos SpellDefines.h
SPELL_EFFECT_APPLY_AREA_AURA_PARTY = 35, // vmangos SpellDefines.h
SPELL_EFFECT_TRIGGER_SPELL = 64, // casts EffectTriggerSpell[i] (Feral Charge 16979 → 19675)
// Kick / Pummel / Shield Bash / Counterspell / Earth Shock — 57 Spell.dbc
// rows carry it. The server's Spell::EffectInterruptCast is its handler.
SPELL_EFFECT_INTERRUPT_CAST = 68,
// EffectTriggerSpell[3] (columns 109-111): the spell an effect 64 casts.
// Verified in Spell.dbc: Feral Charge 16979 → [1] = 19675 "Feral Charge
// Effect" (the row that carries the druid's INTERRUPT_CAST).
OFF_SPELL_RECORD_EFFECT_TRIGGER_SPELL = 0x1B4, // int32[3]
SPELL_EFFECT_CREATE_ITEM = 24,
SPELL_EFFECT_LEARN_SPELL = 36,
SPELL_EFFECT_ENCHANT_ITEM = 53,
SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY = 54,
// Verified from Spell.dbc: 13262 "Disenchant" has Effect[0] = 99 (the
// only row carrying it). Effect 32 is TRIGGER_MISSILE, not disenchant.
SPELL_EFFECT_DISENCHANT = 99,
// EffectBasePoints[3] — the base magnitude of each effect, stored as
// (value - 1) for the fixed-die spells that back item stats (the
// engine adds a 1..dieSides roll; dieSides == 1 makes it value = base
// + 1). Verified empirically: the "Increased Intellect 01/02/03"
// random-property spells (7468/7469/7470) hold base 0/1/2 for the
// +1/+2/+3 tiers. Read by Item::Stats when resolving random-suffix
// stat auras. Parallel [3] array to APPLY_AURA_NAME / MISC_VALUE.
OFF_SPELL_RECORD_EFFECT_BASE_POINTS = 0x130, // int32[3]
// EffectBaseDice[3] — added to EffectBasePoints for the effect's fixed
// magnitude (mangos `CalculateSimpleValue = BasePoints + BaseDice`).
// For every item-stat aura BaseDice == 1, so value = BasePoints + 1;
// reading it directly matches the engine exactly. Verified at field 67
// (Effect@61, DieSides@64, BaseDice@67, BasePoints@76) against 7468.
OFF_SPELL_RECORD_EFFECT_BASE_DICE = 0x10C, // int32[3]
// The rest of the amount inputs, so a caller can reproduce the
// engine's full per-effect magnitude rather than only the fixed
// `BasePoints + BaseDice` case above. Same field run the BASE_DICE
// note verifies (Effect@61, DieSides@64, BaseDice@67, BasePoints@76),
// continued: DicePerLevel@70, RealPointsPerLevel@73.
//
// The magnitude is
// level = clamp(charLevel, spellLevel..maxLevel) - spellLevel
// points = BasePoints + level * RealPointsPerLevel
// random = DieSides + level * DicePerLevel
// value = points + (random <= 1 ? BaseDice : roll(BaseDice, random))
// so `DieSides > 1` marks an effect whose amount is a server-side die
// roll no client can reproduce. Read by C_Spell.GetSpellEffectInfo.
OFF_SPELL_RECORD_EFFECT_DIE_SIDES = 0x100, // int32[3]
// Both per-level fields are FLOAT, not int — verified by reading
// field 73 on spells 10 / 17 / 43 / 91 / 122, which decode as
// 0.1 / 0.8 / 1.0 / -1.0 / 0.5 as float and as garbage as int32.
OFF_SPELL_RECORD_EFFECT_DICE_PER_LEVEL = 0x118, // float[3]
OFF_SPELL_RECORD_EFFECT_REAL_POINTS_PER_LEVEL = 0x124, // float[3]
// Per-effect EffectRadiusIndex[3] → SpellRadius.dbc. Verified by
// FUN_006e6350, which reads spellRec[+0x160] (effect 0) and
// spellRec[+0x164] (effect 1) as radius indices. 0 = effect has no
// radius. Read by GetSpellRadius.
OFF_SPELL_RECORD_EFFECT_RADIUS_INDEX = 0x160, // int32[3]
// SpellFamily classification, used by the SpellMod system (see
// VAR_SPELLMOD_*). Verified from FUN_006e6b30: SpellFamilyName at
// +0x280 (gates whether the player's class mods apply), 64-bit
// SpellFamilyFlags at +0x284 (selects which familyFlagBit rows to
// sum). AttributesEx3 (+0x24) bit 0x20000000 (IGNORE_CASTER_MODIFIERS)
// disables spell mods — the client reads [record + 0x24] in FUN_006e6b30.
OFF_SPELL_RECORD_FAMILY_NAME = 0x280, // u32
OFF_SPELL_RECORD_FAMILY_FLAGS = 0x284, // u64
OFF_SPELL_RECORD_ICON_ID = 0x1D4, // u32 SpellIconID (→ SpellIcon.dbc)
OFF_SPELL_RECORD_ACTIVE_ICON_ID = 0x1D8, // u32 activeIconID (→ SpellIcon.dbc) — shown while the spell's toggle is up (FUN_ACTION_SLOT_TEXTURE)
OFF_SPELL_RECORD_ATTRIBUTES = 0x18, // u32 (column 6, base Attributes)
SPELL_ATTR_PASSIVE = 0x40, // bit 6 — always-on aura
// Attributes bit 31 — the player cannot cancel the aura. Both servers'
// SpellAuraHolder::SetAuraFlag (vmangos, tortoise-wow) give a positive
// aura the descriptor's cancelable bit exactly when this is clear.
SPELL_ATTR_CANT_CANCEL = 0x80000000,
// Attributes bit 5 — a profession recipe (SPELL_ATTR_TRADESPELL). Set on
// all 1,733 trade-skill recipes in the extracted Spell.dbc and on none of
// Enchanting's craft spells (those have record +0x0C == 3 instead, the
// engine's `enchant:` link gate). 3.3.5 gates GetTradeSkillRecipeLink and
// SetHyperlink's `enchant:` on this bit, and its UnitCastingInfo reports
// it as isTradeskill.
SPELL_ATTR_TRADESPELL = 0x20,
// Attributes bits 2 (0x4) and 10 (0x400) — "on next melee swing" (the
// ability replaces the next white hit instead of sending its own attack,
// e.g. Heroic Strike / Maul / Raptor Strike). The CLIENT itself tests
// this exact combined mask: `FUN_006e3480`'s range resolver early-outs
// to a flat 100-yard max (`DAT_008118d4`) for any spell with `Attributes
// & 0x404` — verified in the disassembly. `Combat::Swing` uses the same
// mask on `SMSG_SPELL_GO` to know an on-next-swing cast replaced (and
// therefore reset) the main-hand white hit.
SPELL_ATTR_ON_NEXT_SWING = 0x4 | 0x400,
// PreventionType (column 165) — which control-loss flag stops the cast:
// 0 none, 1 SILENCE (UNIT_FLAG_SILENCED), 2 PACIFY (UNIT_FLAG_PACIFIED);
// the server's `Spell::CheckCast` gate. Verified against the extracted
// Spell.dbc with the column chain Name@120 → Rank@129 → Family@160 →
// FamilyFlags@161-162 → MaxAffectedTargets@163 → DmgClass@164 →
// PreventionType@165: Fireball 133 = 1, Power Word: Fortitude 1243 = 1,
// Heroic Strike 78 = 2, Kick 1766 = 2, Throw 2764 = 2, Attack 6603 = 0.
// Only 0/1/2 occur (20549 / 6201 / 1268 rows). Read by
// `LossOfControl::LockoutForSpell`.
OFF_SPELL_RECORD_PREVENTION_TYPE = 0x294,
SPELL_PREVENTION_TYPE_SILENCE = 1,
SPELL_PREVENTION_TYPE_PACIFY = 2,
OFF_SPELL_RECORD_ATTRIBUTES_EX = 0x1C, // u32 (column 7)
OFF_SPELL_RECORD_ATTRIBUTES_EX2 = 0x20, // u32 (column 8)
OFF_SPELL_RECORD_ATTRIBUTES_EX3 = 0x24, // u32 (column 9)
// AttributesEx4 (column 10). The combat log's cast-start line tests bit
// 0x1 (`test byte ptr [esi+0x28],1` at 0x0062B30D): the cast writes no
// line. Set on 100 records, all proc spells (Holy Strike, Winter's
// Chill, Shadow Weaving).
OFF_SPELL_RECORD_ATTRIBUTES_EX4 = 0x28, // u32 (column 10)
// StackAmount (column 39): the most applications an aura holds. The
// combat log's stack line needs it above 1 (0x0062B800 reads +0x9C).
OFF_SPELL_RECORD_STACK_AMOUNT = 0x9C, // u32 (column 39)
// The client's spell-mod core (FUN_006e6b30) skips all mods when this bit
// is set: it reads [record + 0x24] & 0x20000000 — AttributesEx3 bit 29,
// SPELL_ATTR_EX3_IGNORE_CASTER_MODIFIERS (verified via disassembly; the
// server enum agrees). NOT AttributesEx2's bit 29 (that's CANT_CRIT).
SPELL_ATTR_EX3_IGNORE_CASTER_MODIFIERS = 0x20000000,
// AttributesEx3 bit 13 (vmangos SPELL_ATTR_EX3_HIDE_CHANNEL_BAR): the
// client shows no channel bar. MSG_CHANNEL_START's handler (0x006E7550,
// `test ch,0x20` on +0x24 at 0x006E7595; benilla-re spell/handlers) skips
// SPELLCAST_CHANNEL_START for it, and 4.3.4's Packet_MSG_CHANNEL_START
// also skips SetUIChannelSpell, so UnitChannelInfo reports nothing.
SPELL_ATTR_EX3_HIDE_CHANNEL_BAR = 0x00002000,
// AttributesEx3 bit 18 — the paladin judgement-debuff marker. The server's
// melee-swing judgement refresh selects auras by SPELLFAMILY_PALADIN +
// this bit (tortoise-wow SpellDefines.h SPELL_ATTR_EX3_ALWAYS_HIT,
// Unit::DealMeleeDamage). Verified in the client Spell.dbc: all 14
// Judgement of Light/Wisdom/Justice/Crusader debuff ranks carry it.
SPELL_ATTR_EX3_ALWAYS_HIT = 0x00040000,
// AttributesEx channel bits (CHANNELED_1 0x4 | CHANNELED_2 0x40) and the
// AttributesEx2 autorepeat flag (bit 5, Auto Shot / Shoot) — each shared
// by more than one module, so kept here rather than redefined locally.
SPELL_ATTR_EX_CHANNELED = 0x4 | 0x40,
SPELL_ATTR_EX2_AUTOREPEAT_FLAG = 0x20,
// AttributesEx2 bit 17 — "don't reset the caster's melee/ranged
// auto-attack timers" (tortoise-wow `SPELL_ATTR_EX2_NOT_RESET_AUTO_ACTIONS`).
// Suppresses the InterruptFlags-driven swing reset below for spells like
// Slam / Aimed Shot that have a cast time but are meant to weave with
// the swing timer rather than restart it.
SPELL_ATTR_EX2_NOT_RESET_AUTO_ACTIONS = 0x20000,
OFF_SPELL_RECORD_INTERRUPT_FLAGS = 0x54, // u32 (column 21)
// Bit 0 of InterruptFlags: the cast is interrupted when the caster moves.
// Both the server (HandleMovementOpcodes → InterruptSpellsWithInterruptFlags,
// tortoise-wow) and the client's own CheckCast (FUN_006094f0 gates its MOVING
// failure on this bit) use it; thrown items (grenades — e.g. spell 4068)
// lack it, so movement must not end their cast. See Spell::Cast (issue #23).
SPELL_INTERRUPT_FLAG_MOVEMENT = 0x1,
// Bit 1: the bit the server's interrupt EFFECT tests on a cast before Kick /
// Pummel / Counterspell may stop it — tortoise `Spell::EffectInterruptCast`
// (vmangos names the same bit DAMAGE_PUSHBACK). Player casts carry 0x0F;
// creature casts with 0x00 / 0x08 / 0x09 / 0x0D (Shadow Flame, Frost
// Breath, …) cannot be interrupted by those abilities. Silence auras ignore
// the flags (PreventionType only). Read by Spell::Interruptible.
SPELL_INTERRUPT_FLAG_DAMAGE = 0x2,
// Bit 3 — server rule for "does casting this spell reset the caster's
// melee swing timer" (tortoise-wow `Spell::cast`:
// `IsMeleeAttackResetSpell() = !triggered && (InterruptFlags &
// SPELL_INTERRUPT_FLAG_AUTOATTACK)`, gated off by
// `SPELL_ATTR_EX2_NOT_RESET_AUTO_ACTIONS`). DBC-driven, so it tracks
// whatever spell data the server ships rather than a hardcoded spell
// list — verified against the client's own Spell.dbc: every plain
// cast-time spell (Fireball, …) carries it and resets the swing; the two
// vanilla exceptions that DON'T (Slam, Aimed Shot) both carry
// `SPELL_ATTR_EX2_NOT_RESET_AUTO_ACTIONS` instead. Read by
// `Combat::Swing`.
SPELL_INTERRUPT_FLAG_AUTOATTACK = 0x8,
// ChannelInterruptFlags (column 23). Bit 2 is the channel analog of the
// gate above (CHANNEL_FLAG_INTERRUPT in both cores). Verified in Spell.dbc:
// Blizzard / Arcane Missiles 0x7C0C, non-channels 0.
OFF_SPELL_RECORD_CHANNEL_INTERRUPT_FLAGS = 0x5C, // u32 (column 23)
CHANNEL_FLAG_INTERRUPT = 0x4,
// Remaining Spell.dbc record fields — the single source of truth for the
// record layout (byte = column * 4). Modules must use these rather than
// redefining local copies.
// Single school id (column 1) — 0 physical … 6 arcane; a spell's school
// MASK is `1 << School` (the server's GetSpellSchoolMask). Verified in
// Spell.dbc: Kick 0, Fireball 2, Earth Shock 3, Shadow Bolt 5,
// Counterspell 6. Read by Spell::Interruptible.
OFF_SPELL_RECORD_SCHOOL = 0x04, // u32 (column 1)
OFF_SPELL_RECORD_CASTING_TIME_INDEX = 0x48, // u32 → SpellCastTimes.dbc
OFF_SPELL_RECORD_MAX_LEVEL = 0x6C, // u32 (scaling cap level)
OFF_SPELL_RECORD_SPELL_LEVEL = 0x74, // u32 (this rank's effective level)
OFF_SPELL_RECORD_POWER_TYPE = 0x7C, // i32 (0=mana,1=rage,2=focus,3=energy,4=happiness)
OFF_SPELL_RECORD_MANA_COST = 0x80, // u32 base cost
OFF_SPELL_RECORD_RANGE_INDEX = 0x90, // u32 → SpellRange.dbc
OFF_SPELL_RECORD_EFFECT_IMPLICIT_TARGET_A = 0x148,// i32[3] implicit target A
// Implicit target ids (vmangos SpellDefines.h). A Dispel effect (38) aimed
// at one of these can remove an aura from an enemy: Purge, Shield Slam,
// Tranquilizing Shot (6); Dispel Magic, Devour Magic (25, any unit).
TARGET_UNIT_ENEMY = 6,
TARGET_UNIT = 25,
SPELL_EFFECT_DISPEL = 38,
OFF_SPELL_RECORD_EFFECT_IMPLICIT_TARGET_B = 0x154,// i32[3] implicit target B
OFF_SPELL_RECORD_MANA_COST_PERCENT = 0x270, // i32 % of base resource (0 = flat)
OFF_SPELL_RECORD_RANK = 0x204, // char*[9] localized rank text
OFF_SPELL_RECORD_TOTEM = 0xA0, // i32[2] required totem/tool item IDs
// SpellIcon.dbc record's path string field (char* at +0x04). Distinct
// struct from Spell.dbc — reached via SpellIcon.dbc[Spell.SpellIconID].
OFF_SPELLICON_PATH = 0x04,
// Spell.dbc Mechanic field — the spell-level SpellMechanic ID (→
// SpellMechanic.dbc), 0 = none. Field 5 of the record
// (ID, School, Category, castUI, Dispel, Mechanic), which lands at
// +0x14 given Attributes (field 6) is verified at +0x18. Cross-
// confirmed by FUN_006e9ca0 (the mechanic-immunity check), which
// reads `spellRec[+0x14]` as the spell's mechanic when the per-
// effect EffectMiscValue is 0. Read by C_Spell.GetSpellMechanicByID.
OFF_SPELL_RECORD_MECHANIC = 0x14,
// SpellMechanic.dbc ids (server SpellDefines.h `Mechanics`). Every
// interrupt ability carries 26 — per effect (Kick / Pummel / Shield Bash /
// Earth Shock EffectMechanic[1]) or spell-level (Counterspell Mechanic) —
// so MECHANIC_IMMUNITY of 26 is what makes a caster unkickable.
MECHANIC_SILENCE = 9,
MECHANIC_INTERRUPT = 26,
SPELL_AURA_MOD_STEALTH = 16,
SPELL_AURA_MOD_SHAPESHIFT = 36,
SPELL_AURA_MOUNTED = 78,
// SpellShapeshiftForm.dbc (docs/DBCs.md row; 14 columns). Flags is
// column 11: the parsed 1.12 DBC gives 0x7 for the warrior stances, 0x1
// Stealth, 0x9 Shadowform, matching 3.3.5's column. 0x100 is the form
// flag 3.3.5 / 4.3.4 `CGUnit_C::CanAutoUnshift` refuses on (set there
// only on Spirit of Redemption and the Ghoul forms); no 1.12 row has it.
VAR_SPELL_SHAPESHIFT_FORM_RECORDS = 0x00C0D774,
VAR_SPELL_SHAPESHIFT_FORM_COUNT = 0x00C0D778,
OFF_SPELL_SHAPESHIFT_FORM_FLAGS = 0x2C,
SHAPESHIFT_FORM_FLAG_NO_AUTO_UNSHIFT = 0x100,
// Control-loss aura effect types (EffectApplyAuraName values), used by
// C_LossOfControl to classify a debuff. Values are authoritative from the
// Turtle server's indexed SPELL_AURA proc-handler table (SharedDefines).
SPELL_AURA_MOD_POSSESS = 2,
SPELL_AURA_MOD_CONFUSE = 5,
SPELL_AURA_MOD_CHARM = 6,
SPELL_AURA_MOD_FEAR = 7,
SPELL_AURA_MOD_STUN = 12,
// Movement slow / snare. Not a loss-of-control (C_LossOfControl omits it),
// but the C_UnitAuras CROWD_CONTROL filter counts it — see
// Spell::CrowdControl::IsCrowdControl.
SPELL_AURA_MOD_DECREASE_SPEED = 33,
SPELL_AURA_MOD_PACIFY = 25,
SPELL_AURA_MOD_ROOT = 26,
SPELL_AURA_MOD_SILENCE = 27,
SPELL_AURA_MOD_PACIFY_SILENCE = 60,
SPELL_AURA_MOD_DISARM = 67,
// Immunity aura types (server SpellAuraDefines.h). EffectMiscValue: 37 = a
// SPELL_EFFECT id, 38 = a SPELL_AURA id, 39 = a school MASK (Divine Shield
// rows carry 39 with 1 and 126; verified in Spell.dbc), 77 = a SpellMechanic
// id. The 3.3.5 client's not-interruptible walk tests exactly these four;
// read by Spell::Interruptible.
SPELL_AURA_EFFECT_IMMUNITY = 37,
SPELL_AURA_STATE_IMMUNITY = 38,
SPELL_AURA_SCHOOL_IMMUNITY = 39,
SPELL_AURA_MECHANIC_IMMUNITY = 77,
// SMSG_SPELL_COOLDOWN (0x134) handler, registered by the spell-opcode
// boot registrar FUN_006e7150 exactly like the failure/channel handlers
// Spell::Cast co-hooks — same `int __stdcall(uint32_t *opCode,
// CDataStore *packet)` shape. Body: GUID(u64) then (spellID, durationMs)
// u32 pairs. A player-GUID packet carrying >=2 spells that all share one
// duration is a school-interrupt lockout (Player::ProhibitSpellSchool is
// the only sender of that shape); see src/lossofcontrol/Info.cpp.
FUN_SPELL_COOLDOWN_HANDLER = 0x006E9460,
// Gossip menu data. Populated by the SMSG_GOSSIP_MESSAGE packet
// handler at 0x004E26E0 and reset by FUN_004E26A0 each time a new
// gossip window opens. Two parallel storage arrays:
// Options: 16 slots, stride 0x80C, sentinel = signed `index` == -1.
// Quests: 32 slots, stride 0x20C, sentinel = u32 `questID` == 0.
// Available vs. active is partitioned by the +0x008
// `status` field — values 3 or 4 mark an active-quest
// row, anything else is a deliverable.
VAR_GOSSIP_OPTIONS = 0x00BBBE90,
GOSSIP_OPTIONS_STRIDE = 0x80C,
GOSSIP_OPTIONS_MAX = 16,
OFF_GOSSIP_OPTION_TEXT = 0x000, // char[0x800] inline
OFF_GOSSIP_OPTION_INDEX = 0x800, // int32; -1 = unused slot
OFF_GOSSIP_OPTION_BOX_CODED = 0x804, // u8 (1 = needs password)
OFF_GOSSIP_OPTION_ICON = 0x808, // u8 icon type (0..10)
VAR_GOSSIP_QUESTS = 0x00BB74C0,
GOSSIP_QUESTS_STRIDE = 0x20C,
GOSSIP_QUESTS_MAX = 32,
OFF_GOSSIP_QUEST_ID = 0x000, // u32 questID; 0 = unused slot
OFF_GOSSIP_QUEST_LEVEL = 0x004, // i32 questLevel
OFF_GOSSIP_QUEST_STATUS = 0x008, // u32 status; 3|4 = active
OFF_GOSSIP_QUEST_TITLE = 0x00C, // char[0x200] inline
// The counts Script_GetGossipAvailableQuests (0x004E2930) and
// Script_GetGossipActiveQuests (0x004E29B0) size their (title, level)
// lists by — `uint32_t()`: walk VAR_GOSSIP_QUESTS until questID 0,
// counting status != 3/4 (available) or 3/4 (active). The lists then
// fetch entry i with 0x004E2460 / 0x004E25B0, so each has exactly that
// many pairs. Neither checks for a live gossip session.
FUN_GOSSIP_NUM_AVAILABLE_QUESTS = 0x004E2430,
FUN_GOSSIP_NUM_ACTIVE_QUESTS = 0x004E2580,
// Inline greeting buffer pushed by Script_GetGossipText. Populated
// by the engine after the NPC_TEXT.dbc query for the gossip giver
// resolves the textID embedded in SMSG_GOSSIP_MESSAGE.
VAR_GOSSIP_GREETING_TEXT = 0x00BBB678,
// Engine Lua C functions for the selector half of the gossip
// surface. The `FUN_GOSSIP_SELECT_*` helpers are the engine's
// internal selectors that the `Script_SelectGossip*` Lua wrappers
// call after parsing their args. We call them directly with the
// 0-based slot/index to skip the Lua-stack-stomp round-trip.
//
// FUN_GOSSIP_SELECT_OPTION — __fastcall(uint slot0Based,
// const char *password)
// Sends CMSG_GOSSIP_SELECT_OPTION with `OPTIONS[slot].index`.
// Handles the boxCoded/password-required gate internally —
// pass nullptr if no password.
// FUN_GOSSIP_SELECT_{AVAILABLE,ACTIVE}_QUEST — __fastcall(int idx)
// Walks `GOSSIP_QUESTS`, skipping rows of the wrong status,
// matches by 0-based position into the filtered list, sends
// CMSG with the matching questID.
FUN_GOSSIP_SELECT_OPTION = 0x004E2320,
FUN_GOSSIP_SELECT_AVAILABLE_QUEST = 0x004E24B0,
FUN_GOSSIP_SELECT_ACTIVE_QUEST = 0x004E2600,
FUN_SCRIPT_CLOSE_GOSSIP = 0x004E2B20,
// Current gossip NPC GUID (u64). Set by the SMSG_GOSSIP_MESSAGE
// handler, cleared by the gossip-close worker at 0x004E1FA0 (which
// then fires GOSSIP_CLOSED, event 0x12B). Non-zero = a gossip
// session is live — the gate that keeps `C_GossipInfo` from serving
// the previous NPC's stale arrays/text after close.
VAR_GOSSIP_NPC_GUID = 0x00BC3F58,
// u32, 1 while the greeting is unresolved. The greeting builder
// 0x004E2010 (its only writer) sets it on an NPC-text cache miss or
// textID 0 and clears it once the text resolves, right before
// GOSSIP_SHOW; the option selector 0x004E2320 refuses while it is
// set. The GUID above is latched earlier, so GUID != 0 alone counts
// a window that has not shown yet — with the previous NPC's text
// still in VAR_GOSSIP_GREETING_TEXT. Verified via xrefs (1 read, 2
// writes) and the 0x004E2010 decompile.
VAR_GOSSIP_TEXT_PENDING = 0x00BBB670,
// --- Gossip point of interest (SMSG_GOSSIP_POI, opcode 0x224) ------
// The handler 0x004E2840 stores the marker in static blip record 1
// (records 0x74 apart from 0x00CEA760: 0 = selected quest, 1 = gossip,
// 2 = corpse) through the setter 0x006DAC10, the record's only writer.
// There is one marker at a time; a new packet overwrites it. It is
// live while its position is nonzero: 0x006D93A0 zeroes x/y when the
// player comes within 10 yards or 480 s after it was set. The world
// map's landmark builder 0x004A67A0 reads it the same way and projects
// it with 0x004A7360, which drops it unless the displayed map's row
// has the record's map id and the point lands inside 0..1. Verified
// via the 0x006DAC10 / 0x004A67A0 / 0x004A7360 decompiles.
VAR_GOSSIP_POI_BLIP = 0x00CEA7D4,
VAR_GOSSIP_POI_NAME = 0x00CEA6E0, // char[0x40], slot 1 of the names at 0x00CEA6A0
// u32, wall-clock seconds (0x00429580) + 480 at each set; both clears
// zero it with x/y (0x006D93FB, 0x006D9A3A). 0 = no marker.
VAR_GOSSIP_POI_EXPIRY = 0x00CEAAA4,
OFF_STATIC_BLIP_ICON = 0x08, // u32, POI icon index (the packet's icon)
OFF_STATIC_BLIP_X = 0x10, // float, world X (north)
OFF_STATIC_BLIP_Y = 0x14, // float, world Y (west)
OFF_STATIC_BLIP_MAP = 0x1C, // i32, Map.dbc id: the minimap's map when set
// --- Quest-greeting state (SMSG_QUESTGIVER_QUEST_LIST) -------------
// Vanilla's SECOND questgiver path: NPCs without a gossip menu send
// SMSG_QUESTGIVER_QUEST_LIST, whose handler (FUN_005dbb10) fills a
// storage entirely separate from the gossip arrays and fires
// QUEST_GREETING (event 300 = 0x12C) — the QuestFrameGreetingPanel
// ("Current Quests" / "Available Quests"). Vanilla Lua reads it via
// GetGreetingText / Get{Available,Active}Title / etc.; C_GossipInfo
// merges it in so modern-addon ports work on greeting NPCs too.
//
// Shared quest-session state, written by the panel-begin helper
// FUN_00500bd0(panelType, textID, guidLo, guidHi, ...):
// VAR_QUESTGIVER_GUID — u64, the current questgiver. Cleared by
// the session-close worker FUN_00501130 (fires QUEST_FINISHED,
// event 0x130). Non-zero = quest session live.
// VAR_QUEST_PANEL_TYPE — i32 panel: 0 greeting, 1 detail,
// 2 progress, 3 reward. begin(0) also zeroes both greeting
// arrays + counts + the text buffers.
VAR_QUESTGIVER_GUID = 0x00BE0810,
VAR_QUEST_PANEL_TYPE = 0x00BE0818,
// GUID the greeting arrays were filled for — written ONLY by the
// SMSG_QUESTGIVER_QUEST_LIST handler. The greeting arrays are valid
// iff this equals VAR_QUESTGIVER_GUID (and that is non-zero);
// otherwise they're leftovers from an older NPC (e.g. the current
// quest session came from a gossip-menu quest click, which begins
// at panel 1 without ever clearing the greeting arrays).
VAR_GREETING_NPC_GUID = 0x00C4D740,
// Greeting text (0x200 inline, $N/$C-expanded) — what vanilla's
// Script_GetGreetingText pushes.
VAR_QUEST_GREETING_TEXT = 0x00BDE068,
// The two greeting quest arrays: 32 entries, stride 0x4C =
// { u32 questID @ +0, i32 level @ +4, char title[0x40] @ +8,
// u32 extra @ +0x48 (available: status==0 flag; active: always
// 0 — the appender FUN_00500e90 never stores the status, see
// the scratch arrays below for isComplete) }.
// Appenders: FUN_00500e40 (available), FUN_00500e90 (active).
// Readers: Script_Get{Available,Active}{Title,Level} @ 0x00501AC0/
// 0x00501B30/0x00501BA0/0x00501C20.
VAR_GREETING_AVAILABLE_ENTRIES = 0x00BDFE60,
VAR_GREETING_ACTIVE_ENTRIES = 0x00BDE690,
GREETING_QUESTS_STRIDE = 0x4C,
GREETING_QUESTS_MAX = 32,
OFF_GREETING_QUEST_ID = 0x000,
OFF_GREETING_QUEST_LEVEL = 0x004,
OFF_GREETING_QUEST_TITLE = 0x008,
VAR_GREETING_AVAILABLE_COUNT = 0x00BE0834,
VAR_GREETING_ACTIVE_COUNT = 0x00BE0838,
// Scratch arrays the SMSG_QUESTGIVER_QUEST_LIST handler fills in
// packet order (32 × u32 each, zeroed per packet): questIDs and the
// per-quest dialog status. Status 3|4 = active (same sentinel as
// the gossip quest rows), 4 = complete/turn-in-ready. The canonical
// greeting arrays drop the status, so `isComplete` for an active
// greeting quest is recovered by questID lookup here.
VAR_GREETING_SCRATCH_IDS = 0x00C4D2B0,
VAR_GREETING_SCRATCH_STATUS = 0x00C4D340,
// Engine greeting-quest selectors — the workers vanilla's
// Script_Select{Available,Active}Quest call: `__fastcall(int
// idx0Based)`, index straight into the corresponding greeting
// array. They validate VAR_QUESTGIVER_GUID internally and send
// CMSG_QUESTGIVER_{QUERY_QUEST,COMPLETE_QUEST}.
FUN_GREETING_SELECT_AVAILABLE_QUEST = 0x005012A0,
FUN_GREETING_SELECT_ACTIVE_QUEST = 0x00501320,
// CDataStore primitive readers — `__thiscall void(this, void *out)`.
// Read at the current cursor (`+0x14`) and advance it by the value
// size. We call these directly from `Unit::MirrorTimer` to peek
// packet contents before the SMSG handler consumes them, then
// restore the cursor so the original handler reads the same bytes.
FUN_DATASTORE_READ_U32 = 0x00418E30,
FUN_DATASTORE_READ_U8 = 0x00418CB0,
OFF_DATASTORE_CURSOR = 0x14,
// CDataStore writers and the stack-packet shape the DBCache query send
// builds (FUN_DBCACHE_ITEMSTATS_GET_RECORD, 0x0055BB18..0x0055BB89):
// {vtable, buffer, base, alloc, size, read} with buffer/base/alloc/size 0
// and read -1, PutUInt32 (`__thiscall(this, u32)`), PutGuid
// (`__thiscall(this, lo, hi)`), read = 0, ClientServices::Send, then the
// vtable's slot 1 (`__thiscall(this, &buffer, &base, &alloc)`) frees the
// buffer unless alloc is -1. Verified by disassembly of that send.
FUN_DATASTORE_PUT_U32 = 0x00418190,
FUN_DATASTORE_PUT_GUID = 0x00418370,
VTABLE_CDATASTORE = 0x007FF9E4,
// ClientServices::Send — `__thiscall void(CDataStore *packet)`: sends on
// the current connection through FUN_NET_SEND when one exists (benilla-re
// net/connection#sending-a-packet).
FUN_CLIENT_SERVICES_SEND = 0x005AB630,
// Engine millisecond tick (returns `ulonglong` but truncating to
// `uint32_t` is fine for the time deltas we need — the high
// 32 bits only matter after 49 days of uptime). Same source the
// Lua `GetTime()` function reads, just in milliseconds rather
// than the seconds Lua sees. Returns either `GetTickCount()` or
// a higher-resolution timer depending on the engine's clock-
// selection flag at `0x00884C80`.
FUN_ENGINE_TICK_MS = 0x0042B750,
// Mirror timer (BREATH / FATIGUE-style) SMSG handler. Dispatches
// opcodes `0x1D9` (START), `0x1DA` (PAUSE), `0x1DB` (STOP) — but
// the vanilla engine doesn't cache any timer state, just reads
// the packet and immediately fires the corresponding
// MIRROR_TIMER_* Lua event. Our hook (`Unit::MirrorTimer`) peeks
// the packet via cursor save/restore on the CDataStore and
// builds a side cache that `GetMirrorTimerInfo` /
// `GetMirrorTimerProgress` can read back.
//
// __fastcall void(?, int opcode, ?, void *dataStore)
//
// The helper at `FUN_MIRROR_TIMER_TYPE_NAME` returns the
// engine's static type-name string for IDs 0..2 (`"EXHAUSTION"`,
// `"BREATH"`, `"FEIGNDEATH"`); `FUN_MIRROR_TIMER_LABEL` builds
// the localized display label by looking up `{TYPE}_LABEL` in
// the engine's localized strings, or substituting the spell
// name when the type is FEIGNDEATH and a spellID is non-zero.
FUN_SMSG_MIRROR_TIMER_HANDLER = 0x005E7990,
FUN_MIRROR_TIMER_TYPE_NAME = 0x005E7AE0,
FUN_MIRROR_TIMER_LABEL = 0x005E7B10,
SMSG_OPCODE_MIRROR_TIMER_START = 0x1D9,
SMSG_OPCODE_MIRROR_TIMER_PAUSE = 0x1DA,
SMSG_OPCODE_MIRROR_TIMER_STOP = 0x1DB,
MIRROR_TIMER_SLOT_COUNT = 3,
// `realmList` CVar reader — returns the configured realmlist
// address (e.g. "logon.turtle-wow.org") as a `const char *`, or
// NULL when unset. `__fastcall(int forceRefresh)`; pass 0 to read
// the cached value (callers in the engine pass non-zero only
// around CMSG_AUTH_SESSION reconnects). Lazily registers the CVar
// on first call.
//
// This is the realmlist *address*, not the display name (the
// friendly server name visible in the realm-select dialog lives
// in the `realmName` CVar at `FUN_005AB7D0`, read by
// `Script_GetServerName`). Credentials are scoped on this value
// because two different private servers may share the same
// friendly name but never the same realmlist address.
FUN_CVAR_REALM_LIST = 0x005AB680,
// Engine login entry — the C function `Script_DefaultServerLogin`
// (the glue Lua binding at `0x0046D160`) tail-calls into here with
// the account/password as raw C strings. We invoke it directly from
// C++ when dispatching a saved-credential login, bypassing the
// round-trip through Lua so the plaintext never crosses the
// Lua boundary on the way out.
//
// __fastcall void(ecx = const char *account, edx = char *password)
//
// The function:
// 1. Gates on three globals — VAR_GLUE_LOGIN_READY1,
// VAR_GLUE_LOGIN_READY2 (both must be nonzero) and
// VAR_GLUE_LOGIN_INPROGRESS (must be zero). All set up by the
// normal glue boot flow; a call made while the AccountLogin
// screen is showing is safe, an off-screen call silently no-ops.
// 2. Copies the account into a 0x40-byte buffer at `0x00B41DB0`
// and uppercases it in place.
// 3. Fires the "connecting" status event.
// 4. Hands the (uppercased account, password) pair to the SRP
// initiator at `FUN_005AB4B0`.
// 5. **Zeros the caller's password buffer in place** via an
// unrolled `REP STOSD` loop counting strlen bytes — so the
// decrypted-on-stack buffer we feed in gets scrubbed for free
// after the SRP step consumes it.
// 6. Calls into the AddOn-registry init (`FUN_0051C740`) with the
// uppercased account name. Same call documented in CLAUDE.md
// under "AddOn registry & hot-reload".
FUN_GLUE_LOGIN_ATTEMPT = 0x0046AFB0,
// Glue-state readiness flags read by `FUN_GLUE_LOGIN_ATTEMPT`'s
// prologue. Names reflect the gate-condition logic, not anything
// intrinsic to the engine — the engine just checks `R1 && R2 && !IP`.
VAR_GLUE_LOGIN_READY1 = 0x00B41DFC,
VAR_GLUE_LOGIN_READY2 = 0x00B41E04,
VAR_GLUE_LOGIN_INPROGRESS = 0x00B41DA0,
// The same `VAR_GLUE_LOGIN_INPROGRESS` global doubles as a glue
// state-code: `FUN_GLUE_ENTER_WORLD` sets it to `8` ("entering world")
// on a successful commit, which `Unit::Identity`'s enter-world co-hook
// gates on (the rename / char-locked bail paths return before it).
GLUE_STATE_ENTERING_WORLD = 8,
// `FUN_0046B500` — the enter-world worker behind `Script_EnterWorld` (the
// glue "Enter World" button: `Script_EnterWorld` is just `call this; ret`).
// Computes the selected character's struct into VAR_GLUE_SELECTED_CHAR and,
// on success, sets VAR_GLUE_LOGIN_INPROGRESS = 8. `Unit::Identity` co-hooks
// it to capture the selected character's GUID *before* the engine creates
// the in-world player object — so `UnitGUID("player")` / `PlayerGuid()`
// answer from addon-load time instead of returning nil/0 until the
// SMSG_UPDATE_OBJECT that populates the player object (≈PLAYER_LOGIN).
FUN_GLUE_ENTER_WORLD = 0x0046B500,
// Selected-character struct pointer (glue): char-array base +
// selectedIndex*0x120, written by FUN_GLUE_ENTER_WORLD. The character's
// 64-bit login GUID is at offset 0x00 (name at +0x08, race +0x100, class
// +0x101, level +0x108 — verified against `Script_GetCharacterInfo` at
// `0x004732A0`). Entries are filled from SMSG_CHAR_ENUM.
VAR_GLUE_SELECTED_CHAR = 0x00B41DF4,
OFF_GLUE_CHAR_GUID = 0x00,
// Cursor state — single global type-tag at VAR_CURSOR_TYPE
// dispatches reads through one of several payload slots depending
// on what's picked up. The engine's `CursorHasItem` /
// `CursorHasSpell` / `GetCursorMoney` and the various `Pickup*`
// functions all read/write through these. Discovered by tracing
// `Script_CursorHasItem` (`0x004895D0`) and the writers in
// `FUN_00494B60` (item), `FUN_00494CC0` (money), `FUN_00494D20`
// (spell), `FUN_00494E20` (pet action), `FUN_00494F80` (macro),
// `FUN_004950F0` (action/inv/etc.), `FUN_00495010` (merchant).
//
// Type values:
// 0 empty (nothing on cursor)
// 1 bag item — GUID at `VAR_CURSOR_ITEM_GUID_LO/_HI`,
// itemID resolved by feeding the GUID to
// `FUN_OBJECT_FROM_GUID` (filter 0x2).
// 2 money — copper at `VAR_CURSOR_MONEY_COPPER`
// 3 player spell — spellID at `VAR_CURSOR_SPELL_ID`
// 4 pet action — packed at `VAR_CURSOR_PETACTION_PACKED`
// 5 merchant item — itemID at `VAR_CURSOR_GENERIC_SLOT`,
// 0-based merchant slot at `VAR_CURSOR_GENERIC_SOURCE`.
// Written by `Script_PickupMerchantItem` (`0x004FB760`) →
// `FUN_004950F0(itemID, ?, slot0, 5)`.
// 6/7 other drag-source items — itemID at
// `VAR_CURSOR_GENERIC_SLOT`. Type 7 is action-bar pickup
// (`FUN_004E6130`); type 6 is another drag path (mail/etc.).
// 8 macro — macroID at `VAR_CURSOR_MACRO_ID`
// 9 inventory item (equipped slot) — itemID stored at
// `VAR_CURSOR_GENERIC_SLOT`. Bare itemID rather than a GUID
// because the item is out of the descriptor stream while
// on the cursor.
// 10 stable pet — 0-based slot at `VAR_CURSOR_STABLEPET_INDEX`.
// Written by `Script_ClickStablePet` (`FUN_004CB420`), which
// computes `slot = ftol(arg1) - 1` and passes it to
// `FUN_00495010(slot)`; it also compares the stored value against
// that 0-based slot. Lua's 1-based index is the stored value + 1,
// as 4.3.4 pushes `m_cursorPet + 1`.
//
// `CursorHasItem` returns true for types 1 *and* 9 only.
VAR_CURSOR_TYPE = 0x00B4D900,
VAR_CURSOR_ITEM_GUID_LO = 0x00B4E248,
VAR_CURSOR_ITEM_GUID_HI = 0x00B4E24C,
VAR_CURSOR_MONEY_COPPER = 0x00B4E2F0,
VAR_CURSOR_SPELL_ID = 0x00B4E2F4,
VAR_CURSOR_PETACTION_PACKED = 0x00B4E2F8,
// Holds the macro's **macroID**, not its slot — `Script_PickupMacro`
// (`0x004F1AE0`) turns the Lua 1-based index into a macroID via
// `FUN_004F0EB0` (`VAR_MACRO_SLOT_MAP[index]`) before storing it, so
// this reads as e.g. `0x01000003` rather than `4`. Convert back with
// `FUN_MACRO_ID_TO_SLOT(id) + 1` for anything that wants the slot
// `GetMacroInfo` takes.
VAR_CURSOR_MACRO_ID = 0x00B4E2FC,
VAR_CURSOR_STABLEPET_INDEX = 0x00B4E300,
VAR_CURSOR_GENERIC_SLOT = 0x00B4B41C,
VAR_CURSOR_GENERIC_DISPLAY = 0x00B4D8EC,
VAR_CURSOR_GENERIC_SOURCE = 0x00B4B420,
// Equipment set — 3.3.5's cursor type for it (`FUN_00520dc0` writes
// 0xD). Free in 1.12 (the engine uses 1..10); the setID lives in
// `EquipmentSet::Action`, not an engine global. FUN_CURSOR_CLEAR's
// switch has no case for it, so a clear only resets the type — the
// payload must be read gated on this type.
CURSOR_TYPE_EQUIPMENT_SET = 13,
// Cursor clear — `__fastcall(int returnItem, int fireMoneyEvent)`. The
// macro pickup passes (1, 1). Zeroes the current type's payload, plays
// the drop sound for the types it knows, hides the action-bar grid when
// `VAR_CURSOR_SHOWS_ACTION_GRID` is set, sets the type to 0 and fires
// CURSOR_UPDATE.
FUN_CURSOR_CLEAR = 0x00495190,
// `__fastcall(const char *texturePath)` — the drag icon under the cursor.
FUN_CURSOR_SET_TEXTURE = 0x00523A30,
// `__fastcall(const char *soundName)` — plays a SoundEntries row by name
// (the pickups pass "INTERFACESOUND_CURSORGRABOBJECT").
FUN_PLAY_SOUND_BY_NAME = 0x00458030,
// Fires ACTIONBAR_SHOWGRID; every action-bar-capable pickup calls it and
// then sets `VAR_CURSOR_SHOWS_ACTION_GRID = 1`, which FUN_CURSOR_CLEAR
// turns back into ACTIONBAR_HIDEGRID.
FUN_ACTIONBAR_SHOW_GRID = 0x004E58C0,
VAR_CURSOR_SHOWS_ACTION_GRID = 0x00B4DA24,
// `int __fastcall(int kind)` — the protected-action gate FUN_ACTION_PLACE
// opens with (kind 9). Returns 0 to refuse.
FUN_CURSOR_EDIT_ALLOWED = 0x00494A50,
// GUID → CGObject resolver. `__fastcall(type_filter, guid_lo,
// guid_hi) → CGObject *` at `0x00468460`. Type filter 0x2 = item,
// matching what `FUN_00494B60` and the trade-attached paths pass
// when re-resolving the cursor GUID to a `CGItem *`.
FUN_OBJECT_FROM_GUID = 0x00468460,
// Virtual XML-template registry (a Storm hash table) — the store that
// backs `inherits=` and `C_XMLUtil.GetTemplates`. The XML parser
// (`FUN_006ede10`) registers every `virtual="true"` frame into it via
// `FUN_006ee500`; the inherits resolver reads it via `FUN_006ee6f0`.
// Both operate on these globals, so it's the authoritative template list.
// See src/xml/Templates.cpp.
//
// VAR_XML_TEMPLATE_TABLE holds a POINTER to the bucket array (0 / the
// array unallocated) and VAR_XML_TEMPLATE_MASK the bucket-count mask;
// mask == 0xFFFFFFFF means no template has ever registered (walk = empty).
VAR_XML_TEMPLATE_TABLE = 0x00CEEA1C,
VAR_XML_TEMPLATE_MASK = 0x00CEEA24,
// Bucket struct (0xC bytes): { linkOffset@+0x0, ?@+0x4, chainHead@+0x8 }.
// A node's next pointer is at `*(node + linkOffset + 4)`; the tail
// sentinel has its low bit set (chain ends on `(ptr & 1) != 0`).
XML_TEMPLATE_BUCKET_STRIDE = 0xC,
OFF_XML_TEMPLATE_BUCKET_LINKOFF = 0x0,
OFF_XML_TEMPLATE_BUCKET_HEAD = 0x8,
// Registry node payload: name hash @+0x0 (FUN_SSTR_HASH_HT, the lookup's
// `cmp [ebx],esi`), template name string @+0x14, parsed definition XML
// node @+0x18, and the context word current when it registered @+0x1C —
// the registrar FUN_006EE500(node, name, context, status) stores its
// third argument there (0x006EE6BE), and the XML file loader passes
// VAR_FRAMESCRIPT_EXEC_CONTEXT: the owning addon's name, or 0 for the
// client's own XML. 3.3.5's FrameXML_AcquireHashNode returns it as the
// template's taint.
OFF_XML_TEMPLATE_NODE_HASH = 0x0,
OFF_XML_TEMPLATE_NODE_NAME = 0x14,
OFF_XML_TEMPLATE_NODE_DEF = 0x18,
OFF_XML_TEMPLATE_NODE_CONTEXT = 0x1C,
// The two places the client applies a single `inherits` template — the
// 1.12 counterparts of the two sites where 3.3.5 sets `lua_gctag` to the
// template's taint (CSimpleFrame::LoadXML and LoadXMLInheritance):
// FUN_XML_FRAME_LOAD: `call FUN_XML_TEMPLATE_LOOKUP` (E8, 5 bytes), then
// the re-entry through the node loader, 12 bytes with no jump into
// them: mov ecx,[ebp+0xC]; mov edx,[ebx]; push ecx; push eax;
// mov ecx,ebx; call [edx+8] (EAX = template node, EBX = loader).
// FUN_XML_FRAME_LOAD_CHILD_FRAMES: `call FUN_XML_TEMPLATE_LOOKUP`, then
// the recursive `call FUN_XML_FRAME_LOAD_CHILD_FRAMES` (E8, 5 bytes).
CALL_XML_FRAME_LOAD_TEMPLATE_LOOKUP = 0x0076984A,
SITE_XML_FRAME_LOAD_TEMPLATE_APPLY = 0x00769853,
CALL_XML_CHILD_FRAMES_TEMPLATE_LOOKUP = 0x0076A085,
CALL_XML_CHILD_FRAMES_TEMPLATE_RECURSE = 0x0076A092,
// Parsed XML element node: its tag-name string ("Frame" / "Button" /
// "CheckButton" / …) lives at +0x8 — this is the frame "type".
OFF_XML_NODE_TAG = 0x8,
// The definition node retains its full parsed DOM subtree — used by
// GetTemplateInfo to read `<Size>` / `inherits=`. First child @+0x4, next
// sibling @+0x1C. Attributes are read by name via the node method
// FUN_006f2cf0 (`__thiscall(node, name) -> value string`, null if absent).
OFF_XML_NODE_CHILD = 0x4,
OFF_XML_NODE_SIBLING = 0x1C,
// An element's text content (`const char *`, null when empty) - what the
// XML file processor compiles for an inline <Script> element
// (`mov esi, [esi+0xC]` at 0x006EE0D9, then "%s:<Scripts>").
OFF_XML_NODE_TEXT = 0xC,
FUN_XML_NODE_GET_ATTRIBUTE = 0x006F2CF0,
// Attributes are a flat array of `{char *name, char *value}` pairs at
// +0x14, count at +0x10: the getter above scans it with SStrCmpI and
// returns the first match's value; the setter replaces that value (or
// appends a pair). Both strings are heap copies the destructor frees.
OFF_XML_NODE_ATTR_COUNT = 0x10,
OFF_XML_NODE_ATTRS = 0x14,
XML_NODE_ATTR_STRIDE = 0x8,
// `XMLNode *__thiscall(node, XMLNode *parent, const char *tag)` — the
// node constructor (copies `tag`); the node is XML_NODE_SIZE bytes.
// `void __fastcall(node)` — the destructor (frees tag, attributes, the
// child and sibling subtrees). `void __thiscall(node, name, value)`,
// ret 8 — the attribute setter (copies both). Script_CreateFrame builds
// its request node with exactly these three (0x00706211, 0x0070622D..55,
// 0x0070630C).
FUN_XML_NODE_CTOR = 0x006F2B10,
FUN_XML_NODE_DTOR = 0x006F2B70,
FUN_XML_NODE_SET_ATTRIBUTE = 0x006F2D40,
XML_NODE_SIZE = 0x20,
// `XMLNode *__thiscall(node, const char *tag)` — the first child whose
// tag matches (SStrCmpI), or null. The child-frames builder finds
// `<Frames>` with it (0x0076A09E).
FUN_XML_NODE_GET_CHILD = 0x006F2C50,
// XMLTree_Load — `XMLTree *__fastcall(const char *data, uint32_t size)`,
// null when the text does not parse; the root node is `*(XMLNode **)tree`.
// XMLTree_Free — `void __fastcall(XMLTree *)`. The bindings loader's own
// pair (0x004B6FDE / its exit).
FUN_XML_TREE_LOAD = 0x006F2A30,
FUN_XML_TREE_FREE = 0x006F2AC0,
// The loaders' status sink (their `status` argument): vtable +0xC is
// `Add(status, level, fmt, ...)` (__cdecl, variadic) — e.g. the frame
// loader's "Couldn't find inherited node: %s" at level 1. Levels as 4.3.4
// names them: 0 info, 1 warning, 2 error, 3 fatal.
VTBL_XML_STATUS_ADD = 0x0C,
XML_STATUS_WARNING = 1,
// `float __stdcall SStrToFloat(const char *)` (RET 4, x87 result) — the
// frame loader's `alpha` conversion (0x00769A10).
FUN_SSTR_TO_FLOAT = 0x0064AAA0,
// Per-object XML node loaders. Each lives on the object's layout
// sub-object, OFF_XML_LOADER_SUBOBJECT bytes in, at that sub-object's
// vtable +8: `(object+0x24)->vtable[+8](node, status)`, __thiscall with
// `this` = object+0x24 (all end `ret 8`). The frame builder FUN_006EE280
// makes the call at 0x006EE4D9..E1 (between its main-vtable +0x20
// pre-load and +0x24 finalize/OnLoad); the region factory FUN_006F26F0
// at 0x006F2756..5E, right after the region pre-load FUN_0076FDF0 (which
// reads the name and registers the Lua object via FUN_0076C650 ->
// FUN_FRAMESCRIPT_OBJECT_SCRIPT_REGISTER). Confirmed by a crash stack:
// builder 0x006EE4E4 -> FRAME loader, factory 0x006F2761 -> TEXTURE
// loader. The addresses appear only in those sub-object vtables (8 frame
// classes, 1 texture, 2 font-string).
// FRAME: the CSimpleFrame loader. Every derived frame type's loader
// calls it first (10 direct callers - Button 0x007788C0, which then
// reads "NormalTexture"; ScrollFrame 0x00786B50 "ScrollChild"; Slider
// 0x00789580 "ThumbTexture"; ...). Reads "inherits" (0x0076982E) and
// "hidden" (0x00769881).
// TEXTURE: reads "inherits", "hidden", "alphaMode" (0x00770179).
// FONTSTRING: reads "inherits", "hidden", "justifyH" (0x00771308).
// Identified by the attribute-name strings each passes to
// FUN_XML_NODE_GET_ATTRIBUTE. Co-hooked by xml/ParentKey.cpp. The FRAME
// loader covers attributes, TitleRegion, ResizeBounds, Backdrop,
// HitRectInsets, Layers and Scripts - not <Frames>, which the finalize
// step builds (FUN_XML_FRAME_LOAD_CHILD_FRAMES).
// Script-region name: the resolved global name string, stored by SetName
// (FUN_0076C650, `mov [esi+0x98], eax` at 0x0076C6B2) right before it
// registers the object under that name via
// FUN_FRAMESCRIPT_OBJECT_SCRIPT_REGISTER. SetName is called by the frame,
// texture and font string pre-loads (0x00769770, FUN_0076FDF0, 0x00770F10)
// only when the element has a `name`, so an unnamed XML element keeps
// null here and stays unregistered until Lua first touches it. Shared by
// frames and regions, like OFF_REGION_PARENT (which GetParent, 0x007A1460,
// reads for both at 0x007A14FF).
OFF_SCRIPT_REGION_NAME = 0x98,
OFF_XML_LOADER_SUBOBJECT = 0x24,
FUN_XML_FRAME_LOAD = 0x00769820,
FUN_XML_TEXTURE_LOAD = 0x0076FE20,
FUN_XML_FONTSTRING_LOAD = 0x00770F40,
// CSimpleFrame::LoadXMLLayers — `__thiscall(frame, layersNode, status)`,
// `ret 8`, called by FUN_XML_FRAME_LOAD for each <Layers>. For each
// <Layer> it reads `level` (default ARTWORK, FUN_XML_DRAW_LAYER_FROM_NAME)
// and builds each <Texture> (FUN_XML_ADD_TEXTURE_ELEMENT) and <FontString>
// (FUN_XML_ADD_FONTSTRING_ELEMENT), then places it with
// FUN_REGION_SET_PARENT_AND_LAYER(region, frame, level, [region+0xC4]).
// Any other tag is warned with STR_XML_FRAME_UNKNOWN_CHILD (frame name or
// VAR_STR_UNNAMED, parent tag, child tag). Replaced by xml/Layers.cpp.
FUN_XML_LOAD_LAYERS = 0x00769D70,
// `CSimpleTexture *__fastcall(xmlNode, frame, status)`, `ret 4`: allocates
// a texture parented to the frame, runs its pre-load (name), its node
// loader (FUN_XML_TEXTURE_LOAD) and the implicit anchor.
FUN_XML_ADD_TEXTURE_ELEMENT = 0x006F26F0,
// The font string twin of FUN_XML_ADD_TEXTURE_ELEMENT, same convention.
FUN_XML_ADD_FONTSTRING_ELEMENT = 0x006F2780,
// `bool __fastcall(const char *name, int *outLayer)`: case-insensitive
// BACKGROUND..HIGHLIGHT -> 0..4; leaves *outLayer alone on a miss.
FUN_XML_DRAW_LAYER_FROM_NAME = 0x006F18B0,
// "Frame %s: Unknown child node in %s element: %s"
STR_XML_FRAME_UNKNOWN_CHILD = 0x008786E0,
// Builds a node's <Frames> children. `__thiscall(frame, node, status)`,
// `ret 8`: recurses the node's `inherits` first (0x0076A092), then calls
// the builder FUN_006EE280 per child with EDX = frame as the parent
// (0x0076A0B5). In no vtable; its callers are itself and the frame
// finalize FUN_0076A2F0 (main vtable +0x24, the builder's last call),
// which runs it before firing OnLoad (+0x118) - so a parent's OnLoad
// sees its children built.
FUN_XML_FRAME_LOAD_CHILD_FRAMES = 0x0076A060,
// The frame builder — `CSimpleFrame *__fastcall(node, parent, status)`,
// ret 4 (disassembly: ECX = node, EDX = parent saved to [ebp-8]). Looks
// the node's tag up in the frame-type factory table, picks the parent,
// calls the factory, then pre-load (vtable +0x20), the node loader
// (sub-object vtable +8) and finalize (+0x24: child <Frames>, OnLoad).
// Parent: the node's `parent` attribute; with none, it follows the
// `inherits` chain (one name per node, FUN_XML_TEMPLATE_LOOKUP) until a
// template has one. A non-empty name resolves through
// FUN_FRAMESCRIPT_OBJECT_BY_NAME; a miss logs "Couldn't find frame
// parent: %s" and builds unparented. No name keeps EDX.
FUN_XML_FRAME_BUILD = 0x006EE280,
// `CFrameScriptObject *__fastcall(const char *name, int typeId)` —
// `_G[name][0]`, kept only when its IsA(typeId) passes. The builder's
// parent resolver (0x006EE3E8, EDX = the Frame type id).
FUN_FRAMESCRIPT_OBJECT_BY_NAME = 0x0076C760,
// The node-loader slot on the layout sub-object's vtable (see above).
VTBL_XML_NODE_LOADER = 0x08,
// FrameXML_RegisterFactory — `int __fastcall(const char *type,
// CSimpleFrame *(__fastcall *factory)(CSimpleFrame *parent), uint8_t
// unique)`, callee pops the byte (pushed as a dword). Adds `type` to the
// hash table FUN_XML_FRAME_BUILD looks tags up in (SStrCmpI), returning 0
// when the name is already there. Nothing else writes the table, so a
// registration lasts for the process. Callers: the defaults
// FUN_006EF070 (Button .. MovieFrame), the game UI's FUN_00495940
// (WorldFrame, GameTooltip, Minimap, PlayerModel, DressUpModel,
// TabardModel, LootButton, TaxiRouteFrame) — run by CGGameUI::Initialize
// FUN_0048FBF0 after LoadScriptFunctions and before FrameXML loads — and
// the glue UI's FUN_0046A400.
FUN_FRAMEXML_REGISTER_FACTORY = 0x006EE880,
// ---- Subclassing CSimpleFrame (Frame::Cooldown) -------------------------
// The "Frame" factory of the default list (0x006EEC10) is
// `SMemAlloc(SIMPLEFRAME_SIZE, file, line, 0)` then the constructor
// `CSimpleFrame::CSimpleFrame` — `__thiscall(frame, parent)`, `ret 4` —
// which stores VTBL_SIMPLEFRAME at +0 and VTBL_SIMPLEFRAME_LAYOUT at
// OFF_FRAME_LAYOUT_SUBOBJECT (0x007692E5 / 0x007692EB). Every derived
// factory (Model 0x006EECF0: 0x3DC bytes, CSimpleModel ctor) has the same
// shape. Slot 0's deleting destructor (0x00769380) runs the destructor
// body FUN_FRAME_DESTRUCTOR and SMemFrees the block, so a larger block
// from SMemAlloc frees cleanly. The vtables are 36 and 11 slots: the main
// one ends where the layout one's successor (title region, 0x0081C528)
// begins, and the layout one ends at VTBL_SIMPLEFRAME (benilla-re
// ui/frames, dumped from the exe).
SIMPLEFRAME_SIZE = 0x314,
FUN_SIMPLEFRAME_CONSTRUCTOR = 0x00769090,
VTBL_SIMPLEFRAME = 0x0081C498,
VTBL_SIMPLEFRAME_SLOTS = 36,
VTBL_SIMPLEFRAME_LAYOUT = 0x0081C46C,
VTBL_SIMPLEFRAME_LAYOUT_SLOTS = 11,
// Main-vtable slots, all __thiscall (CSimpleFrame's own in brackets):
// +0x00 deleting destructor (this, flags), ret 4 [0x00769380]
// +0x08 GetScriptMethod (this, L, name) -> int, ret 8 [0x00778590]:
// FUN_FRAMESCRIPT_PUSH_METHOD on the class hash, else the base
// class's lookup — the `__index` dispatcher's per-class step
// +0x10 IsA (this, int typeId) -> bool, ret 4 [0x00484780]
// +0x18 IsObjectType (this, const char *) -> bool, ret 4 [0x004847B0]
// +0x1C GetObjectType (this) -> const char * [0x00484800]:
// what Script GetObjectType (0x007A11D0) and GetFrameType
// (0x00773640) push, after IsA(Region/Frame id) via +0x10
// +0x38 OnFrameUpdate (this, float elapsedSec), ret 4 [0x0076B2C0]:
// the update walk's per-frame call (CSimpleTop 0x00765707);
// runs OnUpdate
// +0x44 EmitLayer (this, batch, int layer), ret 8 [0x0076B3A0]:
// the level rebuild's per-frame call (0x007659ED) — 4.3.4's
// OnFrameRender(batch, layer)
// +0x84 Hide (this) / +0x88 Show (this): the visibility half of 1.12's
// Show/Hide; Script Show/Hide (0x00775750/0x00775810) and the XML
// `hidden` attribute (0x007698A6/0x007698BA) first write
// OFF_FRAME_SHOWN 1/0, then call these.
// (+0x28 is VTBL_FRAME_SET_FRAME_ALPHA.)
VTBL_FRAME_DELETING_DESTRUCTOR = 0x00,
VTBL_FRAME_GET_SCRIPT_METHOD = 0x08,
// +0x0C the script-name resolver (this, const char *name) -> slot*, ret 4:
// FUN_FRAME_SCRIPT_RESOLVER for Frame and MessageFrame, each other
// type's extension of it otherwise (benilla-re ui/xmltypes); what
// SetScriptObjectScript (0x007025C0) and SetScript/GetScript use.
VTBL_FRAME_SCRIPT_RESOLVER = 0x0C,
VTBL_FRAME_IS_A = 0x10,
VTBL_FRAME_IS_OBJECT_TYPE = 0x18,
VTBL_FRAME_GET_OBJECT_TYPE = 0x1C,
VTBL_FRAME_ON_FRAME_UPDATE = 0x38,
VTBL_FRAME_EMIT_LAYER = 0x44,
VTBL_FRAME_HIDE = 0x84,
VTBL_FRAME_SHOW = 0x88,
// Layout-vtable slots, `this` = the layout sub-object:
// +0x00 OnFrameSizeChanged (this, const float *oldRect), ret 4
// [0x0076B580]
// +0x04 deleting destructor thunk: `sub ecx, 0x24; jmp 0x00769380`
// (0x0076C410) — it does NOT go through slot 0
// +0x08 VTBL_XML_NODE_LOADER (FUN_XML_FRAME_LOAD)
// +0x0C GetLayoutParent (this) -> layout or 0 [0x0076C6E0]
VTBL_LAYOUT_ON_FRAME_SIZE_CHANGED = 0x00,
VTBL_LAYOUT_DELETING_DESTRUCTOR = 0x04,
VTBL_LAYOUT_GET_LAYOUT_PARENT = 0x0C,
// CLayoutFrame::LoadXML's `setAllPoints="true"` (0x00767800) is
// FUN_LAYOUT_SET_ALL_POINTS(layout, GetLayoutParent(), 1).
//
// CSimpleFrame::NotifyLayerChanged — `void __thiscall(frame, int layer)`,
// `ret 4`: marks one draw layer for a rebuild, in the frame's own mask
// when it draws itself (FRAME_FLAG_SCROLLED), else in its level's when
// the frame is visible. Nothing to mark when it is not: showing it
// joins the level, which rebuilds it.
FUN_FRAME_NOTIFY_LAYER_CHANGED = 0x0076A990,
// ---- Per-class method hashes --------------------------------------------
// Every frame class keeps its Lua methods in a Storm hash of 10 dwords
// (0x28 bytes): +0x00 the node allocator vtable VTBL_METHOD_HASH_ALLOCATOR,
// +0x04 the node link offset 0xC, +0x08/+0x0C an empty list (head = &+0x08,
// tail = &+0x08 | 1), +0x10..+0x20 zero (the bucket array), +0x24 the
// bucket mask, -1 until the first registration allocates 4 buckets.
// That is the whole static initializer (Model's 0x0076F5F0, Frame's
// 0x00778310 — both store 0x00806CB8). FUN_REGISTER_FRAME_METHODS fills
// one (it always appends a node: re-registering a name it holds without
// unregistering first leaves the old node and its stale ref), and
// FrameScriptUnregisterMethods — `void __fastcall(hash)` — unrefs each
// function in the live Lua state and frees the nodes, keeping the
// buckets for the next registration.
// FrameScriptPushMethod — `int __fastcall(L, const char *name, hash)`,
// callee pops `hash`: pushes registry[ref] and answers 1 when found.
VTBL_METHOD_HASH_ALLOCATOR = 0x00806CB8,
METHOD_HASH_SIZE = 0x28,
FUN_FRAMESCRIPT_PUSH_METHOD = 0x00702000,
FUN_FRAMESCRIPT_UNREGISTER_METHODS = 0x00701F20,
// CGGameUI::UnregisterScriptFunctions — `void __cdecl(void)`: the mirror
// of LoadScriptFunctions, called from the game UI's shutdown (0x00490CBA)
// on /reload and logout while the game Lua state is still open. Releases
// the class hashes (GameTooltip, Minimap, PlayerModel, ...) with
// FUN_FRAMESCRIPT_UNREGISTER_METHODS and unregisters the globals.
FUN_GAMEUI_UNREGISTER_SCRIPT_FUNCTIONS = 0x00490CE0,
// ---- Layer batch quads ----------------------------------------------------
// A layer batch (0x30 bytes, benilla-re ui/draworder) counts its entries
// at +0x04 and keeps its quads in an array at +0x08: capacity, count
// (+0x0C), records (+0x10), growth step. A record is 0x1C bytes: device
// texture (FUN_TEXTURE_GET_RENDERABLE), float[4][3] positions, float[4][2]
// texcoords, blend mode, colour pointer or 0, colour stride (4 = one
// colour per vertex, 0 = one for all), pixel shader or 0. The texture
// emit FUN_00772FD0 writes exactly that after reserving one record with
// FUN_RENDERBATCH_RESERVE_QUADS — `void __thiscall(array, extra, round)`,
// `ret 8`, a no-op while there is room. The batch keeps the POINTERS and
// re-reads them on every draw (FUN_0076FB00: a 4-vertex strip with the
// indices {0,1,2,3} at 0x00878CDC, so the triangles are 0-1-2 and
// 1-2-3); it is rebuilt only when a layer is marked changed. A record
// with a colour and a blend mode below 2 draws with blend 2 (alpha), the
// same promotion 3.3.5's SortByTexture makes.
FUN_RENDERBATCH_RESERVE_QUADS = 0x00773280,
OFF_RENDERBATCH_ENTRY_COUNT = 0x04,
OFF_RENDERBATCH_QUADS = 0x08,
OFF_RENDERBATCH_QUAD_COUNT = 0x0C,
OFF_RENDERBATCH_QUAD_RECORDS = 0x10,
RENDERBATCH_QUAD_SIZE = 0x1C,
// CLayoutFrame::ClearAllPoints — `void __fastcall(layout)`, layout =
// object + OFF_FRAME_LAYOUT_SUBOBJECT. Frees all 9 anchor slots and
// unlinks the frame from each relative frame. Script ClearAllPoints
// (0x007A2B70) calls it through the thunk 0x00767ED0 after resolving self.
FUN_LAYOUT_CLEAR_ALL_POINTS = 0x00767620,
// The Button node loader (same sub-object convention). It calls
// FUN_XML_FRAME_LOAD first, then loads the button's own children: each
// font element into a font object embedded in the button - NormalFont
// (tag compare 0x007789EB) into +0x318, DisabledFont (0x00778A0D),
// HighlightFont (0x00778A28) into +0x394 - reading its `inherits`.
// In 4 loader vtables; CheckButton's loader 0x00785170 calls it first.
FUN_XML_BUTTON_LOAD = 0x007788C0,
// By-name template lookup — the same one `inherits=` resolves through.
// `__fastcall(const char *name) -> definition node`, 0 if unregistered
// (case-insensitive, hashed). See FUN_006ee6f0 in Templates.cpp notes.
FUN_XML_TEMPLATE_LOOKUP = 0x006EE6F0,
// `CreateFrame(type [, name, parent, template])` — the global FrameScript
// function at table 0x00872E74 slot 3. Standard `int __fastcall(void *L)`
// shape. Checks args 1/3, resolves the parent (rawgeti [0] + IsA Frame),
// checks arg 4 as ONE template name, then builds an XMLNode with `name`,
// `parent` "" and `inherits` (FUN_XML_NODE_CTOR / _SET_ATTRIBUTE), runs
// FUN_XML_FRAME_BUILD(node, parent, status), script-registers the frame
// if needed, and pushes its wrapper. Replaced by `Frame::CreateFrame`
// with 4.3.4's version (0x0083FB40): list templates and the 5th `id`.
FUN_SCRIPT_CREATEFRAME = 0x007060B0,
// Its error strings, and the builder's / frame loader's warnings.
STR_CREATEFRAME_UNKNOWN_TYPE = 0x00872FA8, // "CreateFrame: Unknown frame type '%s'"
STR_CREATEFRAME_NO_INHERITED = 0x00872FD0, // "CreateFrame(): Couldn't find inherited node \"%s\""
STR_CREATEFRAME_WRONG_PARENT = 0x00873004, // "CreateFrame: Wrong parent object type, expected frame"
STR_CREATEFRAME_PARENT_NO_THIS = 0x0087303C, // "CreateFrame: Couldn't find 'this' in parent object"
STR_XML_NO_INHERITED_NODE = 0x008786A8, // "Couldn't find inherited node: %s"
STR_XML_NO_FRAME_PARENT = 0x008710F0, // "Couldn't find frame parent: %s"
// XML-build "status" object — a printf-style error/warning accumulator the
// appliers log through (`status->vtable[+0xc](status, level, fmt, ...)`,
// __cdecl varargs). Script_CreateFrame builds one on its stack as the
// 5-dword `{PTR_TEXLOAD_DESC_VTBL, 8, &self+8, (&self+8)|1, 0}` (same shape
// the texture loader reuses; see PTR_TEXLOAD_DESC_VTBL). Reset/emptied by
// `FUN_FRAMESCRIPT_STATUS_RESET` (`__thiscall(this)`), which frees any
// accumulated message nodes and re-stamps the vtable.
FUN_FRAMESCRIPT_STATUS_RESET = 0x00419E30,
// --- Inline texture escape (`|Tpath:h:w:...|t`) backport -------------------
// See src/text/InlineTexture.cpp and docs/InlineTextureEscapes.md. The
// 1.12 text pipeline is a shared `|`-tokenizer feeding per-purpose loops.
// Slice 1 injects an inline-texture quad into the text PAINT pass.
// Text paint pass — flushes each text line's per-font-page glyph vertex
// batches to the GPU every frame. `__fastcall(layoutObj)`; gated on
// DAT_00c2b9d4. Co-hooked post-original: the flush walks the layout's node
// list and queues each recorded inline icon as a fontstring-anchored region
// placement (Text::InlineTexturePool). See FUN_005c8fe0.
// (The GxU raw-quad primitives this site once drew with — dynamic-VB
// lock/write/submit, texture bind/load/force-decode, colorop state — were
// removed with the quad render mode; VAs are preserved in
// docs/InlineTextureEscapes.md and git history if ever needed again.)
FUN_TEXT_PAINT = 0x005C8FE0,
// Default texture-load blend arg (DAT_00878cf0) — passed to the engine's
// SetTexture-by-path (FUN_SIMPLETEXTURE_SET_TEXTURE) exactly as
// Script_Texture_SetTexture's own call site does.
VAR_TEXTURE_BLEND_DEFAULT = 0x00878CF0,
// --- Texture masking (`Texture:SetMask` backport) ---------------------------
// Mirrors the engine's own canonical masked-quad draw: the minimap BLIP mask
// FUN_004eae10 (a sibling of the disc FUN_004ec440; both fed by the mask that
// Minimap:SetMaskTexture at 0x004EE4A0 loads into DAT_00bc7968). FUN_004eae10
// is the exact template — bind base on unit 0, mask on unit 1, force each
// unit's combiner to MODULATE, submit with SEPARATE uv0/uv1, then unbind
// unit 1:
// GxRs(0x17, base); GxRs(0x1F, 1); // unit 0: bind + MODULATE preset
// GxRs(0x18, mask); GxRs(0x20, 1); // unit 1: bind + MODULATE preset
// FUN_0058a2a0(4, corners, …, uv0, uv1); // explicit second UV stream
// GxRs(0x18, 0); // unbind unit 1
// Unit 1's MODULATE combiner multiplies the mask's alpha into the base's
// alpha, so a white-with-alpha mask clips the base to the mask's shape.
//
// The recipe was also pinned by an in-game probe (git history's
// MaskProbe.cpp) on the live backend — findings, load-bearing:
// * The COMBINER PRESET selectors are 0x1F+unit (GXRS_COMBINER0), value 1 =
// MODULATE/MODULATE (the .rdata preset tables at 0x0080a25c/0x0080a274,
// consumed by the D3D9 combiner apply FUN_005a2dd0: COLOROP table
// {4,4,13,7,5,12}, ALPHAOP {3,4,3,7,5,3} — value 1 is the only preset
// that MODULATEs the alpha channel too, which is what masking rides).
// Binding a texture on unit 1 alone happens to give MODULATE by default,
// but FUN_004eae10 sets it EXPLICITLY — we mirror that.
// * The SECOND vertex UV stream (uv1) DOES feed unit 1 (FUN_004eae10
// passes a distinct uv1 = this+0x50), so uv1 = uv0 makes unit 1 sample
// the mask at the base's own texcoords. SetMask originally rode this
// recipe but was moved to texgen (below): texcoord-relative sampling
// breaks for SetTexCoord'd sprites (the mask gets sampled at the same
// sub-rect OF THE MASK IMAGE), and uv1 is the LAST explicit UV slot
// that exists — the vertex-format component table at 0x008097A8
// (13 formats × 13 components) has no format with a third UV set, so
// masks past the first cannot ride an explicit stream anyway.
GXRS_TEXTURE0 = 0x17, // texture bind, +unit 0..7 (via FUN_GX_RS_SET_PTR)
GXRS_COMBINER0 = 0x1F, // combiner preset, +unit 0..7 (via FUN_GX_RS_SET)
GXRS_COMBINE_MODULATE = 1, // preset value: COLOROP=MODULATE, ALPHAOP=MODULATE
// GxRs setters — `__fastcall(selector, value)`. The int form (0x00589E60)
// writes combiner presets and the like; the pointer form (0x00589E80) writes
// texture binds.
FUN_GX_RS_SET = 0x00589E60,
FUN_GX_RS_SET_PTR = 0x00589E80,
// --- Texgen + per-unit texture matrices (multi-mask / rotated masks) -------
// Decoded from the D3D9 backend's draw-time state flush FUN_005a2f00 (the
// selector → SetTextureStageState/SetTransform Rosetta stone) and the
// minimap DISC draw FUN_004ec440, which is the engine's own texgen-mask
// template (it submits positions+colors ONLY and feeds BOTH units via
// texgen + a per-unit texture matrix). Selector namespace is five per-unit
// families, each 8 units wide (device supports 8 fixed-function stages;
// live cap at [VAR_GX_DEVICE]+OFF_GXDEV_STAGE_CAP):
// 0x17+u bind 0x1F+u combiner 0x27+u mip-bias 0x2F+u texgen
// 0x37+u coord-transform mode
// Texgen values (FUN_005a2b40): 0 = passthrough (stage reads vertex UV set
// #u — the default; why stage 1 sees the explicit uv1 stream), 1 = OBJECT-
// space position (D3D TCI_CAMERASPACEPOSITION + an auto inv(view)·inv(model)
// basis matrix — UV becomes a pure function of the RAW vertex position,
// immune to whatever model/view the pass set), 2 = world-space position,
// 3 = camera-space position (identity basis; what the disc draw uses),
// 5/4/6 = normal/reflection.
// Coord-transform values (FUN_005a14e0): 0 = off, 1 = apply the unit's
// texture matrix (basis × user matrix, D3DTTFF_COUNT3), 2 = projected.
// Per-unit texture-matrix STACKS (4 levels, base ctx+0xFD0+unit*0x118;
// slot 8 = model, 10 = view) — the disc draw's push/translate/scale/pop:
GXRS_TEXGEN0 = 0x2F, // texgen mode, +unit (int form)
GXRS_TEXGEN_OBJECT_POS = 1,
GXRS_TEXXFORM0 = 0x37, // coord-transform mode, +unit (int form)
GXRS_TEXXFORM_MATRIX = 1,
// Texture-matrix stack ops — `__fastcall(int unit, ...)`. PUSH duplicates
// the top (max depth 4); PUSH_LOAD pushes then loads an arbitrary 4×4
// (row-vector D3D layout: out = pos·M, translation in row 3). POP restores.
// (PUSH/POP were previously mislabeled FUN_GX_TEXUNIT_ENABLE/_DISABLE —
// they never enabled anything; binding a texture is what enables a stage,
// binding null disables it, per FUN_005a29d0.)
FUN_GX_TEXMTX_PUSH = 0x0058B200, // (unit)
FUN_GX_TEXMTX_PUSH_LOAD = 0x0058B210, // (unit, const float m[16])
FUN_GX_TEXMTX_POP = 0x0058B220, // (unit)
// Gx render-state journal push/pop — brackets a state scope; pop replays
// every selector written since the push back to its prior value. The engine
// wraps each region-layer draw (FUN_0076fb00) and the disc draw in a pair.
FUN_GX_STATE_PUSH = 0x00589F40,
FUN_GX_STATE_POP = 0x00589F50,
// The indexed submit that actually queues the draw for the verts staged by
// FUN_GX_PRIM_STREAMS — `__fastcall(int primType, int indexCount, const
// void *indices)`. Every FUN_GX_PRIM_STREAMS caller invokes it immediately
// after (region layer: FUN_0076fb00; disc: FUN_004ec440). State/matrix
// RESTORES must run AFTER this call, not after the stream call — the disc
// draw pops its matrices/state only past this point, and restoring earlier
// reverts the state the queued draw will be flushed with.
FUN_GX_PRIM_INDEXED = 0x0058A2E0,
// The device/context singleton the Gx wrappers route through (set at
// backend creation, FUN_00589ac0). +0x23C holds the live texture-stage cap
// the per-stage applies clamp against (FUN_005a29d0/FUN_005a2b40).
VAR_GX_DEVICE = 0x00C0ED38,
OFF_GXDEV_STAGE_CAP = 0x23C,
// The vertex-stream primitive every textured region draws through
// (FUN_0076fb00 calls it per region). Decompiler signature (13 params):
// (count, positions, posStride, s3, s3Stride, colors, colorStride, drop8,
// drop9, uv0, uv0Stride, uv1, uv1Stride); RET 0x2C. The inner FUN_0058a3d0
// builds an interleaved vertex from whichever of {s3, colors, uv0, uv1} are
// non-null — so uv1 is a real, buildable second UV slot no engine caller
// populates. `positions` for a region draw is the region's corner array
// (region + OFF_SIMPLETEXTURE_CORNERS), which is how the mask co-hook
// recovers the owning region: region = positions - OFF_SIMPLETEXTURE_CORNERS
// (verified: FUN_00772fd0 appends the batch entry with positions =
// region+0xD4, and FUN_0076fb00 forwards that pointer here).
FUN_GX_PRIM_STREAMS = 0x0058A2A0,
// Path → HTEXTURE loader trio (re-adds of the quad-era offsets removed in
// 56c2670, with the same derivations — see docs/InlineTextureEscapes.md):
// FUN_TEXTURE_LOAD_BY_PATH(path, &desc, flags, 0, 1) __fastcall, desc =
// the 5-dword {PTR_TEXLOAD_DESC_VTBL, 8, &self8, (&self8)|1, 0} on-stack
// node FUN_00770200 builds; flags via FUN_GX_TEXFLAGS_INIT(&flags, blend,
// 0,0, 0,0,0, 1, 0) __thiscall. Never returns null: a file that does not
// load returns the solid green fallback and sets the desc's severity
// (+0x10, the CStatus level) to 2 or more. SetTexture (0x00770288) tests
// that, then closes the handle (FUN_HANDLE_RELEASE), passes the status to
// FUN_SYSMSG_ADD_STATUS with 4 (shows nothing) and destroys it
// (FUN_FRAMESCRIPT_STATUS_RESET, also run on success at 0x007702C6).
// FUN_TEXTURE_GET_RENDERABLE(hTex, 1, 0) __fastcall
// returns the bindable CGxTex at [hTex+0x140] and drives the streaming
// load — calling it each frame IS the residency reference (what the
// minimap's masked draw does for its mask at 0x004ec65c).
FUN_TEXTURE_LOAD_BY_PATH = 0x00449D90,
// TextureCreateFromBlp — `HTEXTURE __fastcall(const char *path, uint32
// fileFlag, uint32 flags, void *log)`, `ret 8` (0x0044A3A3/0x0044A4FC):
// opens `path` (extension included) through SFile and queues the async
// read; null when SFile cannot open it. Called only by TextureCreate
// (0x00449E2B), on a texture-hash miss, which hash-inserts a non-null
// result under the name and the made flags word (0x00449E99).
FUN_TEXTURE_CREATE_FROM_BLP = 0x0044A310,
// TextureCreateWithCallback — `HTEXTURE __fastcall(uint32 w, uint32 h,
// uint32 mips, uint32 format, uint32 flags, void *owner, callback, const
// char *name, int force)`: a named texture whose texels `callback`
// supplies, never deduplicated by name. The portrait cache (0x00525F58:
// 64x64, 1 mip, GXTEX_FORMAT_ARGB8888, FUN_GX_TEXFLAGS_INIT(1, 0,0, 0,0,0,
// 1, 0), "Portrait2") is the model. The callback is `void
// __fastcall(uint32 command, uint32 w, uint32 h, uint32 face, uint32
// level, void *owner, uint32 *stride, const void **texels)`, `ret 0x18`;
// on GXTEX_CMD_LATCH it answers stride = w * 4 and the texels, which it
// keeps (the portrait's 0x00525AE0 hands its cached array over without a
// copy), and ignores every other command.
FUN_TEXTURE_CREATE_WITH_CALLBACK = 0x00449BF0,
// TextureCreateSolid — `HTEXTURE __fastcall(const uint32_t *bgra, uint32_t
// unused)`: the cached 8x8 "Solid Texture" of one colour (0xAARRGGBB),
// built on a miss (benilla-re gx/textures, verified). The caller owns the
// handle: CSimpleTexture::SetSolidColour (0x00770360, what a <Texture>'s
// <Color> child runs) stores it at +0xCC and closes it on replace.
FUN_TEXTURE_CREATE_SOLID = 0x0044A9C0,
// XmlReadColor — `int __fastcall(const XMLNode *node, uint32_t *bgra,
// CStatus *status)`, `ret 4` (0x006F2626): a <Color> element's r/g/b/a,
// clamped to 0..1; a missing r, g or b is 0 and a missing a is 1
// (benilla-re ui/backdrop, verified). CSimpleTexture::LoadXML reads
// <Color> with it, pushing its own load status (0x00770090).
FUN_XML_READ_COLOR = 0x006F23D0,
GXTEX_FORMAT_ARGB8888 = 2,
GXTEX_CMD_LATCH = 1,
PTR_TEXLOAD_DESC_VTBL = 0x007FFA10,
FUN_GX_TEXFLAGS_INIT = 0x0058A980,
FUN_TEXTURE_GET_RENDERABLE = 0x0044ACF0,
// SysMsgAdd — `int __fastcall(CStatus *status, uint32_t level)`: hands a
// status's error text to the system-message printer 0x0044CB20, which in
// this build formats it and drops it (nothing reaches the screen; seen
// in-game: a bad SetTexture/SetMask path prints nothing). SetTexture's
// failure path (0x0077029D) calls it with 4; mirrored for parity.
FUN_SYSMSG_ADD_STATUS = 0x0044CB40,
// --- Texture desaturation (`Texture:SetDesaturation` backport) --------------
// The engine desaturates by binding ONE pixel shader per region: the UI
// shader loaded at CSimpleTop construction (FUN_0076FDA0) from
// "Shaders\Pixel\Desaturate.bls" into VAR_UI_SHADER_DESATURATE, stored in the
// region slot OFF_SIMPLETEXTURE_SHADER and bound by the layer draw
// (FUN_0076FB00 → FUN_GX_RS_SET_PTR(0x3F, shader) → D3D SetPixelShader in
// FUN_005A0570). texture/Desaturation.cpp creates one shader object per
// desaturation level through the engine's own loader and writes it into the
// same slot — no draw hooks. Decoded stock ps_2_0 program: def c0 luma; dcl
// t0.xy; dcl v0; dcl_2d s0; texld r0,t0,s0; dp3 r0.rgb,r0,c0; mul
// r0.a,r0.a,v0.a; mov oC0,r0 — it drops the vertex-colour RGB.
//
// Loader chain (FUN_GX_SHADER_CREATE → device vmethod +0xDC = FUN_005A0370):
// FUN_00595240 dedups by path hash in the device's shader table (a hit
// returns the node, refcount++) and creates the node (vtable 0x00809EA8,
// zero-filled) on a miss; FUN_00595130 opens the path with the HANDLE file
// API (FUN_006477A0 — NOT FUN_FILE_READ, so the addon read hook never sees
// shader loads), reads the header + the block the device profile selects,
// and lets the node parse it (CGxShader vtable slot 0 = FUN_00598320). A
// MISSING file returns silently, leaving the registered node with valid = 0.
// The D3D loader then compiles eagerly (FUN_GX_D3D_COMPILE_PIXEL_SHADER). A
// node whose compile failed binds a NULL shader in FUN_005A0570 — the region
// draws fixed-function, never black. The device is created once per process
// (ConsoleDeviceInitialize 0x0063A230 is the factory's only caller) and the
// reload-from-file vmethod (+0xE8, wrapper 0x0058B390) has no callers, so
// shader pointers are process-lifetime.
//
// .bls container (magic 'SPXG'): u32 version, u32, 12 block offsets (0..4 =
// ps_1_1/1_2/1_3/1_4/2_0 D3D bytecode, 5..8 nv binary, 10 ARBfp text);
// block = u32 constCount, entries, u32 samplerCount, entries, u32 codeType
// (2 = D3D bytecode), u32 codeSize, code. Param entry = 0x90 bytes {char
// name[0x40]; u32 register; float default[16]; u32 type; u32; u32} →
// CGxShaderParam node (+0x4c register, +0x54 data, +0x40 type, +0x50 dirty).
// The per-draw state flush FUN_00594210 re-uploads a bound shader's dirty
// params (FUN_005955F0 → FUN_005A0420 → SetPixelShaderConstantF) — stock
// data only exercises that for vertex shaders, which is why the backport
// bakes the amount into a `def` constant instead of a param.
FUN_SIMPLETEXTURE_SET_SHADER = 0x00770650, // __thiscall(region, CGxShader*): writes the slot, FUN_0077FDF0 re-batch iff changed
FUN_UI_GET_PIXEL_SHADER = 0x00770620, // __fastcall(index): s_uiPixelShaders[index] iff loaded and valid (FUN_0058B360), else 0; 1 = Desaturate (Script_SetDesaturated's gate; 3.3.5 GetImageModePixelShader)
VAR_UI_SHADER_DESATURATE = 0x00CF4CD4, // DAT_00CF4CD0[1]: stock Desaturate.bls CGxShader*; released by FUN_0076FDD0 at shutdown
FUN_SCRIPT_TEXTURE_SET_DESATURATED = 0x0079C1E0, // Texture method batch entry 20; flag via FUN_LUA_TO_BOOLEAN_LOOSE(L, 2, 1)
FUN_GX_SHADER_CREATE = 0x0058B2B0, // __fastcall(type /*ecx*/, CGxShader **out /*edx*/, const char *path)
FUN_GX_D3D_COMPILE_PIXEL_SHADER = 0x005A0250, // __thiscall(dev, shader): +0x2c = 0, CreatePixelShader iff +0x50 == 2 && +0x58 → +0x20, +0x2c = 1
FUN_GX_ARRAY_GROW_BYTES = 0x005268B0, // __thiscall({cap,size,data,quantum}*, newCap): sets cap, SMemReAllocs data; size is the caller's
PTR_GXDEVICE_D3D_VTBL = 0x00809EF8, // CGxDeviceD3d vtable (ctor FUN_00598CE0); the OpenGL device's (0x00809AF8) has another layout
OFF_GXDEVD3D_DEVICE9 = 0x38A8, // IDirect3DDevice9* (every D3D call in FUN_005A2F00 / FUN_005A0250 goes through it)
OFF_GXDEVD3D_ALIVE = 0xF2C, // 1 after CreateDevice / a successful Reset (FUN_005995C0 / FUN_005A1680), 0 after a failed Present (FUN_005A1910); gates draws and compiles
OFF_GXDEV_PS_PROFILE = 0x2D4, // dev+0x2D0+type*4, from D3DCAPS9.PixelShaderVersion in FUN_00598EE0: 4 = ps_2_0+, 3/2/1/0 = ps_1_4/1_3/1_2/1_1, -1 none
OFF_GXSHADER_D3D_OBJECT = 0x20, // IDirect3DPixelShader9* (created by the compile)
OFF_GXSHADER_TYPE = 0x24, // 0 = vertex, 1 = pixel
OFF_GXSHADER_VALID = 0x2C,
OFF_GXSHADER_CODE_TYPE = 0x50, // GXSHADER_CODE_D3D for bytecode blocks
OFF_GXSHADER_CODE_DESC = 0x54, // {cap, size, data, quantum}
OFF_GXSHADER_CODE_SIZE = 0x58,
OFF_GXSHADER_CODE_DATA = 0x5C,
GXSHADER_TYPE_PIXEL = 1,
GXSHADER_CODE_D3D = 2,
GXRS_PIXEL_SHADER = 0x3F, // pointer-form selector (0x40 = vertex shader); doc only — the engine's draw binds it
FUN_LUA_TO_BOOLEAN_LOOSE = 0x006F1C10, // __fastcall(L, idx, default): nil→0, boolean, number→int, "1/t/y…"→1, "0/f/n…"→0, "enabled"→1, "disabled"→0, other→default. Called through Game::Lua::ToFlag (4.3.4 StringToBOOL(L, idx, default))
// --- Texture memory accounting: the zero-dimension hang -------------------
// FUN_GX_TEXTURE_MIP_BYTES totals a texture's bytes across its mip chain:
// `__thiscall(device, GxTexture, width, height)` (RET 0xC), where a width or
// height of -1 means "read the texture's own". Both dimensions are shifted
// right by OFF_GXDEV_TEXTURE_REDUCE, then divided into format blocks
// (DAT_00809D48 = block side, DAT_00809D6C = bytes per block, both indexed by
// OFF_GXTEXTURE_FORMAT * 4). A single-level texture returns after the base
// level; a mipmapped one (OFF_GXTEXTURE_FLAGS & 7 >= 2) enters the halving
// loop at 0x00594D47.
//
// THAT LOOP HANGS ON A ZERO DIMENSION — the engine bug Texture::MipAccounting
// guards. Its only exit is both dimensions reaching exactly 1 (`CMP EBX,1 /
// JNZ` then `CMP EDI,EBX / JNZ`), and each halving is gated by `JBE`, so a 0
// never shifts and never reaches 1:
// 00594D47 CMP EBX,1 ; width == 1?
// 00594D4A JNZ 00594D59
// 00594D4C CMP EDI,EBX ; height == 1 too? -> return
// 00594D4E JNZ 00594D60
// 00594D59 JBE 00594D60 ; width <= 1 -> skip the SHR (0 stays 0)
// The spin does no allocation and no I/O, so it presents as a hard freeze at
// 100% of one core rather than a crash. Caught live at 0x00594D78 by a
// SIGSEGV-forced backtrace: the frame's four printed stack slots are this
// function's own reused parameter slots, which read back as 4 bytes/block
// (uncompressed 32-bit) with both dimensions 0.
//
// Reachable from two callers. FUN_00594D90 (the per-frame bind stamp, run
// once per texture per frame from the texture-stage apply FUN_005A29D0) passes
// -1/-1 for a whole texture; FUN_00594C80 (lock / dirty-rect accounting)
// passes a RECT's width and height, so an empty-but-flagged rect hangs it just
// the same. The guard covers both by clamping at the entry.
FUN_GX_TEXTURE_MIP_BYTES = 0x00594CE0,
// Device-relative global texture-reduction level, consumed here as `SHR
// dimension, CL` (so the CPU masks it to 5 bits). Its writer has not been
// identified; the guard needs only the value this accounting itself applies,
// and reads it from the same field for exactly that reason.
OFF_GXDEV_TEXTURE_REDUCE = 0x31C,
// GxTexture fields, every one written verbatim by the constructor
// FUN_00591600 with no validation of any kind — which is how a 0x0 texture
// comes to exist in the first place.
OFF_GXTEXTURE_WIDTH = 0x24,
OFF_GXTEXTURE_HEIGHT = 0x28,
OFF_GXTEXTURE_FORMAT = 0x34,
OFF_GXTEXTURE_FLAGS = 0x3C, // bits 0..2 = mip mode; >= 2 means a mip chain
// --- Texture dimension gates (power-of-two / max size) --------------------
// 1.12 rejects a non-power-of-two texture TWICE, and both are plain software
// checks — no device caps are consulted for the POT rule at either site:
// 1. the allocator/recycler FUN_00448450, which returns NULL outright
// (`TEST w,w-1 / JNZ reject` per axis, then `CMP dim,0x400 / JAE`);
// 2. the GX create validator FUN_0058AB10, which re-tests POT for every
// texture type but 2 (type 0 = 2D, 1 = cubemap — the BLP loader passes
// `width == height*6` as the type, and FUN_00542180-style atlas creates
// pass 0).
// Verified unchanged in both later clients: 3.3.5 FUN_00681d90 and 4.3.4
// FUN_00840d30 carry the validator's POT test verbatim, same type-2
// exemption. What they DO change is the allocator: its dimension test is
// demoted to a pool-eligibility window (`dim - 0x20 < 0x1e1`, i.e. [32,512]),
// so an out-of-range dimension skips the recycle pool and allocates fresh
// rather than failing. That demotion is only safe there because 3.3.5 clamps
// its device-caps max to the scratch size (1024) and lets the validator carry
// the bound. 1.12's validator ALSO compares against the per-type caps max
// (`caps + 0x60 + type*4`, caps via FUN_0058A230) — but that value is raw
// hardware (a 2560x1080 passed it), so in 1.12 the allocator's hardcoded
// 0x400 is the ONLY thing protecting the decode scratch described below. It
// is not redundant. Do not port the demotion without porting a bound.
//
// The recycle pool is indexed by log2(dim >> 5) and its hit test compares
// only flags/type/miplevels — never width/height — so an NPOT texture must
// never reach it or it recycles a bucket of unrelated dimensions. Any patch
// relaxing the POT rule therefore has to route the failures through a bound
// check and THEN to the pool-skip site — never simply delete them, and never
// straight to pool-skip (see CODE ORDER MATTERS below).
FUN_GX_TEXTURE_ALLOC = 0x00448450,
PATCH_TEXALLOC_POT_W_JMP = 0x004484AE, // 0F 85 rel32 -> VA_TEXALLOC_REJECT
PATCH_TEXALLOC_POT_H_JMP = 0x004484B9, // 0F 85 rel32 -> VA_TEXALLOC_REJECT
// `CMP EBX,imm32` (81 FB) / `CMP EAX,imm32` (3D) — the size bound per axis,
// 0x400 stock. VanillaHelpers.dll leaves these and flips the jumps below
// from 0F 83 (JAE) to 0F 87 (JA) so exactly-1024 passes.
PATCH_TEXALLOC_SIZE_W_IMM = 0x004484C1,
PATCH_TEXALLOC_SIZE_H_IMM = 0x004484CC,
PATCH_TEXALLOC_SIZE_W_JMP = 0x004484C5, // 0F 83 rel32 -> VA_TEXALLOC_REJECT
PATCH_TEXALLOC_SIZE_H_JMP = 0x004484D0, // 0F 83 rel32 -> VA_TEXALLOC_REJECT
VA_TEXALLOC_POOL_SKIP = 0x0044864B, // "skip the pool, create fresh"
VA_TEXALLOC_REJECT = 0x00448665, // XOR EAX,EAX; RET 0x14
// CODE ORDER MATTERS: the POT jumps sit ABOVE the size CMPs, so a POT
// failure retargeted straight to VA_TEXALLOC_POOL_SKIP jumps OVER the size
// bound — an NPOT 3000x3000 would reach the decoder unbounded. Any NPOT
// relaxation must route POT failures through a bound check first
// (Texture::DimensionGate does it with a code cave). At the jump sites EBX =
// width and EAX = height, EDI = 0 and the 9-dword descriptor at [EBP-0x2C]
// is complete, so the pool-skip tail is enterable from any of them.
//
// Recycle-pool index arithmetic, `index = h_log + w_log * SIDE`, SIDE = 5
// for the stock 5x5 (32..512) table. VanillaHelpers grows the table to 6x6
// (its init-count immediate below reads 36 instead of 25) but leaves BOTH of
// these at stride 5, so a log of 5 on either axis collides: 32x1024 shares a
// bucket with 64x32, 64x1024 with 128x32 — and the bucket match never
// compares w/h, so the wrong-size texture is silently recycled. Fix = rewrite
// each 5-byte pair to `IMUL r,r,6; ADD r,other` (6B F6 06 03 F3 at the
// allocator, 6B DB 06 03 D8 at free), which preserves whichever operand
// stock treats as the row and only changes the stride. Stock's alloc and
// free agree with each other, so the fixed pair does too.
PATCH_TEXPOOL_INDEX_STRIDE_ALLOC = 0x00448529, // 8D 04 B3 03 F0 LEA EAX,[EBX+ESI*4]; ADD ESI,EAX
PATCH_TEXPOOL_INDEX_STRIDE_FREE = 0x004487AD, // 8D 0C 98 03 D9 LEA ECX,[EAX+EBX*4]; ADD EBX,ECX
PATCH_TEXPOOL_INIT_COUNT = 0x00447C45, // B9 imm32 — bucket count: 25 stock, 36 VanillaHelpers
// The stock table lives at 0x00B05BE8 (25 x 12 bytes) and ends EXACTLY at
// VAR_TEXTURE_DECODE_SCRATCH — an out-of-range bucket index reads the scratch
// pointer as a list head. So the size gate may never admit a dimension the
// pool can't index unless that dimension is also routed around the pool.
FUN_GX_TEXTURE_VALIDATE = 0x0058AB10,
// The recycle-pool FREE path — the mirror of the allocator, and the other
// half the size relaxation has to cover. It files a freed texture into a
// bucket indexed by `tz(w>>5) + tz(h>>5)*stride` (tz = power-of-two factor),
// gated ONLY by `w>31 && h>31 && mips<8` — there is NO upper bound. Stock
// never overran because the allocator refused anything >=1024, so an
// oversized texture never existed to be freed; the cave breaks that
// invariant, so a 2048x2048 (tz 6 per axis) files at bucket 36-42, past the
// 36-entry table, and writes through a garbage list head (verified crash:
// MOV [EAX],ECX at 0x004487D9, EAX = out-of-table pointer + 4). Fix
// (Texture::DimensionGate): route a texture larger than the pool can index to
// the engine's own non-pooled free FUN_TEXTURE_FREE_RAW — exactly what the
// guard's else-branch already does for too-small / too-many-mip textures.
// The same gate has no power-of-two test either (decompiled; benilla-re
// TexturePoolRelease), so an NPOT texture files by its power-of-two FACTOR —
// a 600x600 lands in the 64x64 bucket — and the allocator's hit test, which
// compares only filter bits and format, hands it to the next 64x64 request.
// 4.3.4's TextureFreeGxTex gates on GxTexReusable (target == GxTex_2d, never
// GxTex_NonPow2), so NPOT is routed to the raw free as well.
FUN_TEXTURE_POOL_FREE = 0x00448670, // __fastcall(tex); the pool free path
FUN_TEXTURE_FREE_RAW = 0x0058AD60, // __fastcall(tex); non-pooled free (device release)
FUN_TEXTURE_GET_DESC = 0x0058ADA0, // __fastcall(tex, out*) — fills width@+4, height@+8
OFF_TEXDESC_WIDTH = 0x04,
OFF_TEXDESC_HEIGHT = 0x08,
// THE ACTUAL SIZE CEILING. FUN_00448BD0 runs once at startup and allocates a
// SINGLE global decode scratch buffer, sized `FUN_005a4b80(2, 0x200, 0x200)`
// — one 512x512 texture's worth. Every loader points the decoder at it
// (`texObj + 0x120`; see FUN_0044A260's param_1==0 branch and FUN_0044A560),
// and the decoder writes rows with no bounds check, so a texture larger than
// this buffer overruns the heap. The allocator's `< 0x400` gate is therefore
// NOT redundant with the validator's device-caps max — the caps max runs to
// thousands, this buffer does not. VanillaHelpers.dll patches both 0x200
// immediates to 0x400 in the same function it relaxes the size limit in;
// the pairing is mandatory, not incidental. Verified by crash: a 2560x1080
// TGA faulted in the decoder's pixel writer at 0x004492E5 (ACCESS_VIOLATION,
// write) 2.6x past a 1024x1024 buffer.
// Single caller (boot, 0x00402862); the matching free + NULL is the exit
// teardown FUN_00448D30. No mid-session re-init path exists, and the five
// readers all re-read the global at use time, so the pointer can be swapped
// for a larger engine-allocated buffer without a hook.
FUN_TEXTURE_DECODE_SCRATCH_ALLOC = 0x00448BD0,
VAR_TEXTURE_DECODE_SCRATCH = 0x00B05D14, // void* — the buffer itself
// The two size immediates the boot alloc feeds FUN_GX_FORMAT_IMAGE_BYTES:
// `MOV EDX,imm32` is width (BA imm32), `PUSH imm32` is height (68 imm32).
// Read them back (+1) to learn what the buffer was ACTUALLY sized to on this
// DLL stack — 0x200 stock, 0x400 once VanillaHelpers has run.
PATCH_TEXDECODE_SCRATCH_DIM_W = 0x00448BE1,
PATCH_TEXDECODE_SCRATCH_DIM_H = 0x00448BDC,
// __fastcall(ecx = format, edx = width, [stack] = height) -> total bytes for
// the image plus its mip chain plus the per-level row-pointer table.
FUN_GX_FORMAT_IMAGE_BYTES = 0x005A4B80,
// The engine's own decode-buffer constructor: `__fastcall(ecx = format,
// edx = width, [stack] height, file, line) -> void*` (RET 0xC). Exactly
// `SMemAlloc(FUN_GX_FORMAT_IMAGE_BYTES(fmt,w,h), file, line, 0)` followed by
// the row-pointer-table init FUN_005A4BB0 performs per decode. Both decoders
// call it (via the small-texture recycle front FUN_0044AF90, which falls
// through to it above 256px) when the scratch is NULL, so a buffer it
// returns is precisely what the scratch slot expects — and SMemAlloc-backed,
// so the exit teardown's SMemFree on it is valid.
FUN_TEXTURE_DECODE_BUFFER_ALLOC = 0x005A4AF0,
// That recycle front and its free: a per-format cache of decoded buffers for
// sides 8..256, bucketed by `tz(w>>3)*6 + tz(h>>3)` with no power-of-two test
// on either side (verified, disassembly). Freeing an NPOT buffer files it
// under its power-of-two factor and a later request of that bucket's size
// gets it — or, the dangerous way round, a 200x100 request gets the 8x32
// buffer the bucket holds and decodes past its end. Out-of-window sizes take
// FUN_TEXTURE_DECODE_BUFFER_ALLOC / FUN_STORM_SMEM_FREE directly, so NPOT is
// routed there too (Texture::DimensionGate). Callers: the BLP IMG/cache path
// FUN_00449840 and the TGA decoder FUN_004491F0 when its slot is NULL (the
// live TGA path pre-seeds the slot with the scratch, so it never allocates);
// the free is ~CTexture with the texture's +0x118 type code and +0x144/+0x148
// size.
FUN_TEXTURE_ALLOC_MIPS = 0x0044AF90, // __fastcall(format, width, [stack] height) -> buffer, RET 4
FUN_TEXTURE_FREE_MIPS = 0x0044B110, // __fastcall(buffer, format, [stack] width, height), RET 8
// Device-relative: the caps block at +0x23C (what FUN_0058A230 returns) plus
// the type-0 (2D) max-texture-dimension slot at +0x60 — the exact field the
// create validator FUN_0058AB10 compares width and height against
// (`CMP EDI,[EAX + ESI*4 + 0x60]`, ESI = type). This is the GPU's own limit,
// and the only size ceiling the dimension gate enforces: reading it before
// growing the decode scratch means we never allocate for a texture the
// validator would refuse a moment later. Raw hardware max on modern cards
// (a 2560x1080 passed it) — 3.3.5 clamps the equivalent to 1024, 1.12 does
// not.
OFF_GXDEV_CAPS_MAX_TEX_DIM = 0x29C,
// --- Async texture I/O: the force-load path and its 512 KiB trap ----------
// FUN_TEXTURE_GET_RENDERABLE(hTex, force=1) calls this when the GxTex does
// not exist yet — i.e. for every UI texture on first draw. `__fastcall(ecx =
// HTEXTURE)`. If the pending read at [hTex + OFF_HTEXTURE_ASYNC_REQUEST] was
// never dispatched (request byte +0x1D == 0: it didn't fit the 2 MiB shared
// buffer at 0x00905BE4, or the buffer was busy), it unlinks the request,
// points it at a STATIC fallback buffer, dispatches, and blocks until the
// read completes. There is no size check. The fallback spans
// 0x00885804..0x00905804 — 0x80000 bytes, bounded exactly by the first live
// global after it — so a file larger than 512 KiB read through this path
// overruns the async list heads, the recycle-pool table and the shared
// buffer. That is VanillaHelpers' "crashes while loading textures bigger
// than 2 MiB"; its 32 MiB shared buffer makes the path rarer, not safe. The
// stock size gate hid the bug by keeping every BLP under ~1.4 MB. Guard
// (Texture::DimensionGate): refuse to force a request larger than the
// fallback — the texture stays blank instead of overrunning. Growing the
// fallback to fit was tried and reverted: the read runs on the engine's
// async reader thread (no crash handler), and a read into a right-sized heap
// buffer faulted where the same read into the oversized shared buffer does
// not — not yet isolated. TGA reads are synchronous and never on this path.
FUN_TEXTURE_FORCE_LOAD = 0x0044AD50,
OFF_HTEXTURE_ASYNC_REQUEST = 0x138, // async request node, or 0
OFF_ASYNCREQ_SIZE = 0x08, // file size (FUN_006487F0 result)
OFF_ASYNCREQ_IN_SHARED = 0x1D, // byte: 1 once assigned a buffer and dispatched
VAR_ASYNC_FALLBACK_BUFFER = 0x00885804,
ASYNC_FALLBACK_BUFFER_SIZE = 0x80000,
// --- BLP decompresses BEFORE it allocates -----------------------------------
// The .blp loader FUN_0044A560 copies the shared scratch pointer into
// texObj+0x120, calls this decompressor to write the decoded image THROUGH
// THAT COPY, and only then calls the allocator FUN_00448450. TGA does it the
// other way round (allocate, decode later at upload), which is why the
// allocator's gate protects TGA but never sees a BLP's dimensions in time; a
// 2048x2048 BLP has always overrun the scratch on this client. The other
// caller, the IMG path FUN_00449840 (completion FUN_004497F0), does NOT use
// the scratch: it allocates a private buffer sized for the image through
// FUN_0044AF90, stores it in the same slot, and its release frees whatever
// the slot holds — so a hook here must act only when the slot equals
// VAR_TEXTURE_DECODE_SCRATCH, and must repoint that slot after growing. (The BLP pre-scale FUN_00448B60 halves against caps+0x60, the
// raw hardware max, so it never fires on a modern GPU and protects nothing.)
// `__thiscall(reader, format, int *scratchSlot, mipBase, flag)`, RET 0x10;
// the reader carries the level-0 dimensions, `>> mipBase` is the level
// actually written. Both callers are completion callbacks that the
// main-thread pump FUN_00443E70 runs, so a pre-hook here is main-thread and
// never inside another decode. Encoding 3 (uncompressed) only writes the row
// table into the scratch and points the rows at the file buffer; DXT and
// palettized decompress into it — the crash case.
FUN_BLP_DECOMPRESS = 0x005A8430,
OFF_BLPREADER_WIDTH = 0x10,
OFF_BLPREADER_HEIGHT = 0x14,
// The `NEG EAX; SBB EAX,EAX` (F7 D8 1B C0) pair inside the validator's isPOT
// idiom `(x & (x-1)) -> NEG/SBB -> INC -> TEST/JZ`, once per axis. The two
// axes share the final TEST/JZ with the type-2 branch, so the arithmetic is
// the surgical patch point — neutering the shared JZ would also disable the
// type-2 flags check.
PATCH_TEXVALIDATE_POT_W = 0x0058AB7C,
PATCH_TEXVALIDATE_POT_H = 0x0058AB8D,
// The imm8 of the validator's minimum side, `CMP EDI,8` (83 FF 08) /
// `CMP EBX,8` (83 FB 08), each followed by JC fail. 4.3.4 keeps the same 8
// ("Texture size must be at least 8x8"). Lowered to 1 so 0 is still refused.
// Nothing downstream needs 8: the allocator sends sides <= 16 straight here,
// the pool free takes only >= 32, the mip cache sends < 8 to the plain
// allocator, and a stock mip chain already uploads levels down to 1x1. If the
// D3D create fails anyway (a driver refusing a sub-4 DXT top level), LoadTexture
// 0x005A0D70 skips the upload while the D3D object at +0x48 is NULL, so the
// texture just stays blank.
PATCH_TEXVALIDATE_MIN_W_IMM = 0x0058AB42,
PATCH_TEXVALIDATE_MIN_H_IMM = 0x0058AB4E,
// --- Inline-texture positioning (slice 1: measure/emit integration) --------
// The 1.12 text pipeline builds a layout as a list of render "nodes" (one
// per wrapped line); each node owns per-font-page glyph vertex batches and a
// screen origin, and the paint pass (FUN_005c8fe0) walks the layout's node
// list drawing each node's batches translated by that origin. See
// docs/InlineTextureEscapes.md and the decompiled map in InlineTexture.cpp.
// Per-line glyph emitter. `__thiscall(node, byte *text, int len, uint
// *colorState, float *penXYZ, uint *pageMask, int *linkState)`. Reads the
// pen start from penXYZ[0..2] (node-local), appends glyph quads to the
// node's page batches, and on return writes the final pen x (node-local,
// as a FLOAT via `FSTP dword` — read linkState[4] as float, not int) into
// linkState[4]. We co-hook it and, for a line that
// contains an inline `|T…|t`, render the plain runs by delegating to the
// original per segment (threading the pen via linkState[4]) and record an
// icon quad at the pen between segments. Safe to call repeatedly per line
// because the batch-clear at its top is gated on OFF_TEXT_NODE_FLAGS bit 3,
// which is clear during normal accumulation draw. See FUN_005ccbe0.
FUN_TEXT_EMITTER = 0x005CCBE0,
// Node flags. Bit 3 (0x08) gates the emitter's per-call batch-clear (set
// only in a rebuild mode we don't take); we segment only when it's clear.
// Bit 6 (0x40) is NON-SPACE-WRAP (fs+0x120 bit 0x1000 via FUN_0044d420;
// the macro editbox is 0x4D, chat display 0x20D, FontStrings 0x0D).
OFF_TEXT_NODE_FLAGS = 0x5C,
// Node horizontal justify (int): 0 = left, 1 = centre, 2 = right — the draw
// builder's encoding. The emitter pre-shifts an inline icon's pen by the
// line's justify offset for centre/right nodes (left needs no shift).
// Verified in-game against centred/right-aligned text layout.
OFF_TEXT_NODE_JUSTIFY = 0x54,
// Node vertical justify (int): 0 = top, 1 = middle, 2 = bottom. Read by the
// origin finalize FUN_005cdf70 (0 → origin y += block height, 1 → centred
// on the text height, else → += text height) — the same three-way branch
// as 4.3.4's CGxString::InitializeViewTranslation over m_vertJust. Inline
// icons align to the line by it, as 4.3.4's InitializeTextLine does.
OFF_TEXT_NODE_JUSTIFY_V = 0x50,
// Node screen origin (float x, float y). The paint pass translates the
// node's node-local glyph verts by this; an inline icon recorded in
// node-local pen coords is drawn at (localX + originX, localY + originY).
OFF_TEXT_NODE_ORIGIN_X = 0x70,
OFF_TEXT_NODE_ORIGIN_Y = 0x74,
// Node position y (float, node units: × [VAR_TEXT_RASTER_Y] = render px)
// — the {x, y, z} at +0x20 the position setter FUN_005ccb10 writes. The
// origin finalize copies it into the origin and adds the vertical-justify
// term (see FUN_TEXT_NODE_FINALIZE_ORIGIN).
OFF_TEXT_NODE_POSITION_Y = 0x24,
// The whole position {x, y, z} (x, y in DDC ÷ screen scale; back to DDC
// with FUN_COORD_NDC_TO_DDC). 4.3.4's TextBlockGetStringPos reads it.
OFF_TEXT_NODE_POSITION = 0x20,
// Node origin finalize: `void __fastcall(node)`. Copies the position
// (+0x20..+0x28) into the origin (+0x70..+0x78); when the node has built
// lines and flags bit 7 is clear it adds the horizontal justify (+0x54) and
// the vertical one (+0x50: 0 → block height +0x40; 1 → (block − T)/2 + T;
// 2 → T, with T = lines × fontH + (lines − 1) × spacing), then floors both
// to render px (× raster X/Y). 4.3.4's CGxString::InitializeViewTranslation
// without its m_extraLineHeight term. Callers: the draw builder's exit
// (0x005CDEBE) and the position setter FUN_005ccb10. Prologue
// 55 8B EC 83 EC 10. Co-hooked by Text::InlineTexture.
FUN_TEXT_NODE_FINALIZE_ORIGIN = 0x005CDF70,
// Node → per-font-page vertex buffers. The glyph emitter (FUN_TEXT_EMITTER)
// bakes each glyph as a 4-vertex quad into one of up to TEXT_NODE_PAGE_COUNT
// font-page buffers hanging off the node; the paint copy-out (FUN_005c8710)
// reads them back TRANSLATE-ONLY (gpu.xy = local.xy + node origin). So a
// rotation baked into these node-local verts survives to the screen — the
// basis for fontstring:SetRotation (Texture::Transform::RotateFontStringNode).
// node + OFF_TEXT_NODE_PAGE_BUFFERS + page*4 -> page buffer ptr (may be 0)
// pageBuf + OFF_TEXT_PAGE_VERT_COUNT -> int vertex count
// pageBuf + OFF_TEXT_PAGE_VERTS -> float* vertex array
// each vertex = 5 floats {x, y, z, u, v}, stride TEXT_VERT_STRIDE bytes.
// Cross-verified: the emitter (writes verts here), FUN_005c8710 (copies them
// to the GPU buffer), and FUN_005ce0c0 (indexes the page array) all agree.
OFF_TEXT_NODE_PAGE_BUFFERS = 0xA0,
TEXT_NODE_PAGE_COUNT = 8,
OFF_TEXT_PAGE_VERT_COUNT = 0xC,
OFF_TEXT_PAGE_VERTS = 0x10,
TEXT_VERT_STRIDE = 0x14, // bytes; 5 floats per vertex (x, y, z, u, v)
// Per-page baked PER-GLYPH colours (BGRA dword per vertex), parallel to the
// vertex array above. Written by the emitter's bit-3-clear path
// (`[pageBuf+0x20] + ([pageBuf+0x1C] + i)*4 = colorState` at 0x005CCC0x);
// the paint copy-out FUN_005c8710 uses them VERBATIM — but only when the
// colour count equals the vertex count, else it falls back to the node's
// uniform colour (OFF_TEXT_NODE_COLOR). No later modulation: whatever alpha
// is baked here is final, which is why InlineTexture's flush mirrors the
// node's live alpha into these entries per frame.
OFF_TEXT_PAGE_COLOR_COUNT = 0x1C,
OFF_TEXT_PAGE_COLORS = 0x20,
// Node uniform colour (BGRA). Seeded from fs colors[0] at block creation
// (FUN_007724a0 → FUN_0044d420) and rewritten on every colour/alpha change
// via the fs colour-changed vmethod (FUN_00772180 → FUN_0044d650 →
// FUN_005ccb40). Its alpha byte (+0x2F) is the FOLDED live opacity —
// SetTextColor alpha (fs+0xA8 array) × the owning frame's effective alpha
// (*(fs+0x9C)+0xC8), maintained by FUN_0077fac0 — so it tracks parent
// SetAlpha per change. The paint reads it per frame for uniform text; the
// emitter's |c splice (case 0) and the draw builder's colorState seed both
// copy it at bake time. NOTE: FUN_005ccb40 only invalidates (re-bakes) a
// node on colour change when bit 3 is CLEAR — a bit-3 (standalone
// FontString) node with baked per-glyph colours goes stale instead, hence
// the flush-side alpha mirror.
OFF_TEXT_NODE_COLOR = 0x2C,
// Layout node list — intrusive singly-linked list of render nodes. Head at
// [layout+0x24]; next = *(node + [layout+0x1c] + 4); the tail sentinel has
// its low bit set (mirrors the paint pass's own walk in FUN_005c8fe0).
OFF_TEXT_LAYOUT_NODE_HEAD = 0x24,
OFF_TEXT_LAYOUT_NODE_LINK = 0x1C,
// Node source-text pointer. The draw builder FUN_005cdc20 starts from
// [node+0x48] and advances it per wrapped line, calling the emitter once
// per line on the SAME node — so `emitterText == [node+0x48]` identifies
// the first wrapped line (used to clear the node's icon list once per
// build, then accumulate across lines). This buffer is a node-owned COPY of
// the DISPLAY text (SStrCopy'd in the node init FUN_005cd6d0, capacity
// [node+0x4c]) — the full source when it fits, or the ellipsized
// "<prefix>..." form when the display-text resolver truncated it. So
// comparing it against the fs source (OFF_FONTSTRING_TEXT) is the render-
// truth "displayed vs full" signal FontString:IsTruncated uses.
OFF_TEXT_NODE_TEXT = 0x48,
// Node font-size field (float), fed to the font-height helper.
OFF_TEXT_NODE_FONT_SIZE = 0x1C,
// Node's gxu font-face pointer. The emitter FUN_005ccbe0 reads *(node+0x44)
// as the `this` for every glyph call (glyph lookup FUN_005cabd0, the pair
// advance, the native-height getter below).
OFF_TEXT_NODE_FONT_FACE = 0x44,
// Font pixel-height helper. `__fastcall(int flag /*ecx = (nodeFlags>>7)&1*/,
// float fontSize /*stack = [node+0x1c]*/) -> float` (returns in ST0). The
// emitter calls it to size glyphs; we call it to derive the text's vertical
// extent so an inline icon can be centred on the line independent of font
// size. See FUN_005c6fa0.
FUN_TEXT_FONT_HEIGHT = 0x005C6FA0,
// Font-face NATIVE pixel height getter: `__fastcall(void *fontFace) -> int`
// (returns *(font+0x24C)). The emitter's pen scale is
// FUN_TEXT_FONT_HEIGHT(...) / (float)nativeHeight — glyph-record advances
// are in native-font units and multiply by that scale into pen units.
// See FUN_005cae90.
FUN_TEXT_FONT_NATIVE_HEIGHT = 0x005CAE90,
// Glyph PAIR advance: `__thiscall(void *fontFace, uint prevCh, uint curCh)
// -> float (ST0)`, native-font units = baseAdvance(prevCh) +
// kern(prevCh,curCh)·[font+0x188], memoized per pair. The emitter computes
// this at the top of each token iteration and places the CURRENT glyph at
// pen + pairAdvance(prev, cur) — i.e. the pen is LAZY: a glyph's own
// advance is only consumed when the NEXT token lands, so the final pen
// write (linkState[4]) is NOT the end of the last glyph. The emitter
// co-hook therefore replays the run's glyph placements itself to find
// the last glyph's x (see FUN_TEXT_GLYPH_DESC). In snap mode (node flags
// bit 7 clear) the emitter rounds each step: `FADD 0.5; __ftol`.
// See FUN_005ca2d0.
FUN_TEXT_GLYPH_PAIR_ADVANCE = 0x005CA2D0,
// The flags&0x10 variant of the pair advance (same shape; the emitter
// selects it when node flags bit 4 is set). See FUN_005ca4b0.
FUN_TEXT_GLYPH_PAIR_ADVANCE_ALT = 0x005CA4B0,
// Glyph BASE advance: `__thiscall(void *fontFace, uint ch) -> float (ST0)`,
// native-font units — the pair advance's first term, a glyph's advance
// with no following kern. The width a measure counts for a glyph, so the
// emitter co-hook caps an inline icon's start at it. See FUN_005ca240.
FUN_TEXT_GLYPH_BASE_ADVANCE = 0x005CA240,
// CGxFont::NewCodeDesc — `__thiscall(void *fontFace, uint ch) ->
// CHARCODEDESC*` (NULL when the face has no such glyph). Hash lookup, and
// on a miss rasterizes the glyph into the face's pages; the emitter calls
// it for every glyph it draws, so a just-drawn glyph is always a hit. The
// descriptor layout matches 4.3.4's (Gxu/GxuFontMiscClasses.h):
// GLYPHBITMAPDATA at +0x38, so its m_glyphCellWidth (u32) is +0x48, its
// m_glyphAdvance (float) +0x4C and m_glyphBearing (float) +0x50. The
// emitter draws a glyph's quad from x + bearing to
// x + bearing + cellWidth × scale, flooring the width in snap mode
// (FUN_0073ff3f with the round-down control word at 0x00875F00).
FUN_TEXT_GLYPH_DESC = 0x005CABD0,
OFF_GLYPH_DESC_CELL_WIDTH = 0x48,
// CGxFont::GetGlyphBearing — `__thiscall(void *fontFace, CHARCODEDESC
// *desc, char scaled, float fontSize) -> float (ST0)`: ceil(bearing)
// when `scaled` is 0, else bearing × (fontPx ÷ native height). The emitter
// passes (nodeFlags >> 7) & 1 and the node's font size. See FUN_005cb080.
FUN_TEXT_GLYPH_BEARING = 0x005CB080,
// Hyperlink hit-rect registration (the GXUFONTHYPERLINKINFO append).
// `__thiscall(node, float yA, float xLeft, float yB, float xRight,
// char *linkStart, uint linkLen, char *escStart, uint escLen)` — 8 stack
// dwords, RET 0x20. Appends a 0x20-byte record to the node's link array
// (cap +0x7C, count +0x80, data +0x84): the four floats normalized to
// screen space ({yA,left,yB,right} — the engine's y-first rect order; the
// emitter's |H open writes linkState[2]=xLeft, |h close linkState[4]=
// xRight, the draw builder provides the line's yA/yB), then the four link
// dwords raw. Called from the emitter's |h close (case 5). The y extent is
// the TEXT band (fontH tall) — co-hooked so a link containing a tall
// inline icon gets its hit band expanded by the icon's overflow (the
// line-height-growth counterpart; without it only the text-high slice of
// a 32px emote link was hoverable). See FUN_005cd310.
FUN_TEXT_LINK_RECT_ADD = 0x005CD310,
// Shared `|`-escape tokenizer. `__fastcall(byte *text /*ecx*/, int
// *bytesConsumed /*edx*/, uint *colorOut, uint flags, uint *payloadOut) ->
// tokenType`. ~11 callers (measure loops, line-fit/wrap, the emitter, the
// draw builder, the edit box's class array 0x77ba90). It has NO `|T` case,
// so `|T` falls through to a literal `|`. We co-hook it so an
// inline-texture span `|T…|t` is consumed as ONE near-zero-width token —
// this stops every measure/wrap caller from counting the path text and
// wrapping early. `||` stays the escaped pipe (class 3), so `||T` is
// literal text, as in the stock engine and 4.3.4. The emitter detects
// icons on its own (and delegates plain segments that never contain `|T`),
// so the draw path is unaffected by this hook. See FUN_005c2810.
FUN_TEXT_TOKENIZER = 0x005C2810,
// GxuStripControlCodes `int __fastcall(const char *text /*ecx*/, int
// length /*edx*/, uint32_t mask, char *out, int capacity)`, RET 0xC
// (benilla font/markup "Stripping"): copies the text with the codes the
// mask names removed and always terminates `out`. It returns `out` (or
// `text` for an empty one) — NOT the byte count benilla lists (Ghidra:
// `return (int)pcVar2`). Stops when `written + tokenLen >= capacity`.
// 4.3.4 adds mask bit 0x1000 for `|T…|t`; co-hooked by Text::InlineTexture
// to honour it.
FUN_GXU_STRIP_CONTROL_CODES = 0x005C2590,
// CSimpleEditBox::CopySelection (0x77e1d0) `push 0x500` (68 00 05 00 00) —
// the strip mask for Ctrl+C: colours and links. 4.3.4's CopyToClipboard
// passes 0x1500 (textures too); Text::InlineTexture patches the immediate.
PATCH_EDITBOX_COPY_STRIP_MASK = 0x0077E230,
// 4.3.4's copy strip mask for FUN_GXU_STRIP_CONTROL_CODES: 0x100 colours,
// 0x400 links, 0x1000 textures (newlines become `\n`, `||` becomes `|`).
// The patched Ctrl+C mask and CopyToClipboard's removeMarkup.
GXU_STRIP_MASK_COPY = 0x1500,
// Shared wrap-stepper dispatcher — lays out ONE wrapped line per call.
// `__fastcall(gxuFont /*ecx*/, byte *text /*edx*/, float fontH, float
// wrapWidth, int *outBreak, float *outWidth, void *outNext, float indent,
// uint flags, byte *p10)`, callee cleans 0x20 (verified RET 0x20; prologue
// PUSH EBP; MOV EBP,ESP; FLD [EBP+8] — MinHook-safe). Thin validator that
// routes flags&0x80 to the no-wrap path (FUN_005C7300, ignores wrapWidth)
// and everything else to the real stepper FUN_005C7470. Its exactly 4
// callers are EVERY wrap consumer: the draw builder FUN_005CDC20 (render
// breaks), the height measure FUN_005C2070 (GetStringHeight), the
// chars-that-fit counter FUN_005C21C0 (ellipsis truncation), and the
// break-array computer FUN_005C2430 (behind FUN_00772B60) — so a co-hook
// here keeps render, height, truncation, and break arrays mutually
// consistent. Text::InlineTexture shrinks the wrapWidth arg by the line's
// inline-icon advances (the tokenizer hook hides them from the measure, so
// breaks otherwise land as if icons were 0 wide and the emitter's real
// advances overflow the right edge). UNITS: each caller passes
// fontH/wrapWidth in its OWN space (node text units from the builder, the
// small anchor-converted space from the fs-level callers — the path chat
// wraps through); a raw-pixel subtraction annihilates the small spaces
// (shredded chat lines into 2-glyph fragments on first flight). Convert
// px→caller units by (fontH / FUN_TEXT_FONT_HEIGHT(flag, fontH)) — the
// engine's own pixel realization of the fontH param (FUN_005C6940's final
// scale uses exactly that call), so the ratio is valid in every caller's
// space.
FUN_TEXT_WRAP_STEPPER = 0x005C7260,
// The stepper's four calls, one per wrap loop: the draw builder, the
// block height 0x005C2070, the fit-to-height count 0x005C21C0 and the
// line enumeration 0x005C2430 (4.3.4's string layout,
// GxuFontGetWrappedTextHeight, GxuFontGetMaxCharsWithinWidthAndHeight
// and GxuFontWrapText - the four loops 4.3.4 indents in). In the draw
// builder the node is in EBX and the line's x lives at [ebp-0x48]
// (DRAW_BUILDER_FRAME_LINE_X); it is copied into a wrapped link's rect
// (-0x6C) before the emitter call, so the x has to be set before then.
CALL_TEXT_DRAW_BUILDER_STEP = 0x005CDDD3,
CALL_TEXT_BLOCK_HEIGHT_STEP = 0x005C210A,
CALL_TEXT_FIT_HEIGHT_STEP = 0x005C22B1,
CALL_TEXT_ENUMERATE_LINES_STEP = 0x005C24F9,
DRAW_BUILDER_FRAME_LINE_X = 0x48,
// The draw builder's right / centre x: `FUN_TEXT_SCREEN_TO_PIXEL_WIDTH(raw,
// -width)` (or -width / 2), `float __fastcall(int raw, float)`, `ret 4`,
// result in ST0, stored to the line x at 0x005CDE28.
CALL_TEXT_DRAW_BUILDER_JUSTIFY_X = 0x005CDE23,
FUN_TEXT_SCREEN_TO_PIXEL_WIDTH = 0x005C7010,
// The font string's text-engine entry points. Each builds the engine's
// flag word from the font string's flags (OFF_FONTSTRING_FLAGS, one of
// its arguments) inline, keeping only the bits it knows, and passes the
// text (edx) through unchanged:
// FUN_FS_TEXT_BLOCK_CREATE `__fastcall(..., 8 stack args)`, ret 0x20,
// flags = stack arg 5; its one caller is RebuildString (0x00772693).
// It creates the node through FUN_TEXT_CREATE_STRING (CALL_...): `__fastcall(font,
// text, 11 stack args)`, ret 0x2C, engine flags = stack arg 8
// (stored to OFF_TEXT_NODE_FLAGS).
// FUN_FS_TEXT_BLOCK_HEIGHT ret 0x14, flags = stack arg 4 -> 0x005C2070.
// FUN_FS_TEXT_FIT_HEIGHT ret 0x1C, flags = stack arg 6 -> 0x005C21C0.
// FUN_FS_TEXT_WRAP_LINES ret 0x1C, flags = stack arg 6 -> 0x005C2430;
// its one caller is the font string's WrapText (0x00772BAD).
FUN_FS_TEXT_BLOCK_CREATE = 0x0044D420,
CALL_FS_TEXT_BLOCK_CREATE_STRING = 0x0044D597,
FUN_TEXT_CREATE_STRING = 0x005C1C30,
FUN_FS_TEXT_BLOCK_HEIGHT = 0x0044D750,
FUN_FS_TEXT_FIT_HEIGHT = 0x0044D960,
FUN_FS_TEXT_WRAP_LINES = 0x0044DB50,
// Their only calls, all in the font string, each passing its flags
// (+0x120, RebuildString with 0x400 or'd in): RebuildString's create,
// the cached height's measure, the two fits of FitText, and WrapText.
CALL_FONTSTRING_BLOCK_CREATE = 0x00772693,
CALL_FONTSTRING_BLOCK_HEIGHT = 0x00772A42,
CALL_FONTSTRING_FIT_HEIGHT_1 = 0x00772034,
CALL_FONTSTRING_FIT_HEIGHT_2 = 0x007720D5,
CALL_FONTSTRING_WRAP_LINES = 0x00772BAD,
// IndentedWordWrap. 4.3.4's style bit 0x20000 (font and font string);
// its text engine flag is 0x2000. Neither is used by 1.12 (no test or
// store of either in the font, font string or text engine code).
FONT_STYLE_INDENTED_WORD_WRAP = 0x20000,
// 4.3.4's style bit 0x40 (no word wrap; Set/CanWordWrap). TextBlockCreate
// (0x0044D420) turns it into text flag 0x2, as 4.3.4's ConvertStringFlags
// does, and 1.12's layout (0x005CDC20) and line count (0x005C2070) stop
// after one line on that flag (benilla-re font/string, font/measure).
FONT_STYLE_NO_WORD_WRAP = 0x40,
TEXT_FLAG_INDENTED_WORD_WRAP = 0x2000,
// A font string's own style setter: `void __thiscall(fs, uint32 flags)`,
// `ret 4` - stores OFF_FONTSTRING_FLAGS and rebuilds its text when it has
// a block (4.3.4's inline `if (changed) { m_styleFlags = ...;
// UpdateString(); }`). SetNonSpaceWrap (0x00771089) calls it.
FUN_FONTSTRING_SET_STYLE_FLAGS = 0x00773500,
// The style bits a font string takes from its font object (4.3.4's
// m_settableStyleFlags): applying a font's style does `(fontStyle &
// settable) | (own & ~settable)` (0x00770859), and a script setter clears
// its bits here so the explicit value wins. The constructor stores 0x3F
// (justification only) with `mov dword [esi+0x124], 0x3F` at
// PATCH_FONTSTRING_SETTABLE_STYLE_INIT (imm32 at +6); 4.3.4's is 0x2107F.
OFF_FONTSTRING_SETTABLE_STYLE = 0x124,
PATCH_FONTSTRING_SETTABLE_STYLE_INIT = 0x00770DDD,
// CSimpleFont (Font objects, and the font every EditBox, MessageFrame,
// ScrollingMessageFrame and SimpleHTML element holds). Its style setters
// (SetJustifyH: 0x0079FC20, called by all five classes) are 4.3.4's
// CSimpleFont_Set*: change the style dword at OFF_SIMPLEFONT_STYLE_FLAGS,
// `|= 0x202` the attribute flags at OFF_SIMPLEFONT_ATTR_FLAGS, `&= ~2`
// the fontable flags at OFF_SIMPLEFONT_FONTABLE_FLAGS, then vtable+0x14
// (UpdateObjects) copies the style to every font string that follows it
// (the block merge 0x00770910 copies the whole dword).
OFF_SIMPLEFONT_FONTABLE_FLAGS = 0x2C,
OFF_SIMPLEFONT_ATTR_FLAGS = 0x38,
OFF_SIMPLEFONT_STYLE_FLAGS = 0x54,
VTBL_SIMPLEFONT_UPDATE_OBJECTS = 0x14,
// The font height, internal units; the shared Font/EditBox/... GetFont
// body 0x0079F3B0 pushes it as its second value (`mov eax,[esi+0x48]`),
// and the shared SetFont 0x0079F210 stores it at 0x0079F329.
OFF_SIMPLEFONT_HEIGHT = 0x48,
// The engine's own GetFont / SetFont Lua methods of FontString (table
// 0x0087C1D8) and Font (table 0x0087C7C8), `int __fastcall(L)`. Each
// resolves its own self; SetFont reads (file, height[, flags]) from stack
// slots 2-4, GetFont pushes (file, height, flagsText).
FUN_SCRIPT_FONTSTRING_GET_FONT = 0x0079D400,
FUN_SCRIPT_FONTSTRING_SET_FONT = 0x0079D4F0,
FUN_SCRIPT_FONT_GET_FONT = 0x007A0330,
FUN_SCRIPT_FONT_SET_FONT = 0x007A0270,
// The two engine calls of every font-height push (GetFont 0x0079D4A5 /
// 0x0079F3D1): `DivideByScreenScaleX(GetScaledScreenAspect() * 1024 * h)`.
// GetScaledScreenAspect: `float __cdecl()`, returns
// [VAR_COORD_ASPECT_COMPENSATION] in ST0. DivideByScreenScaleX:
// `float __stdcall(float)`, ST0 = arg / [VAR_COORD_DDC_WIDTH_SCALE], left
// at x87 precision (the caller stores it with `fstp qword`).
FUN_COORD_GET_SCALED_SCREEN_ASPECT = 0x0041AD70,
FUN_COORD_DIVIDE_BY_SCREEN_SCALE_X = 0x0041AE40,
// Each class's font, as its SetJustifyH passes it to 0x0079FC20, and the
// class's Lua type id and method registry. A Font object is its own font;
// SimpleHTML has one per text type, `fonts[FUN_SIMPLEHTML_READ_TEXT_TYPE(L)]`
// (`int __fastcall(L)`, which reads and removes an optional "h1".."p").
VAR_FONT_LUA_TYPE_ID = 0x00CF4EA8,
VAR_FONT_METHOD_REGISTRY = 0x00CF546C,
OFF_EDITBOX_FONT = 0x324,
OFF_MESSAGEFRAME_FONT = 0x344,
VAR_MESSAGEFRAME_LUA_TYPE_ID = 0x00CF4EEC,
VAR_MESSAGEFRAME_METHOD_REGISTRY = 0x00CF52DC,
OFF_SCROLLINGMESSAGEFRAME_FONT = 0x35C,
VAR_SCROLLINGMESSAGEFRAME_LUA_TYPE_ID = 0x00CF4F2C,
OFF_SIMPLEHTML_FONTS = 0x350,
VAR_SIMPLEHTML_LUA_TYPE_ID = 0x00CF4F64,
FUN_SIMPLEHTML_READ_TEXT_TYPE = 0x00795D80,
// Focused-editbox global — holds the CSimpleEditBox that currently has
// keyboard focus (the one showing a cursor), or 0 when no input field is
// active. Written by EditBox SetFocus (`mov [0xcf4dc8],esi` @0x0077e3f8),
// cleared by ClearFocus (FUN_0077e410). See the editbox vtable at
// 0x0081c8c0 / FUN_0077e410.
VAR_FOCUSED_EDITBOX = 0x00CF4DC8,
// 4.3.4's CSimpleEditBox::ClearKeyboardFocus — `void __thiscall(editbox)`:
// when the box holds the focus, runs its focus change (0x0077AF50) and
// clears VAR_FOCUSED_EDITBOX. What Script ClearFocus (0x00798F1A) calls.
FUN_EDITBOX_CLEAR_FOCUS = 0x0077E410,
// CSimpleEditBox cursor / selection internals (backs EditBox::Methods'
// SetCursorPosition / GetCursorPosition). Verified from the engine's own
// HighlightText (FUN_00798870 → FUN_0077cca0) and Insert (FUN_00798400 →
// FUN_0077bee0) paths:
// +0x31c dirty-flag dword — bit 2 = selection/highlight changed, bit 4 =
// cursor changed (both trigger the next-paint relayout).
// +0x338 text length in BYTES (the clamp bound below).
// +0x35c / +0x360 selection start / end (byte offsets).
// +0x36c cursor insertion point, a BYTE offset — matches modern WoW's
// byte-based EditBox cursor (GetCursorPosition returns bytes; for
// ASCII text byte == character).
OFF_EDITBOX_FLAGS = 0x31c,
OFF_EDITBOX_TEXT_LENGTH = 0x338, // current text length in bytes
OFF_EDITBOX_CURSOR_BYTE = 0x36c,
// `void __thiscall(editbox, byteOffset)` — sets the cursor to a byte
// offset, clamping to [0, textByteLen] and OR-ing the +0x31c cursor-dirty
// bit. The engine's own "restore cursor" primitive (called from the insert
// path FUN_0077bee0 to put the caret back after splicing text).
FUN_EDITBOX_SET_CURSOR_BYTE = 0x0077e360,
// `void __thiscall(editbox)` — collapses the selection onto the cursor
// (selStart = selEnd = +0x36c). The engine's own "clear selection to the
// caret" helper (FUN_0077ccf0), used before extending a shift-selection.
FUN_EDITBOX_COLLAPSE_SELECTION = 0x0077ccf0,
// `int __thiscall(editbox, startByteIndex, byteCount)` — counts CHARACTERS
// (UTF-8 codepoints) in a byte range, walking the per-byte char-class table
// at +0x330 (a byte begins a codepoint when its class is 2/3/6). So
// `COUNT_CHARS(eb, 0, cursorByteOffset)` is the cursor's character index —
// backs GetUTF8CursorPosition. Verified from the arrow-key mover
// FUN_0077cb20's own `FUN_0077bc80(this, byteOff, cursorByte - byteOff)`.
FUN_EDITBOX_COUNT_CHARS = 0x0077bc80,
// The per-byte table it walks is at OFF_EDITBOX_CHAR_CLASS, rebuilt from
// the text by FUN_0077BA90 with FUN_TEXT_TOKENIZER: at each token's first
// byte, `length | class << 16` (bit 31 set inside a hyperlink), zero at
// the token's other bytes. Classes 2 (line break), 3 (character) and 6
// (a `|` that starts no code) are visible; the rest are markup - color
// codes, the hyperlink's `|H...|h` and closing `|h` - which it skips.
OFF_EDITBOX_CHAR_CLASS = 0x330,
// 4.3.4's CSimpleEditBox::GetNumToLen — `int __thiscall(editbox, int
// byteOffset, int steps, int atomic)`, `ret 0xC`: the bytes from
// byteOffset that `steps` cursor steps cover (backwards for a negative
// count), walking OFF_EDITBOX_CHAR_CLASS. A forward step skips leading
// colour (class 0) and link-start (4) tokens, with `atomic` the whole of
// a link, then absorbs trailing colour-restore (1) and link-stop (5)
// tokens. Every keyboard move and delete goes through it (benilla-re
// ui/editboxmarkup "Steps").
FUN_EDITBOX_STEP_BYTES = 0x0077BB30,
// The visible lines (4.3.4's m_visibleLines): a count at +0x37C and an
// array at +0x380 of each line's first byte, the last entry the end. The
// hit test 0x0077D0D0 picks line i by the click's y and reads entries i
// and i + 1.
OFF_EDITBOX_LINE_COUNT = 0x37C,
OFF_EDITBOX_LINE_STARTS = 0x380,
// The right-justified hit test's conversion (0x0077D29B): it measures how
// many glyphs fit from the line's right end, then turns them into bytes
// with `FUN_EDITBOX_STEP_BYTES(lineStart, glyphs, 0)` - counted from the
// line's start - and takes the index as lineEnd minus that. 4.3.4's
// ConvertCoordinateToIndex does the same.
CALL_EDITBOX_HIT_RIGHT_STEP = 0x0077D29B,
// SetMaxLetters stores its limit here (Script 0x00799110); the insert
// path FUN_0077BEE0 enforces it after splicing text in: it counts the
// text with FUN_EDITBOX_COUNT_CHARS (calls at 0x0077C09A, 0x0077C0BC,
// 0x0077C0E4) and deletes from the end until the count fits. The byte
// cap SetMaxBytes (+0x33C, -1 = none) is enforced just before, by length.
OFF_EDITBOX_MAX_LETTERS = 0x340,
RET_EDITBOX_MAX_LETTERS_COUNT_1 = 0x0077C09F,
RET_EDITBOX_MAX_LETTERS_COUNT_2 = 0x0077C0C1,
RET_EDITBOX_MAX_LETTERS_COUNT_3 = 0x0077C0E9,
// The EditBox node loader (the FUN_XML_FRAME_LOAD sub-object convention:
// `__thiscall(loader, node, status)`, `ret 8`, object = loader -
// OFF_XML_LOADER_SUBOBJECT). It calls FUN_XML_FRAME_LOAD first
// (0x00779FC6), then reads its own attributes: "letters" (0x0077A046),
// "autoFocus" (0x0077A0A5), "multiLine", "numeric", "historyLines".
// Booleans go through FUN_XML_ATTR_TO_BOOL - `int __fastcall(const char *)`,
// 4.3.4's StringToBOOL(const char *): 1 for text starting 1-9/T/Y or equal
// to on/enabled, else 0 (null too) - as for autoFocus at 0x0077A0BC.
// Called through Game::StringToFlag.
FUN_XML_EDITBOX_LOAD = 0x00779FB0,
FUN_XML_ATTR_TO_BOOL = 0x006F1B30,
// Selection-highlight regions — three consecutive CSimpleTexture pointers
// (start-line +0x350, middle-block +0x354, end-line +0x358) the editbox
// shows/positions to paint the selection (FUN_0077d950). Their vertex
// color IS the highlight color — Set/GetHighlightColor read/write it via
// the generic region color accessors. The blinking caret is a SEPARATE
// region at +0x3d4, deliberately left alone.
OFF_EDITBOX_HIGHLIGHT_REGION = 0x350,
// Input-history ring buffer: max lines (ring capacity) at +0x388 (what
// GetHistoryLines reads), write position at +0x38c, container
// {size@+0x390, alloc@+0x394, data@+0x398} of {char* text, int exec}
// entries. AddHistoryLine writes at +0x38c and advances modulo +0x388.
OFF_EDITBOX_HISTORY_MAX = 0x388,
// 4.3.4's m_imeComposition: nonzero while an input method composes text.
// The input-method slot 0x0077AFC0 sets it on composition start (action 1,
// 0x0077B0F9) and clears it on end (actions 5 and 6, 0x0077B118), at the
// same points as 4.3.4's OnLayerIme; mouse-down reads it (0x0077B81E).
OFF_EDITBOX_IME_COMPOSITION = 0x3CC,
// 4.3.4's CSimpleEditBox::Insert without its `script` argument —
// `void __thiscall(editbox, const char *text, const char *context, int
// runScripts, int highlight)`, `ret 0x10`. Script Insert passes (text,
// context, 1, 0), SetText's internal (text, context, 0, 0).
FUN_EDITBOX_INSERT = 0x0077BEE0,
// The input-method slot's insert of the composition string: `call
// FUN_EDITBOX_INSERT` with (buffer, 0, 0, 1), where 4.3.4's OnLayerIme
// then runs OnCharComposition with the same buffer.
CALL_EDITBOX_IME_COMPOSITION_INSERT = 0x0077B097,
// Text-change bookkeeping (4.3.4's dirty bit 0x8, OnTextChanged's
// `userInput`). FUN_EDITBOX_REBUILD_CHAR_CLASS (4.3.4's UpdateTextInfo,
// `void __thiscall(editbox)`) has one caller, FUN_EDITBOX_INSERT's tail
// (0x0077C022), so it runs once per insert that went ahead (the insert
// returns early for a cursor inside a link or a non-digit in a numeric
// box). FUN_EDITBOX_DELETE_RANGE (4.3.4's DeleteSubstring, `void
// __thiscall(editbox, int from, int to)`, `ret 8`) is every deletion: the
// character deletes (0x0077C2B8, 0x0077C2C8), the selection delete
// (0x0077CD7E) and FUN_EDITBOX_CLEAR (`void __thiscall(editbox)`, delete
// all, 0x0077C509). SetText's internal 0x0077BE00 clears with
// FUN_EDITBOX_CLEAR and inserts with FUN_EDITBOX_INSERT; these are its two
// return addresses, the calls 4.3.4 makes with `script` = 1.
FUN_EDITBOX_REBUILD_CHAR_CLASS = 0x0077BA90,
CALL_EDITBOX_INSERT_REBUILD_CHAR_CLASS = 0x0077C022,
// What the rebuild reads: the text (+0x32C), the class table's size in
// dwords (+0x344, zeroed first) and OFF_EDITBOX_CHAR_CLASS. It walks the
// text with FUN_TEXT_TOKENIZER and a decoder flag word of 0 (0x0077BAD9).
OFF_EDITBOX_TEXT = 0x32C,
OFF_EDITBOX_CHAR_CLASS_SIZE = 0x344,
// The box's own font string - SetMultiLine (0x0077A5C3) sets flag 0x4000
// (no |n) in its OFF_FONTSTRING_FLAGS for a single-line box, clears it
// for a multi-line one.
OFF_EDITBOX_FONTSTRING = 0x328,
// A font string's flags (the constructor sets 0x212, 0x00770DD3). Its
// measure and draw hand FUN_TEXT_TOKENIZER the decoder flag word built
// from them (0x0044D6A9..0x0044D6FC); the escape bits map 0x2000 -> 0x100
// (no |c |r), 0x4000 -> 0x200 (no |n), 0x8000 -> 0x400 (no |H |h),
// 0x0080 -> 0x800 (none) (benilla-re ui/editboxmarkup "Which escapes are
// on").
OFF_FONTSTRING_FLAGS = 0x120,
FUN_EDITBOX_DELETE_RANGE = 0x0077C510,
FUN_EDITBOX_CLEAR = 0x0077C500,
RET_EDITBOX_SET_TEXT_CLEAR = 0x0077BE5B,
RET_EDITBOX_SET_TEXT_INSERT = 0x0077BE6B,
// The edit box's text update 0x0077D3E0 fires OnTextChanged (slot at
// OFF_EDITBOX_ONTEXTCHANGED_SLOT) when the text changed, with the 24
// bytes at PATCH_EDITBOX_TEXT_CHANGED_FIRE: load the handler, skip when 0,
// `push &slot; mov ecx, esi; call 0x00702690` (the no-argument fire),
// ending at 0x0077D49D.
PATCH_EDITBOX_TEXT_CHANGED_FIRE = 0x0077D485,
OFF_EDITBOX_ONTEXTCHANGED_SLOT = 0x418,
// `void __thiscall(editbox, int maxLines)` — the SetHistoryLines internal
// (FUN_0077cd90). Reallocates the history ring to maxLines; maxLines == 0
// frees the whole buffer and zeroes the container. ClearHistory calls it
// with 0 then the saved max — empties every entry and resets the write
// position while keeping the limit (so recording still works after).
FUN_EDITBOX_SET_HISTORY_MAX = 0x0077cd90,
// --- FontString measure internals (GetStringWidth icon fix + GetStringHeight) ---
// CSimpleFontString::GetStringWidthInternal — `float(__fastcall)(fs /*ecx*/)`,
// returns in x87 ST0. Lazily computes into the fs+0xFC cache (ANCHOR units,
// sentinel 0.0f = DAT_007ffd74): display-text getter FUN_00771EC0, then measure
// core FUN_0044D670(fontHandle fs+0xE0, text, len, fontH*[fs+0x7C], &out,
// fs+0x108, 0, flags fs+0x120), then `fs+0xFC = out / [fs+0x7C]`. Exactly 4
// callers: Script_GetStringWidth (0x0079E510), GameTooltip auto-size
// (0x00530640), the editbox caret positioner (0x0077DE70), and the layout
// effective-width vmethod (FUN_00772930 = fs+0x24 vtbl slot +0x1C: explicit
// rect width else string width). Prologue PUSH EBX; PUSH ESI; MOV ESI,ECX;
// FLD [ESI+0xFC] — MinHook-safe. Co-hooked by Text::InlineTexture to add
// inline |T icon advances; the hook must NEVER write the fs+0xFC cache (the
// original may serve the cached value — the icon sum is re-added per call).
FUN_FONTSTRING_STRING_WIDTH = 0x00772890,
// CSimpleFontString::GetStringHeightInternal — `float(__fastcall)(fs)`, ST0.
// Wrap-aware: FUN_0044D750 → FUN_005C2070 → wrap engine FUN_005C7260 (the
// same wrap math the render uses); returns lines*fontH + (lines-1)*spacing
// (spacing = fs+0xF4), cached at fs+0x100 (anchor units, 0.0 sentinel; empty
// text → 0). Wrap width = the effective-width vmethod (fs+0x24 vtbl +0x1C).
// Used internally by the tooltip auto-size (0x00530640), multi-line editbox
// height (0x0077D4D0), and ScrollingMessageFrame line stacking (0x00788750)
// — FontString::Metrics only CALLS it (the GetStringHeight backport), no hook.
FUN_FONTSTRING_STRING_HEIGHT = 0x007729B0,
// Per-fontstring font-height getter, ANCHOR units (reads fs+0xE4; with
// mode=1 and measure-flag 0x200 set, re-derives from the gxu font's native
// height). ECX = fs, mode on the STACK (`PUSH 0x1; MOV ECX,ESI; CALL` at
// 0x007728F4) → declare `__fastcall(fs, edx_unused, int mode)`. The ENGINE's
// width path multiplies its return by [fs+0x7C] (the layout UI SCALE) before
// handing it to the measure core. Our width hook instead converts it to UI
// PIXELS (× the anchor→px push factor VAR_COORD_ASPECT_COMPENSATION × 1024 /
// VAR_COORD_DDC_WIDTH_SCALE, ≈1468) to resolve `:0` auto-sized icon dims —
// escape sizes are PIXELS, not fs+0x7C-scaled pen units; dividing a pixel
// advance by fs+0x7C (~0.68) inflated a 16px icon to +44k measured px on
// first flight. Distinct from FUN_TEXT_FONT_HEIGHT (0x005C6FA0), the
// node-level gxu helper.
FUN_FONTSTRING_FONT_HEIGHT = 0x007727B0,
// CSimpleFontString::GetDisplayText — the engine's truncation MECHANISM (the
// reason FontString:IsTruncated has anything to detect). `char* __thiscall(fs
// /*ecx*/, float availW, float availH)` (dummy-EDX __fastcall form; RET 0x8).
// Reads the raw text at fs+0xF0 and, when the box is BOUNDED (availW>0 AND
// (maxLines fs+0x128 != 0 OR availH>0)), measures how much fits via the
// chars-that-fit counter FUN_0044D960; on overflow it writes "<prefix>...\0"
// into the shared scratch buffer VAR_TEXT_ELLIPSIS_BUFFER and returns THAT,
// else the fs+0xF0 pointer (or NULL). The rebuild FUN_007724A0 calls it with
// availW=(rect.right−rect.left)/[fs+0x7C], availH=(rect.bottom−rect.top)/
// [fs+0x7C] and lays out whatever it returns — the node then COPIES that
// string into OFF_TEXT_NODE_TEXT. IsTruncated does NOT call this (the rect at
// fs+0x64 is zero between frames, so a Lua-time re-call always sees an
// unbounded box); it reads the node copy instead. Kept for the availW/availH
// derivation + the bounded-box gate. Verified in the Octo binary: prologue
// 55 8B EC 83 EC 0C 53 56 8B F1, ellipsis literal "..." at 0x00800188.
FUN_FONTSTRING_DISPLAY_TEXT = 0x00771EC0,
// Shared 0x1000-byte BSS scratch buffer the display-text resolver above writes
// the truncated, "..."-suffixed string into (memset FUN_0064A5A0 at 0x00772054,
// suffix append at 0x00772086) and returns on truncation. Transient — every
// layout rebuild overwrites it, and the node keeps its OWN copy (see
// OFF_TEXT_NODE_TEXT), so it is not read directly by any live path.
VAR_TEXT_ELLIPSIS_BUFFER = 0x00CF0CC0,
// Per-fontstring MAX LINE COUNT. 0 = no cap. When non-zero, the display-text
// resolver forces availH = maxLines × lineHeight (verified in FUN_00771EC0:
// `if (fs+0x128 != 0) param2 = fs+0x128 * lineHeight`), so text past that
// many wrapped lines is ellipsized. Backs FontString:SetMaxLines/GetMaxLines
// — the truncation control 1.12 never exposed for fontstrings (SetMaxLines is
// ScrollingMessageFrame-only). Vanilla fontstrings always word-wrap, so this
// is the way to force a single-line, ellipsized label: SetMaxLines(1).
OFF_FONTSTRING_MAX_LINES = 0x128,
// Lazily-computed measure caches (anchor units, 0.0f = dirty sentinel):
// fs+0xFC = string width (GetStringWidth), fs+0x100 = string height
// (GetStringHeight). SetText (FUN_00771D80) zeroes BOTH when the content
// changes; SetMaxLines mirrors that so the getters recompute after the cap.
OFF_FONTSTRING_WIDTH_CACHE = 0xFC,
OFF_FONTSTRING_HEIGHT_CACHE = 0x100,
// Ref-counted handle DecRef (resolve via FUN_0041af30 → --refcount → dtor at
// 0). `__fastcall(void *handle)`. SetText releases the text-block handle
// (fs+0xF8) through it before nulling the field; SetMaxLines does the same to
// force a fresh node rebuild with the new line cap.
FUN_HANDLE_RELEASE = 0x0041AED0,
// 4.3.4's CLayoutFrame::Resize(force) — `__thiscall(layout, int force)`
// on a region's layout sub-object (region+OFF_REGION_ANCHOR), `ret 4`.
// force 0 marks the region dirty and propagates to parent/children so it
// re-lays-out later (SetText's tail: `FUN_007680e0(fs+0x24, 0)`); force 1
// resolves it now (Script GetLeft 0x007A1A19: `if
// (FUN_REGION_LAYOUT_DIRTY(layout)) FUN_007680e0(layout, 1)`, 4.3.4's
// `if (IsResizePending()) Resize(1)`).
FUN_LAYOUT_RESIZE = 0x007680E0,
};