diff --git a/DDrawCompat/Win32/Registry.cpp b/DDrawCompat/Win32/Registry.cpp index 3835f0c..a9a4e0b 100644 --- a/DDrawCompat/Win32/Registry.cpp +++ b/DDrawCompat/Win32/Registry.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -41,6 +42,7 @@ namespace template const char* g_funcName = nullptr; + Compat::CriticalSection g_openKeysCs; std::map g_openKeys; const std::map g_predefinedKeys = { @@ -121,10 +123,13 @@ namespace return it->second; } - it = g_openKeys.find(key); - if (it != g_openKeys.end()) { - return it->second; + Compat::ScopedCriticalSection lock(g_openKeysCs); + it = g_openKeys.find(key); + if (it != g_openKeys.end()) + { + return it->second; + } } enum KEY_INFORMATION_CLASS @@ -304,6 +309,7 @@ namespace const auto result = CALL_ORIG_FUNC(RegCloseKey)(hKey); if (ERROR_SUCCESS == result) { + Compat::ScopedCriticalSection lock(g_openKeysCs); g_openKeys.erase(hKey); } return LOG_RESULT(result); @@ -352,6 +358,8 @@ namespace keyName += L'\\'; keyName.append(lpSubKey, lpSubKey + getLength(lpSubKey)); } + + Compat::ScopedCriticalSection lock(g_openKeysCs); g_openKeys[*hkeyPtr] = keyName; } }