Commit Graph
79 Commits
Author SHA1 Message Date
Adeeb Rahman 2e8d7faa32 Add UCRT _msize, _recalloc and aligned allocation
_msize, _recalloc, _aligned_malloc, _aligned_realloc, _aligned_msize
and _aligned_free on the CRT heap. Aligned blocks are tracked so double
and mismatched frees stop the guest.

Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 19:32:23 -05:00
Adeeb Rahman 112853ff88 Add std::exception message copy and destroy helpers
__std_exception_copy duplicates an owned message on the CRT heap and
shares a borrowed one; __std_exception_destroy frees an owned message
and clears the record.

Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 19:27:26 -05:00
Adeeb Rahman 9f472c9115 Add C++ type_info helpers to vcruntime140
__std_type_info_compare, __std_type_info_hash, __std_type_info_name and
__std_type_info_destroy_list compare and hash by decorated name and
undecorate plain class, struct, union and enum names. Decorations they
do not model stop the guest instead of returning a wrong name.

Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 19:19:23 -05:00
Adeeb Rahman 626de36f39 Add XInput controller services with a simulated source
XInputGetState, XInputSetState, XInputGetCapabilities and XInputEnable
on xinput1_4.dll, reachable from xinput1_3.dll and xinput9_1_0.dll.
Readings come from a host-connected ControllerSource; without one,
every slot reports ERROR_DEVICE_NOT_CONNECTED.

Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 19:16:39 -05:00
Adeeb Rahman 1fdefc7250 Add ioctlsocket FIONREAD and FIONBIO for loopback sockets
FIONREAD reports unread stream bytes or the size of the next datagram.
FIONBIO accepts non-blocking mode; blocking mode returns WSAEOPNOTSUPP
because loopback sockets never block.

Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 18:57:02 -05:00
Adeeb Rahman 16e0ff446a Add process-local Winsock TCP loopback
Stream sockets listen, accept and connect between guest sockets on
127.0.0.1 inside the runtime; no host socket is opened. Each socket
buffers up to 64 KiB, send takes what fits, recv returns 0 at end of
file after shutdown(SD_SEND) or closesocket, and sending to a closed
peer reports WSAECONNRESET. WSAPoll reports listen-queue readiness,
write space and POLLHUP. TCP and UDP ports are separate namespaces.

Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 18:54:04 -05:00
Adeeb Rahman 6229447a6a Add MoveFileExW with replace and write-through on both drives
MoveFileExW accepts MOVEFILE_REPLACE_EXISTING, MOVEFILE_WRITE_THROUGH
and MOVEFILE_COPY_ALLOWED. A closed file may atomically replace another
closed file on a host mount or the synthetic C: drive; directories are
never replaced, and open files can neither move nor be replaced. Write
through flushes both host directories. Moves between drives report
ERROR_NOT_SAME_DEVICE, or ERROR_NOT_SUPPORTED when a copy is allowed.

Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 18:47:18 -05:00
Adeeb Rahman 7bb47989e5 Rename files and directories within writable host mounts
MoveFileW now renames closed files and directories inside one writable
host mount using an exclusive host rename (renameatx_np RENAME_EXCL on
macOS, renameat2 RENAME_NOREPLACE on Linux), so an existing name is
never replaced. A change of case alone renames in place. Open files,
read-only mounts, the mount root and moves between drives fail with
explicit Win32 errors.

Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 18:38:16 -05:00
Adeeb Rahman 30cf55e753 Bound net growth of writable host mounts with an optional quota
HostMount::with_quota limits the net bytes and the number of files and
directories guest operations add to a writable mount. Win32 writes,
extending SetEndOfFile, CreateFileW, CreateDirectoryW, GetTempFileNameW
and CRT fopen/fclose are charged; deletion and shrinking give the
amount back, never below zero. Exceeding a limit fails with
ERROR_DISK_FULL (CRT ENOSPC) and leaves the host unchanged.

Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 18:33:49 -05:00
Adeeb Rahman bbfe9027a9 Honor timestamp suppression on synthetic guest file handles
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 16:00:28 -05:00
Adeeb Rahman b031640fef Advance synthetic file timestamps using the guest clock
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 15:59:03 -05:00
Adeeb Rahman 6dc241323b Track explicit timestamps on synthetic guest files
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 15:57:53 -05:00
Adeeb Rahman cda25954fa Update mounted file timestamps through guest handles
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 15:56:26 -05:00
Adeeb Rahman c4a2b53ac4 Read Win32 file timestamps from open guest handles
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 15:55:12 -05:00
Adeeb Rahman da9f2c0035 Expose mounted file timestamps to Win32 guests
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 15:53:55 -05:00
Adeeb Rahman b15226efe9 Return extended Win32 path metadata
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 15:52:08 -05:00
Adeeb Rahman 0fdd33a440 Flush writable guest file handles
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 15:48:41 -05:00
Adeeb Rahman ef5337557f Support ASCII Win32 file creation and open
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 15:47:18 -05:00
Adeeb Rahman f21d8ea1be Create guest temporary files on explicit host mounts
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 15:43:10 -05:00
Adeeb Rahman 941ac8cf2e Create temporary files on the synthetic guest drive
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 15:41:41 -05:00
Adeeb Rahman db20a1870f Expose guest-scoped Win32 temporary directory lookup
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 15:39:40 -05:00
Adeeb Rahman c45e11d5af Report host directory creation collisions consistently
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 15:37:28 -05:00
Adeeb Rahman d0f199b0e8 Merge remote-tracking branch 'origin/main' into feat/system-runtime-expansion
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>

