Skip to content

Commit

Permalink
Opt, 新增__ENABLE_WORKAROUND_ALL开关
Browse files Browse the repository at this point in the history
  • Loading branch information
mingkuang-Chuyu committed Jun 16, 2024
1 parent ad7b7de commit 9255040
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 18 deletions.
11 changes: 11 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,17 @@ Compatible with all platforms.
* All runtime modes are supported (such as: `/MD`, `/MT`, `/MDd`, `/MTd`).
### 3.2. Windows SDK Version Requirements
| Thunks Target | At Least Windows SDK Version is required
| ------------------ | -----------
| Windows 2000 | SDK 6.0 (VS2008 built-in)
| Windows XP(2003) | SDK 6.0 (VS2008 built-in)
| Windows Vista | SDK 6.0 (VS2008 built-in)
| Windows 7 | SDK 7.0
| Windows 8 | SDK 8.0
| Windows 8.1 | SDK 8.1
| Windows 10 10240 | SDK 10.0.10240
| Windows 10 19041 | SDK 10.0.19041
At least Windows SDK 6.0 is required.
> Note: VC6.0 and VS2005 users should note that the SDK version that comes with these compilers by default is too low.
Expand Down
12 changes: 11 additions & 1 deletion Readme.osc.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,17 @@ ULONGLONG WINAPI GetTickCount64(VOID)
* 所有运行库模式均支持(比如:`/MD`、`/MT`、`/MDd`、`/MTd`)。
### 3.2. SDK版本要求
至少需要SDK 6.0(VS2008默认附带)
| Thunks等级 | 最低SDK要求
| ------------------ | -----------
| Windows 2000 | SDK 6.0(VS2008默认附带)
| Windows XP(2003) | SDK 6.0(VS2008默认附带)
| Windows Vista | SDK 6.0(VS2008默认附带)
| Windows 7 | SDK 7.0
| Windows 8 | SDK 8.0
| Windows 8.1 | SDK 8.1
| Windows 10 10240 | SDK 10.0.10240
| Windows 10 19041 | SDK 10.0.19041
> 温馨提示:VC6.0、VS2005用户请注意,由于这些编译器默认附带的SDK版本太低。请先将SDK升级到6.0或者更高版本,然后再使用YY-Thunks,否则将发生链接失败!
高版本的SDK不影响对老系统的兼容性,请坐和放宽,安心升级。
Expand Down
36 changes: 21 additions & 15 deletions src/Thunks/YY_Thunks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ YY-Thunks支持的控制宏:
2. __USING_NTDLL_LIB:假定构建环境存在ntdll.lib,这可以减少一些NTDLL相关函数的动态加载。
特殊支持的变通方案:
1. __ENABLE_WORKAROUND_1_GetProcAddress_ProcessPrng
1. __ENABLE_WORKAROUND_ALL
启用所有兼容方案,即__ENABLE_WORKAROUND_1 ~ __ENABLE_WORKAROUND_N,全部开启。
2. __ENABLE_WORKAROUND_1_GetProcAddress_ProcessPrng
兼容方案1:让GetProcAddress也能取到ProcessPrng函数地址。某些代码可能强制依赖ProcessPrng。
2. __ENABLE_WORKAROUND_2_UNNAME_OBJECT_DACL
3. __ENABLE_WORKAROUND_2_UNNAME_OBJECT_DACL
兼容方案2:Windows 8.1以前的版本对于匿名对象无法生效DACL。就会导致Chrome的CheckPlatformHandlePermissionsCorrespondToMode判断不准确。
修复方案通过给匿名对象创建一个名字解决该问题。
Expand Down Expand Up @@ -133,15 +136,25 @@ YY-Thunks支持的控制宏:
#define __WarningMessage__(msg) __pragma(message (__FILE__ "(" STRING(__LINE__) "): warning Thunks: " # msg))
#endif

#if defined(__APPLY_CHROMIUM_WORKAROUNDS)
#ifndef __ENABLE_WORKAROUND_1_GetProcAddress_ProcessPrng
#define __ENABLE_WORKAROUND_1_GetProcAddress_ProcessPrng
#if !defined(__ENABLE_WORKAROUND_1_GetProcAddress_ProcessPrng) && (defined(__ENABLE_WORKAROUND_ALL) || defined(__APPLY_CHROMIUM_WORKAROUNDS))
#define __ENABLE_WORKAROUND_1_GetProcAddress_ProcessPrng 1
#endif

