Triforce v0.9.1

The 16 GB update: idle memory unlocked and handed back to Windows while playing, empty pages under freed locks returned, and a page-file check at launch that warns before a too-small page file can crash the game.
This commit is contained in:
ruckus7382sfgsgdf
2026-12-01 17:47:00 -06:00
parent 822ee913bc
commit dad28e2d4b
11 changed files with 802 additions and 7 deletions

View File

@@ -96,6 +96,13 @@ def main():
"the heap is left reserved on Linux too, or committed whole on Windows")
touch = block(glue, "static LONG CALLBACK commit_on_touch(")
# ((Triforce, 12-01) a write into a block of zeros being given back (hos_mem.c zero_release) waits for it and is tried again,
# first thing after the guest checks: checked here, then left out of the order below)
zero_wait = (" {\n int hos_zero_wait(uint64_t guest);\n if (hos_zero_wait(guest)) return EXCEPTION_CONTINUE_EXECUTION;\n"
" }\n")
touch = touch.replace("\r\n", "\n")
check(zero_wait in touch, "commit_on_touch does not wait out a block of zeros being given back (hos_zero_wait)")
touch = touch.replace(zero_wait, "")
in_order(touch, ["if (!VirtualQuery(p, &mbi, sizeof mbi)) return EXCEPTION_CONTINUE_SEARCH;", "#ifdef _WIN32",
"if (heap_touch_again(mbi.State == MEM_COMMIT, mbi.Protect == PAGE_READWRITE, rec->ExceptionInformation[0]))",
"return EXCEPTION_CONTINUE_EXECUTION;", "#endif",
@@ -130,11 +137,11 @@ def main():
"SetMemoryHeapSize does not say the heap is committed as it is touched: the kernel calls' buffers are not touched")
read = block(fs, "static uint64_t read_at(")
in_order(read, ["const int away = hos_vcore_away();", "hos_guest_touch(buf, size);", "const int io = hos_guest_io_begin(GP(buf), size);",
in_order(read, ["const int away = hos_vcore_away();", "hos_guest_kio_begin(buf, size);", "const int io = hos_guest_io_begin(GP(buf), size);",
"ReadFile(fh->h, GP(buf + done)"],
"read_at does not touch its buffer before the kernel's read (with no virtual core held)")
write = block(fs, "HLE(_ZN2nn2fs9WriteFileENS0_10FileHandleElPKvmRKNS0_11WriteOptionE)")
in_order(write, ["hos_guest_touch(ARG(2), ARG(3));", "const int io = hos_guest_io_begin(GP(ARG(2)), ARG(3));", "WriteFile(fh->h, GP(ARG(2))"],
in_order(write, ["hos_guest_kio_begin(ARG(2), ARG(3));", "const int io = hos_guest_io_begin(GP(ARG(2)), ARG(3));", "WriteFile(fh->h, GP(ARG(2))"],
"WriteFile does not touch its buffer before the kernel's write")
check("void hos_guest_touch(uint64_t addr, uint64_t size);" in (HOST / "hos.h").read_text(encoding="utf-8"),
"hos.h does not declare hos_guest_touch")