Adding a New Inventory

A step-by-step guide to adding a new inventory number to the game server (gs) and the client (elementclient.exe), without changing the database format. The new inventory works like the game's existing pouches: it has its own window, its own size, saves with the character, and supports move, swap, split, take out and timed items.

Throughout this guide N is the new inventory number. The game uses 0–9, so the first free number is 10, then 11, and so on.

1. How it works

1.1 Inventory numbers

No. Storage
0 Bag
1 Equipment
2 Quest bag
3 Stash
4 Clan / alliance stash
5 / 6 Pet bag / pet-related
7 Special pouch 1 (saved in store1)
8 Special pouch 2 (saved in store2)
9 Garden
N New inventory

Every inventory number is checked in a handful of places on the server (bounds checks and switch tables) and on the client (the pack lookup and the storage window). Adding one means extending each of those places.

1.2 Saving without a database change

The character record has no field for a new inventory, and changing the record format would mean patching gamedbd, gdeliveryd and every tool that reads characters. Instead, the new inventory rides inside an existing saved list:

gamedbd does not check the contents of store1 or store2, so the extra entries pass through unchanged. The host inventory never sees them, because they are removed before the host list is loaded.

Marker entry (one saved item record, 44 bytes):

Offset Field Value
0x00 item id an item ID that exists in elements.data on server and client
0x04 slot 0xFFFFFFFE
0x08 count 1
0x0C max count 1
0x10 guid1 a 4-character tag that identifies the inventory, e.g. 'PK10'
0x14 guid2 inventory N's size
0x18–0x28 rest 0

Use a different tag for each new inventory, so two inventories can share a host list.

Rules that follow from this design

2. What you need

Addresses below are from the ESO gs and client this method was built and tested on. Function names are stable; if your binaries differ, find each function by name and the same instruction pattern inside it. If earlier patches already hook a site, call or jump to the existing hook from your new code rather than replacing it.

3. Server (gs)

3.1 Make room for new code

The gs has no free space for a few kilobytes of code. Add a segment:

  1. Pad the file to a 0x1000 boundary and append the new code.
  2. Turn the unused PT_NOTE program header (program header 5) into a PT_LOAD: file offset = where the code starts, VA = 0x08700000, file size = code size, memory size large enough for the per-player table (below), flags 7 (read/write/execute), align 0x1000.

The memory beyond the file size is zero-filled at start-up and holds a per-player table: one pointer per player slot (65,536 slots × 4 bytes, at 0x08800000).

3.2 Engine functions used

Name Address Use
player manager GetIndex 0x0814458E player slot index for a gplayer
player manager object 0x0860D52C first argument to GetIndex
small allocator 0x081677B8 new for the 0x1C-byte item_list
item_list constructor 0x0809FD76 (list, location, size)
item_list destructor 0x0809FE08  
item_list set owner 0x080A09A4 (list, gplayer_imp)
item_list size / set size 0x080A098A / 0x080A0076 set size only grows
item_list clear 0x080AB176  
MakeDBData 0x08142BBE item_list → saved item array
InitFromDBData 0x08130D08 saved item array → item_list
array alloc / free 0x08062844 / 0x080634A4 saved item arrays
GetInventoryDetail 0x0807B412 sends a whole inventory to the client
expiry functor ctor / ForEachExpireItems / update 0x080A68BA / 0x0809C922 / 0x0809F102 timed items

Player fields: special pouch 1 list at gplayer_imp + 0x7CC4 (inventory 7), special pouch 2 list at + 0x7CE0 (inventory 8).

3.3 GetBox(N): find the player's list

A helper, called from every hook, that returns inventory N's item_list for a player:

  1. Get the player's slot index (GetIndex).
  2. Look up the per-player table. If empty: allocate 0x1C bytes, construct an item_list (location N, default size), store the pointer.
  3. Set the list's owner to the current player (slots are reused by different characters).
  4. If anything fails, return the host list, and have callers treat "host list returned" as "inventory N not available".

3.4 Save

In user_save_data (logout and autosave) the host list is written by a call to MakeDBData. Replace that call with your own routine:

