FFXiMain.dll / FFXi.dll build 2025-11-12: R1 function discovery for static recompilation
=====================================================================================

Retail files  a private-server install's FINAL FANTASY XI folder (patch.ver present)
  FFXiMain.dll  SHA-256 bda769e226d71a43335c105fd6f72ed19af0a3d815a079b367356de0731a0d9a
                PE timestamp 0x69144fb9 (2025-11-12)
  FFXi.dll      SHA-256 4ee15af61bbc94e886ce6a0f761f3c57d2a50a4c15b059a2a8a426e20fd07cd7
                PE timestamp 0x69144fa8
Version       30251101_2, decrypted from patch.ver
Metadata      FFXiMain.2025-11-12.meta.json, FFXi.2025-11-12.meta.json (ffxi-recomp-meta/1)
Label         the date of the PE timestamp. Older than every known build (2025-12-26 is next).

What changed from 2025-12-26
----------------------------
Both DLLs' .text differ from every known build; the packer is the same (tools/unpack.py unchanged).

Carrying addresses over
-----------------------
Not possible: no other build's retail DLLs were at hand, so `newbuild.py carry` had no images to
map from. The verdicts were made from this build's own gate reports (below), and the one address
the macOS host needs to run was found directly:
  character table pointer       0x104dd500: the only global loaded within 8 instructions before an
                                access at +0x1382x, 11 code sites (2025-12-26: 0x104dd600)
The frame-rate divisor and aspect signatures are found at run time (global 0x1045474c).

The rest of builds.json's entry (present_site, crt, hooks, wraps, modern) was mapped afterwards
from the two builds' metadata alone, by function shape and then by how this build's code uses
what was mapped:

  Code addresses   the functions of both metas, ordered by address, each as (size, switch-case
                   count), aligned with difflib's SequenceMatcher: 99.4% of 2025-12-26's functions
                   pair with one of this build's. An address inside a paired function of the same
                   size is carried at the same offset. Every hook, wrap and modern code address
                   came this way, each from a pair inside a long run of consecutive pairs.
                   The four wraps agree with an independent search for them.
  crt              each 2025-12-26 address -0x780 (the CRT is one block, unchanged); every one
                   checked against its prologue.
  present_site     0x100035cb, after `call [ecx+0x3c]` (Present) as in 2025-12-26.
  nameplate_scale  0x100861e6, after `fstp [esp+0x50]` and before the `jle`, as in 2025-12-26.

  Data addresses, each from a use in this build's code and checked by a second one:
    mgr, sheets          the `mov ecx, imm32` before calls to layout_find/menu_open and
                         sheet_find/sheet_add (mgr: 470 such calls, all one value)
    disp_gfx, log_inst   the `mov ecx, [abs]` before calls to disp_viewport/disp_rt and log_fit
    page_vtbl            the immediate page_ctor stores at [this]
    config_vtbl          the one .rdata table whose slots 0, 1, 4 and 6 hold config_slot0/1/4/6
    lobby_vtbl           the one .rdata table whose slot 6 holds lobby_input
    config_inst, lobby_inst, lobby_help, help_inst, log_inst, log2_inst
                         the handler globals of the menu table's entries ("configwi", "lobycwin",
                         "lobyhelp", "helpwind", "logwindo", "logwin2": 0x2c apart, the global's
                         pointer 0x18 past the name); config_inst is also config_get's global +0x4c
    menus_conf1win, menus_display, menus_addons, menus_end
                         the menu table's entries "menu    conf1win" (the second), "tkdebug dbdelsel",
                         "menu    oplev   " and the zero entry ending it
    action_lists         the bytes 4,8,7,25,9,12,13,22,24,28, found once
    disp_scene           the global the run-time aspect scan finds (0x1045474c)
    disp_win_w/h, disp_mode, disp_menu_w/h, disp_device
                         the globals referenced near 2025-12-26's addresses less this region's
                         shift (-0x40 for the display globals, -0x44 for disp_device),
                         each read where 2025-12-26 reads its own (disp_device: followed by
                         +0x28, +0xc and +0x10)

  In game (a local LandSandBoat server, signed in from the sign-in screen and with --user): the
  nameplate fix; Config > Modern, its row in the Config list and a display size set there kept
  over a restart; Ashita and Windower addons loaded from Config > Addons, the chat and packet
  wraps running. The title screen's Config window gets no Display Settings row: in
  this build it is older, 12 items with no Gamepad button (the row goes under Gamepad), and the
  host says so and leaves it as it is.

