diff --git a/DDrawCompat/DDrawCompat.vcxproj b/DDrawCompat/DDrawCompat.vcxproj
index 3f4a12d..660aad5 100644
--- a/DDrawCompat/DDrawCompat.vcxproj
+++ b/DDrawCompat/DDrawCompat.vcxproj
@@ -293,6 +293,7 @@
+
@@ -405,6 +406,7 @@
+
diff --git a/DDrawCompat/DDrawCompat.vcxproj.filters b/DDrawCompat/DDrawCompat.vcxproj.filters
index d8495ac..de71362 100644
--- a/DDrawCompat/DDrawCompat.vcxproj.filters
+++ b/DDrawCompat/DDrawCompat.vcxproj.filters
@@ -585,6 +585,9 @@
Header Files\Config\Settings
+
+ Header Files\Win32
+
@@ -917,6 +920,9 @@
Source Files\Config\Settings
+
+ Source Files\Win32
+
diff --git a/DDrawCompat/Dll/DllMain.cpp b/DDrawCompat/Dll/DllMain.cpp
index 17b6aa9..39617bb 100644
--- a/DDrawCompat/Dll/DllMain.cpp
+++ b/DDrawCompat/Dll/DllMain.cpp
@@ -26,6 +26,7 @@
#include
#include
#include
+#include
HRESULT WINAPI SetAppCompatData(DWORD, DWORD);
@@ -289,9 +290,10 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
Win32::MemoryManagement::installHooks();
Win32::Thread::installHooks();
Win32::Version::installHooks();
+ Win32::Winmm::installHooks();
Compat::closeDbgEng();
- timeBeginPeriod(1);
+ CALL_ORIG_FUNC(timeBeginPeriod)(1);
setDpiAwareness();
SetThemeAppProperties(0);
Time::init();
diff --git a/DDrawCompat/Win32/Winmm.cpp b/DDrawCompat/Win32/Winmm.cpp
new file mode 100644
index 0000000..4f61898
--- /dev/null
+++ b/DDrawCompat/Win32/Winmm.cpp
@@ -0,0 +1,41 @@
+#include
+#include
+
+#include
+#include
+#include
+
+namespace
+{
+ MMRESULT WINAPI TimeBeginPeriod(UINT uPeriod)
+ {
+ LOG_FUNC("timeBeginPeriod", uPeriod);
+ return LOG_RESULT(TIMERR_NOERROR);
+ }
+
+ MMRESULT WINAPI TimeEndPeriod(UINT uPeriod)
+ {
+ LOG_FUNC("timeEndPeriod", uPeriod);
+ return LOG_RESULT(TIMERR_NOERROR);
+ }
+}
+
+namespace Win32
+{
+ namespace Winmm
+ {
+ void installHooks()
+ {
+ if (Compat::getProcAddress(GetModuleHandle("kernel32"), "timeBeginPeriod"))
+ {
+ HOOK_FUNCTION(kernel32, timeBeginPeriod, TimeBeginPeriod);
+ HOOK_FUNCTION(kernel32, timeEndPeriod, TimeEndPeriod);
+ }
+ else
+ {
+ HOOK_FUNCTION(winmm, timeBeginPeriod, TimeBeginPeriod);
+ HOOK_FUNCTION(winmm, timeEndPeriod, TimeEndPeriod);
+ }
+ }
+ }
+}
diff --git a/DDrawCompat/Win32/Winmm.h b/DDrawCompat/Win32/Winmm.h
new file mode 100644
index 0000000..d24d4bb
--- /dev/null
+++ b/DDrawCompat/Win32/Winmm.h
@@ -0,0 +1,9 @@
+#pragma once
+
+namespace Win32
+{
+ namespace Winmm
+ {
+ void installHooks();
+ }
+}