Your routine:

  1. Run the original MakeDBData for the host list.
  2. Run MakeDBData for inventory N into a temporary array.
  3. Allocate a new array of host count + N count + 1 entries (44 bytes each).
  4. Copy the host entries; copy inventory N's entries with slot + 1000; add the marker.
  5. Free the two old arrays and return the new one in the output structure.

3.5 Load

In do_player_login the host list is filled by a call to InitFromDBData. Replace it:

Your routine:

  1. Scan the saved entries. Find the marker (slot 0xFFFFFFFE and your tag) and read the size. Without a marker, use the default size.
  2. Size = the larger of the marker size and the highest used slot + 1.
  3. Rebuild inventory N's list for this player (clear, destroy, construct with the size).
  4. Copy entries with slot ≥ 1000 into a temporary array with slot − 1000 and load them into inventory N with InitFromDBData.
  5. Load only entries below 1000 into the host list. Never pass the marker or the +1000 entries to the host.

3.6 Instant saves

Mail, auctions, faction creation and similar actions save the character immediately using a different path. The host list's capacity and contents are fetched there, so both must include inventory N:

These messages carry the whole saved list, so large inventories can exceed their size limit (see section 6).

3.7 Inventory number bounds

Four functions take an inventory number, check it with cmp [ebp+0xc], 9, and use a switch table:

Function cmp at table load at old table
PlayerGetItemInfo 0x0807AF70 0x0807AF80 0x08488904
PlayerGetInventoryDetail 0x0807B428 0x0807B438 0x08488950
PlayerGetInventory 0x0807E31E 0x0807E32E 0x08488ADC
gplayer_imp::GetInventory 0x080A3EAE 0x080A3EBA 0x08489EB0

For each: copy the old table into your segment, add entries up to N that point to your new case blocks, change the cmp value to N, and point the mov eax, [eax+table] at the new table. Each case block calls GetBox(N) and continues the way the inventory 8 case does.

3.8 Moving, swapping and filtering

Players move items with four requests, each with a validate step, a list-selection step and (for bag → pouch) a filter:

Function Hook sites
PlayerMoveItemBetweenInventorySpecTrashBox validate 0x0807BF52, lists 0x0807C008, filter 0x0807C086
PlayerExchangeInventorySpecTrashBox validate 0x0807C1E9, filter 0x0807C2D1, list selection 0x0807C27C / 0x0807C3BB / 0x0807C3F5
PlayerExchangeInvItem validate 0x0807B660, active check 0x0807B6E9, list selection 0x0807B72B
PlayerMoveInvItem validate 0x0807B792, active check 0x0807B81C, list selection 0x0807B85F

At each site: accept N wherever 7 and 8 are accepted, and return GetBox(N) when N is selected.

Accepting only some items (optional). In the two filter hooks, call your own check for inventory N. Look the item up in the item data manager, read its data type and sub type, and refuse anything else. Example: data type 0x50 (equipment) with sub type X or Y only.

3.9 Access, login, size and expiry

4. Client (elementclient.exe)

4.1 Room for code and data

Engine functions: operator new 0x00832DA0, inventory (pack) constructor 0x004A21D0 (thiscall, 0x1C bytes), dialog GetDlgItem 0x007CBD90.

4.2 GetPack(N)

The host player's GetPack checks cmp eax, 9 at 0x470214 and uses a jump table whose next entries are free (0x4702A8 for 10, 0x4702AC for 11). Raise the bound to N and add a case:

  1. If the pack doesn't exist, create it (new 0x1C bytes, constructor), remember it and its host player.
  2. If the host player changed (another character logged in), empty it (vtable + 4, argument 0).
  3. Return the pack (ret 4).

4.3 Storage window

All pouches share one storage window, which uses the inventory number as its mode. Six switch tables in the window decide what each mode does. Each has a cmp reg, 5 (modes 3..8) and a jmp [table + reg*4]:

cmp at jmp at
0x58B6E5 0x58B6EE
0x58B94C 0x58B951
0x58B992 0x58B997
0x58BA35 0x58BA3A
0x58BB34 0x58BB39
0x58BBEC 0x58BBF1