Method
------
Ghidra 11.3.2 headless (tools/version/discover.py), JDK 21. The first run's gate failed with 4 conflicts,
3 suspect functions and 4 switches to review; FFXi.dll's with 1 suspect function. Each site was
read by disassembly and matched to a class the earlier builds record; one --reuse run each passed.

Verdicts, FFXiMain.dll
  NOT_CODE 0x10007670   the 21-case table of `jmp [ecx*4+0x10007670]` at 0x100063fc, after a ret
                        ("0x1000769c falls into 0x100076a0", as in 2025-12-26)
  NOT_CODE 0x100f4290   4-entry jump table after `ret; nop` (0x100f41b7, 0x100f41c5, 0x100f4273,
                        0x100f41ac); the next function is `mov eax,[esp+8]; sub esp,0xb0` at 0x100f42a0
  NOT_CODE 0x1015c1c0   4-entry jump table after a ret (0x1015c148, 0x1015c17f, 0x1015c188,
                        0x1015c191); `push esi; mov esi,[esp+8]` follows at 0x1015c1d0
  NOT_CODE 0x1015a8c0   aligned start inside `mov [edi+0xccc],esi`; REDECODE 0x1015a8bd
  NOT_CODE 0x1030cd80, 0x1030cdf0   16-byte records {ptr, int, flags, 0} in .text
  NOT_CODE 0x1030ed40   inside an 11-byte `mov eax,[0x1045487c]; jmp [eax+off]` stub; REDECODE 0x1030ed38
  SWITCHES 0x100063fc: 21   cmp ecx,0xa / ja ; add ecx,0xa (64-bit compare above): -10..10
  SWITCHES 0x10006fe1: 11   cmp edx,-5 / jb ; cmp edx,5 / ja ; add edx,5
  SWITCHES 0x1022014d: 9    ecx = byte [ebx+0x10220380]; 9 entries, then the index bytes
  SWITCHES 0x102a5118: 4    ecx = arg [esp+0x38]; entry 4 is 0x90909090 padding
Verdicts, FFXi.dll
  NOT_CODE 0x100067d0, REDECODE 0x100067c8   the stub false start every build has

Results
-------
                                  auto-analysis   after discovery   2025-12-26 after discovery
FFXiMain functions in .text       14,113          21,685            21,698
instructions                      887,960         993,608           994,162
instruction bytes                 83.3%           93.0%             93.0%
instructions outside functions    151,564         0                 0
scaled-index switches             856             942               943
tail_jumps                        -               2,152             2,156
FFXi.dll                          functions 374, switches 42, tail jumps 17 (as 2025-12-26)

Verification (macOS arm64, M2 Max)
----------------------------------
tools/build_posix.py prepare -> build 2025-11-12.
boot64: translated 21,816 functions (212 with unimplemented instructions, as 2025-12-26); BOOT64 OK.
host64: built. Signed in to a local LandSandBoat server (it asked for loader 2.0.0), entered
Bastok Mines and ran windowed at 1920x1080 and 60 fps without a translation fault (on ef145a0;
after rebasing onto 639ef7a, prepare, boot64 and host64 were run again and pass).
Not yet tested: a fight and a zone change. Not run: Windows targets (difftest, host, boot64 on
x64), and the modern menu (no addresses).
