Commit Graph
42 Commits
Author SHA1 Message Date
BastienRdz ea78bb9483 Loader: a clwb in the last bytes of a page is emulated instead of faulting
emulate_amd_only copies only the bytes left in the faulting page and
gated clwb_len on n >= 15 because clwb_len took a fixed [u8; 15]. A
4- to 10-byte clwb starting in the last 14 bytes of a page (or falling
back from a clwb_loop that straddles the page end) was therefore
skipped, leaving pre-Ice Lake Intel CPUs with an unhandled
STATUS_ILLEGAL_INSTRUCTION.

Change clwb_len to take &[u8], bounds-checking each byte read and
returning Some(len) only when len <= code.len(), and drop the n >= 15
guard in emulate_amd_only.

Fixes #924.

Co-Authored-By: Gemini 4 Neon <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 60d2cf9cbcf5a2abc773d5de10c3c892e77d3340)
2026-11-25 01:03:00 -06:00
quaternion 7a4f0018b5 fix(loader): stage prepared images in per-writer files
write_if_changed used a shared <hash>.tmp file, so two concurrent cold launches of the same image could truncate each other's staging bytes or fail the rename after the other had published. Move publication into a portable module that stages under a unique pid/sequence name and removes it on failure. Two hermetic tests cover concurrent publishers and a failed rename.

(cherry picked from commit 1aac20aa8fd97237053c985b942225d54c0194a7)
2026-11-25 01:03:00 -06:00
给伊莉雅补魔 6aa6fc1cbb loader(crash): verify unwind against known caller frames when RtlCaptureStackBackTrace returns empty
(cherry picked from commit 121412bec21b0790d04d56399f49e2d140652864)
2026-11-25 01:02:59 -06:00
Manuel Pérez 91d41b2c90 Loader: suspend a thread before reading its TEB; skip bad dump times
Stack dumps (VICTORY_STACKS, diagnostics builds) read another thread's
TEB right after NtQueryInformationThread and suspended it only later: a
thread exiting in between frees its TEB, and the read faults. The
thread is now suspended first and resumed on every way out.

The dump times went through Duration::from_secs_f64, which panics on
`inf` or `1e20`, killing the dump thread (the crash hook logs it as a
crash). They are parsed by `schedule` now, which leaves out NaN and
times no Duration holds. 1 new test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit acdcc41687be2ecd2bf2efc43ab7449329483382)
2026-11-25 01:02:57 -06:00
Maledetto 1466eb61a2 Loader: clzero loops in one exception; rdpru
Based on #34 by ka1qux (commit faa0a9a), rebased over #45, which added the
same flag and register helpers for clwb loops; the duplicates are merged
into gpr/cmp_flags/CMP_FLAGS.

clzero: the two loops compilers build around it are done whole in one
exception, leaving registers and flags as the last pass would. Anything else
around it is one line and the next instruction.

rdpru: returns the time-stamp counter for MPERF and APERF, 0 for other
counters, and leaves the flags as they are: a Ryzen 7 5800X3D running it
natively in user mode changes none, for known counters or not.

Added over #34:
- loop 1 rejects cmp rax, rax (it fell into the loop and left wrong flags);
- tests that go through the emulation on any CPU (both loop shapes, the
  rax-rax and wrong-neighbour fallbacks, rdpru with both flag states), since
  on an AMD host the native tests never enter the handler.

(cherry picked from commit 0de9efced179dfb523748f21cf4bdbe0d3aa7533)
2026-11-25 01:02:57 -06:00
fxcelessandClaude Fable 5.2 4e17478b9c The game is no longer named in the tree
Comments, documents and descriptions now say "the title". No code changes.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-24 15:45:05 -05:00
fxcelessandClaude Fable 5.2 6a2d9f99c9 Shadow and trace programs translate, lint clean, ray-tracing write-up
- 59 of the 64 trace programs and the irradiance-cache shading program
  translate; 51 programs leave the approximate wave64 forms.
- The workspace passes the lint with warnings as errors in both feature sets;
  a few style lints are let through in Cargo.toml for this fork.
- README status updated (relay and in-place memory results);
  docs/fork-ray-tracing.md describes what the title does and what is built.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-24 13:48:06 -05:00
