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.
master
jp9000 2017-03-07 09:11:44 -08:00
parent 77ceb97f96
commit 4f64be278c
1 changed files with 26 additions and 0 deletions

View File

@ -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];