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:
parent
97197dde6a
commit
15d78048d0
@ -7,6 +7,19 @@
|
|||||||
|
|
||||||
namespace
|
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)
|
MMRESULT WINAPI TimeBeginPeriod(UINT uPeriod)
|
||||||
{
|
{
|
||||||
LOG_FUNC("timeBeginPeriod", uPeriod);
|
LOG_FUNC("timeBeginPeriod", uPeriod);
|
||||||
@ -26,6 +39,8 @@ namespace Win32
|
|||||||
{
|
{
|
||||||
void installHooks()
|
void installHooks()
|
||||||
{
|
{
|
||||||
|
disableTimerResolutionThrottling();
|
||||||
|
|
||||||
if (Compat::getProcAddress(GetModuleHandle("kernel32"), "timeBeginPeriod"))
|
if (Compat::getProcAddress(GetModuleHandle("kernel32"), "timeBeginPeriod"))
|
||||||
{
|
{
|
||||||
HOOK_FUNCTION(kernel32, timeBeginPeriod, TimeBeginPeriod);
|
HOOK_FUNCTION(kernel32, timeBeginPeriod, TimeBeginPeriod);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user