gamecore common-function-table slots: session, lobby, per-frame pump, FFXi.dll's own slots
============================================================================================
Date: 2026-09-24. Static only (capstone 5 + pefile over reverse-engineering/unpacked/*.unpacked.dll,
image base 0x10000000), plus the live call log gamecore_live_calls.txt (translated FFXiMain against
retail gamecore). Table at gamecore 0x1006fbe8; slot N at +4*N. Scratch scripts (not in repo):
session scratchpad d.py / callers.py / grepm.py / gref.py.

CONVENTIONS THAT APPLY TO EVERY SLOT BELOW
  * Every slot in this group is CDECL: each gamecore target ends in a plain `ret` (no `ret N`), and
    every FFXiMain/FFXi caller cleans the stack (`add esp,4*n`) after calling the thunk
    (`mov eax,[tbl]; jmp [eax+disp]`). Pop count = 0 for all. A native slot reads its args at
    guest [esp+4], [esp+8], ... and leaves esp alone. Return value in eax.
  * "Handle" values are small non-negative ints; negative returns are error codes (retail uses
    them as -(code), several shown below). FFXiMain generally treats <0 as fatal for the step.
  * +0x5e0 (slot 376) holds the SAME pointer as +0x30c (slot 195): 0x1001db60. It is an alias in
    the table, not a second use: FFXiMain has no call to the +0x5e0 thunk. The live log labels
    195 as "+0x30c/0x5e0" because it resolves by address. Likewise +0x5e4 (377) = 0x1001db90, the
    engine 196 calls. Native: put the same function in both slots (harmless) or leave 376/377 null.

Confidence scale: HIGH = read instruction by instruction and matches the live log; MEDIUM = read
but a detail (meaning of a field, exact retail value) is inferred; LOW = inferred.

============================================================================================
A. LOBBY BRING-UP SLOTS
============================================================================================

--------------------------------------------------------------------------------------------
+0x0cc8  slot 818  gamecore 0x10045480   online-session pump (lobby-entry check)   conf HIGH
--------------------------------------------------------------------------------------------
Convention: cdecl, no args (live: stack words are caller garbage). int pump(void).
gamecore:
  if [0x103df7f8] == 0 (online-session engine not initialised)  -> return 1 immediately.
  else: takes mutex 0 (0x10047fb0/fe0: WaitForSingleObject/ReleaseMutex on 0x103df808[0]), runs the
  returns ebp: 0 or 1 in normal operation, or a negative code:
     -1024 (0xfffffc00), -1039 (0xfffffbf1), -1038 (0xfffffbf2, keepalive timeout > 5000 ms),
     -1041 (0xfffffbef), -1025 (0xfffffbff, disconnected), -1043 (0xfffffbed, not latched).
  A negative result (except -1043) is LATCHED in [0x10099254]; while it is negative every later
  call returns the latched code. Also invokes a registered error callback [0x10099268](code).
State read: 0x103df7f8, 0x1009924c, 0x1009941c (sign-in state), timers 0x1009a6d8..0x1009a808.
State written: 0x10099254 (sticky result), assorted session timers.
FFXiMain: only through 0x100edee0 (called from the lobby machine 0x100ed7f0 when step==0):
   r = slot818(); return (r==0 || r==1) ? 0 : -1;   -1 aborts the lobby bring-up.
Live: 2 calls, both = 1.
Native: return 1 (the "session engine not initialised" answer; always acceptable to FFXiMain). If
  the host later has a real online session and loses it, return a negative code (e.g. -1025) to
  make FFXI drop to its error screen; not needed for v1.

--------------------------------------------------------------------------------------------
+0x0b04  slot 705  gamecore 0x1004a420   per-frame session pump                      conf HIGH
--------------------------------------------------------------------------------------------
Convention: cdecl, no args. int pump_frame(void).
gamecore: r = slot818-body (0x10045480)(); if callback [0x103e0340] != 0 call it(0) (never set by
  anything visible statically: 0x103e0340 has no writer in gamecore's recovered code); return r.
FFXiMain: 0x100daf40 (network manager's per-frame state machine, states 0-2) at 100daf61,
  100dafe0, 100db00b: result stored to [mgr+0xb8] and not otherwise tested in that function
  (no reader of +0xb8 on that object was found in 0x100d0000-0x100f8000; LOW that nothing else
  reads it). Called once per frame.
Live: 32 calls, all = 1.
Native: return 1. No side effects.

--------------------------------------------------------------------------------------------
+0x0374  slot 221  gamecore 0x1000ff40   start async DNS resolve                     conf HIGH
--------------------------------------------------------------------------------------------
Convention: cdecl. int dns_begin(const char *hostname).
gamecore:
  malloc(0x120) record; [0x100a66d4]==0 (resolver not initialised) -> -2071 (0xfffff7e9);
  allocate a handle = first free index in the 4-entry table 0x100a66c4 (none free -> -2);
  0x10012be0(name): 4-entry name cache (+ a 13-char hashed cache) -> on hit copy the cached 0x14-byte
    result into rec+0x10c, rec.done=1 (no thread);
  on miss: strncpy name (0xff) to rec+0xc and CreateThread(0x100100a0) which calls
    gethostbyname(name) and stores, under lock 0x100a66ac:
       rec+0x10c u16 = 1, rec+0x110 u32 = ntohl(h_addr_list[0]) (HOST byte order), rec+6 i16 = 0;
       on failure rec+6 = -19 (0xffed). Then rec.done(+4)=1.
  Returns the handle (0..3); -12 (0xfffffff4) on malloc/thread failure.
Record (0x120): +0 next, +4 u8 done, +5 u8 from-cache, +6 i16 status, +8 i32 handle, +0xc name[0x100],
  +0x10c result[0x14].
FFXiMain use: stored at [lobbyctl+0x136b0]; <0 -> stored at [lobbyctl+0x136ac] (error) and the
  bring-up returns -1.
Live: 1 call (the lobby host string, at 0x0be62054) = 0.
Native: record the name, return handle 0 (or a small counter). Resolve lazily in 222. Here,
  map the lobby host name to the configured LSB lobby address (see DESIGN DECISION D2); do not rely on
  system DNS. Never return <0 unless configuration is missing.

--------------------------------------------------------------------------------------------
+0x0378  slot 222  gamecore 0x100101e0   poll async DNS resolve                      conf HIGH
--------------------------------------------------------------------------------------------
Convention: cdecl. int dns_poll(int handle, uint8_t out[0x14]).
Returns: -2071 resolver not initialised; -10 (0xfffffff6) unknown handle; 0 still pending;
  <0 = the record's status (e.g. -19 lookup failed) - handle freed; 1 = done: copies 0x14 bytes
  rec+0x10c -> out, inserts the result into the name cache (0x10012a10) unless it came from it,
  frees the handle (0x100102f0) and the record.
Pointer write (only on return 1): out[0x00..0x14):
   +0x00 u16  1 (address family/"valid" marker)
   +0x02 u16  not written by the thread path (malloc garbage) - FFXiMain does not read it
   +0x04 u32  IPv4 address in HOST byte order (u32 value 0x7F000001 for 127.0.0.1, i.e. memory
              bytes 01 00 00 7F)
   +0x08..+0x14 not written (garbage) - not read
FFXiMain (100ed8b8, lobby step 1): r = slot222(h, &buf /*esp+0x30, 0x14-byte local*/);
   r<0 -> error/-1; r==0 -> return 0 (poll again next frame); r>0 -> addr =
   buf[4]<<24|buf[5]<<16|buf[6]<<8|buf[7] -> inet_ntoa(addr) -> lobby host string at
   [lobbyctl+0x136bc]. With the host-order store above that prints the right dotted quad.
   Port: htons(word [lobbyctl+0x10]) - FFXiMain's own state, not gamecore's.
