From 079b5414e1a6a3e1d7a6d5ba9435d921d5e54841 Mon Sep 17 00:00:00 2001 From: Ivan John Ozimchuk <3846306+ozimchuk@users.noreply.github.com> Date: Mon, 23 Nov 2026 12:27:13 +0200 Subject: [PATCH] VFS hooks: the guard keeps the thread's last error The hooks' re-entrancy guard is a thread_local. In a build with the GNU toolchain (x86_64-pc-windows-gnu) a thread_local access goes through TlsGetValue, which sets the thread's last error to 0. The guard is dropped after the original function has returned, so a failing call came back with GetLastError() == 0: std::fs::create_dir_all on an existing directory then fails with "Success. (os error 0)" and no title loads. The drop now saves the last error and puts it back. MSVC builds use static TLS and are not affected either way. Co-Authored-By: Claude Fable 5.2 --- crates/xcl/src/vfs_hooks.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/xcl/src/vfs_hooks.rs b/crates/xcl/src/vfs_hooks.rs index deb96e5..bb5dc48 100644 --- a/crates/xcl/src/vfs_hooks.rs +++ b/crates/xcl/src/vfs_hooks.rs @@ -39,7 +39,9 @@ impl Guard { } impl Drop for Guard { fn drop(&mut self) { + let e = unsafe { windows_sys::Win32::Foundation::GetLastError() }; IN_HOOK.with(|c| c.set(false)); + unsafe { windows_sys::Win32::Foundation::SetLastError(e) }; } }