upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorAndréLanD <andreviniciusmerlia@gmail.com>2026-11-25 18:28:20 -0300
committerGitHub <noreply@github.com>2026-11-25 18:28:20 -0300
commit337f0a4dc91bfab7e706ea8fd286e238eec48789 (patch)
tree99262b9c2e0857b88276c61d0b8f70e87d578e33 /docs
parent5c6b60e8ad6db1ba8a042f67579f12f720efa673 (diff)
parentebaa5e2e60c2b17af92ad60ab79e5e302c502fc5 (diff)
Merge pull request #1794 from Ch1mpleo/carry/old-10038
docs: correct the retail XMem shim status (OLD-10038)
Diffstat (limited to 'docs')
-rw-r--r--docs/xcl_compare.md2
-rw-r--r--docs/xmem_exe_calls.md56
2 files changed, 33 insertions, 25 deletions
diff --git a/docs/xcl_compare.md b/docs/xcl_compare.md
index 07d3e42e4..cd7a0b6a0 100644
--- a/docs/xcl_compare.md
+++ b/docs/xcl_compare.md
@@ -71,5 +71,5 @@ What the differences come down to:
71| XUser, XGameSave folder | #279 and #3363 (open). | 71| XUser, XGameSave folder | #279 and #3363 (open). |
72| `XAudio2Create` | RT-197, #3831 (open). | 72| `XAudio2Create` | RT-197, #3831 (open). |
73| `d3d12_xs.dll!D3D12CreateDevice` not found (16 D3D12.X checks) | The runtime serves the console's `D3D12XboxCreateDevice`; the title asks for `D3D12CreateDevice`. Whether the console's `d3d12_xs.dll` exports that name is not measured here. | 73| `d3d12_xs.dll!D3D12CreateDevice` not found (16 D3D12.X checks) | The runtime serves the console's `D3D12XboxCreateDevice`; the title asks for `D3D12CreateDevice`. Whether the console's `d3d12_xs.dll` exports that name is not measured here. |
74| `kernelx.dll` imports `XMemAlloc`, `XMemVirtualAlloc`, `TitleMemoryStatus`, `GetConsoleType`, `SetThreadName`/`GetThreadName`; `xmem.dll` physical pages; `xcrdapi.dll!DStorageGetFactory`; `MFResetDXGIDeviceManagerX` | Unimplemented here. None is in the measured imports of the shipped modules ([runtime_imports.md](runtime_imports.md)), and the executable is not available to measure, so they are leads, not known needs. `xmem.dll!XMemAlloc` is served; the same name under `kernelx.dll` is not. | 74| `kernelx.dll` imports `XMemAlloc`, `XMemVirtualAlloc`, `TitleMemoryStatus`, `GetConsoleType`, `SetThreadName`/`GetThreadName`; `xmem.dll` physical pages; `xcrdapi.dll!DStorageGetFactory`; `MFResetDXGIDeviceManagerX` | These are the XCL title's bindings, not the game's. The executable's own import table and call sites are measured at `1cc6e3c1` ([runtime_imports.md](runtime_imports.md#the-retail-executable-rt-5)): `xmem.dll!XMemAlloc`, `XMemFree` and `XMemVirtualAlloc` bind (the last at 23 measured call sites), and the four `xmem.dll` physical-page calls (`XMemAllocatePhysicalPages`, `XMemFreePhysicalPages`, `XMemMapPhysicalPages`, `XMemMapPhysicalPagesScatter`) are served; the same names under `kernelx.dll` are not. `XCRDAPI.dll!DStorageGetFactory` is a measured import served by `dstorage.cpp` (since `2d7be48de`). `TitleMemoryStatus`, `GetConsoleType`, `SetThreadName`/`GetThreadName` and `MFResetDXGIDeviceManagerX` are not in that table, so they remain leads, not known needs. |
75| The title's window is not a hidden 1920x1080 tool window | An XCL design choice (its console screen), not a console fact. | 75| The title's window is not a hidden 1920x1080 tool window | An XCL design choice (its console screen), not a console fact. |
diff --git a/docs/xmem_exe_calls.md b/docs/xmem_exe_calls.md
index 99b62fbe1..071cb6b7f 100644
--- a/docs/xmem_exe_calls.md
+++ b/docs/xmem_exe_calls.md
@@ -1,11 +1,12 @@
1# XMem: how the retail executable calls it (RT-5) 1# XMem: how the retail executable calls it (RT-5)
2 2
3`game_scarlett_master.exe` imports 12 functions from `xmem.dll` (`docs/runtime_imports.md`, "The retail executable"). 3`game_scarlett_master.exe` imports 12 functions from `xmem.dll` (`docs/runtime_imports.md`, "The retail executable").
4Seven have no shim yet. This page records, from the file alone, how the executable calls them: how many call sites each 4This page records, from the file alone, how the executable calls them: how many call sites each has and the constant
5has and the constant arguments those sites pass. Nothing was run: `tools/import_call_sites.py` finds the call sites, and 5arguments those sites pass. Nothing was run: `tools/import_call_sites.py` finds the call sites, and the instructions
6the instructions that load the argument registers before each call were read by hand. No code or data of the executable 6that load the argument registers before each call were read by hand. No code or data of the executable is quoted, only
7is quoted, only the constants a call passes and the counts. Measured at `main` `1cc6e3c1`, SHA-256 7the constants a call passes and the counts. The call sites were measured at `main` `1cc6e3c1`, SHA-256
8`e95020b2fa4a721db3df59fdecf75621730ac559d8835252f6c3b658d5a08993`. 8`e95020b2fa4a721db3df59fdecf75621730ac559d8835252f6c3b658d5a08993`; the shim column below is the current state, and
9it has moved since then: `042c5f378` (#6919) gave every one of the 12 imports a shim (seven had none at `1cc6e3c1`).
9 10
10```powershell 11```powershell
11python -I tools/import_call_sites.py game_scarlett_master.exe --dll xmem.dll --dll d3d12_xs.dll --dll xg_xs.dll 12python -I tools/import_call_sites.py game_scarlett_master.exe --dll xmem.dll --dll d3d12_xs.dll --dll xg_xs.dll
@@ -15,19 +16,19 @@ The tool finds each import's thunk (`jmp [rip+disp32]` through its address-table
15instructions that reach it. Its counts cover direct calls only, and a stray `E8`/`E9` byte could add one, so they are 16instructions that reach it. Its counts cover direct calls only, and a stray `E8`/`E9` byte could add one, so they are
16bounds, not a proof that every site is reached. 17bounds, not a proof that every site is reached.
17 18
18| Import | Call sites | Shim at `main` `1cc6e3c1` | 19| Import | Call sites | Shim at `main` (since #6919) |
19|---|---:|---| 20|---|---:|---|
20| `XMemVirtualAlloc` | 23 | yes, refuses every one of these 23 (below) | 21| `XMemVirtualAlloc` | 23 | yes, all 23 types served (below) |
21| `XMemMapPhysicalPages` | 12 | no | 22| `XMemMapPhysicalPages` | 12 | yes (pagefile-backed 64 KiB pool) |
22| `XMemAllocatePhysicalPages` | 4 | no | 23| `XMemAllocatePhysicalPages` | 4 | yes |
23| `XMemFreePhysicalPages` | 3 | no | 24| `XMemFreePhysicalPages` | 3 | yes |
24| `XMemMapPhysicalPagesScatter` | 2 | no | 25| `XMemMapPhysicalPagesScatter` | 2 | yes |
25| `XMemAlloc` | 3 | yes | 26| `XMemAlloc` | 3 | yes |
26| `XMemFree` | 3 (2 calls, 1 tail jump) | yes | 27| `XMemFree` | 3 (2 calls, 1 tail jump) | yes |
27| `XMemGetWorkingSetStatistics` | 3 | yes | 28| `XMemGetWorkingSetStatistics` | 3 | yes |
28| `XMemTransferMemory` | 1 | yes | 29| `XMemTransferMemory` | 1 | yes |
29| `XMemIsToolsMemAvailable` | 1 | no | 30| `XMemIsToolsMemAvailable` | 1 | yes (returns `FALSE`) |
30| `XMemAllocDefault`, `XMemFreeDefault` | 1 tail jump each, no call | no | 31| `XMemAllocDefault`, `XMemFreeDefault` | 1 tail jump each, no call | yes |
31 32
32The executable also exports one symbol, `__XMemAllocationHooks__`. 33The executable also exports one symbol, `__XMemAllocationHooks__`.
33 34
@@ -50,10 +51,16 @@ The 23 sites pass these constants (`allocation_type`, `attributes`, `protect`; t
50| `0x20406000` | `0x27` | `0x1004`, `0x1404`, `0x8404`, `0x2404`, `0x2004` | 5 (one each) | 51| `0x20406000` | `0x27` | `0x1004`, `0x1404`, `0x8404`, `0x2404`, `0x2004` | 5 (one each) |
51| `0x42000` | `0x7` | `0x1` | 1 | 52| `0x42000` | `0x7` | `0x1` | 1 |
52 53
53Every `attributes` value is nonzero, and `runtime/shims/xmem.cpp` returns `ERROR_NOT_SUPPORTED` for a nonzero value 54Every `attributes` value is nonzero. Since #6919 `runtime/shims/xmem.cpp` does not decode them: `XMemVirtualAlloc`
54("until their host mapping is known"), so none of the 23 calls succeeds there. Past that check the shim would also 55records the word (`xmem_attributes` in the startup trace) and accepts it. All 23 allocation types are served as well.
55refuse the calls with `allocation_type` `0x20003000` (5 sites: the 2 MiB page mode) and those with bits it does not 56The page-mode mask is `kXmem64kPages` `0x20400000`, which *is* `MEM_LARGE_PAGES | MEM_PHYSICAL`, so `0x20406000`
56know: `0x4000` in `0x20406000` (5 sites) and `0x40000` in `0x42000` (1 site). 57(`0x20400000 | MEM_RESERVE | MEM_REPLACE_PLACEHOLDER`) selects the 64 KiB page mode and replaces part of the
58placeholder — `test_placeholders` in `runtime/test/xmem_test.cpp` allocates that exact shape and maps physical pages
59into the carved window. The 23 sites divide as 17 in the 64 KiB mode (3 committed, 8 reserve-only windows, 1 plain
60commit, 5 placeholder replacements), five in the 2 MiB mode `0x20000000` (committed 2 MiB-aligned through
61`VirtualAlloc2`), and one `0x42000` = `MEM_RESERVE | MEM_RESERVE_PLACEHOLDER`, the ~185 MiB reservation the five
62windows are carved out of (`docs/retail_boot_chain.md`, stops 10-11). That agrees with `docs/runtime_imports.md`
63("The retail executable", `xmem.dll` notes), which records the same 2 MiB and placeholder paths.
57 64
58The `protect` values are not Win32 protections alone. The Windows SDK's `winnt.h` defines the graphics page protections 65The `protect` values are not Win32 protections alone. The Windows SDK's `winnt.h` defines the graphics page protections
59the high bits match: `PAGE_GRAPHICS_NOACCESS` `0x800`, `_READONLY` `0x1000`, `_READWRITE` `0x2000`, `_EXECUTE_READ` 66the high bits match: `PAGE_GRAPHICS_NOACCESS` `0x800`, `_READONLY` `0x1000`, `_READWRITE` `0x2000`, `_EXECUTE_READ`
@@ -81,13 +88,14 @@ those two facts. The meaning of `flags`, and whether the page numbers in `pageAr
81are **unmeasured**. 88are **unmeasured**.
82 89
83The sequence in the first function that calls them is: `XMemAllocatePhysicalPages`, then `XMemVirtualAlloc` of a range 90The sequence in the first function that calls them is: `XMemAllocatePhysicalPages`, then `XMemVirtualAlloc` of a range
84with `0x20402000` and attributes `0x23`, then `XMemMapPhysicalPages` of those pages at that range. So the physical-page calls depend on the 91with `0x20402000` and attributes `0x23`, then `XMemMapPhysicalPages` of those pages at that range. That path no longer
85attribute check above: until `XMemVirtualAlloc` accepts these attribute words, the map calls are never reached from 92stops at `XMemVirtualAlloc`: since #6919 it accepts that attribute word and the reserve-only 64 KiB window.
86there. 93
87 94The host's own AWE functions need `SeLockMemoryPrivilege`, which an ordinary user does not hold, so the shim emulates
88The host's own AWE functions need `SeLockMemoryPrivilege`, which an ordinary user does not hold, so a shim would 95the pool rather than forwarding (#6919): a pagefile-backed section in 64 KiB pages, committed at once on Wine (and on demand on native Windows) and given
89emulate the pool (a pagefile-backed section of 64 KiB pages, with views placed at the reserved range) instead of 96physical memory as it is touched, with views placed at the reserved range. Pages keep their contents while unmapped or
90forwarding. That is a design note, not a measurement. 97mapped elsewhere, and one page can be mapped at several addresses. The attribute word is recorded, still not decoded,
98and every page is 64 KiB, which all four callers' arithmetic agrees with (`runtime/shims/xmem.cpp`).
91 99
92## The other imports 100## The other imports
93 101