#ifndef __ENABLE_WORKAROUND_2_UNNAME_OBJECT_DACL
#define __ENABLE_WORKAROUND_2_UNNAME_OBJECT_DACL
#if !defined(__ENABLE_WORKAROUND_2_UNNAME_OBJECT_DACL) && (defined(__ENABLE_WORKAROUND_ALL) || defined(__APPLY_CHROMIUM_WORKAROUNDS))
#define __ENABLE_WORKAROUND_2_UNNAME_OBJECT_DACL 1
#endif

#ifndef __FALLBACK_PREFIX
#define __FALLBACK_PREFIX
#define __YY_Thunks_libs 0
#else
#define __YY_Thunks_libs 1
#endif

#if !defined(__USING_NTDLL_LIB) && (__YY_Thunks_libs || YY_Thunks_Support_Version >= NTDDI_WIN10)
// lib模式下必然存在 ntdll.lib,此外最小支持Windows 10时,我们因为强制依赖Windows 10 SDK,所以也必然存在ntdll.lib。
#define __USING_NTDLL_LIB 1
#endif
#endif // defined(__APPLY_CHROMIUM_WORKAROUNDS)

#define _Disallow_YY_KM_Namespace
#include "km.h"
Expand Down Expand Up @@ -230,13 +243,6 @@ RtlCutoverTimeToSystemTime(

#include <HookThunk.h>

#ifndef __FALLBACK_PREFIX
#define __FALLBACK_PREFIX
#define __YY_Thunks_libs 0
#else
#define __YY_Thunks_libs 1
#endif

//展开函数的所有的 声明 以及 try_get_ 函数
#define __DEFINE_THUNK_EXTERN_PREFIX(_PREFIX, _MODULE, _SIZE, _RETURN_, _CONVENTION_, _FUNCTION, ...) \
__APPLY_UNIT_TEST_BOOL(_FUNCTION); \
Expand Down
4 changes: 2 additions & 2 deletions src/YY-Thunks.UnitTest/YY-Thunks.UnitTest.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>SymbolBuildTestPath=LR"($(ProjectDir)TestProject\)";YY_ThunksRootPath=LR"($(ProjectDir)..\..\)";MSBuildBinPath=LR"($(MSBuildBinPath)\)";__YY_Thunks_Unit_Test;WIN32;NDEBUG;YY_Thunks_Support_Version=NTDDI_WIN2K;__APPLY_CHROMIUM_WORKAROUNDS;__USING_NTDLL_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>SymbolBuildTestPath=LR"($(ProjectDir)TestProject\)";YY_ThunksRootPath=LR"($(ProjectDir)..\..\)";MSBuildBinPath=LR"($(MSBuildBinPath)\)";__YY_Thunks_Unit_Test;WIN32;NDEBUG;YY_Thunks_Support_Version=NTDDI_WIN2K;__ENABLE_WORKAROUND_ALL;__USING_NTDLL_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<UseFullPaths>true</UseFullPaths>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<PrecompiledHeader>Use</PrecompiledHeader>
Expand All @@ -117,7 +117,7 @@
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<AdditionalIncludeDirectories>$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>SymbolBuildTestPath=LR"($(ProjectDir)TestProject\)";YY_ThunksRootPath=LR"($(ProjectDir)..\..\)";MSBuildBinPath=LR"($(MSBuildBinPath)\)";__YY_Thunks_Unit_Test;WIN32;_DEBUG;YY_Thunks_Support_Version=NTDDI_WIN2K;__APPLY_CHROMIUM_WORKAROUNDS;__USING_NTDLL_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>SymbolBuildTestPath=LR"($(ProjectDir)TestProject\)";YY_ThunksRootPath=LR"($(ProjectDir)..\..\)";MSBuildBinPath=LR"($(MSBuildBinPath)\)";__YY_Thunks_Unit_Test;WIN32;_DEBUG;YY_Thunks_Support_Version=NTDDI_WIN2K;__ENABLE_WORKAROUND_ALL;__USING_NTDLL_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<UseFullPaths>true</UseFullPaths>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<PrecompiledHeader>Use</PrecompiledHeader>
Expand Down

0 comments on commit 9255040

Please sign in to comment.