Skip to content

Commit 25d1221

Browse files
Fea,规避msvcp140_2.dll在低版本系统中加载失败
1 parent 1f4e930 commit 25d1221

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Thunks/api-ms-win-core-libraryloader.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1269,7 +1269,11 @@ namespace YY::Thunks
12691269
{
12701270
if (const auto _pfnDisableThreadLibraryCalls = try_get_DisableThreadLibraryCalls())
12711271
{
1272-
return _pfnDisableThreadLibraryCalls(_hLibModule);
1272+
// 至少从 Windows 8.1开始,改API会始终返回TRUE,如果DLL存在TLS,则DLL_THREAD_ATTACH可能继续发送
1273+
// 而Windows 7如果,DLL存在TLS会导致接口失败。
1274+
// msvcp140_2.dll,会调用此接口。如果失败,DLL则加载失败。为了规避早期系统加载失败的问题。我们保持跟Windows 8.1以及更改版本系统一致,始终返回TRUE,即可。
1275+
// 具体请参考:"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\crt\src\stl\dllmain_satellite.cpp"
1276+
_pfnDisableThreadLibraryCalls(_hLibModule);
12731277
}
12741278
}
12751279

0 commit comments

Comments
 (0)