Commit Graph
62 Commits
Author SHA1 Message Date
atharvranjan 2f68ee9d4a Integrate PR #276 with explicit unsupported-service behavior
Signed-off-by: Arths17 <Atharvranjan8@gmail.com>
2026-11-24 21:57:08 -06:00
atharvranjan bfe0bbfaf7 Rename project and native applications to BetterXen
Update active repository links and coordination settings while retaining upstream history, notices, legacy library names and guest interfaces. Document the independent-copy migration and its limits.

Signed-off-by: Arths17 <Atharvranjan8@gmail.com>
2026-11-24 20:51:08 -06:00
zachdoxsee f30e4af4eb Merge upstream main into task/388-must-exist-stubs
Signed-off-by: zachdoxsee <zachdoxsee36@gmail.com>
2026-11-25 02:10:46 +01:00
zachdoxsee 66f7127553 Merge upstream main into task/329-gate-a1
Signed-off-by: zachdoxsee <zachdoxsee36@gmail.com>
2026-11-25 02:10:46 +01:00
Ranveer Soni 042c08c855 Merge pull request #337 from zachdoxsee/task/333-pe-headers
loader: map the PE headers at the image base (#333)
2026-11-25 06:33:39 +05:30
Ranveer Soni 7e4ccd1e97 Merge pull request #316 from soggyramennoodle/feat/runtime-fuzz-bench
Runtime fuzzing, dispatch benchmarks, CRT string scans and MSVC name decoding
2026-11-25 06:32:53 +05:30
zachdoxsee 721073169c Merge upstream main into task/388-must-exist-stubs
Signed-off-by: zachdoxsee <zachdoxsee36@gmail.com>
2026-11-25 01:56:51 +01:00
zachdoxsee 496938aef4 Merge upstream main into task/333-pe-headers
Signed-off-by: zachdoxsee <zachdoxsee36@gmail.com>
2026-11-25 01:56:51 +01:00
zachdoxsee 4e18000798 Merge upstream main into task/329-gate-a1
Signed-off-by: zachdoxsee <zachdoxsee36@gmail.com>
2026-11-25 01:56:31 +01:00
Adeeb Rahman 324eab08c3 Merge remote-tracking branch 'origin/main' into feat/runtime-fuzz-bench
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 18:32:27 -05:00
zachdoxsee 007ad360e9 loader: add VirtualProtect, VirtualQuery and __C_specific_handler as stubs (#388)
A program built with the mingw-w64 runtime imports all three and does not
call them on a normal run. Without them the loader refused the program
before its entry point.

They are declared stub in the typed registry. A call stops the guest with
the runtime-limit fault and writes nothing, so a program that needs one
stops there and cannot run on with a made-up result.

Part of Gate A2.

Signed-off-by: zachdoxsee <zachdoxsee36@gmail.com>
2026-11-24 23:30:09 +01:00
jelly013 38359969cd Merge main into phase3b-runtime
Signed-off-by: jelly013 <22855910+jelly013@users.noreply.github.com>
2026-11-24 22:44:09 +01:00
zachdoxsee fd0e73bc28 Merge upstream main into task/333-pe-headers
Conflict in CHANGELOG.md only: every entry is kept.

Signed-off-by: zachdoxsee <zachdoxsee36@gmail.com>
2026-11-24 21:43:49 +01:00
zachdoxsee 35de41bd5f Merge upstream main into task/329-gate-a1
Conflict in CHANGELOG.md only: every entry is kept.

Signed-off-by: zachdoxsee <zachdoxsee36@gmail.com>
2026-11-24 21:43:49 +01:00
jelly013 e5aca73c55 cli: use a neutral default folder for probe reports
`xenora probe` and `xenora imports sync` defaulted to a folder named after
one commercial game. Give both one shared default, `diagnostics/probe`, and
ignore it in Git. Keep the old ignore rules so existing local reports stay
out of commits.

Closes #364

Signed-off-by: jelly013 <22855910+jelly013@users.noreply.github.com>
2026-11-24 20:31:13 +01:00
zachdoxsee 830f93ff14 loader: address review of process exit and the Gate A1 program (#329)
- An ExitProcess call in a TLS callback is a normal startup outcome with
  its status. The remaining callbacks and the entry point do not run.
- Exit closes Winsock sockets and task-queue handles as well as kernel
  objects, and open_handle_count counts all three tables.
- Startup reserves the page holding the entry-return and callback-return
  addresses, so an image mapped over them is refused and a guest
  allocation there fails.
- The Gate A1 program checks unequal memcmp results and compares the
  bytes it read back without memcmp.
- The gate test builds in a directory of its own per test process.
- The build script checks its tools and their libraries with file,
  lipo -archs and otool -L.

Signed-off-by: zachdoxsee <zachdoxsee36@gmail.com>
2026-11-24 19:55:20 +01:00
zachdoxsee 67dfb18166 loader: address review of the PE header mapping (#333)
- Check the mapping budget before anything is mapped, and map the header
  bytes straight from the file instead of copying them first.
- Refuse bytes that are not the PE32+ headers that were parsed: the
  optional header magic and size, the section count, the preferred base
  and SizeOfHeaders must agree before anything is patched.
- Write the load base into the mapped ImageBase field after relocations
  are applied, so a DIR64 entry aimed at that field cannot move it twice.
- Describe the ImageBase rewrite as Xenora's policy, and document the
  zero fill past SizeOfHeaders and the stricter page rule.

Signed-off-by: zachdoxsee <zachdoxsee36@gmail.com>
2026-11-24 19:47:11 +01:00
zachdoxsee 48e1e5c8c1 Merge upstream main into task/329-gate-a1
Conflict in CHANGELOG.md only: both new entries are kept.

Signed-off-by: zachdoxsee <zachdoxsee36@gmail.com>
2026-11-24 18:24:36 +01:00
zachdoxsee 6947fe7ff6 Merge upstream main into task/333-pe-headers
Conflict in CHANGELOG.md only: both new entries are kept.

Signed-off-by: zachdoxsee <zachdoxsee36@gmail.com>
2026-11-24 18:22:23 +01:00
elforeign d7f7d586d3 gpu: bind a texture and sampler to guest draws through descriptor tables (#303) (#336)
* gpu: bind a texture and sampler to guest draws through descriptor tables (#303)

A guest command list had no way to bind a texture: GraphicsCommand stopped
at vertex and index buffers. This adds the smallest D3D12-shaped binding the
translated image_sample_lz pixel stage needs: shader-visible CBV_SRV_UAV and
sampler heaps, CreateShaderResourceView for one-level RGBA8 and BC1 2D
textures, a point/clamp CreateSampler, a root signature with one pixel-stage
SRV table and one sampler table, and SetDescriptorHeaps and
SetGraphicsRootDescriptorTable. Everything else fails explicitly before any
draw.

The native path hands the bound level to a textured backend.
NativeCompute::render_rgba8_sampled_bc1 binds a BC1 level natively to
fragment texture 0 and sampler 0. The software reference point-samples with
clamp addressing.

BC1 fixtures use only endpoint colours. Apple's hardware decoder gives
171/84 for the interpolated palette entries where the spec-exact decoder
gives 170/85.

Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>

* gpu: tighten guest texture binding after independent review (#303)

The independent review found binding rules that diverged from D3D12:
changing descriptor heaps kept tables bound in the old heaps, setting the
same root signature again cleared its tables, and unsupported draw shapes
were drawn as one triangle. Now heap changes and a different root signature
invalidate tables, while redundant sets keep them. Table bases are checked
against the bound heap of their type when bound. Textured draws other than
one instance of three vertices fail, and zero vertices or instances draw
nothing.

Descriptor handle offsets can no longer carry into another heap's ID. SRVs
of array or multi-level textures are rejected. A texture whose state
excludes pixel-shader reads is not sampled. Vertex buffer offsets are
overflow-checked. The tests now cover swapped root parameters, a second
sampler slot, off-centre and out-of-range coordinates, state transitions,
draw shapes and resource bounds.

Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>

* loader: format the guest texture test (#303)

Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>

* gpu: close the review's remaining texture-binding gaps (#303)

The re-review found three partial fixes. The public software reference
could overflow on a huge viewport. A texture in a combined write and read
state could be sampled. The sampler-slot test used two identical filled
slots. The viewport is now bounded to 4096 pixels. A sampled texture must be
COMMON or a read-only state that includes PIXEL_SHADER_RESOURCE. The sampler
heap now leaves its middle slot empty. The docs now state the start-instance
rule and when table bases are checked.

Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>

---------

Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
2026-11-24 11:21:03 -06:00
zachdoxsee b8fbdf35b9 loader: map the PE headers at the image base (#333)
Windows maps the first SizeOfHeaders bytes of an image read-only at its
base, and programs read them: the mingw-w64 C runtime walks its own
section table before main. The loader mapped sections only, so that read
faulted.

Map the headers in whole 4 KiB pages before the sections, with the
optional header's ImageBase field set to the base the image is loaded
at. Refuse the load with PeError::InvalidHeaderSize when SizeOfHeaders
ends before the section table, runs past the file, or its pages reach
into a section. The header pages count toward the mapping budget.
ParsedPe::parse is unchanged.

The hand-built image in pe_mapping_limits.rs wrote SizeOfHeaders as
zero; it now writes a valid value.

Signed-off-by: zachdoxsee <zachdoxsee36@gmail.com>
2026-11-24 18:15:56 +01:00
jelly013 84866956b9 runtime: add a deterministic guest thread scheduler
Run guest threads on one host thread with independent CPU contexts, guarded
stacks and TEBs, in first-in, first-out order with bounded turns that end at
translated-block boundaries. Add CreateThread, ExitThread, TerminateThread,
GetExitCodeThread, SuspendThread, ResumeThread and SwitchToThread, and let
waits on threads, events, semaphores and mutexes block only the caller.
Report deadlocks, abandoned mutexes and per-thread faults.

Reclaim per-thread state at thread end without passing held locks to a thread
that reuses the TEB address, and bound pending one-time initializations.
Guest threads never run concurrently. Critical sections, SRW locks,
condition variables and Sleep do not block per thread yet.

Verify with C programs compiled for x86-64 Windows and run as translated
guest code at several quanta.

Refs #323

Signed-off-by: jelly013 <22855910+jelly013@users.noreply.github.com>
2026-11-24 17:47:01 +01:00
zachdoxsee 47cb26ebdd loader: add process exit and the Gate A1 compiled C program (#329)
A guest can now end its process. kernel32.dll!ExitProcess stops execution
with the new ExitReason::ProcessExit(status), keeping all 32 bits of the
status, and never ends the host. A returning entry point does the same
with EAX: startup puts an exit address under the entry point. The exit
closes every guest handle, and the DbtEngine that ran the guest executes
no further guest instruction.

Gate A1 is an original C program with no C library linked. The test
builds it from source with clang and an LLD, runs it through
run_synthetic_startup, the standard services and the DBT at four
optimization levels, and checks its exit status, report, files and
memory against values recomputed in Rust. Three controls must fail in
the stated way. Gate A stays open until the hosted milestone, A2.

Signed-off-by: zachdoxsee <zachdoxsee36@gmail.com>
2026-11-24 17:42:09 +01:00
Adeeb Rahman b49d50e34e Decode MSVC decorated names for import diagnostics
Add a clean-room decoder for the common decoration grammar, show its
output in generator manifests, and test it against names clang mangles
for x86_64-pc-windows-msvc.

Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
(cherry picked from commit 506e09c909e75c92ef8a0050df67fc79f787028a)
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 10:33:26 -05:00
zachdoxsee db40a1307d loader, cli: bound delay-load tables by their declared size (#244)
Address review on the delay-import probe change:

- Read only descriptors inside the delay import directory's declared
  size, and require that size to hold the terminating empty descriptor.
- Require each descriptor's DLL name, import address table and import
  name table to be present and to start in section data, with a
  diagnostic naming the missing field.
- Leave delayed rows out of the xenora imports sync backlog, so its
  totals stay ordinary-only.

Signed-off-by: zachdoxsee <zachdoxsee36@gmail.com>
2026-11-24 16:28:02 +01:00
zachdoxsee b174b45bed loader: report delay-loaded PE imports in the static probe (#244)
Read the PE32+ delay-load directory (data directory 13) with a bounded
parser and list each delay-loaded import in imports.csv, marked by a new
import_table column. Ordinary totals and missing_imports.csv are
unchanged; the JSON report counts delayed slots and DLLs separately and
carries a diagnostic for truncated, out-of-range or unsupported tables.

Adds an original fixture with ordinary and delayed imports, generated by
fixtures/pe/delay-imports.py and cross-checked with llvm-readobj.

Signed-off-by: zachdoxsee <zachdoxsee36@gmail.com>
2026-11-24 16:25:14 +01:00
Adeeb RahmanandCursor 17fa47f058 Add CRT onexit tables, atexit and _cexit
Exit functions are guest code run through callback tasks in reverse
registration order. Table storage lives on the default guest heap.

Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-24 09:52:50 -05:00
Adeeb RahmanandCursor 8d7f7fadb4 Add guest system information, calendar time and sleeping
The guest sees a configurable simulated machine, kept separate from the
detected host hardware. Sleeping goes through the injectable clock.
Move the PE fixture harness into a shared test support module.

Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-24 09:48:16 -05:00
Adeeb RahmanandCursor 1eae910ce1 Let services call guest code and continue after it returns
Add callback tasks to the import dispatcher. A task runs guest callbacks
on a reserved stack frame, checks the nonvolatile registers after each,
and returns to the original caller. Use it for qsort, qsort_s, bsearch,
bsearch_s, _initterm, _initterm_e, InitOnceExecuteOnce and FlsFree
cleanup callbacks.

Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-24 09:41:39 -05:00
Adeeb RahmanandCursor ac6f9daff3 Add guest mutexes, locks, one-time init, SLists and TLS slots
Ownership is keyed by guest TEB. Operations that would block another
guest thread stop with the runtime-limit fault because no guest
scheduler exists. Also stop the import generator from overriding the
semaphore handlers with stubs, and check every generator standard
service against the loader registry.

Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-24 09:33:07 -05:00
Adeeb Rahman a7a0235c79 Merge remote-tracking branch 'origin/main' into feat/system-runtime-expansion
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>

# Conflicts:
#	CHANGELOG.md
#	crates/loader/src/memory.rs
2026-11-24 06:48:06 -05:00
Ranveer Soni 08c4451e68 docs: add draw, blend and depth contract sections to the interface contracts 2026-11-24 15:01:17 +05:30
Adeeb Rahman c4ce9a4e38 Resolve named exports from built-in guest modules
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 01:53:16 -05:00
Adeeb Rahman 2de0483142 Share guest file positions across duplicated handles
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 01:50:28 -05:00
Adeeb Rahman 6ecbd14915 Enumerate the synthetic guest namespace through typed search handles
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 01:49:25 -05:00
Adeeb Rahman 3c9b8d988b Move closed guest files and report namespace attributes
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 01:47:34 -05:00
Adeeb Rahman ab598f0820 Manage directories and closed files in the guest namespace
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 01:46:24 -05:00
Adeeb Rahman 2bc08a1851 Seek and resize files on the synthetic guest drive
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 01:45:02 -05:00
Adeeb Rahman 6a60749939 Provide bounded synchronous guest file IO on a synthetic drive
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 01:43:49 -05:00
Adeeb Rahman 06bdf189e4 Add counted guest semaphores to immediate waits
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 01:41:24 -05:00
Adeeb Rahman 9b22c664bb Handle non-alertable extended guest event waits
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 01:39:46 -05:00
Adeeb Rahman 654e4c28b5 Resolve immediate guest waits on multiple events
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 01:38:04 -05:00
Adeeb Rahman b861348667 Support 64-bit integer conversion in the guest CRT
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 01:36:13 -05:00
Adeeb Rahman a4a2425bcc Parse Windows long integers in the guest CRT
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 01:35:00 -05:00
Adeeb Rahman edba4df430 Expose guest CRT errno and report allocation failures
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 01:33:03 -05:00
Adeeb Rahman f992721fda Back CRT allocation imports with the default guest heap
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 01:31:29 -05:00
Adeeb Rahman 8e29b54919 Track allocations owned by private guest heaps
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 01:30:00 -05:00
Adeeb Rahman cd01d04a96 Resize default guest heap blocks with transactional failure
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 01:27:52 -05:00
Adeeb Rahman 6b068a225d Expose a bounded default process heap to Win64 guests
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 01:26:23 -05:00
Adeeb Rahman 4c1ac39c7e Support Win64 wide string length and comparison
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 01:23:47 -05:00