Skip to content

Commit

Permalink
Fea,添加QueryInterruptTime、QueryInterruptTimePrecise、QueryUnbiasedInter…
Browse files Browse the repository at this point in the history
…ruptTimePrecise、QueryIdleProcessorCycleTimeEx
  • Loading branch information
mingkuang-Chuyu committed May 8, 2024
1 parent 1673cf3 commit 202abd6
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ThunksList.md
Original file line number Diff line number Diff line change
Expand Up @@ -335,14 +335,18 @@
| GetQueuedCompletionStatusEx | 不存在时,调用 GetQueuedCompletionStatus。
| FindFirstFileEx(W/A) | Windows XP、Vista兼容 FIND_FIRST_EX_LARGE_FETCH、FindExInfoStandard参数。
| GetProcessGroupAffinity | 不存在时,始终认为只有一组CPU。
| QueryInterruptTime | 不存在时,读取KUSER_SHARED_DATA::InterruptTime值。
| QueryInterruptTimePrecise | 不存在时,读取KUSER_SHARED_DATA::InterruptTime值。
| QueryUnbiasedInterruptTime | 不存在时,读取KUSER_SHARED_DATA::InterruptTime值模拟UnbiasedInterruptTime。
| QueryUnbiasedInterruptTimePrecise | 不存在时,调用QueryUnbiasedInterruptTime。
| FindStringOrdinal | 不存在时,调用CompareStringOrdinal。
| GetEnabledXStateFeatures | 不存在时,调用IsProcessorFeaturePresent。
| SetXStateFeaturesMask | 不存在时,内部实现。
| InitializeContext | 不存在时,内部实现。
| InitializeContext2 | 不存在时,调用InitializeContext。
| LocateXStateFeature | 不存在时,内部实现。
| CopyContext | 不存在时,内部实现。
| QueryIdleProcessorCycleTimeEx | 不存在时,调用QueryIdleProcessorCycleTime。
| SetThreadIdealProcessorEx | 不存在时,调用SetThreadIdealProcessor。
| GetThreadIdealProcessorEx | 不存在时,调用SetThreadIdealProcessor。
| GetUserPreferredUILanguages | 不存在时,调用GetThreadPreferredUILanguages。
Expand Down
1 change: 1 addition & 0 deletions src/Thunks/YY_Thunks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
_APPLY(bluetoothapis, "bluetoothapis" , 0 ) \
_APPLY(netapi32, "netapi32" , 0 ) \
_APPLY(powrprof, "powrprof" , 0 ) \
_APPLY(api_ms_win_core_realtime_l1_1_1, "api-ms-win-core-realtime-l1-1-1" , 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 ) \
Expand Down
102 changes: 102 additions & 0 deletions src/Thunks/api-ms-win-core-realtime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,108 @@ namespace YY
return TRUE;
}
#endif


#if (YY_Thunks_Support_Version < NTDDI_WIN10)

// 最低受支持的客户端 Windows 10 [桌面应用 |UWP 应用]
// 最低受支持的服务器 Windows Server 2016[桌面应用 | UWP 应用]
__DEFINE_THUNK(
api_ms_win_core_realtime_l1_1_1,
4,
VOID,
WINAPI,
QueryUnbiasedInterruptTimePrecise,
_Out_ PULONGLONG _puUnbiasedInterruptTimePrecise
)
{
if (const auto _pfnQueryUnbiasedInterruptTimePrecise = try_get_QueryUnbiasedInterruptTimePrecise())
{
return _pfnQueryUnbiasedInterruptTimePrecise(_puUnbiasedInterruptTimePrecise);
}

// 用中断时间模拟非中断时间,凑合一下吧。
QueryInterruptTimeDownlevel(_puUnbiasedInterruptTimePrecise);
}
#endif


#if (YY_Thunks_Support_Version < NTDDI_WIN10)

// 最低受支持的客户端 Windows 10 [桌面应用 |UWP 应用]
// 最低受支持的服务器 Windows Server 2016[桌面应用 | UWP 应用]
__DEFINE_THUNK(
api_ms_win_core_realtime_l1_1_1,
4,
VOID,
WINAPI,
QueryInterruptTime,
_Out_ PULONGLONG _puInterruptTime
)
{
if (const auto _pfnQueryInterruptTime = try_get_QueryInterruptTime())
{
return _pfnQueryInterruptTime(_puInterruptTime);
}

QueryInterruptTimeDownlevel(_puInterruptTime);
}
#endif


#if (YY_Thunks_Support_Version < NTDDI_WIN10)

// 最低受支持的客户端 Windows 10 [桌面应用 |UWP 应用]
// 最低受支持的服务器 Windows Server 2016[桌面应用 | UWP 应用]
__DEFINE_THUNK(
api_ms_win_core_realtime_l1_1_1,
4,
VOID,
WINAPI,
QueryInterruptTimePrecise,
_Out_ PULONGLONG _puInterruptTimePrecise
)
{
if (const auto _pfnQueryInterruptTimePrecise = try_get_QueryInterruptTimePrecise())
{
return _pfnQueryInterruptTimePrecise(_puInterruptTimePrecise);
}

QueryInterruptTimeDownlevel(_puInterruptTimePrecise);
}
#endif


#if (YY_Thunks_Support_Version < NTDDI_WIN7)

// 最低受支持的客户端 Windows 7 [仅限桌面应用]
// 最低受支持的服务器 Windows Server 2008 R2[仅限桌面应用]
__DEFINE_THUNK(
kernel32,
12,
BOOL,
WINAPI,
QueryIdleProcessorCycleTimeEx,
_In_ USHORT _uGroup,
_Inout_ PULONG _puBufferLength,
_Out_writes_bytes_opt_(*_puBufferLength) PULONG64 _puProcessorIdleCycleTime
)
{
if (const auto _pfnQueryIdleProcessorCycleTimeEx = try_get_QueryIdleProcessorCycleTimeEx())
{
return _pfnQueryIdleProcessorCycleTimeEx(_uGroup, _puBufferLength, _puProcessorIdleCycleTime);
}

// 不支持的平台统一认为只有1组CPU可用
if (_uGroup != 0)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}

return QueryIdleProcessorCycleTime(_puBufferLength, _puProcessorIdleCycleTime);
}
#endif
}//namespace Thunks

} //namespace YY

0 comments on commit 202abd6

Please sign in to comment.