From 8e602837e81e30ec6d0c32778f12eb4e3419c4eb Mon Sep 17 00:00:00 2001 From: Skyth <19259897+blueskythlikesclouds@users.noreply.github.com> Date: Wed, 18 Dec 2024 19:21:40 +0300 Subject: [PATCH] Call timeBeginPeriod/timeEndPeriod. --- UnleashedRecomp/app.cpp | 5 +++++ UnleashedRecomp/kernel/imports.cpp | 8 +++++++- UnleashedRecomp/main.cpp | 4 ++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/UnleashedRecomp/app.cpp b/UnleashedRecomp/app.cpp index ac936fc7..fa8c0982 100644 --- a/UnleashedRecomp/app.cpp +++ b/UnleashedRecomp/app.cpp @@ -15,6 +15,11 @@ void App::Restart(std::vector restartArgs) void App::Exit() { Config::Save(); + +#ifdef _WIN32 + timeEndPeriod(1); +#endif + std::_Exit(0); } diff --git a/UnleashedRecomp/kernel/imports.cpp b/UnleashedRecomp/kernel/imports.cpp index 552bdc3d..d570d16a 100644 --- a/UnleashedRecomp/kernel/imports.cpp +++ b/UnleashedRecomp/kernel/imports.cpp @@ -546,7 +546,13 @@ uint32_t KeDelayExecutionThread(uint32_t WaitMode, bool Alertable, be* if (Alertable) return STATUS_USER_APC; - std::this_thread::sleep_for(std::chrono::milliseconds(GuestTimeoutToMilliseconds(Timeout))); + uint32_t timeout = GuestTimeoutToMilliseconds(Timeout); + +#ifdef _WIN32 + Sleep(timeout); +#else + std::this_thread::sleep_for(std::chrono::milliseconds(timeout)); +#endif return STATUS_SUCCESS; } diff --git a/UnleashedRecomp/main.cpp b/UnleashedRecomp/main.cpp index 47fae078..2387886e 100644 --- a/UnleashedRecomp/main.cpp +++ b/UnleashedRecomp/main.cpp @@ -137,6 +137,10 @@ uint32_t LdrLoadModule(const std::filesystem::path &path) int main(int argc, char *argv[]) { +#ifdef _WIN32 + timeBeginPeriod(1); +#endif + os::logger::Init(); bool forceInstaller = false;