# Conflicts:
#	CHANGELOG.md
2026-11-24 15:10:54 -05:00
Adeeb Rahman 8a677bc265 Drop dead AT_EMPTY_PATH unlink and document name-based remove limits.
Linux unlinkat rejects AT_EMPTY_PATH, and macOS never compiled that path,
so every remove was already name-based. State the in-mount TOCTOU plainly.

Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 15:00:57 -05: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
Adeeb Rahman 550b2cec5f Merge upstream main d7f7d58 into system runtime branch
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 12:29:00 -05:00
Adeeb Rahman 680f572af4 Expand CRT I/O, env, time, rand and Winsock UDP helpers.
Mount-backed fopen, atoi/_putenv/time/rand/_stricmp, synthetic
GetModuleFileName paths, and sendto/recvfrom for the loopback stack.

Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 12:26:04 -05: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
Adeeb Rahman 2aa0cb0a5a Schedule XAsync work and completion through manual queues
When an XAsyncBlock carries a non-null XTaskQueue handle, submit work to
the work port and completion to the completion port so guests can
XTaskQueueDispatch them. Null-queue immediate dispatch is unchanged.

Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 11:41:05 -05:00
Adeeb Rahman 3c3d1f5cc0 Add printf and fprintf on the in-memory CRT stream subset
Route formatted output through the shared sprintf converter; stdout and
stderr discard payloads while file streams append the rendered bytes.

Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 11:09:47 -05:00
Adeeb Rahman 8ae0d847c9 Add in-memory CRT FILE streams and process environment queries
Implement fopen/fread/fwrite and related stream helpers over a bounded
runtime file store, plus getenv and GetEnvironmentVariableA/W against a
guest-owned environment block that does not expose the host process.

Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 11:09:13 -05:00
Adeeb Rahman fd0a19658e Document expanded CRT string and locale surface
Keep interfaces and changelog aligned with the newly registered C-locale
and string services.

Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 11:04:14 -05:00
Adeeb Rahman d292e537f1 Add strcpy, strncpy, strcat, strncat and memchr CRT services
Checked guest-memory implementations for the remaining core byte-string
mutators, registered as standard services alongside the existing scans.

Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 11:02:51 -05:00
Adeeb Rahman 587711ab6e Add C-locale ctype classification and case mapping
Implement isalnum/isalpha/isdigit and related predicates plus
tolower/toupper with MSVC EOF rules, registered as standard services.

Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 11:01:39 -05:00
Adeeb Rahman 991a02ea04 Add C-locale CRT, sprintf subset, and immediate XAsync helpers
Extend the system runtime with setlocale/localeconv (C only), a bounded
sprintf/snprintf converter, and XAsyncRun/GetStatus/Cancel/GetResultSize
on the calling thread. Register the new symbols as standard services.

Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 11:00:25 -05:00
Adeeb Rahman 1780d0bd3d Merge upstream main fb05446 into system runtime branch
Harden host-backed guest drives after agent security and implementation
review: O_NOFOLLOW mount roots, identity re-check before unlink with
Linux AT_EMPTY_PATH when available, CREATE_ALWAYS truncate coverage,
and honest docs about residual trusted-host limits.

Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 10:52:12 -05:00
Adeeb Rahman 5ee54f1eb6 Fail closed on unreadable host file identity and bound file sizes
Author-side review findings: sharing and delete checks now treat an
unreadable identity as the same file, writable mounts limit file size
(1 GiB by default), and errno handling is portable.

Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 10:44:45 -05:00
Adeeb Rahman 228f968df3 Merge upstream main b9f6985 into system runtime branch
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 10:35:58 -05:00
Adeeb Rahman d65240969e Harden host-backed guest drives after review
Accept only D: to Z:. Hide multiply linked files. Verify each opened
descriptor's type and identity against the listing. Compare live
device and inode for sharing and deletion, and check sharing before a
truncating open. Report directory listing errors and limits
explicitly. Add regression tests for hard links, host swaps between
listing and open, renames, read-only enforcement and limits, and
describe the policy and its remaining limits without unconditional
confinement claims.

Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 10:33:02 -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 Rahman 41c6942180 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>
2026-11-24 10:24:44 -05:00
Adeeb Rahman 21738c9d67 Back guest drives with explicitly mounted host directories
Resolve each path component from the mount's root descriptor with
openat and O_NOFOLLOW, matching names case-insensitively and hiding
symbolic links, so guest paths cannot leave the mounted root. Mounts
are read-only unless configured writable.

Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 10:02:59 -05: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