Fea #29, 添加PowerDeterminePlatformRole,PowerDeterminePlatformRoleEx

This commit is contained in:
mingkuang
2023-03-13 19:33:56 +08:00
parent 32495369a6
commit cc1e3ca8a3
6 changed files with 88 additions and 0 deletions
+6
View File
@@ -303,6 +303,12 @@
| ---- | -----------
| PdhAddEnglishCounterW(A) | 不存在时,调用PdhAddCounterW(A)。
## powrprof.dll
| 函数 | Fallback
| ---- | -----------
| PowerDeterminePlatformRole | 不存在时,返回PlatformRoleDesktop。
| PowerDeterminePlatformRoleEx | 不存在时,调用PlatformRoleDesktop。
## psapi.dll
| 函数 | Fallback
| ---- | -----------
+1
View File
@@ -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 ) \
+42
View File
@@ -0,0 +1,42 @@
#if (YY_Thunks_Support_Version < NTDDI_WIN8)
#include <powrprof.h>
#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
}
}
+31
View File
@@ -0,0 +1,31 @@
#if (YY_Thunks_Support_Version < NTDDI_VISTA)
#include <powrprof.h>
#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
}
}
@@ -185,6 +185,7 @@
<ItemGroup>
<ClInclude Include="..\Thunks\api-ms-win-core-com.hpp" />
<ClInclude Include="..\Thunks\api-ms-win-eventing-provider.hpp" />
<ClInclude Include="..\Thunks\api-ms-win-power-base.hpp" />
<ClInclude Include="..\Thunks\bcrypt.hpp" />
<ClInclude Include="..\Thunks\bluetoothapis.hpp" />
<ClInclude Include="..\Thunks\ext-ms-win-ntuser-window.hpp" />
@@ -192,6 +193,7 @@
<ClInclude Include="..\Thunks\mfplat.hpp" />
<ClInclude Include="..\Thunks\netapi32.hpp" />
<ClInclude Include="..\Thunks\Pdh.hpp" />
<ClInclude Include="..\Thunks\powrprof.hpp" />
<ClInclude Include="..\Thunks\userenv.hpp" />
<ClInclude Include="pch.h" />
<ClInclude Include="..\Thunks\api-ms-win-core-datetime.hpp" />
@@ -200,6 +200,12 @@
<ClInclude Include="..\Thunks\netapi32.hpp">
<Filter>Thunks</Filter>
</ClInclude>
<ClInclude Include="..\Thunks\api-ms-win-power-base.hpp">
<Filter>Thunks</Filter>
</ClInclude>
<ClInclude Include="..\Thunks\powrprof.hpp">
<Filter>Thunks</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\def\x86\PSAPI2Kernel32.def">