Live: 2 calls: first = 0 (pending), second = 1.
Native: on first poll (or immediately) write out[0]=1 (u16), out[2]=0, out[4] = u32 host-order
  IPv4 of the lobby server, zero the rest; return 1. Returning 0 once first is optional.
  Hostname must resolve to IPv4; there is no IPv6 path.

--------------------------------------------------------------------------------------------
+0x030c  slot 195  gamecore 0x1001db60 (-> 0x1001d7e0)  presence "session login / ChangeMyStatus"
                                                                                    MEDIUM (field names)
--------------------------------------------------------------------------------------------
Convention: cdecl, 6 args. int status_begin(int handle, int chr, int mode, int openstat,
                                            int friendauth, int contents_class)
  (0x1001db60 just re-pushes a1..a6 and calls 0x1001d7e0.)
handler, session_login/describe_status; -2 always means "keep the current global value"):
  a1 handle       -2 = keep [0x1007541c]; -1..0x3f -> conn+0xc8; < -2 -> -7190 (0xffffe3ea);
                  >= 0x40 -> -7190
  a2 chr          -2 = keep [0x10075420]; -1..0x3f -> conn+0xcc (active character id in the
                  handle); >= 0x40 -> -7171 (0xffffe3fd)
  a3 mode         -2 = keep byte [0x100ac54c]; 0 or 1 -> conn+0xdc; else -7185 (0xffffe3ef)
  a4 openstat     -2 = keep [0x10075424]; 0..4 -> conn+0xd0; else -7185
  a5 friendauth   <0 = keep [0x100aaac8]; >=0 -> conn+0xd8
  a6 class        0..0x3ff -> conn+0xd4 (contents class; 1 = FFXI); else keep word [0x10075428]
  Also: if the resulting openstat==3 and handle<0 or handle is flagged in 0x100aaae0 -> -263.
  Every field that differs from the current global, or the very first call ever
  ([0x100ac548]==0), sets conn+0xde "changed" = 1.
  -256), fill the 0x28-byte request body at [conn+0x328] (layout in section C), start the
  connection state machine (0x1001ff20(conn,6,0)). Returns the connection handle 0..3, or <0.
