Skip to content

fix(WeaselSetup): robust 32-bit and 64-bit TSF installation and registration - #1977

Open
dizicheng wants to merge 1 commit into
rime:masterfrom
dizicheng:fix/wow64-tsf-registration
Open

dizicheng wants to merge 1 commit into
rime:masterfrom
dizicheng:fix/wow64-tsf-registration

Conversation

@dizicheng

Copy link
Copy Markdown

Problem

On 64-bit Windows, WeaselSetup.exe runs as a 32-bit (WOW64) process. In previous versions, 32-bit applications (such as 32-bit WPS Office, TianRuo OCR, and 32-bit games) frequently fail to load Weasel, resulting in a disabled IME status (circle with a slash icon) and inability to input Chinese (fixes #1831, relates to #1716).

Root Causes

  1. Implicit redirection reliance: install_ime_file and uninstall_ime_file relied on a single destination path (C:\Windows\system32\weasel.dll) and implicit filesystem redirection to copy files to SysWOW64 and System32. During upgrades or reinstallation, 32-bit weasel.dll in SysWOW64 could be removed without being properly restored.
  2. Spawning child processes during disabled redirection: In install_ime_file, func (register_text_service) was invoked while Wow64DisableWow64FsRedirection was active. Microsoft MSDN explicitly warns:

    "Do not call CreateProcess or ShellExecute while file system redirection is disabled, because it can result in unpredictable behavior."

  3. Bare name regsvr32.exe & unused is_wow64 parameter: register_text_service accepted bool is_wow64 but completely ignored it in its implementation, launching regsvr32.exe without an absolute path. Consequently, 32-bit and 64-bit registrations could not be reliably dispatched to their respective bitness utilities.

Solution (Minimal Diff)

  1. Explicit 32-bit path resolution: In install_ime_file and uninstall_ime_file, explicitly resolve GetSystemWow64DirectoryW on 64-bit systems to ensure 32-bit weasel.dll is consistently copied to and deleted from SysWOW64.
  2. Revert redirection before spawning child processes: In install_ime_file, call Wow64RevertWow64FsRedirection immediately after file copying completes, ensuring ShellExecuteExW is never executed while redirection is disabled.
  3. Architecture-aware absolute regsvr32.exe paths: Utilize the existing is_wow64 parameter in register_text_service:
    • For 64-bit registration: use %windir%\Sysnative\regsvr32.exe (accessible from 32-bit WOW64 process) or System32 fallback.
    • For 32-bit registration on 64-bit systems: use %windir%\SysWOW64\regsvr32.exe.
    • For 32-bit systems: use %windir%\System32\regsvr32.exe.

Verification

  • Verified on Windows 10 22H2 (x64) with 32-bit WPS Office (et.exe / wps.exe): 32-bit weasel.dll is correctly registered in WOW6432Node, loaded by 32-bit host processes, and Chinese input functions as expected.
  • Preserved existing ARM64 / ARM32 redirection DLL logic without disruption.

@fxliang

fxliang commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

我记得之前都是OK的,是哪个提交引入的回归?

@dizicheng
dizicheng force-pushed the fix/wow64-tsf-registration branch from 49b6c54 to f1e2e84 Compare November 9, 2026 11:40
…tration

- Explicitly resolve System32 and SysWOW64 directory paths instead of relying on fragile implicit filesystem redirection.
- Avoid spawning child processes (ShellExecuteEx/regsvr32) while Wow64DisableWow64FsRedirection is active, adhering to MSDN guidelines.
- Provide absolute executable paths for regsvr32.exe based on target bitness (via Sysnative for 64-bit registration from WOW64, and SysWOW64 for 32-bit).
- Fixes rime#1831 (and related rime#1716) where 32-bit applications fail to load Weasel and show as disabled.
@dizicheng
dizicheng force-pushed the fix/wow64-tsf-registration branch from f1e2e84 to 467e4a1 Compare November 9, 2026 11:43
@dizicheng

Copy link
Copy Markdown
Author

我记得之前都是OK的,是哪个提交引入的回归?

在提交 d636e0a(PR #1775 refactor: drop WeaselIME)之前,小狼毫一直同时分发并注册 TSF(weasel.dll)和 IMM32(weasel.ime)。 像 32 位 WPS Office 这类历史悠久的桌面软件(以及大量 32 位老游戏),历来原生优先支持经典的 Win32 IMM32 架构。当时哪怕 32 位的 TSF(SysWOW64\weasel.dll)注册有缺失,WPS 也会直接无缝退回到 weasel.ime 处理键盘输入,因此此前在 WPS 中输入中文一直表现正常。

是哪个提交导致了现象的显现?

  1. 彻底移除 IMM 兜底:d636e0a(refactor: drop WeaselIME)正式移除了 weasel.ime,小狼毫转为纯 TSF(TSF-only build)。此时 32 位 WPS 等软件无法再回退到 IMM,只能完全依赖 32 位的 TSF 模块(SysWOW64\weasel.dll)。
  2. 安装升级时的清理时机:c6a3fa2(installer: ensure old ime/dll files deleted by running WeaselSetup.exe /u before installing)在每次安装前都会执行 /u。由于 32 位的 SysWOW64\weasel.dll 通常不会被 64 位的常驻进程(如 Explorer)占用,在卸载时会被立刻干净删除并注销 COM;而在紧接着重新安装时,受限于重定向机制,32 位 TSF 容易未能正确重新入驻。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows 10 使用 WPS 无法输入中文

2 participants