Skip to content

Fix candidate: guarded heap-backed car ID decoding after car swaps - #5

Draft
Refilewski wants to merge 5 commits into
mainfrom
fix/car-id-heap-strings
Draft

Refilewski wants to merge 5 commits into
mainfrom
fix/car-id-heap-strings

Conversation

@Refilewski

Copy link
Copy Markdown
Owner

What changed

  • Decode a plausible MSVC std::string heap-backed identifier at AudioEngine+0x278 when the recorded size/capacity are compatible with long IDs (16–127 bytes). Retain the original inline decoder for short IDs and other layouts.
  • Validate pointer alignment/range, size and capacity, NUL, ASCII identifier shape, and repeat the remote payload/object read to avoid racing against vehicle changes.
  • Apply the same guarded fallback to standalone and native FH2ML DLL.
  • Add synthetic tests for two sequential long IDs, returning to a short ID, unreadable payload, invalid contents and mid-read mutation.
  • Document that the structure is hypothetical, not live-validated; no offsets or unrelated features changed.

Evidence

Issue #4: standalone 0.9.9 logs indicate CarProbe=invalid-character while Discord, speeds, and racing context work. This is consistent with pointer-backed strings, but does not prove it.

Validation

  • Windows CI build/tests (awaiting workflow)
  • Live Azimuth: initial car, several car changes, race and return, with and without Extra Options
  • Verify CarProbe=ok-heap for long IDs, and no stale vehicle on failure

Do not merge until live gameplay validation. Closes no issue automatically; related: #4.

Copy link
Copy Markdown
Owner Author

Cross-check against Extra Options (2026-10-18)

Reviewed RokkuDayo/ForzaHorizon2_ExtraOptions (game_addresses.h, features/autodrive_game.c, features/vehicle_controls.c, features/rims.c).

Key finding: Extra Options' GameString is a 32-byte MSVC-style small-string layout: inline storage of 16 bytes; size at +0x10; capacity at +0x18; heap pointer at +0x00 if capacity >= 16. This supports the representation hypothesis tested by this PR, but it does not establish that the AudioEngine + 0x278 field holds the same structure in failing user sessions.

For a more authoritative future source, Extra Options uses PlayerManager -> GetLocalPlayer (RVA 0x21e0c0) -> GetPlayerCar (RVA 0x2da060) and validates player-car vtable (0x2c5cb80). It can read numeric model ID at car + 0x118, releasing the car reference via vtable slot 0x18. This does not directly provide the friendly car/media name. A mapping to Data_Car.MediaName or another validated field would still be necessary.

Recommended: Run this PR's tested heap-string fallback through live car-switch tests first. Native FH2ML integration of the current-car object could then be researched independently on the game thread; don't invoke these game functions from the standalone cross-process reader or an arbitrary background thread. Preserve separate read-only EXE behavior unless we establish a safe pointer path. Do not merge based on the Extra Options code alone.

CI for head cf92fcaf7021a95034a94940544d0e0019e81bc8 finished successfully, but that is synthetic/build verification, not live FH2 validation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant