summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-12-11 19:13:21 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-12-11 19:13:21 +0300
commit06038dc1d0e03adb40777d13656e82efe9045e84 (patch)
tree0a1d4be26a075a7f5606b1d83c743acb2ef2deea
parentc1f5051afa6c3da16231e2af5b8e52d2c0de0090 (diff)
libmdbx: XP compatibility fix
-rw-r--r--libs/libmdbx/src/src/elements/osal.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/libs/libmdbx/src/src/elements/osal.c b/libs/libmdbx/src/src/elements/osal.c
index a4fec8e4df..33fead5005 100644
--- a/libs/libmdbx/src/src/elements/osal.c
+++ b/libs/libmdbx/src/src/elements/osal.c
@@ -1747,20 +1747,49 @@ static uint64_t windows_bootime(void) {
return 0;
}
+typedef LSTATUS (APIENTRY *pfnRegGetValueW)(HKEY, LPCWSTR, LPCWSTR, DWORD, LPDWORD, PVOID, LPDWORD);
+static pfnRegGetValueW fnRegGetValueW = nullptr;
+
+static LSTATUS APIENTRY stubRegGetValueW(
+ HKEY hkey,
+ LPCWSTR lpSubKey,
+ LPCWSTR lpValue,
+ DWORD dwFlags,
+ LPDWORD pdwType,
+ PVOID pvData,
+ LPDWORD pcbData)
+{
+ HKEY tmp;
+ LSTATUS rc = RegOpenKeyW(hkey, lpSubKey, &tmp);
+ if (rc != 0)
+ return rc;
+
+ DWORD dwType = (dwFlags == RRF_RT_ANY) ? REG_SZ : REG_DWORD;
+ rc = RegQueryValueExW(tmp, lpValue, 0, &dwType, pvData, pcbData);
+ RegCloseKey(tmp);
+ return rc;
+}
+
static LSTATUS mdbx_RegGetValue(HKEY hkey, LPCWSTR lpSubKey, LPCWSTR lpValue,
DWORD dwFlags, LPDWORD pdwType, PVOID pvData,
LPDWORD pcbData) {
+ if (fnRegGetValueW == nullptr) {
+ fnRegGetValueW = (pfnRegGetValueW)GetProcAddress(GetModuleHandleA("advapi32.dll"), "RegGetValueW");
+ if (fnRegGetValueW == nullptr)
+ fnRegGetValueW = stubRegGetValueW;
+ }
+
LSTATUS rc =
- RegGetValueW(hkey, lpSubKey, lpValue, dwFlags, pdwType, pvData, pcbData);
+ fnRegGetValueW(hkey, lpSubKey, lpValue, dwFlags, pdwType, pvData, pcbData);
if (rc != ERROR_FILE_NOT_FOUND)
return rc;
- rc = RegGetValueW(hkey, lpSubKey, lpValue,
+ rc = fnRegGetValueW(hkey, lpSubKey, lpValue,
dwFlags | 0x00010000 /* RRF_SUBKEY_WOW6464KEY */, pdwType,
pvData, pcbData);
if (rc != ERROR_FILE_NOT_FOUND)
return rc;
- return RegGetValueW(hkey, lpSubKey, lpValue,
+ return fnRegGetValueW(hkey, lpSubKey, lpValue,
dwFlags | 0x00020000 /* RRF_SUBKEY_WOW6432KEY */, pdwType,
pvData, pcbData);
}