Files and storage
Paths
| xexkit path | Kernel device | What |
|---|---|---|
game:/ | set up by the loader | the folder the XEX was started from (writable on the console) |
hdd:/ | \Device\Harddisk0\Partition1 | the hard disk, Aurora's Hdd1: |
usb0:/-usb2:/ | \Device\Mass0-2 | USB drives (FAT32 or FATX) |
xex_mount_devices() creates the links with ObCreateSymbolicLink as \??\name:. xex_kernel_path() turns usb0:/a/b into \??\usb0:\a\b. Relative paths are under game:. Both / and \ work.
The rest goes through newlib's reentrant syscalls on NtCreateFile, NtReadFile, NtWriteFile and friends, with a 64-entry descriptor table: open, read, write, lseek, close, stat, fstat, unlink, mkdir, rmdir, opendir, readdir, closedir. stdio and iostreams work on top.
The FAT32 USB listing bug
A FAT32 USB stick's driver returns one entry per NtQueryDirectoryFile and leaves NextEntryOffset and FileIndex unwritten. Whatever the buffer held before stays there. A readdir that follows NextEntryOffset then walks into garbage:
- FAKE-08 died after listing the first cart: an access violation in
readdir, reading 0xF687CC9A; - the hard disk and Xenia list correctly, so nothing showed there.
xexkit clears the buffer before every query and bounds-checks the offset (runtime/fs.c). xsdk found the same.
Deleting files
NtDeleteFilefails on the console; xexkit falls back toNtSetInformationFile(FileDispositionInformation)on an open handle, thenNtClose.- A file that's still open can't be deleted: a sharing violation, which
xexkit maps to
EBUSY. Close every stream first. Our first fs test failed because anifstreamwas still open.
Sizes and attributes
FileStandardInformation gives the size; FileNetworkOpenInformation is the fallback. stat tries NtQueryFullAttributesFile and falls back to opening the file and asking the handle.
Where to keep data
Write settings, saves and logs next to the XEX (game:/yourtitle/). game: is read-only in Xenia, so fall back to hdd:/ or Xenia's writable cache:. FAKE-08 tries game:/fake08, then hdd:/fake08, then cache:/fake08, probing each with a test file.