static bool get_32bit_system_dll_ver(const wchar_t *system_lib,
		struct win_version_info *ver)
{
	wchar_t path[MAX_PATH];
	UINT ret;

#ifdef _WIN64
	ret = GetSystemWow64DirectoryW(path, MAX_PATH);
#else
	ret = GetSystemDirectoryW(path, MAX_PATH);
#endif
	if (!ret) {
		blog(LOG_ERROR, "Failed to get windows 32bit system path: "
		                "%lu", GetLastError());
		return false;
	}

	wcscat(path, L"\\");
	wcscat(path, system_lib);
	return get_dll_ver(path, ver);
}
Пример #2
0
void get_win_ver(struct win_version_info *info)
{
	static struct win_version_info ver = {0};
	static bool got_version = false;

	if (!info)
		return;

	if (!got_version) {
		get_dll_ver(L"kernel32", &ver);
		got_version = true;

		if (ver.major == 10) {
			HKEY    key;
			DWORD   size, win10_revision;
			LSTATUS status;

			status = RegOpenKeyW(HKEY_LOCAL_MACHINE,
					WINVER_REG_KEY, &key);
			if (status != ERROR_SUCCESS)
				return;

			size = sizeof(win10_revision);

			status = RegQueryValueExW(key, L"UBR", NULL, NULL,
					(LPBYTE)&win10_revision, &size);
			if (status == ERROR_SUCCESS)
				ver.revis = (int)win10_revision > ver.revis ?
						(int)win10_revision : ver.revis;

			RegCloseKey(key);
		}
	}

	*info = ver;
}