For each: copy the table into free space, add entries up to mode N that copy mode 8's entry (unused numbers in between get the default entry), raise the cmp to N − 3, and point the jmp at the new table.

Four more places check "is this a pouch mode" with cmp …, 8. Jump to code that also accepts N and returns to the original branch targets:

Site Original bytes
0x58B0B6 (window close) 83 F8 08 74 12
0x58B4F8 83 F8 08 75 28
0x527E37 (bag window) 83 FD 08 74 07
0x46298B (server message refresh) 83 F8 08 0F 85 26 09 00 00

4.4 Opening the inventory

Two ways, use either or both.

From an item. The special pouch items are mapped to an inventory number in the item-use code at 0x464E01. Change the mapping so your item opens mode N. The item must also be set as a special pack item in elements.data (SPECIAL_ID_CONFIG) on server and client.

From a button. Interface buttons send a text command to their window's command map:

To add a command without touching the game's own list:

  1. Reserve room in .data for a new map {base, entries} and two entries (yours + terminator).
  2. Hook a spot that runs once at start-up after the bag window's map is built (0x526FD5). Fill the new map with the original base (0x9E58D8), build your entry ("mycommand" → your handler), build the terminator, then jump back.
  3. Change the bag window map's base pointer at 0x9E90D0 to your new map. Your map chains to the original base, so every original command still works.
  4. The handler (thiscall, ret 4): if the storage window is open in mode N, close it (0x58AFF0); otherwise set mode N (0x58B6C0) and show the window.

In interfaces\inventory.xml add the button with Command="mycommand".

4.5 Window title

0x58B6C0 sets the storage window's mode and shows Title1 (stash), Title2 (clan stash) or Title3 (special pouch). Jump from its start to a wrapper that calls the original, then shows a new label (for example TitleN) for mode N and hides Title3. Add that label to interfaces\storage.xml (copy Title3, change the name and text). If the label is missing, the window keeps the special pouch title.

5. interfaces.pck

