1
0
mirror of https://github.com/narzoul/DDrawCompat synced 2024-12-30 08:55:36 +01:00

Disable timer resolution throttling

This commit is contained in:
narzoul 2022-12-13 13:31:22 +01:00
parent 97197dde6a
commit 15d78048d0

View File

@ -7,6 +7,19 @@
namespace
{
void disableTimerResolutionThrottling()
{
auto setProcessInformation = reinterpret_cast<decltype(&SetProcessInformation)>(
Compat::getProcAddress(GetModuleHandle("kernel32"), "SetProcessInformation"));
if (setProcessInformation)
{
PROCESS_POWER_THROTTLING_STATE ppts = {};
ppts.Version = PROCESS_POWER_THROTTLING_CURRENT_VERSION;
ppts.ControlMask = 4; // PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION
setProcessInformation(GetCurrentProcess(), ProcessPowerThrottling, &ppts, sizeof(ppts));
}
}
MMRESULT WINAPI TimeBeginPeriod(UINT uPeriod)
{
LOG_FUNC("timeBeginPeriod", uPeriod);
@ -26,6 +39,8 @@ namespace Win32
{
void installHooks()
{
disableTimerResolutionThrottling();
if (Compat::getProcAddress(GetModuleHandle("kernel32"), "timeBeginPeriod"))
{
HOOK_FUNCTION(kernel32, timeBeginPeriod, TimeBeginPeriod);