diff --git a/ThunksList.md b/ThunksList.md index 986ca96..1f54a27 100644 --- a/ThunksList.md +++ b/ThunksList.md @@ -303,6 +303,12 @@ | ---- | ----------- | PdhAddEnglishCounterW(A) | 不存在时,调用PdhAddCounterW(A)。 +## powrprof.dll +| 函数 | Fallback +| ---- | ----------- +| PowerDeterminePlatformRole | 不存在时,返回PlatformRoleDesktop。 +| PowerDeterminePlatformRoleEx | 不存在时,调用PlatformRoleDesktop。 + ## psapi.dll | 函数 | Fallback | ---- | ----------- diff --git a/src/Thunks/YY_Thunks.cpp b/src/Thunks/YY_Thunks.cpp index 76140fa..9159e17 100644 --- a/src/Thunks/YY_Thunks.cpp +++ b/src/Thunks/YY_Thunks.cpp @@ -19,6 +19,7 @@ _APPLY(mfplat, "mfplat" , 0 ) \ _APPLY(bluetoothapis, "bluetoothapis" , 0 ) \ _APPLY(netapi32, "netapi32" , 0 ) \ + _APPLY(powrprof, "powrprof" , 0 ) \ _APPLY(api_ms_win_core_winrt_l1_1_0, "api-ms-win-core-winrt-l1-1-0" , 0 ) \ _APPLY(api_ms_win_core_winrt_string_l1_1_0, "api-ms-win-core-winrt-string-l1-1-0", 0 ) \ _APPLY(api_ms_win_core_winrt_error_l1_1_0, "api-ms-win-core-winrt-error-l1-1-0" , 0 ) \ diff --git a/src/Thunks/api-ms-win-power-base.hpp b/src/Thunks/api-ms-win-power-base.hpp new file mode 100644 index 0000000..8b09122 --- /dev/null +++ b/src/Thunks/api-ms-win-power-base.hpp @@ -0,0 +1,42 @@ +#if (YY_Thunks_Support_Version < NTDDI_WIN8) +#include +#endif + +#if (YY_Thunks_Support_Version < NTDDI_WIN8) +#pragma comment(lib, "PowrProf.lib") +#endif + +namespace YY +{ + namespace Thunks + { +#if (YY_Thunks_Support_Version < NTDDI_WIN8) + + // ֵ֧Ŀͻ Windows 8 [Ӧ|UWP Ӧ] + // ֵ֧ķ Windows Server 2012[Ӧ | UWP Ӧ] + __DEFINE_THUNK( + powrprof, + 4, + POWER_PLATFORM_ROLE, + WINAPI, + PowerDeterminePlatformRoleEx, + _In_ ULONG _uVersion + ) + { + if (auto const _pfnPowerDeterminePlatformRoleEx = try_get_PowerDeterminePlatformRoleEx()) + { + return _pfnPowerDeterminePlatformRoleEx(_uVersion); + } + + if (_uVersion == POWER_PLATFORM_ROLE_V1) + { + return PowerDeterminePlatformRole(); + } + else + { + return PlatformRoleUnspecified; + } + } +#endif + } +} diff --git a/src/Thunks/powrprof.hpp b/src/Thunks/powrprof.hpp new file mode 100644 index 0000000..4c515ba --- /dev/null +++ b/src/Thunks/powrprof.hpp @@ -0,0 +1,31 @@ +#if (YY_Thunks_Support_Version < NTDDI_VISTA) +#include +#endif + +namespace YY +{ + namespace Thunks + { +#if (YY_Thunks_Support_Version < NTDDI_VISTA) + + // ֵ֧Ŀͻ Windows 8 [Ӧ|UWP Ӧ] + // ֵ֧ķ Windows Server 2012[Ӧ | UWP Ӧ] + __DEFINE_THUNK( + powrprof, + 0, + POWER_PLATFORM_ROLE, + WINAPI, + PowerDeterminePlatformRole, + ) + { + if (auto const _pfnPowerDeterminePlatformRole = try_get_PowerDeterminePlatformRole()) + { + return _pfnPowerDeterminePlatformRole(); + } + + // ٶԼûе + return PlatformRoleDesktop; + } +#endif + } +} diff --git a/src/YY-Thunks.UnitTest/YY-Thunks.UnitTest.vcxproj b/src/YY-Thunks.UnitTest/YY-Thunks.UnitTest.vcxproj index b852d6d..7e86768 100644 --- a/src/YY-Thunks.UnitTest/YY-Thunks.UnitTest.vcxproj +++ b/src/YY-Thunks.UnitTest/YY-Thunks.UnitTest.vcxproj @@ -185,6 +185,7 @@ + @@ -192,6 +193,7 @@ + diff --git a/src/YY-Thunks.UnitTest/YY-Thunks.UnitTest.vcxproj.filters b/src/YY-Thunks.UnitTest/YY-Thunks.UnitTest.vcxproj.filters index 8392680..76543e5 100644 --- a/src/YY-Thunks.UnitTest/YY-Thunks.UnitTest.vcxproj.filters +++ b/src/YY-Thunks.UnitTest/YY-Thunks.UnitTest.vcxproj.filters @@ -200,6 +200,12 @@ Thunks + + Thunks + + + Thunks +