Files
OpenFUT/fifa17-recon/tools/ghidra_queries/q_cd_state_6.py
T
funman300 e578443d73 fifa17-recon: tradingEnabled is 0, and that is why the transfer options are greyed out
Card-subsystem pass, 11 agents plus three adversarial verifiers. Full writeup in
docs/plan-2026-08-06-card-subsystem.md. Two of the results below correct things I
committed earlier today.

THE GREYED-OUT TRANSFER OPTIONS ARE EXPLAINED. "Place on Transfer List" and "List on
Transfer Market" have been disabled in the reveal screen and nobody knew why.
TO_TRADE_PILE (FUN_1801a7260) requires BOTH item+0x49 tradeable AND a service gate at
vtable slot +0x270. That slot is `movzx eax, byte [rcx+0x1fd2e]; ret`, and 0x1fd2e is
the tradingEnabled gate byte. Read live and reproduced independently:

  slot +0x2b0 friendlySeasons  disp 0x1fd3a  VALUE=1
  slot +0x2c8 draftMode        disp 0x1fd3d  VALUE=1
  slot +0x2e0 packOpeningAnim  disp 0x1fd45  VALUE=1
  slot +0x270 tradingEnabled   disp 0x1fd2e  VALUE=0

tradingEnabled is the FIRST gate byte found that is not 1. This partly rehabilitates
the settings work from this morning: that plan died because every gate it targeted
already read 1, and the conclusion drawn was that the settings array does not matter.
It does. It matters for a flag nobody was looking at, and tradingEnabled is ALREADY in
_SETTINGS_KEEP, plumbed and never sent because _SETTINGS_MODE defaults to off.

So the fix is two things, not one: FUT_SETTINGS=keep AND untradeable false. Shipping
only the boolean would look like the finding failed.

THE DISCARD "MISS" NEVER EXISTED, which corrects e3092ca. fcc_discardcoins is resident
and complete, the client lookup runs and is correct, and it lands at item+0x3c. The
tile simply binds +0x38, which is OUR value, and nothing falls back to +0x3c. So the
client was not failing a lookup; it was faithfully displaying the 0 we sent. Same
observable, completely different mechanism, and the version in e3092ca is wrong.
FUT_DISCARD_SEND remains exactly the right fix, now for the right reason.

WHAT FUT PAYS FOR STAFF IS NO LONGER UNKNOWN. Same formula, but the rating input is the
table `value` column: gkcoachcards 9000081 value 66 gives 36, and the client's own
+0x3c reads 36. That closes the gap I flagged in e3092ca as not-guessed.

CLUB ITEM SUBTYPES, the standing unknown in CARD_SYSTEM.md, are settled: kit 9,
stadium 10, badge 11 are cardtype 7 (not 9), ball 30, league logo 31 by elimination.
All five constants in fut_clubitems.FAMILIES are wrong and all five currently sit in
the TROPHY block 0x91..0x96. Note the probe route the doc preferred could never have
answered this: probe_shelf()'s candidate set lacks 9, 10 and 11, so it would have spent
a launch and returned nothing for three of five families.

THE CARD MODEL FIELD MAP now exists, 28 rows, every field we send with the byte it
lands on and whether the client keeps it. Built by diffing what we serve against the
parsed records in the live heap (stride 0x180, anchored by a satellite back-pointer
rather than by assuming the +0x38 offset). Corrections that change what we serve:
+0x54 is the discard LEVEL not itemType, +0x49 is untradeable INVERTED, +0x5c is
itemState, definitionId is not an atom at all.

A HIGH-CONFIDENCE ABSENCE CLAIM WAS REFUTED IN VERIFICATION: playStyle IS stored, at
+0x88. Its controls were raw scalars while playStyle is a DECODED scalar, so the
control was the wrong FORM. That is a new variant of the absence trap, which has now
cost six wrong verdicts, and it is recorded in the doc.

FIX TO MY OWN PATCH from e3092ca: purchased() and last_pack() lacked the _with_discard
wrapper that items() had, so the pending pile, which is the one place a quick-sell
value is actually read, served unstamped cards. Found by verification, not testing.
All three read paths now stamp.

Correcting an overstatement in e3092ca: "turning the flag off is a true revert" holds
for the read paths, which copy, but NOT for cards minted while armed, because _item()
stamps at creation and those persist (9 items currently). Kept deliberately: the pack
reveal serves itemList straight from open_pack(), not through purchased(), so removing
creation-stamping would leave the screen that matters unstamped. Persisted values are
correct and self-heal, since every read recomputes and overwrites.

Nothing here has been on screen. Six patches are proposed in the doc as pasteable text,
env-flagged, defaulting off, none applied.

Live: 439 contract checks, 414 card-family checks, market suite, all pass.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-06 10:07:01 -07:00

130 lines
5.4 KiB
Python

