Files
ClassicAPI/src/Offsets.h
T

515 lines
27 KiB
C

// This file is part of ClassicAPI.
//
// ClassicAPI is free software: you can redistribute it and/or modify it under the terms
// of the GNU Lesser 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 Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License along with
// ClassicAPI. If not, see <https://www.gnu.org/licenses/>.
#pragma once
enum Offsets {
FUN_FRAME_SCRIPT_INITIALIZE = 0x7039E0,
FUN_FRAME_SCRIPT_EXECUTE = 0x704CD0,
FUN_INVALID_FUNCTION_PTR_CHECK = 0x42A320,
FUN_LOAD_SCRIPT_FUNCTIONS = 0x490250,
// GameTooltip script-method prologue helpers (used to resolve self → CFrameScriptObject*).
FUN_FRAMESCRIPT_PUSH_OBJECT = 0x6F3BC0,
FUN_FRAMESCRIPT_GET_OBJECT = 0x6F3740,
// Inner spell-tooltip builder, called from Script_GameTooltip_SetSpell at 0x00532E92.
// __thiscall(spellID, 0, 0, isPet, 0, 0, 0); we always pass isPet=0.
FUN_GAMETOOLTIP_BUILD_SPELL_TOOLTIP = 0x0052E610,
// 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,
// Registers a single global Lua function. __fastcall(name, func).
FUN_FRAMESCRIPT_REGISTER_FUNCTION = 0x00704120,
// 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,
// Per-player inventory manager lives at this offset on the player object.
OFF_PLAYER_INVENTORY_MANAGER = 0x1D38,
// 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,
// 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`.
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,
// PackBagSlot — __fastcall(L, void **outInvMgr, int *outLinearSlot, int *outUnused) → 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.
FUN_PACK_BAG_SLOT = 0x004F9820,
// 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, bit 3 = broken (see GetInventoryItemBroken at 0x4C8626
// which tests `[descriptor+0x3C] & 0x08`). Confirmed empirically by dumping
// descriptor bytes for a worn-and-bound item.
OFF_DESCRIPTOR_FLAGS = 0x3C,
ITEM_FLAG_SOULBOUND = 0x01,
// 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,
// 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,
// 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,
OFF_ITEMSTATS_DISPLAY_INFO_ID = 0x18,
OFF_ITEMSTATS_INVENTORY_TYPE = 0x2C,
// 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,
// 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,
// 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,
// 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.
FUN_RESOLVE_FACTION_INDEX = 0x004D5FA0,
FUN_SCRIPT_GET_FACTION_INFO = 0x004D64F0,
VAR_FACTION_DISPLAY_COUNT = 0x00B73764,
VAR_FACTION_VISIBLE_MAX_INDEX = 0x00B73760,
// 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,
OFF_FACTION_PARENT_ID = 0x48,
OFF_FACTION_NAMES = 0x4C,
OFF_FACTION_DESCRIPTIONS = 0x70,
// 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,
VAR_QUEST_LOG_SELECTED_QUEST_ID = 0x00BB7480,
// 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,
// 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,
// 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,
// 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,
// 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
VAR_SPELL_RANGE_RECORDS = 0x00C0D79C, // SpellRange.dbc
VAR_SPELL_RANGE_COUNT = 0x00C0D7A0,
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,
VAR_LOCALE_INDEX = 0x00C0E080, // 0..8, picks one of the 9 localized strings
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_PUSH_VALUE = 0x6F30D0, // (was 0x6F3350, which is lua_replace — see docs/LuaCAPI.md)
LUA_PUSH_CCLOSURE = 0x6F3920,
LUA_NEW_TABLE = 0x6F3C90,
LUA_GET_TABLE = 0x6F3A40, // (was 0x6F3EA0, which is lua_rawset)
LUA_RAW_GET = 0x6F3B00,
LUA_SET_TABLE = 0x6F3E20,
LUA_RAW_SET = 0x6F3EA0,
LUA_INSERT = 0x6F31A0,
LUA_TYPE = 0x6F3400,
LUA_SET_TOP = 0x6F3080,
LUA_ERROR = 0x6F4940,
// 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,
// 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,
EVENT_ENTRY_STRIDE = 0x10,
OFF_EVENT_ENTRY_NAME = 0x00,
OFF_EVENT_ENTRY_HEAD = 0x0C,
// `Frame::RegisterEvent` — the C++ helper called by the Lua
// `frame:RegisterEvent(eventName)` method (`Script_RegisterEvent` at
// `0x00774A40`). `__thiscall` with `(this=frame, eventName)`. Walks
// the entry array at `[VAR_EVENT_TABLE_BASE_PTR]`, case-insensitively
// strcmps against each entry's name, and appends `frame` to the
// matching entry's chain. We hook this so any addon's RegisterEvent
// call gives `Event::Custom::RetryAll` a chance to fix up custom
// events that boot-time registration couldn't claim yet.
FUN_FRAME_REGISTER_EVENT = 0x00702140,
// `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,
// 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,
// 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,
// 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,
};