Instant saves (mail, mail attachments, auctions, faction and family creation and a few others) send the whole saved pocket and stash in one message, capped at 100–128 KB. Equipment takes about 190 bytes per item, so very full storages can exceed that and the message is rejected. If you add large inventories, raise those size checks (cmp [ebp+0xc], imm32 in each message's size policy) in gs, gdeliveryd and gamedbd together.

7. Install

  1. Stop the server safely: players log out, killall gs, then the other services, then gamedbd (wait until pidof gamedbd prints nothing).
  2. Back up the old gs, the client files and the database.
  3. Copy the new gs, chmod 755, check md5sum, start the server.
  4. Give every player the new elementclient.exe and interfaces.pck at the same time.
  5. Make sure the marker item ID exists in elements.data on server and client.

8. If something goes wrong

Symptom Likely cause
Button does nothing old interfaces.pck, wrong command name, or the command map chain
Window opens with the wrong title label missing from storage.xml, or the title wrapper
Items vanish after relog old gs started, load hook passing +1000 entries to the host, or an outside tool rewrote the list
Items appear in the host inventory load hook not filtering slots ≥ 1000
Character can't log in marker item missing from elements.data
Realm drops on mail with full storages message size limits (section 6)
Other characters see someone's items GetBox not setting the owner, or client pack not emptied on host change

9. Adding another inventory (N + 1)

Each further inventory repeats sections 3–5 with its own number. Nothing from the first one is removed: the second one is added beside it.

9.1 What each new inventory needs of its own

Item Rule
Inventory number the next free one (N + 1)
Per-player table (server) a separate table in the new segment (for example 0x08800000 for N, 0x08840000 for N + 1); raise the segment's memory size to cover both
GetBox routine (server) one per inventory, each using its own table
Host list and tag either host (store1 or store2); if both inventories use the same host, give them different marker tags and different slot offsets (for example +1000 and +2000)
Marker same item ID can be reused; the tag tells them apart
Pack globals (client) its own pack pointer and host player in .data
Button command, handler, title label their own names (for example a new command and Title<N+1>)

Using two hosts (one inventory in store1, the other in store2) is the simplest, because each saved list then carries only one extra inventory and one marker, and the +1000 offset can be the same.

9.2 Server changes for N + 1

Extend every place from section 3 by one more number:

  1. Save / load: if N + 1 uses the other host, hook that host's save and load calls (store1 at 0x08141223 / 0x08140427, store2 at 0x0814128F / 0x0814046D). If it shares the host, extend the existing save and load routines to write and split a second range and a second marker.
  2. Instant saves: hook the 5 capacity calls and the detail function of N + 1's host (section 3.6).
  3. Bounds and switch tables: raise the four cmp [ebp+0xc], … values to N + 1 and add one more entry and case block to each relocated table (section 3.7).
  4. Move / swap / filter: add N + 1 to every check that accepts N, and return GetBox(N + 1) when N + 1 is selected (section 3.8).
  5. Access, login, expiry: add N + 1 to the active check, send it at login after N, and run the expiry pass over it (section 3.9).

Tip: write each routine as an assembler macro that takes the inventory number, its table, its host and its tag. Each further inventory is then one macro call per routine, and the tested code stays identical.

9.3 Client changes for N + 1

  1. GetPack: raise the bound at 0x470214 to N + 1 and fill the next jump-table entry (4 bytes after N's) with a case that uses N + 1's own globals.
  2. Storage window tables: rebuild the six tables with one more entry (copy of mode 8) and raise each cmp to (N + 1) − 3. The old tables are too short, so place the new ones in fresh free space.
  3. Pouch checks: the four checks from section 4.3 accept 8, N and N + 1.
  4. Opening: a second command entry (and its handler) in your extra command map, placed before the terminator, or a second item mapping.
  5. Title: extend the title wrapper with one more label for mode N + 1.

10. Choosing which items an inventory accepts

Without a filter, an inventory takes the same items as special pouch 2 (inventory 8). To restrict it, add a check routine and call it from the two filter hooks for your inventory only.

10.1 Where the check goes

Request Hook Item to check Accept → Otherwise →
Move bag → pouch filter at 0x0807C086 item at the bag slot: list [ebp−0xC], slot byte [ebp−0x5] 0x0807C156 0x0807C0D8
Swap bag ↔ pouch filter at 0x0807C2D1 item at the bag slot: list = player + 0x958, slot byte [ebp−0xA] 0x0807C3A0 0x0807C31F

The "otherwise" address continues into the game's own check, which refuses items that don't belong. Get the item pointer with the item_list "item at" function (0x080A09B2, arguments list and slot). Then call your check with the item pointer in eax: it returns 1 to accept or 0 to refuse.

10.2 Engine pieces a check uses

What How
Item template ID [item + 0x0] (0xFFFFFFFF = empty slot: refuse)
Equip mask (which equipment slots it fits) [item + 0x0C]
Item data manager call 0x0806A52E, returns the manager in eax
Template data and data type call 0x082388CC (manager, template ID, 0, pointer to an int): returns the template's data, writes its data type into the int
Equipment sub type [template data + 0x08] when the data type is 0x50 (equipment)

10.3 Fashion only

Fashion items are recognised by their equip mask: they fit one of the fashion slots, whose bits are 0x6F80. Mounts and flying mounts can be added by data type.

FashionFilter:                 ; eax = item*, returns eax = 1 accept / 0 refuse
    push ebp
    mov  ebp, esp
    push ebx
    sub  esp, 0x14
    mov  ebx, eax
    test dword ptr [ebx+0x0C], 0x6F80   ; fits a fashion slot?
    jnz  ff_yes
    cmp  dword ptr [ebx], 0xFFFFFFFF    ; empty slot
    je   ff_no
    call 0x0806A52E                     ; item data manager
    lea  edx, [ebp-0x8]
    mov  dword ptr [edx], 0
    push edx
    push 0
    push dword ptr [ebx]                ; template ID
    push eax
    call 0x082388CC                     ; data + data type
    add  esp, 16
    test eax, eax
    jz   ff_no
    cmp  dword ptr [ebp-0x8], 0x42      ; mount        (optional)
    je   ff_yes
    cmp  dword ptr [ebp-0x8], 0x51      ; flying mount (optional)
    je   ff_yes
ff_no:
    xor  eax, eax
    jmp  ff_out
ff_yes:
    mov  eax, 1
ff_out:
    mov  ebx, [ebp-0x4]
    leave
    ret

Remove the two data type lines to accept fashion only.

10.4 Signets only

Signets are equipment (data type 0x50) with their own equipment sub types in elements.data: 22864 (Diplomatic) and 22865 (Trinity Signet). Check both your server's and the client's elements.data for the sub type IDs before building.

SignetFilter:                  ; eax = item*, returns eax = 1 accept / 0 refuse
    push ebp
    mov  ebp, esp
    push ebx
    sub  esp, 0x14
    mov  ebx, eax
    test ebx, ebx
    jz   sf_no
    cmp  dword ptr [ebx], 0xFFFFFFFF    ; empty slot
    je   sf_no
    call 0x0806A52E                     ; item data manager
    lea  edx, [ebp-0x8]
    mov  dword ptr [edx], 0
    push edx
    push 0
    push dword ptr [ebx]                ; template ID
    push eax
    call 0x082388CC                     ; data + data type
    add  esp, 16
    test eax, eax
    jz   sf_no
    cmp  dword ptr [ebp-0x8], 0x50      ; equipment?
    jne  sf_no
    mov  eax, [eax+0x08]                ; equipment sub type
    cmp  eax, 22864                     ; Diplomatic
    je   sf_yes
    cmp  eax, 22865                     ; Trinity Signet
    je   sf_yes
sf_no:
    xor  eax, eax
    jmp  sf_out
sf_yes:
    mov  eax, 1
sf_out:
    mov  ebx, [ebp-0x4]
    leave
    ret

The same pattern works for any group of equipment: change or add sub type IDs. For non-equipment items, compare the data type alone (for example 0x42 for mounts).

10.5 Calling the check from the hooks

Move bag → pouch (from the hook at 0x0807C086, case for your inventory):

    sub   esp, 8
    movzx eax, byte ptr [ebp-0x5]       ; bag slot
    push  eax
    push  dword ptr [ebp-0xC]           ; bag list
    call  0x080A09B2                    ; item at slot
    add   esp, 0x10
    call  SignetFilter                  ; or FashionFilter
    test  eax, eax
    jne   0x0807C156                    ; accept
    jmp   0x0807C0D8                    ; game's own check (refuses)

Swap bag ↔ pouch (from the hook at 0x0807C2D1):

    sub   esp, 8
    movzx eax, byte ptr [ebp-0xA]       ; bag slot
    push  eax
    mov   eax, [ebp+0x8]
    add   eax, 0x958                    ; player's bag list
    push  eax
    call  0x080A09B2
    add   esp, 0x10
    call  SignetFilter                  ; or FashionFilter
    test  eax, eax
    jne   0x0807C3A0                    ; accept
    jmp   0x0807C31F                    ; game's own check (refuses)

Moves and swaps inside the inventory itself (PlayerMoveInvItem, PlayerExchangeInvItem) need no filter: the item is already in it.

10.6 Test the filter

11. Test checklist (inventory 10 and 11)

In-game tests for a newly added inventory 10 and inventory 11, to make sure nothing breaks. Run them on a test server with a database backup, using throwaway characters. Tick each box only when it passes; if one fails, stop and restore the backup before players log in.

11.1 Before you start

11.2 Inventory 10

11.2.1 Opening and size

11.2.2 Items in and out

11.2.3 Saving

11.2.4 Actions that save instantly

Do each with items in inventory 10, then relog and check both inventory 10 and the host pouch:

11.2.5 Other players and timed items

11.2.6 Existing storage still works

11.3 Inventory 11

Run all of section 11.2 again for inventory 11, then the checks below.

11.3.1 Both inventories together

11.3.2 Item filter (if inventory 11 accepts only some items)

11.3.3 Full storages

11.3.4 Shared host list (only if 10 and 11 are saved in the same list)

11.4 After going live


Revision #1
Created 2026-11-30 14:46:24 UTC by Neko
Updated 2026-11-30 15:05:12 UTC by Neko