浏览代码

UI/updater: Ignore 64bit files on 32bit windows

This would cause people to download the 64bit files when they were on
the 32bit version of windows, even though those files aren't meant to be
installed.
jp9000 8 年之前
父节点
当前提交
4f64be278c
共有 1 个文件被更改,包括 26 次插入0 次删除
  1. 26 0
      UI/win-update/updater/updater.cpp

+ 26 - 0
UI/win-update/updater/updater.cpp

@@ -580,6 +580,27 @@ static bool NonCorePackageInstalled(const char *name)
 	return false;
 }
 
+static inline bool is_64bit_windows(void)
+{
+#ifdef _WIN64
+	return true;
+#else
+	BOOL x86 = false;
+	bool success = !!IsWow64Process(GetCurrentProcess(), &x86);
+	return success && !!x86;
+#endif
+}
+
+static inline bool is_64bit_file(const char *file)
+{
+	if (!file)
+		return false;
+
+	return strstr(file, "64bit") != nullptr ||
+	       strstr(file, "64.dll") != nullptr ||
+	       strstr(file, "64.exe") != nullptr;
+}
+
 #define UTF8ToWideBuf(wide, utf8) UTF8ToWide(wide, _countof(wide), utf8)
 #define WideToUTF8Buf(utf8, wide) WideToUTF8(utf8, _countof(utf8), wide)
 
@@ -592,6 +613,8 @@ static bool AddPackageUpdateFiles(json_t *root, size_t idx,
 	json_t *name    = json_object_get(package, "name");
 	json_t *files   = json_object_get(package, "files");
 
+	bool isWin64 = is_64bit_windows();
+
 	if (!json_is_array(files))
 		return true;
 	if (!json_is_string(name))
@@ -628,6 +651,9 @@ static bool AddPackageUpdateFiles(json_t *root, size_t idx,
 		if (strlen(hashUTF8) != BLAKE2_HASH_LENGTH * 2)
 			continue;
 
+		if (!isWin64 && is_64bit_file(fileUTF8))
+			continue;
+
 		/* convert strings to wide */
 
 		wchar_t sourceURL[1024];