fxcelessandClaude Fable 5.2 578d459c34 victory-gta6: this fork's changes on top of VIctory main (ffe310e)
World rendering, lighting, frame-rate and memory work for Grand Theft Auto VI
(Xbox Series X profile) on one Windows PC with an NVIDIA RTX 4070. The README
describes the state, the changes and the credits. Based on VIctory by Marvisak
and contributors (GPL-3.0-or-later); XCL by ivall and contributors was used as
a reference. No game files are included.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-24 13:02:18 -05:00
Marvis 22700b9771 Merge pull request #675 from lameloball2813-ui/docs/rustdoc-private-links
Docs: rustdoc builds the loader, GPU and shader crates without warnings
2026-11-24 09:21:26 +01:00
Marvis 16bd5771a0 Merge pull request #666 from lameloball2813-ui/fix/load-probe-target-dir
Loader tests: build the probe fixture under CARGO_TARGET_TMPDIR
2026-11-24 09:20:26 +01:00
Marvis 5a16e66f9e Merge pull request #313 from Abdellah-Khanani/loader-aligned-unwind
loader: unwind a 16-byte aligned copy of the context
2026-11-24 09:00:12 +01:00
Marvis 93c0852d3f Merge pull request #285 from Dufftwt/fix/name-title-dll-that-fails-to-prepare
Loader: a title DLL that fails to prepare is named in the error
2026-11-24 08:59:50 +01:00
Marvis 56d503228a Merge pull request #245 from Dufftwt/fix/import-trap-in-crash-log
Loader: a trapped unimplemented import goes into the crash log
2026-11-24 08:58:12 +01:00
Marvis 27c960ba6c Merge pull request #204 from Dufftwt/fix/crash-report-fault-memory
Crash reports: say what an access violation's address holds
2026-11-24 08:54:19 +01:00
lameloball2813-ui 5864aaba28 Docs: rustdoc builds the loader, GPU and shader crates without warnings 2026-11-23 23:39:42 -07:00
lameloball2813-ui 764fa19373 Loader tests: build the probe fixture under CARGO_TARGET_TMPDIR 2026-11-23 23:24:49 -07:00
Abdellah K.andClaude Opus 5.5 b5c66787da loader: unwind a 16-byte aligned copy of the context
RtlVirtualUnwind and RtlCaptureContext want a 16-byte aligned CONTEXT,
and windows-sys 0.61 declares the x64 CONTEXT without align(16). In a
debug build the by-value copy in unwind_into, and the test's stack
context, landed 8 bytes off (an address ending in ...838), so
unwinds_like_the_system_walk crashed the whole victory-loader test binary
with a stack-overflow message and STATUS_ACCESS_VIOLATION. Aligning only
the test's context was not enough: the copy in unwind_into, which the
crash handler and stacks.rs also unwind with, faulted as well.

unwind_into now copies its context into an Aligned16 wrapper and unwinds
that; the test captures into one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 03:14:00 +01:00
Duff 5f29f3ae5a Loader: a title DLL that fails to prepare is named in the error
Reading and loading a title DLL report its path when they fail;
preparing it, in between, did not. A DLL the PE parser refuses ended
the run with just "malformed image: ..." (or the like), without saying
which of the title's DLLs it was.

The prepare step now adds "preparing <path>" like its neighbours.
2026-11-24 02:54:49 +01:00
Duff 5f670bbfdb Loader: a trapped unimplemented import goes into the crash log
An unimplemented import with the default Trap policy printed its name
and aborted. abort() is a fast fail: it skips the exception handlers
and the panic hook, which are what append to crashes.log, so the most
common bring-up crash left nothing there, not even which import it was.

The trap now reports through log_crash, which prints the same line,
appends it to the crash log and adds the title's last debug output.
2026-11-24 02:39:39 +01:00
Duff 3390e47328 Crash reports: say what an access violation's address holds
An access violation is reported with the address it touched and
nothing else, so a read of free memory, a write to memory that was
reserved but whose commit failed, a stack guard page and a write to
code or constants all look the same in a report.

The report now adds what VirtualQuery says is at that address: nothing,
reserved but never committed, a guard page, or the page's protection,
with the module for an image's pages.
2026-11-24 02:18:49 +01:00
Duff babe2db61f Crash reports: show the bytes of an instruction the CPU refused
An illegal or privileged instruction is reported by its address only,
which does not say which instruction it was. On an Intel host that is
the question every such report raises (clwb, clzero, rdpru, an SSE4a
form...), and reporters have had to guess or dump the bytes by hand.

