Commit Graph
21 Commits
Author SHA1 Message Date
Marvis 5f540cd231 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 056cc6b3f2 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 247cd6baa2 Merge branch 'main' into fix/windows10-import-directory 2026-11-23 16:23:29 -08:00
Henrique Bueno 0369ebe42a loader: a clwb write-back loop runs in one exception 2026-11-23 21:14:15 -03:00
ifBars 178bbb7915 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 47f321ed15 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 8b8ca7e746 loader: emulate clwb on Intel CPUs before Ice Lake 2026-11-23 20:43:13 -03:00
raffclar d1aa2093b8 Loader: test 64-bit extrq at index 0, not in AMD's undefined range 2026-11-23 23:34:49 +00:00
Marvis 6d7df474b3 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 27b5152288 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 96a964e16c Keep an empty import descriptor for the Windows 10 loader 2026-11-23 15:20:22 -08:00
Marvis abb8d9fe14 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 1d1f82651a 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