diff options
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/runtime_imports.md | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/docs/runtime_imports.md b/docs/runtime_imports.md index b6ee0db7c..5edf6a84b 100644 --- a/docs/runtime_imports.md +++ b/docs/runtime_imports.md | |||
| @@ -103,6 +103,27 @@ bootstrap call it as `if (!XMemTransferMemory(XMemTransferTitleToSystem, size))` | |||
| 103 | returns `TRUE` for every direction and size and allocates nothing; with `--trace` it records each distinct direction | 103 | returns `TRUE` for every direction and size and allocates nothing; with `--trace` it records each distinct direction |
| 104 | and size as an `xmem_transfer` event, because the enum values are not public. `xmem_test` covers it. | 104 | and size as an `xmem_transfer` event, because the enum values are not public. `xmem_test` covers it. |
| 105 | 105 | ||
| 106 | Seven more `xmem.dll` imports follow argument shapes measured locally at a title's call sites (the comments in | ||
| 107 | `runtime/shims/xmem.cpp` give each shape): | ||
| 108 | |||
| 109 | - `XMemAllocDefault` and `XMemFreeDefault` take `XMemAlloc`'s and `XMemFree`'s arguments and share their heap. | ||
| 110 | - `XMemAllocatePhysicalPages(attributes, UINT64* count, UINT64* pages)` returns a `BOOL` and the count it allocated. | ||
| 111 | Each call is one pagefile-backed section of `count` 64 KiB pages. A page number is a 4 KiB frame number: a | ||
| 112 | non-zero multiple of 16 below 2^25, which is what the measured title assumes when it packs them. `0` means "unmap". | ||
| 113 | - `XMemMapPhysicalPages(address, UINT64 count, pages)` returns the address. A null page array unmaps. | ||
| 114 | `XMemMapPhysicalPagesScatter(addresses, UINT32 count, pages)` returns a `BOOL`, and a `0` entry unmaps. | ||
| 115 | `XMemFreePhysicalPages(UINT64 count, pages)` returns a `BOOL`. Every page is its own view, mapped with | ||
| 116 | `MapViewOfFile3` into a 64 KiB placeholder, so a page keeps its contents across remaps and can be mapped twice. | ||
| 117 | - The windows are reserve-only 64 KiB-page `XMemVirtualAlloc` regions. The shim reserves them as placeholders and | ||
| 118 | keeps their protection, which mapped pages get (AWE's rule). The measured title also reserves a placeholder with | ||
| 119 | `MEM_RESERVE_PLACEHOLDER` and carves windows out of it with `MEM_REPLACE_PLACEHOLDER`, and the shim passes both | ||
| 120 | through. **ASSUMPTION:** nothing commits into a window with `kernel32!VirtualAlloc`, which a placeholder refuses. | ||
| 121 | - `XMemVirtualAlloc` used to refuse 2 MiB pages, and five of the 23 measured calls commit them. They are now | ||
| 122 | committed 2 MiB-aligned through `VirtualAlloc2`. The attribute word is recorded (`xmem_attributes`) and the | ||
| 123 | console's `PAGE_GRAPHICS_*` bits are dropped from the protection, as before. | ||
| 124 | - `XMemIsToolsMemAvailable()` is `FALSE`: a PC has no development-kit tools memory. The measured title asks only | ||
| 125 | on an out-of-memory path, after an allocation has already failed. | ||
| 126 | |||
| 106 | ## The retail executable (RT-5) | 127 | ## The retail executable (RT-5) |
| 107 | 128 | ||
| 108 | `game_scarlett_master.exe` (120,181,760 bytes on disk, SHA-256 | 129 | `game_scarlett_master.exe` (120,181,760 bytes on disk, SHA-256 |
| @@ -144,6 +165,8 @@ Only two of these DLLs have a shim in the repository (`xmem.dll` and `d3d12_xs.d | |||
| 144 | they hold 8 of the 30 unimplemented imports. The other 22 are in five DLLs (`xg_xs.dll`, `XCRDAPI.dll`, `chad.dll`, | 165 | they hold 8 of the 30 unimplemented imports. The other 22 are in five DLLs (`xg_xs.dll`, `XCRDAPI.dll`, `chad.dll`, |
| 145 | `xapu.dll`, `AcpHal.dll`) with no shim at all. | 166 | `xapu.dll`, `AcpHal.dll`) with no shim at all. |
| 146 | 167 | ||
| 168 | The seven `xmem.dll` imports are served now (see the `xmem.dll` notes above), so the same dry run lists 23. | ||
| 169 | |||
| 147 | `--init` on the same files also exits 0 with nothing on stderr. Its `--trace` file has 15 lines: the four package DLLs' | 170 | `--init` on the same files also exits 0 with nothing on stderr. Its `--trace` file has 15 lines: the four package DLLs' |
| 148 | `DllMain(DLL_PROCESS_ATTACH)` each return 1, the executable's two TLS callbacks run at process attach (reason 1) and | 171 | `DllMain(DLL_PROCESS_ATTACH)` each return 1, the executable's two TLS callbacks run at process attach (reason 1) and |
| 149 | again at detach (reason 0), and there is no `exception`, `error` or `unimplemented_call` event. So none of the 30 | 172 | again at detach (reason 0), and there is no `exception`, `error` or `unimplemented_call` event. So none of the 30 |