The report's first line now ends with up to 15 bytes at the faulting
address, as hex, read no further than the end of that page, so the
report names the instruction by itself.
2026-11-24 02:12:05 +01:00
Marvis cbd71a9bde Merge pull request #38 from raffclar/emulation-tests
Loader: test the AMD-only instruction emulation on any CPU (including AMD!)
2026-11-24 01:32:45 +01:00
Marvis 27e64428ca Merge pull request #28 from ifBars/fix/windows10-import-directory
Loader: preserve an empty import table for Windows 10 static TLS
2026-11-24 01:31:11 +01:00
ifBars 0e5953d1dd Merge branch 'main' into fix/windows10-import-directory 2026-11-23 16:23:29 -08:00
Henrique Bueno c4e915f95e loader: a clwb write-back loop runs in one exception 2026-11-23 21:14:15 -03:00
ifBars 25a3e9596f Keep an empty import descriptor so Windows assigns static TLS
Use the descriptor count already validated by the PE parser, so the directory size need not include the null terminator. Check the OS-assigned static TLS index on a mapped test DLL.
2026-11-23 16:07:09 -08:00
ifBars 4da3d63666 Clear the IAT directory alongside the import directory
Windows 10 maps the prepared image with both entries empty. The binder already retains the original slot RVAs, so preparation need not locate a linker-provided terminator.
2026-11-23 15:55:36 -08:00
Henrique Bueno 71cfe84558 loader: emulate clwb on Intel CPUs before Ice Lake 2026-11-23 20:43:13 -03:00
raffclar f00caec1cf Loader: test 64-bit extrq at index 0, not in AMD's undefined range 2026-11-23 23:34:49 +00:00
Marvis d222b87c08 Merge pull request #19 from raffclar/exit-watchdog
Process exit: start the watchdog before other threads end
2026-11-24 00:31:26 +01:00
raffclar 0c91c03116 Loader: test the AMD-only instruction emulation on any CPU
The test for the emulation runs the real instructions. AMD CPUs, and
most CI runners, execute them natively, so the emulation was tested
only on Intel CPUs.

The new tests give the emulation instruction bytes and saved registers
directly, so they work on any CPU. They cover clzero, monitorx/mwaitx,
the immediate and register forms of extrq/insertq, xmm8 to xmm15,
length 0, and the instructions and exceptions it must not emulate.

The old test stays: on an Intel CPU it is the only test of the full
path through the vectored handler.
2026-11-23 23:30:15 +00:00
ifBars d85097af2e Keep an empty import descriptor for the Windows 10 loader 2026-11-23 15:20:22 -08:00
Marvis d348b9a14a Merge pull request #10 from ismailchaka1/emulate-amd-only-instructions
loader: emulate AMD-only instructions on Intel CPUs
2026-11-24 00:08:20 +01:00
raffclar d4ed2de2f4 Process exit: start the watchdog before other threads end
The exit code ended the other threads first and then started the
watchdog. A thread that ends can hold the heap lock or the loader lock.
A new thread needs both, so the watchdog did not start and the exit did
not stop.

Now the exit code starts the watchdog and waits until it runs its own
code: only then are its loader notices and Rust's thread set-up done.
The watchdog publishes its thread id, and end_other_threads does not
end it. The wait has the same deadline as the detach, because this
thread, or a thread that waits for it, can hold the loader lock; then
the watchdog cannot start.

After the deadline the watchdog only ends the process. It does not
log, because logging needs the heap and the lock of the log writer.

The exit test now also checks that a thread in `keep` is not ended.
2026-11-23 23:08:01 +00:00
ismailchaka1andClaude Opus 5.5 934e67fbad loader: emulate AMD-only instructions on Intel CPUs
The title is built for Zen 2 and uses clzero, monitorx/mwaitx and SSE4a's
extrq/insertq, which Intel CPUs lack: it died at startup with an illegal
instruction on an i7-14700KF. The vectored handler now does their job and
resumes: clzero zeroes the 64-byte line at rax, monitorx is skipped, mwaitx
yields, extrq/insertq run on the saved XMM registers.

Tested: victory-loader crash tests (new one runs each instruction), and the
title now gets past startup on an i7-14700KF with an RTX 4070 SUPER.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-23 22:49:54 +00:00
ExorionandClaude Opus 5.5 c21208c18a Loader: keep the cleared TLS callback pointer out of base relocations
prepare() zeroes the title's TLS AddressOfCallBacks but left the
IMAGE_REL_BASED_DIR64 entry that patches it. When the loader maps the
prepared copy away from its preferred base, that entry turns the 0 into
the rebase delta and the loader reads TLS callbacks from there. On
Windows the copy lands at 0x140000000 so the delta is 0; under Wine,
which maps DYNAMIC_BASE images high, LoadLibraryExW faults in ntdll
before any title code runs.

The entry is now rewritten as IMAGE_REL_BASED_ABSOLUTE (a no-op), and
the prepare test checks that no relocation targets the cleared field.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-23 23:37:05 +01:00
MarvisandClaude Fable 5.2 2849477415 Run Grand Theft Auto VI from first boot into the world
The title now boots through every first-boot and menu screen at its own
30 fps, drawing with translated shaders, with input, sound, saves and
loading served; it reaches the world, where the host GPU path still
fails (see "Not working yet").

Loader and runtime
- Crash reports unwind properly, name C++ throws and host GPU failures,
  carry the title's last debug lines and are appended to crashes.log.