FFXiMain call sites (11; the lobby one is 100edb36, step 11):
  100edb36  (-2,-1, 0,-2,-1, 1)  lobby bring-up: class FFXI, no active char   -> [lobbyctl+0x136a8]
  100ee3b0  ( 0, 2, 0,-2, ...)   live at char select (100ee170)                  (see live log)
  100f1894  (-2,-1,-2,-2,...)    live later (100f1880 wrapper; logout/status)
  100f186a, 100f18af, 100f18cf, 100f18fb, 100f6569: other status wrappers (100f1800..100f1904,
            100f6520) - same request with other field values.
  <0 -> lobby error, bring-up returns -1.
Live: 3 calls, all = 0 (handle 0).
Native: see "Native for 195/196" after slot 196.

--------------------------------------------------------------------------------------------
+0x0310  slot 196  gamecore 0x1001df10 (-> 0x1001db90)  poll the 195 request             conf HIGH
--------------------------------------------------------------------------------------------
Convention: cdecl. int status_poll(int handle).
Returns: 0 pending; 1 complete; <0 error (connection freed). Specific errors: -2054 (0xfffff7fa)
  handle out of 0..3; -5136 (0xffffebf0) slot not in use; -515 (0xfffffdfd) 0x10019bc0 false
  (no session crypto template / not signed in); -260 (0xfffffefc) 100 s request timeout;
  -(5200+status) for a non-zero reply-header status; -5314 (0xffffeb3e) server-side refusal
  (reply status path; latches body[0], body[8], body[0xc] into 0x100ac540/530/534).
Engine 0x1001db90 per call: 0x1001ebd0 (validate/timeouts, returns 1 to proceed), then one step of
  byte state [conn+8]:
   0: if conn+0xde ("changed") == 0 -> finish, return 1 WITHOUT any network traffic and WITHOUT
      touching V. Else ->1.
      plaintext hello 0x28 / reply 0x18 (nonce at +0x14 -> conn+0xb8).
   2: 0x1001f4d0(conn, cmd=4, sub=5, len=0x28): send 0x28-byte request header (section C).
   3: 0x1001f970(conn, 0x28, 1, body): send the body.
   4: 0x1001f690: receive the 0x18-byte reply header.
   5: 0x1001f800(conn, 0x20, 1, rbuf): receive the 0x20-byte body (0x1c + sum32, checked). Then:
        memcpy(0x100aaad0, rbuf, 0x10)                 <- SESSION VALUE V   (read by slot 1003)
        0x10019c50(&iv); x = 0x10019b90(0x1001a1a0(0), byte[0x10404a92]);
        0x1001a2d0(0x104057b0, &iv, rbuf, x); 0x100135f0(0x104057b0)
                                                        <- 0x34-byte block  (read by slot 936)
   6: commit conn fields to the globals (0x1007541c handle, 0x10075420 chr, 0x10075424 openstat,
      0x10075428 class, 0x100ac54c mode, 0x100aaac8 friendauth, 0x100ac548=1), maybe 0x1002a520
      (presence refresh), close (0x1001fbd0), return 1.
