Repository navigation
Conversation
…the environment gta6rt had no general way to try a patch of the title's code: the watchdog kick is the only one, with its own variable. LEONIDA_TITLE_PATCH=<rva>:<expected hex>:<new hex> (several, separated by ',' or '+') rewrites places of the executable before it runs, each only when the expected bytes are there, and logs each as applied or left alone. As with the watchdog's RVAs, the values stay out of the runtime (runtime/src/title_patch.h). docs/running.md: one use, the title's own upscaler at a fixed 2/3 scale on Series S (the d3d12 runtime's OWN_UPSCALER and render-scale patches), with why both patches are needed (the title's out-of-memory int3 with the first alone) and the frame rate measured. Test: title_patch_test (parser, checked writes into a page of executable memory). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
#2554 | head 5039a8d (merged cleanly with main 02f71cc) | Minor non-blocking note on |
lixonik
left a comment
There was a problem hiding this comment.
Reviewed the diff and tested merged onto main (493867366) with Ninja Release (MSVC).
The LEONIDA_TITLE_PATCH parser and checked apply() path (VirtualQuery + exact memcmp + VirtualProtect restore + FlushInstructionCache) are clean, bounds-checked against overflow, and well covered by title_patch_test.
Tests run
ctest --output-on-failure -R "^title_patch$": 1/1 passed (title_patch0.02 s).python -m unittest tests/test_ctest_registration.py: 7/7 passed.- Note:
tests/test_docs_env_vars.pyconfirmsLEONIDA_TITLE_PATCHis documented (its only failure on currentmainis the unrelated pre-existingLEONIDA_CLWB_PATCH).
AI-assisted (Antigravity, Gemini).
…reading it Review note on ProjectLeonida#2554 (zmasi): apply() asked VirtualQuery only about the region holding the patch's first byte, so a patch running into an uncommitted or no-access region inside the image would make memcmp read it. Each region the patch covers is now checked (committed, readable, not a guard page) before anything is read (Result::unreadable otherwise), and the protection is changed and restored region by region, so pages with different protections keep their own. Test: title_patch_test case 6 (a reserved page, a no-access page, two committed pages with different protections). With the old apply() the test crashes on the reserved page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@zmasi thanks, you were right: with a patch running from a committed page into a reserved one, the old |
|
Re-verified updated head
AI-assisted. |
|
Run of #2554 (
Commands (in a vcvars64 shell, build folder inside the worktree): Green (PR head): builds, Red (non-test changes reverted: |
timbot103
left a comment
There was a problem hiding this comment.
Static review of c556144d8 against 48bae6cad. Three changes requested.
runtime/src/main.cpp:701runs the patch hook afterLoader::initialise()can execute the main image's TLS callbacks. Apply on the--runpath before initialization and before starting the watchdog worker.runtime/src/title_patch.h:58accepts signed and overflowing RVAs throughstrtoull. A negative field can become a valid in-image offset. Reject signs and out-of-range values before applying.runtime/src/title_patch.h:98,:105, and:107discard restore and cache flush errors. Check rollback and restoration, report distinct failures, and stop startup if protections or cache synchronization cannot be confirmed.
AI-assisted.
|
Verified on the C++ runtime here: it applies, both test and runtime build, and the test passes. Applied onto The test covers what a checked byte patch has to get right without a title: parse, the values it accepts and refuses, and the protection of the pages it writes What is not covered: applying a patch to a real title. That needs the game, and the part that matters most there - that a refused patch stops instead of leaving One small thing for the reviewer, not for me to change: the branch is 1780 commits behind and Written with an AI assistant. |
|
Independent verification on this machine (Windows 11, MSVC 19.44.35226). It applies, builds and passes; the negative control is impossible by construction, same shape as #2651, #2645 and #2555. 1. It applies. 2. It builds and passes, three times: 3. There is no What the tests do cover, from the diff: that a patch is checked against every page it covers before applying, and that an out-of-range or misaligned byte patch is refused rather than written. Whether the title in a real run survives a patch is the run-level question, and it needs the executable this machine has in What I did not test: Written with an AI assistant. |
|
Verified with a negative control, and the result is worth knowing: the tests pass with the header reverted, so they do not observe the change. 1. It applies and builds. merge-tree clean onto main 2. With the branch: 3. The control - revert only the source change, keep the test, rebuild: What that says: the What I am not saying: that the change is wrong. Two readings are possible and I did not choose between them - the test may be a unit test of a header whose behaviour is unchanged in the cases it covers (in which case green either way is correct and the change is elsewhere), or it may be a test that was written beside the change rather than against it. What would settle it in one case: a test that drives the path through the new code - e.g. for this one, the Why I am commenting: I verify open pull requests that replay onto current main, build the binaries their tests name, run them, then revert only the source change. A green control is a real result, and it is the one a reviewer cannot get from the diff. Written with an AI assistant. |
|
Independent check on Windows (not the author), at
Environment: Ryzen 9 7950X3D, Windows 11 Pro 10.0.26200.9711. AI-assisted: yes (opencode). |
Claimed in the coordination issue as: RT-TITLE-PATCH-ENV (#1608 (comment))
What and why
gta6rt had no general way to try a patch of the title's code: the watchdog kick is the only one, with a variable of
its own.
LEONIDA_TITLE_PATCH=<rva>:<expected hex>:<new hex>(several, separated by,or+;+fits alauncher whose own list is comma-separated) rewrites places of the executable before it runs:
bytes) and the place lies inside the image;
appliedorleft alone: ...for each, and names malformed items;LEONIDA_TITLE_WATCHDOG_KICK, the values stay out of the runtime: this is the mechanism, not a list ofpatches (
runtime/src/title_patch.h).docs/running.mdgets one use, measured on NVIDIA withLEONIDA_DEVICE_TYPE=6(Series S):eight
fspx/amd_fidelityfx_upscaler_xbox_*dispatches (wave32, not emulated) at about 400 ms of GPU time perworld frame on an RTX 4070, the largest single item of the frame.
OWN_UPSCALERpatch (d3d12/crates/leonida-loader/src/hooks.rs) switches the title to itsown temporal upscaler. With that patch alone the title stops about 30 s in on its out-of-memory
int3:a title allocator over a 1,277 MiB range (FidelityFX fills it to 1,245 MiB) cannot give a 2.1 MiB block,
because the own upscaler sizes its targets for its largest scale. Traced with the fault report of the companion
pull request (RVA, registers, the allocator's vtable) and the range's fields read with
LEONIDA_PEEK.run goes on.
Tested
title_patch_test(new): parser (both separators, upper-case hex, six kinds of malformed items) and the checkedwrites into a page of executable memory (applied, protection restored, neighbours untouched, a second run refused,
past-the-end refused). 13/13.
cteston this branch (Windows 11, MSVC 2022, Ninja, RelWithDebInfo): 508 of 510 passed, 11 skipped (needthe game or a validation layer). The two failures,
xbox_present(present failed (VkResult -11)) andd3d12_set_descriptor_heaps(recorded_commandscheck), are separate executables that do not buildsrc/main.cppor the new header.tests/test_docs_env_vars.py,test_docs_encoding.py,test_docs_repeated_lines.py,test_docs_list_items.py,test_docs_links.py,test_ctest_registration.py,test_text_encoding.py: OK.scripts/check_no_game_data.pyon the changed files: clean.
935a2cd5bplus local changes) andlibrary/lib_cs_03010translated by Translator: gather a lane mask's bits where a merge takes it as data (SHADER-WAVE-LOOP-EXEC-VOTE) #2501's branch: world median over 280-600 s 0.99 frames/s without the two patches, 1.75 with them
(one 600 s run each, no exception). The picture changes from near black to a lit scene in that run; not compared
frame by frame. Not yet measured on this
main.GPUs tested: NVIDIA GeForce RTX 4070 12 GB, driver 621.40, Windows 11 (ctest and the game runs above)
AI-assisted: yes (Claude Code)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a)