- Thread notices on our own threads, reentrant late DLL loading, exit in
  the console's order, relaunch on a launch-new-game request.
- Offline guard: the title cannot reach the network (sockets, name
  lookups, WinHTTP, the media source resolver); by-name lookups and
  loads follow the import rules.
- Every runtime area the title calls is served (networking hint,
  packages, store, saves, display, UI, speech stubs, user, async pool).
  Saves persist; an update is one rename and survives a kill at any step.
- DirectStorage reads for real: shared worker pool, priorities, zlib and
  BCPack. BCPack is our own decoder; the format's constant tables ship in
  crates/victory-formats/src/bcpack-tables.bin (the asset policy's one
  exception, see docs/asset-policy.md).
- GameInput from XInput pads and the keyboard, with a keyboard stand-in
  pad; console timers (1 ms) for the whole process.
- Audio: XMA2 decoding on the emulated contexts, Opus on the decoder
  queues, the DSP interface as a stub; title memory placed below 2^40.
- Console texture layouts (sizes, tiling, detiling) and the layout
  library's imports.

GPU
- Draws, mesh dispatches and compute dispatches run on the host with
  shaders translated at first use and cached on disk; descriptor heaps,
  views, root signatures, barriers and host texture states; rectangle
  lists; comparison samplers.
- Title memory reaches the host through persistent mirrors that copy
  only pages written since the last copy; shader-written buffers are
  copied back.
- Presentation with frame pacing per event kind; framerate in the window
  caption.

Shaders
- DXIL emission for vertex, pixel, compute and mesh programs from the
  console's native code, with a differential test suite against the PC
  compile. World set: mesh 8,191 of 8,506, vertex/pixel 10,617 of
  12,346, compute 1,643 of 2,539; utility set complete.

Build
- Debugging aids (debug logs, frame capture, stack dumps, scripted keys,
  the host debug layer, the software adapter) exist only with the
  `diagnostics` feature; `[profile.diag]` keeps that build apart.

Not working yet
- In the world the host device is removed within seconds (descriptor
  handling fixes are in, unproven by a surviving run) and frames present
  black.
- 64-bit image atomics, merged geometry stages and the BVH builder's own
  shaders do not translate; reverb is silent.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-23 23:10:01 +01:00
MarvisandClaude Opus 5.5 bc3070991a Thread notices: leave out threads Rust's std starts
Their TLS callbacks run before std's start routine records the thread,
and std aborts if anything asks for the current thread first (stdout and
stderr locks do, so title code calling our logging functions would).
Threads starting in our exe (the title's main thread and our runtime's
workers) now get no notices; the probe test starts its thread in title
code.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-23 15:29:46 +01:00
MarvisandClaude Opus 5.5 4b2526918b Thread notices for title images
The prepared images get no DLL_THREAD_ATTACH/DETACH from Windows. A TLS
callback in our exe, called on every thread of the process, passes each
start and end on to the attached images: their TLS callbacks, then a
DLL's DllMain. DisableThreadLibraryCalls stops the DllMain calls and
fails for images with static TLS, as on Windows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-23 15:16:37 +01:00
MarvisandClaude Opus 5.5 d032b8a241 Title DLLs at run time: find by name, map on first LoadLibrary
GetModuleHandle* and LoadLibrary* find the title's images and our
console modules by file name. LoadLibrary* of a title DLL nothing
imports maps, binds and attaches it on the calling thread (a title's
own loader DLL may load its backends this way). FreeLibrary never
unloads title images.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-23 14:59:03 +01:00
MarvisandClaude Opus 5.5 754619f30e Run Minecraft: runtime HLE, D3D12.X device on the host GPU, shader IR
Loader: map title-shipped DLLs, patch static TLS loads to slot 0, crash
reporter, title paths for GetModuleFileName*.

HLE: task queue and async, XUser (one offline user), system ids,
title id, features, invites, game events, persistent local storage,
GameInput with no devices, xmem, console audio hardware queues, life
cycle (close suspends, then terminates), and a file layer with virtual
drives rewritten in path-taking imports.

GPU: D3D12.X device, DXGI chain, heaps, resources, fences, queues and
command lists translated onto a host D3D12 device; clears, barriers,
copies, resolves and PresentX into the title's window.

Shaders: SGD5 reader and `victory translate`; SSA IR with node
splitting for irreducible flow; structurisation removing EXEC.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-23 14:42:21 +01:00
MarvisandClaude Sonnet 5.5 f4504f6413 Initial commit
Rust workspace for VIctory: PE analysis, loader, HLE skeleton,
DXBC/DXIL parsing with a GFX10 decoder, conversion cache, CLI and
asset-policy enforcement.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-11-23 01:15:26 +01:00