Merge pull request #287 from appergb/fix/windows-ime-static-crt
fix(windows-ime): 静态链接 CRT 防 host 进程 MSVCP140 劫持(修 QQ 切微软拼音崩溃)
This commit is contained in:
2 files changed
+14
-1
No files matched your search
@@ -75,6 +75,12 @@
|
||||
<PreprocessorDefinitions>WIN32;_WINDOWS;_USRDLL;OPENLESSIME_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<!-- 静态链接 CRT:让 OpenLessIme.dll 自带 MSVCP / VCRUNTIME / UCRT,
|
||||
避免被宿主进程(如 QQ)app/ 目录下的私有 MSVCP140 副本劫持。
|
||||
QQ 把 MSVCP140.dll 放在 versions/<ver>/resources/app/,DLL 搜索
|
||||
顺序优先 → 我们的 std::* 调用会跑 QQ 那份旧版 → ABI 漂移 → 0xc0000005。
|
||||
DLL 大小 +~300 KB;DLL 内部 STL 不再可跨边界共享(我们也不需要)。 -->
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@@ -89,6 +95,7 @@
|
||||
<PreprocessorDefinitions>WIN32;_WINDOWS;_USRDLL;OPENLESSIME_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@@ -105,6 +112,7 @@
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;OPENLESSIME_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@@ -123,6 +131,7 @@
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;OPENLESSIME_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
||||
@@ -13,9 +13,13 @@ LONG g_object_count = 0;
|
||||
BOOL APIENTRY DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved) {
|
||||
UNREFERENCED_PARAMETER(reserved);
|
||||
|
||||
// 不调用 DisableThreadLibraryCalls:DLL 现在用 /MT 静态链接 CRT,CRT 需要
|
||||
// DLL_THREAD_ATTACH / DLL_THREAD_DETACH 通知做 per-thread TLS 初始化与清理。
|
||||
// 在 host 进程(如 QQ / Office)切输入法新建 input thread 时禁用通知,会让
|
||||
// 静态 CRT 的 thread-local 资源泄漏 / 行为不稳定,反而把这次想修的崩溃问题
|
||||
// 重新引回来。详见 Microsoft 文档 DisableThreadLibraryCalls 备注。
|
||||
if (reason == DLL_PROCESS_ATTACH) {
|
||||
g_module = instance;
|
||||
DisableThreadLibraryCalls(instance);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
Reference in new issue
Block a user