FFXiMain (lobby step 12, 100edb75): r=slot196(h): 0 -> poll again; >0 -> next step; <0 -> error.
Live: lobby call polled 15x0 then 1; char-select call 15x0 then 1; later call 15x0 then 1.

Native for 195/196 (both slots):
  195: validate args exactly as above (return the same negative codes for out-of-range values;
       FFXiMain never passes bad ones), fold -2/-1 "keep" semantics into a native status struct
       {handle, chr, mode, openstat, friendauth, class}, return handle 0 (or 0..3 round-robin).
  196: return 1 when the request is complete, 0 while waiting, <0 on failure. On completion the
       native state must hold V (16 bytes) and the 0x34-byte block (see 1003/936).
  WHERE V COMES FROM is DESIGN DECISION D1 (end of file). Summary: V is the first 16 bytes of the
  ffxi_session_value -> publish_session_value). So the native gamecore does NOT need its own

--------------------------------------------------------------------------------------------
+0x0ea0  slot 936  gamecore 0x10020020   copy the 0x34-byte "authCode" block        conf HIGH
--------------------------------------------------------------------------------------------
Convention: cdecl. int get_auth_block(uint8_t *out).
gamecore: memcpy(out, 0x104057b0, 0x34); return 0. (The block is written only by 196's state 5.)
Pointer write: out[0..0x34). Nothing else.
FFXiMain (lobby step 13, 100edbba): buffer = 0x40-byte local (esp+0x44 .. end of frame);
  r<0 -> error; then 0x101163d0(lobby, buf) copies ALL 0x40 bytes to lobby+0xa24 and sets
  lobby+0xa20 = 1. So bytes 0x34..0x3f of the authCode are uninitialised stack in retail too.
  Uses of lobby+0xa24/+0xa20:
   - RequestLobbyLogin 0x26 builder (0x10116620): authCode 0x40 bytes -> packet +0x34..+0x74;
     because +0xa20 != 0 it zeroes the first byte of the account-name field (+0x1c).
   - RequestSelectChr 0x07 builder (0x101167f0..): packet +0x48 = MD5(authCode[0x40] || passwd[16]
     || lobby+0x1a2c || lobby+0x1a30 || ...) over 0x5c bytes.
   - 0x10116d90 (passwd builder): +0xa20 != 0 selects MD5(V[0..16) || LE32(md5key)) - a fixed
     16-byte V - instead of MD5(V[0..strlen) || LE32(md5key)) (the -pass/direct-boot mode).
     THIS is the load-bearing effect of slot 936: calling it (return >=0) switches the client to
     "binary 16-byte V" hashing.
LSB check (C:\Dev\rubymatrix-server\src\login\view_session.cpp): 0x26 logs the account-name field and
  ignores authCode (l.513-529); 0x07 checks only passwd at +0x34 (l.104-130, verifyNear); the 0x07
  +0x48 digest is not read. xi_map uses session_key only. So NO server checks these bytes.
Live: 1 call = 0.
Native: fill out[0..0x34) with zeros (or random bytes, if we want the field to look retail-ish),
  return 0. Must not return <0. Content is free (conf HIGH for the current LSB fork; would change
  only if a server someday verifies authCode, which retail servers cannot sensibly do).

--------------------------------------------------------------------------------------------
+0x0fac  slot 1003 gamecore 0x1001c870   copy the 16-byte session value V            conf HIGH
--------------------------------------------------------------------------------------------
Convention: cdecl. int get_session_value(uint8_t out[16]).
gamecore: memcpy(out, 0x100aaad0, 0x10); returns 0x10 (the helper 0x10012380 returns the count).
  0x100aaad0 is written only by 196's state 5 (reply body bytes 0..15); zero before that.
Pointer write: out[0..16).
FFXiMain (100edbf7, lobby step 13): return value ignored; 0x101164e0(lobby, buf) copies 16 bytes to
  lobby+0x10. That is the V used by every lobby passwd: 0x1F RequestGetChr +0x1c and 0x07
  RequestSelectChr +0x34 = MD5(V || LE32(md5key)) (0x100d7ee0 with length 16, because 936 set
  lobby+0xa20), md5key = K+1 / K+3 per the LSB integration notes s3/s10.
Live: 1 call = 0x10.
What LSB checks (rubymatrix-server src/login/: its account-identity source, and view_session.cpp
0x1F/0x07):
  - the account table's session_value must be exactly 16 bytes with NO 0x00 byte (readValue/
  - 0x1F: passwd must equal MD5(value || LE32(k)) for k in a small window around K+1, over the
    recently-issued candidate set; match identifies the account. 0x07: same at lastKeyUsed+1..+2.
Native: memcpy(out, V, 16); return 16. V MUST be byte-identical to the value in
  the account table's session_value for this member (in the account DB), 16 bytes, no NUL.

============================================================================================
B. OTHER FFXiMain SLOTS IN THIS GROUP
============================================================================================

--------------------------------------------------------------------------------------------
+0x10e0  slot 1080 gamecore 0x10012920   client UDP base port                        conf HIGH
--------------------------------------------------------------------------------------------
Convention: cdecl. FFXiMain passes one arg (push 0; add esp,4); gamecore ignores it.
  uint32 get_udp_port(int unused).
gamecore: v = [0x100739d4] (init -1); if v >= 0 return v + 54090 (0xd34a);
         else return (v & 0xffff0000) | word[0x100739d8]  (word init 0xd34a = 54090).
  0x100739d4 is set by the sign-in machine (0x10012900 from 0x10044b00: 0 or [0x1009a4f4], an
  account-server "port offset"); 0x100739d8 by a presence profile parser (0x10012910 from 0x1001bbc0:
  54090 + (word[+0x22]-1)).
FFXiMain (100dc4d4, UDP socket setup 0x100dc440): port = htons(low16(ret)); bind(INADDR_ANY:port);
  on failure port += 0x100, up to 100 tries.
Live: 1 call = 0xffffd34a (low 16 = 54090).
Native: return 54090 (0xd34a). Optionally a configured base port. High 16 bits don't matter.

--------------------------------------------------------------------------------------------
+0x0ac4  slot 689  gamecore 0x1004ccf0   service clock (Unix seconds)                conf HIGH
--------------------------------------------------------------------------------------------
Convention: cdecl. int core_time(uint32 *out).
gamecore: *out = [0x103e4c30] + (GetTickCount() - [0x103e4c40]) / 1000;  return [0x103e4c38].
  Base set at init (0x1004cc00: CRT time() = GetSystemTimeAsFileTime -> Unix epoch seconds,
  aligned to a second boundary, flag 0) and replaced by server time from an account-server message
  (0x1004cca0(t) from 0x10016120, flag = 1).
Pointer write: out[0..4) u32 Unix time (seconds since 1970, UTC).
FFXiMain: only via 0x100dbe20 (returns the time; the flag is discarded). 33 call sites
  (timestamps for chat/logs/mail etc.).
Live: 32 calls, all return 1.
Native: *out = (uint32)time(NULL) (UTC, Unix epoch); return 1.

--------------------------------------------------------------------------------------------
+0x0d18  slot 838  gamecore 0x10046010   online-session sign-in state                conf HIGH (read),
                                                                                    MEDIUM (value)
--------------------------------------------------------------------------------------------
Convention: cdecl, no args. int signin_state(void).
gamecore: under mutex 0 returns [0x1009941c]: the sign-in machine's (+0xcbc) coarse state,
  0 = not signed in, 2/3 = signing in / signed in (818 treats 3 specially).
FFXiMain (100db0ad, network manager state 4 = game shutdown / return to the viewer):
  if slot838() == 0 -> [0x10456940] = -1 (FFXiMain's pending error code; <0 makes the main loop
  and WndProc 0x10011a00 raise error message 0x7d1).
Live: not reached (no shutdown in the log).
Native: return 3 (signed in). Returning 0 would raise a spurious connection error at exit.
  If the host's online session is genuinely gone, 0 reproduces retail.

--------------------------------------------------------------------------------------------
+0x0694  slot 421  gamecore 0x10018200   region/language code                        conf HIGH
--------------------------------------------------------------------------------------------
Convention: cdecl, no args. int get_lang(void).
gamecore: if [0x100740f8] < 0 (init -1): [0x100740f8] = [0x100aa31c] (set by slot 1528 +0x17e0,
  init 0). Return [0x100740f8]. Slot 420 (+0x690) sets 0x100740f8 if value < 9.
Callers: FFXi.dll 0x10004790 -> param block +0x28; FFXiMain 0x10015841 (FFXiGameMain).
Live: 1 call = 1.
Native: return the configured language code; 1 for the US/English client (what retail returned
  live). (Retail values 0..8; 0 = JP presumably, 1 = US/EN, 2 = EU - MEDIUM on the others.)

--------------------------------------------------------------------------------------------
+0x0730  slot 460  gamecore 0x10044380   a flag set by the Viewer                    conf HIGH (read),
                                                                                    LOW (meaning)
--------------------------------------------------------------------------------------------
Convention: cdecl, no args. int get_flag460(void). Returns [0x1009aa58] (init 0xffffffff), set only
  by slot 459 (+0x72c, 0x10044370(v)), which app.dll (the Viewer) calls.
Caller: FFXi.dll 0x10004a4e -> byte at param block +0x44.
Live: not in the log (FFXi.dll calls were not traced).
Native: return 0xffffffff (the value with no Viewer, i.e. what FFXI sees if the Viewer never set
  it) unless a Viewer-equivalent decision says otherwise. Block +0x44 gets 0xff.

--------------------------------------------------------------------------------------------
+0x06e4  slot 441  gamecore 0x100183e0   read a counter (2010 client only)           conf HIGH (read),
                                                                                    LOW (meaning)
--------------------------------------------------------------------------------------------
Convention: cdecl. int get_counter441(uint32_t* out). *out = [0x100aa828]; returns 0.
gamecore: 0x100aa828 is zero-initialised and only slots 410 (+0x668, set), 411 (+0x66c, add 1
  when flag 0x100aa830 bit 0 is set) and 444 (+0x6f0, subtract when the same flag is set) change
  it; slots 1173/1174 read and set the flag. FFXI has no thunk for any of those five, so only
  the Viewer could move it.
Caller: the 2010 FFXiMain (build 2010-03-16) only, 0x100d5235: on 0 it stores the low word of
  *out at +0xe of the object it is setting up. Later builds dropped the call (2025-11-12's same
  function, 0x100f1b5e, goes straight on).
Native: *out = 0, return 0 (the value with no Viewer).

--------------------------------------------------------------------------------------------
+0x0f24  slot 969  gamecore 0x1004a440   set exit/error code                         conf HIGH
+0x1008  slot 1026 gamecore 0x1004a450   set exit/error code + message
--------------------------------------------------------------------------------------------
Convention: cdecl. void set_error(int code)  /  int set_error_msg(int code, const char *msg).
gamecore 1026: [0x103e0328] = code; if msg: copy 0x3ff bytes of msg to 0x103dfd28 and NUL-terminate
  at [0x103dfd28+0x3ff]; return 0x3ff. If msg NULL: 0x103dfd28[0] = 0; return 0.
gamecore 969: 1026(code, NULL).
State read back by: slot 970 (+0xf28, 0x1004a490) returns the code; slot 1027 (+0x100c, 0x1004a4a0)
  returns 0x103dfd28 - consumers are the retail launcher/the Viewer after the game exits.
Callers: FFXi.dll 10004fff: slot969(0 | -14 | -15) at GameStart exit (-14/-15 from the block
  flags +0x1c.. restart/exit variants); FFXi.dll 1000498d: slot1026(-1, message) when the single-
  instance mutex already exists; FFXiMain 100176fe: slot969(0) at shutdown unless a message was
  set; FFXiMain 10017647: slot1026(0, msg) (then counts messages in 0x10456a90).
Native: store code and message (<= 1023 chars) in native state; 1026 returns strlen-independent
  0x3ff/0 as above (callers ignore it). The host reads them after GameStart returns to
  decide what to show (error dialog / exit code).

--------------------------------------------------------------------------------------------
+0x0f54  slot 981  gamecore 0x10039630   "-patch" buffer size                        conf HIGH
+0x0f58  slot 982  gamecore 0x1003963a   "-patch" fill buffer
--------------------------------------------------------------------------------------------
981: cdecl, no args, returns 0x10000.
982: cdecl, int (void *buf): buf==NULL -> -0x3000 (0xffffd000); else 0x1003965a(buf,0) which just
  returns 1. The buffer is NOT written.
Caller: FFXi.dll 10004dfb/10004e09 on the "-patch" command-line path: size=981(); p=malloc(size);
  r=982(p); ... free(p).
Native: 981 -> 0x10000; 982 -> buf ? 1 : -0x3000. No writes.

============================================================================================
D. THE LOBBY BRING-UP SEQUENCE (FFXiMain 0x100ed7f0)
============================================================================================
Driver: FFXiMain 0x100da760 (network top-level state machine, called from the per-frame manager
0x100daf40, which is called from 0x10001ba1/0x10016596/0x1024cb1a..) calls
  r = 0x100ed7f0(&mgr->step /* esi+0xc */) once per frame while mgr state requires the lobby
  (and [esi+0x90]==0x64): r = 0 keep going, 1 done, -1 failed (-> error path).
Context object: lobbyctl = [0x104df7b0] (NULL -> -1). Lobby connection object = [lobbyctl+0x13690].
Error code of the failing step is stored at [lobbyctl+0x136ac].
Frame locals: V buffer esp+0x20 (16), DNS result esp+0x30 (0x14), authCode esp+0x44 (0x40).
On entry with step==0: 0x100edee0 = slot 818 must be 0/1, else -1; then 0x100edeb0 resets the
  wait counter [0x104ca688].
Each "msg(8,n)" below is a progress message (0x10152f00/0x100f0010).
 step 0  msg(8,0). If [0x104ca470]==0 (first time): h = slot221(lobby host);
         h<0 -> -1. step=1 and FALL THROUGH into step 1 in the same call.
 step 1  If [0x104ca470]!=0: step += 2 (-> 3, skip DNS+connect). Else r = slot222(h,&dns):
         r<0 -> -1; r==0 -> return 0; r>0: host = inet_ntoa(dns+4), port = htons([lobbyctl+0x10]),
         copy 15-byte string 0x104ca678 -> lobbyctl+0x136cc, 0x101152e0(), 0x10115510(lobby conn
         start, TCP to host:port), [0x104ca470]=2, step=2.
 even steps 2,4*,6,8,10,14,16,18,20: WAIT = 0x10115d60(lobby, &st /*+0x13698*/): st==0 -> step++;
         st==-1 -> -1; else (still waiting) if step >= 14 count frames in [0x104ca688] and fail at
         3600 frames (~1 min). (*step 4 is special: 0x10115d60 then step++ unconditionally.)
 step 3  msg(8,1); 0x10115830(lobby); step++.
 step 5  if no error and 0x101163b0(lobby)==1 (lobby+0x2f0f8: already logged in) -> step=21;
         else clear error, 0x101158b0(lobby,1); step++.
 step 7  msg(8,2); 0x101157f0(lobby); step++.
 step 9  msg(8,3); 0x10115580(lobby); step++.
 step 11 msg(8,4); h = slot195(-2,-1,0,-2,-1,1) -> [lobbyctl+0x136a8]; h<0 -> -1; step++.
 step 12 r = slot196(h): 0 -> return 0; <0 -> -1; >0 -> step++.
 step 13 msg(8,5); 0x100f7750(); r = slot936(authbuf) <0 -> -1; 0x101163d0(lobby,authbuf)
         [lobby+0xa24 = 0x40 bytes, +0xa20 = 1]; slot1003(vbuf) (return ignored);
         0x101164e0(lobby,vbuf) [lobby+0x10 = V]; 0x10116400 (8 bytes: byte [[0x103601cc]+0xa8]);
         expansion bitmask from [0x10456a68]+0x10 -> 0x10116430; two dwords from
         [0x10456a68]+0x1c.. -> 0x10116490 x2; 0x10115610(lobby) (queues 0x26 RequestLobbyLogin);
         step++.
 step 15 msg(8,6); 0x10116450/0x10116470 read server results into [0x103601cc]+0xac/+0xb4,
         expansion flags into [0x10456a68]+0x14; 0x10115620(lobby); step++.
 step 17 msg(8,7); 0x10115bc0(lobby); step++.
 step 19 0x10115980(lobby, lobbyctl+0x136dc); step++.
 step 21 return 1 (lobby ready; character list etc. continue in other machines 0x100ee0b0,
         0x100edfc0, 0x100ee170 - the latter makes the second 195/196 pair at character select).
Expected gamecore returns, in order (matches the live log seq 9645-10021):
   818 -> 1 ; 221 -> 0 (handle) ; 222 -> 0 then 1 (+ out[4]=IP) ; 195 -> 0 (handle) ;
   196 -> 0 ... then 1 ; 936 -> 0 (+ 0x34 bytes) ; 1003 -> 16 (+ V).
Later: 195(0,2,0,-2,...)/196 at character select (100ee3b0/100ee3dd, live seq 27491-27600),
   1080 at UDP setup for the zone (27748), 195(-2,-1,-2,-2,...)/196 later (34238-34253).
   These later 195 calls do not re-read V through 1003, but in retail each completed request
   sign-in for exactly this reason).
