mdbx-windows: using RegGetValueA() instead of wchar_t version.

Change-Id: I0848eaf2083985ae27fec605358329830b0733c2
This commit is contained in:
Leo Yuriev 2020-02-19 16:00:40 +03:00
parent f750086bc1
commit 9aa816dc73

View File

@ -1795,20 +1795,20 @@ static uint64_t windows_bootime(void) {
return 0; return 0;
} }
static LSTATUS mdbx_RegGetValue(HKEY hkey, LPCWSTR lpSubKey, LPCWSTR lpValue, static LSTATUS mdbx_RegGetValue(HKEY hkey, LPCSTR lpSubKey, LPCSTR lpValue,
DWORD dwFlags, LPDWORD pdwType, PVOID pvData, DWORD dwFlags, LPDWORD pdwType, PVOID pvData,
LPDWORD pcbData) { LPDWORD pcbData) {
LSTATUS rc = LSTATUS rc =
RegGetValueW(hkey, lpSubKey, lpValue, dwFlags, pdwType, pvData, pcbData); RegGetValueA(hkey, lpSubKey, lpValue, dwFlags, pdwType, pvData, pcbData);
if (rc != ERROR_FILE_NOT_FOUND) if (rc != ERROR_FILE_NOT_FOUND)
return rc; return rc;
rc = RegGetValueW(hkey, lpSubKey, lpValue, rc = RegGetValueA(hkey, lpSubKey, lpValue,
dwFlags | 0x00010000 /* RRF_SUBKEY_WOW6464KEY */, pdwType, dwFlags | 0x00010000 /* RRF_SUBKEY_WOW6464KEY */, pdwType,
pvData, pcbData); pvData, pcbData);
if (rc != ERROR_FILE_NOT_FOUND) if (rc != ERROR_FILE_NOT_FOUND)
return rc; return rc;
return RegGetValueW(hkey, lpSubKey, lpValue, return RegGetValueA(hkey, lpSubKey, lpValue,
dwFlags | 0x00020000 /* RRF_SUBKEY_WOW6432KEY */, pdwType, dwFlags | 0x00020000 /* RRF_SUBKEY_WOW6432KEY */, pdwType,
pvData, pcbData); pvData, pcbData);
} }
@ -1921,30 +1921,30 @@ __cold MDBX_INTERNAL_FUNC bin128_t mdbx_osal_bootid(void) {
char DigitalProductId[248]; char DigitalProductId[248];
} buf; } buf;
static const wchar_t HKLM_MicrosoftCryptography[] = static const char HKLM_MicrosoftCryptography[] =
L"SOFTWARE\\Microsoft\\Cryptography"; "SOFTWARE\\Microsoft\\Cryptography";
DWORD len = sizeof(buf); DWORD len = sizeof(buf);
/* Windows is madness and must die */ /* Windows is madness and must die */
if (mdbx_RegGetValue(HKEY_LOCAL_MACHINE, HKLM_MicrosoftCryptography, if (mdbx_RegGetValue(HKEY_LOCAL_MACHINE, HKLM_MicrosoftCryptography,
L"MachineGuid", RRF_RT_ANY, NULL, &buf.MachineGuid, "MachineGuid", RRF_RT_ANY, NULL, &buf.MachineGuid,
&len) == ERROR_SUCCESS && &len) == ERROR_SUCCESS &&
len > 42 && len < sizeof(buf)) len > 42 && len < sizeof(buf))
got_machineid = bootid_parse_uuid(&bin, &buf.MachineGuid, len); got_machineid = bootid_parse_uuid(&bin, &buf.MachineGuid, len);
if (!got_machineid) { if (!got_machineid) {
/* again, Windows is madness */ /* again, Windows is madness */
static const wchar_t HKLM_WindowsNT[] = static const char HKLM_WindowsNT[] =
L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"; "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion";
static const wchar_t HKLM_WindowsNT_DPK[] = static const char HKLM_WindowsNT_DPK[] =
L"SOFTWARE\\Microsoft\\Windows " "SOFTWARE\\Microsoft\\Windows "
L"NT\\CurrentVersion\\DefaultProductKey"; "NT\\CurrentVersion\\DefaultProductKey";
static const wchar_t HKLM_WindowsNT_DPK2[] = static const char HKLM_WindowsNT_DPK2[] =
L"SOFTWARE\\Microsoft\\Windows " "SOFTWARE\\Microsoft\\Windows "
L"NT\\CurrentVersion\\DefaultProductKey2"; "NT\\CurrentVersion\\DefaultProductKey2";
len = sizeof(buf); len = sizeof(buf);
if (mdbx_RegGetValue(HKEY_LOCAL_MACHINE, HKLM_WindowsNT, if (mdbx_RegGetValue(HKEY_LOCAL_MACHINE, HKLM_WindowsNT,
L"DigitalProductId", RRF_RT_ANY, NULL, "DigitalProductId", RRF_RT_ANY, NULL,
&buf.DigitalProductId, &len) == ERROR_SUCCESS && &buf.DigitalProductId, &len) == ERROR_SUCCESS &&
len > 42 && len < sizeof(buf)) { len > 42 && len < sizeof(buf)) {
bootid_collect(&bin, &buf.DigitalProductId, len); bootid_collect(&bin, &buf.DigitalProductId, len);
@ -1952,7 +1952,7 @@ __cold MDBX_INTERNAL_FUNC bin128_t mdbx_osal_bootid(void) {
} }
len = sizeof(buf); len = sizeof(buf);
if (mdbx_RegGetValue(HKEY_LOCAL_MACHINE, HKLM_WindowsNT_DPK, if (mdbx_RegGetValue(HKEY_LOCAL_MACHINE, HKLM_WindowsNT_DPK,
L"DigitalProductId", RRF_RT_ANY, NULL, "DigitalProductId", RRF_RT_ANY, NULL,
&buf.DigitalProductId, &len) == ERROR_SUCCESS && &buf.DigitalProductId, &len) == ERROR_SUCCESS &&
len > 42 && len < sizeof(buf)) { len > 42 && len < sizeof(buf)) {
bootid_collect(&bin, &buf.DigitalProductId, len); bootid_collect(&bin, &buf.DigitalProductId, len);
@ -1960,7 +1960,7 @@ __cold MDBX_INTERNAL_FUNC bin128_t mdbx_osal_bootid(void) {
} }
len = sizeof(buf); len = sizeof(buf);
if (mdbx_RegGetValue(HKEY_LOCAL_MACHINE, HKLM_WindowsNT_DPK2, if (mdbx_RegGetValue(HKEY_LOCAL_MACHINE, HKLM_WindowsNT_DPK2,
L"DigitalProductId", RRF_RT_ANY, NULL, "DigitalProductId", RRF_RT_ANY, NULL,
&buf.DigitalProductId, &len) == ERROR_SUCCESS && &buf.DigitalProductId, &len) == ERROR_SUCCESS &&
len > 42 && len < sizeof(buf)) { len > 42 && len < sizeof(buf)) {
bootid_collect(&bin, &buf.DigitalProductId, len); bootid_collect(&bin, &buf.DigitalProductId, len);
@ -1968,11 +1968,11 @@ __cold MDBX_INTERNAL_FUNC bin128_t mdbx_osal_bootid(void) {
} }
} }
static const wchar_t HKLM_PrefetcherParams[] = static const char HKLM_PrefetcherParams[] =
L"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Memory " "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Memory "
L"Management\\PrefetchParameters"; "Management\\PrefetchParameters";
len = sizeof(buf); len = sizeof(buf);
if (mdbx_RegGetValue(HKEY_LOCAL_MACHINE, HKLM_PrefetcherParams, L"BootId", if (mdbx_RegGetValue(HKEY_LOCAL_MACHINE, HKLM_PrefetcherParams, "BootId",
RRF_RT_DWORD, NULL, &buf.BootId, RRF_RT_DWORD, NULL, &buf.BootId,
&len) == ERROR_SUCCESS && &len) == ERROR_SUCCESS &&
len > 1 && len < sizeof(buf)) { len > 1 && len < sizeof(buf)) {
@ -1981,7 +1981,7 @@ __cold MDBX_INTERNAL_FUNC bin128_t mdbx_osal_bootid(void) {
} }
len = sizeof(buf); len = sizeof(buf);
if (mdbx_RegGetValue(HKEY_LOCAL_MACHINE, HKLM_PrefetcherParams, L"BaseTime", if (mdbx_RegGetValue(HKEY_LOCAL_MACHINE, HKLM_PrefetcherParams, "BaseTime",
RRF_RT_DWORD, NULL, &buf.BaseTime, RRF_RT_DWORD, NULL, &buf.BaseTime,
&len) == ERROR_SUCCESS && &len) == ERROR_SUCCESS &&
len >= sizeof(buf.BaseTime) && buf.BaseTime) { len >= sizeof(buf.BaseTime) && buf.BaseTime) {