""" FAlogger: flight recorder for Fighters Anthology (FA.EXE). It only reads memory; FA.EXE is not modified. Run it with no arguments (or double-click the packaged falogger.exe) for flight mode: it records a .bin file per mission that you can play back at https://kuoyichen.github.io/FAoutput/tools/fa_replay.html Modes: python falogger.py same as flight python falogger.py objects list all current objects once per second (name, position, speed) python falogger.py log log all objects at 10 Hz to objlog.csv, and object spawns / despawns (missile launches, kills...) to events.csv python falogger.py flight * record flight_DATE_TIME.bin for playback (all objects + player actions); open it in fa_replay.html python falogger.py record for finding action fields (gear, ammo...). No window switching: start it, then fly and perform the actions in order, at least 5 s apart; it stops when the game closes. Saves the player object's raw bytes and key-press times to player_rec.bin python falogger.py analyze analyse player_rec.bin and write analyze_report.txt FA.EXE and this script can be started in either order. Build an exe (Windows, Python 3.8+): pip install pyinstaller pyinstaller --onefile --console --name falogger tools/falogger.py -> dist/falogger.exe Structures from static analysis (image base 0x400000 is fixed): 0x553838 uint16 object count limit (loop runs from 1 to count-1) 0x553848 ptr[] object pointer table 0x50CE80 working copy of the object being processed (same layout as other objects) Object layout: +0x00 uint8 class code +0x01 uint32 flags (bit0 = active) +0x05 ptr type definition; its 3rd NUL-terminated string is the type name +0x11/15/19 int32 X / Y (altitude) / Z (>>8 = feet) +0x1D uint16 heading +0x1F pitch +0x21 roll (65536 = 360 degrees) +0x34 int32 speed (>>8 = ft/s) verified on the player only """ import argparse, csv, ctypes, ctypes.wintypes as wt, struct, sys, time k32 = ctypes.WinDLL("kernel32", use_last_error=True) PROCESS_VM_READ, PROCESS_QUERY_INFORMATION, TH32CS_SNAPPROCESS = 0x10, 0x400, 0x2 PLAYER = 0x50CE80 OBJ_COUNT = 0x553838 OBJ_TABLE = 0x553848 OBJ_READ = 0xF0 # bytes read per object (includes the +0xEE target) PLAYER_IDX = 0x520A1C # u16: the player aircraft's object-table index (set by FA.EXE at 0x49139e) TARGET_OFF = 0xEE # object +0xEE u16: index of the object it is watching / locked on (0 = none) HUMAN_FLAG = 0x80 # object +0x10 bit 0x80 = human-controlled (low 7 bits = player number) MAX_OBJS = 2048 # safety limit class PROCESSENTRY32(ctypes.Structure): _fields_ = [("dwSize", wt.DWORD), ("cntUsage", wt.DWORD), ("th32ProcessID", wt.DWORD), ("th32DefaultHeapID", ctypes.c_void_p), ("th32ModuleID", wt.DWORD), ("cntThreads", wt.DWORD), ("th32ParentProcessID", wt.DWORD), ("pcPriClassBase", ctypes.c_long), ("dwFlags", wt.DWORD), ("szExeFile", ctypes.c_char * 260)] def find_pid(name=b"fa.exe"): snap = k32.CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0) e = PROCESSENTRY32(); e.dwSize = ctypes.sizeof(e) ok = k32.Process32First(snap, ctypes.byref(e)) while ok: if e.szExeFile.lower() == name: k32.CloseHandle(snap); return e.th32ProcessID ok = k32.Process32Next(snap, ctypes.byref(e)) k32.CloseHandle(snap); return None def attach(): pid = find_pid() if not pid: print("Waiting for FA.EXE to start... (Ctrl+C to quit)") while not pid: time.sleep(1); pid = find_pid() h = k32.OpenProcess(PROCESS_VM_READ | PROCESS_QUERY_INFORMATION, False, pid) if not h: sys.exit(f"OpenProcess failed ({ctypes.get_last_error()}); try running as administrator") print(f"Connected to FA.EXE (PID {pid})") return h def read(h, addr, n): buf = ctypes.create_string_buffer(n); got = ctypes.c_size_t() if not k32.ReadProcessMemory(h, ctypes.c_void_p(addr), buf, n, ctypes.byref(got)): return None return buf.raw _name_cache = {} def type_name(h, tptr): """Type name: type definition +5 points to the name strings (short name "F-14", then the long name, the data file and the .SH shape file). Returns "F-14|f14.SH"; if it can't be read, the type definition address is used as an ID (T1429C388).""" if tptr in _name_cache: return _name_cache[tptr] name = f"T{tptr:08X}" hdr = read(h, tptr, 9) if tptr else None if hdr and len(hdr) == 9: sp, = struct.unpack_from("> 8, "alt_ft": y >> 8, "z_ft": z >> 8, "hdg_deg": round(hdg / 65536 * 360, 1), "pitch_deg": round(pitch / 65536 * 360, 1), "roll_deg": round(roll / 65536 * 360, 1), "spd_kts": round((spd >> 8) * 3600 / 6076), } def snapshot(h): """Returns {index: object data}; index 0 = player. None = the game has exited.""" pb = read(h, PLAYER, OBJ_READ) if pb is None: return None objs = {0: decode(h, PLAYER, pb)} cnt_raw = read(h, OBJ_COUNT, 2) cnt = min(struct.unpack("4} {'cls':>3} {'name':<14} {'x':>9} {'alt':>7} {'z':>9} {'hdg':>6} {'kts':>5} flags") for i, o in sorted(s.items()): print(f"{i:>4} {o['cls']:>3} {o['name'][:14]:<14} {o['x_ft']:>9} {o['alt_ft']:>7} " f"{o['z_ft']:>9} {o['hdg_deg']:>6} {o['spd_kts']:>5} {o['flags']}") time.sleep(1) # Player action fields (from two test recordings on 2026-11-11) CTRL1_ADDR = 0x50CFEF # bit 0x40 = gear down (G), bit 0x80 = brake (B); 0x50CFF3 is a mirror CTRL2_ADDR = 0x50CFF0 # bit 0x01 = flaps (F), bit 0x04 = hook (H); 0x50CFF4 is a mirror STATION_BASE = 0x50D16E # weapon station array, 0x11 bytes each, +0 = uint16 rounds left STATION_STRIDE = 0x11 # station 0 = gun (675 rounds, ~14 per 0.2 s), then missiles / bombs STATIONS = 8 SELECT_ADDR = 0x50CF9C # selected weapon: value - 3 = station (3 = gun; [ ] cycles; empty stations are skipped) SELECT_OFFSET = 3 THROTTLE_ADDR = 0x50D074 # throttle setting % (100->68->58->44->41 in the first recording; 0x50D072 mirrors) [candidate, unconfirmed] RPM_ADDR = 0x50D06F # actual engine thrust % (slowly follows the throttle) [candidate, unconfirmed] ACT_BITS = [("gear", CTRL1_ADDR, 0x40, "gear"), ("brake", CTRL1_ADDR, 0x80, "brake"), ("flaps", CTRL2_ADDR, 0x01, "flaps"), ("hook", CTRL2_ADDR, 0x04, "hook")] ACT_FIELDS = [n for n, *_ in ACT_BITS] + ["sel_stn"] + [f"stn{i}" for i in range(STATIONS)] def player_actions(h): c = read(h, CTRL1_ADDR, 2); st = read(h, STATION_BASE, STATION_STRIDE * STATIONS) sel = read(h, SELECT_ADDR, 1) if not (c and st and sel): return None act = {n: int(bool(c[addr - CTRL1_ADDR] & bit)) for n, addr, bit, _ in ACT_BITS} act["sel_stn"] = sel[0] - SELECT_OFFSET for i in range(STATIONS): act[f"stn{i}"] = struct.unpack_from(" (addr, size, key names, times[], key bit masks[], frames[])""" raw = open(path, "rb").read() if raw[:6] == b"FAREC1": addr, size = struct.unpack_from("> bit & 1: lines.append(f" {ts[i]:8.2f}s pressed {nm}") lines.append("") lines.append("== Rarely changing bytes (most likely gear, ammo, weapon state) ==") cands = [] for off in range(size): ev = [] for i in range(1, len(frames)): a, b = frames[i - 1][off], frames[i][off] if a != b: ev.append((ts[i], a, b)) if 1 <= len(ev) <= 40: cands.append((off, ev)) cands.sort(key=lambda c: len(c[1])) for off, ev in cands: lines.append(f"+0x{off:03X} (0x{addr + off:X}) changed {len(ev)} times:") lines.append(" " + ", ".join(f"{t:.2f}s {a}->{b}" for t, a, b in ev[:20]) + (" ..." if len(ev) > 20 else "")) txt = "\n".join(lines) open(report, "w", encoding="utf-8").write(txt) print(txt); print(f"\nWrote {report}; send this file to Claude.") AIRCRAFT_CLS = 4 AI_FLAG = 0x80 # object +1 byte bit 0x80: AI-controlled (2026-11-12 test: player F-14 = 0x17, B-52 = 0x97) RAW_AIRCRAFT = 0x380 # raw bytes saved per aircraft per frame (objects are ~0x374 apart); used for HP etc. HARD_LAST = 0x35B # start of the LAST hardpoint entry in an aircraft object (entries are 0x11 bytes, # +6 type pointer, +0xA u16 count). The array is end-aligned, so where hardpoint 0 # starts depends on how many hardpoints the .PT defines (factory F14.PT: 11 -> 0x2BB; # Kuoyi's F14.PT: 10 -> 0x2CC). GUN_HARD = 3 # hardpoint 3 = gun on FA aircraft; the select byte is the hardpoint index HARD_PTR = 0x114 # dword in the object: offset of the hardpoint array (FA.EXE reads [0x50CF94]); # it points at an entry's type pointer, i.e. our entry start + 6 ECM_CLASS = 9 # hardpoint type class of ECM / dispenser stores (AV8.ECM, F18.ECM...) CHAFF_OFF, FLARE_OFF = 0xC, 0xD # in an ECM hardpoint entry: chaff left, flares left (FA.EXE 0x4C39A0) def hard_base(raw): """Offset of hardpoint 0 in an aircraft object's raw bytes. Uses the object's own array pointer (+0x114); if that looks wrong, walks back from HARD_LAST while the entry still has a type pointer. Returns None if the layout isn't recognised.""" if len(raw) < HARD_LAST + STATION_STRIDE: return None o = struct.unpack_from("= 0x200: p, = struct.unpack_from("> 24 != last >> 24: break o -= STATION_STRIDE return o _cls_cache = {} def countermeasures(h, raw): """(chaff, flares) left on an aircraft: summed over its ECM hardpoints. None if it has none.""" hb = hard_base(raw) if hb is None: return None ch = fl = 0; found = False for o in range(hb, HARD_LAST + 1, STATION_STRIDE): tp, = struct.unpack_from(" TARGET_OFF + 1: t, = struct.unpack_from("