"""D3 Q6: the item ACTION vocabulary (TO_TRADE_PILE / DISCARD ...) and every consumer
of the tradeable flag; plus a precise search for code that compares item+0x5c against
an itemState value.
WHAT LED HERE. 'TO_TRADE_PILE' (0x1801f4d48) and 'DISCARD' (0x1801f4d28) are adjacent
in .rdata and BOTH are referenced by the single function FUN_18003e370, which also
manipulates a byte at +0x49 -- the tradeable flag's offset. That is the action-menu
builder, i.e. the thing that greys entries out.
CONTROL for the string window: the window must also contain other action names we can
recognise as menu entries (not random data); if the neighbourhood is unreadable garbage
the window is wrong and the identification is not made.
CONTROL for the itemState-value scan: the same look-ahead machinery, pointed at
displacement 0x3c with the constant 0, must rediscover the KNOWN discard guard
`if ((int)local_150 == 0)`-style tests. If the look-ahead finds nothing anywhere the
scan is broken and its silence about +0x5c means nothing.
"""
import traceback, os
from collections import defaultdict
OUT = "/tmp/claude-1000/-home-alex-Documents-OpenFUT/8e521ca1-ca3e-4138-bb96-df1744dd1d30/scratchpad/cards/"
os.makedirs(OUT, exist_ok=True)
STATES = {1, 2, 5, 6, 0x64, 0x65, 0x66, 0x67, 0x68, 0xff, 0xffffffff}
def dump(tag, va, echo=True):
f = func(va)
if f is None:
print("%s %#x -> NO FUNCTION" % (tag, va))
return ""
src = dec(va)
print("=" * 78)
print("%s %#x %s len(src)=%d (FULL)" % (tag, va, f.getName(), len(src)))
print("=" * 78)
if echo:
print(src)
with open(OUT + "q6_%s_%x.c" % (tag, va), "w") as fh:
fh.write(src)
return src
try:
print("###### A. the action-name neighbourhood in .rdata")
a = 0x1801f4a00
while a < 0x1801f5200:
s = rd_str(a, 120)
if s and all(32 <= ord(c) < 127 for c in s):
xs = xrefs_to(a)
fns = sorted({(fn, e) for _, _, fn, e in xs if e})
print(" %#x %-46r xrefs=%d %s" % (a, s, len(xs),
["%s(%#x)" % (n, e) for n, e in fns][:5]))
a += len(s) + 1
else:
a += 1
print()
print("###### B. the action-menu builder and the tradeable-flag consumers")
for tag, va in (("actionmenu_18003e370", 0x18003e370),
("call_get49_1800bc580", 0x1800bc580),
("call_gate_1800e2a40", 0x1800e2a40),
("call_get48_1800d0600", 0x1800d0600),
("call_get48_1800e4fd0", 0x1800e4fd0)):
dump(tag, va)
print()
print("###### C. precise scan: [reg+DISP] loaded then compared to a constant")
print(" targets DISP=0x5c (itemState) and DISP=0x49 (tradeable)")
print(" CONTROL DISP=0x3c and DISP=0x4c, which we know are compared")
res = defaultdict(list)
for DISP in (0x5c, 0x49, 0x3c, 0x4c):
it = listing.getInstructions(True)
window = []
while it.hasNext():
ins = it.next()
window.append(ins)
if len(window) > 12:
window.pop(0)
s0 = str(window[0])
if ("+ %#x]" % DISP) not in s0:
continue
if "RSP" in s0 or "RBP" in s0:
continue
mn = window[0].getMnemonicString().upper()
if mn == "CMP":
# direct compare with immediate
try:
v = int(window[0].getOpObjects(1)[0].getValue())
except Exception:
v = None
f = fm.getFunctionContaining(window[0].getAddress())
res[DISP].append((int(window[0].getAddress().getOffset()),
f.getName() if f else "?", "DIRECT", v, s0))
continue
if mn not in ("MOV", "MOVZX", "MOVSX", "MOVSXD"):
continue
try:
dst = str(window[0].getOpObjects(0)[0])
except Exception:
continue
for nxt in window[1:]:
sn = str(nxt)
mn2 = nxt.getMnemonicString().upper()
if mn2 in ("CMP", "SUB", "TEST") and dst.replace("R", "E") in sn.replace("R", "E"):
try:
v = int(nxt.getOpObjects(1)[0].getValue())
except Exception:
v = None
f = fm.getFunctionContaining(window[0].getAddress())
res[DISP].append((int(window[0].getAddress().getOffset()),
f.getName() if f else "?", mn2, v, s0 + " ; " + sn))
break
print(" DISP %#04x -> %d load/compare pairs" % (DISP, len(res[DISP])))
for DISP in (0x3c, 0x4c, 0x49, 0x5c):
tag = "CONTROL" if DISP in (0x3c, 0x4c) else "TARGET"
print(" --- %s DISP %#04x, constants seen: %s"
% (tag, DISP, sorted({v for _, _, _, v, _ in res[DISP] if v is not None})[:40]))
print()
print(" --- every DISP 0x5c compare whose constant is an itemState value")
for a, fn, kind, v, txt in res[0x5c]:
if v in STATES:
print(" %#x %-20s %s %s | %s" % (a, fn, kind, hex(v), txt))
print()
print(" --- every DISP 0x49 compare")
for a, fn, kind, v, txt in res[0x49]:
print(" %#x %-20s %s %s | %s" % (a, fn, kind, v if v is None else hex(v), txt))
except Exception:
traceback.print_exc()