1
0
mirror of https://github.com/valinet/ExplorerPatcher.git synced 2024-11-30 18:24:36 +01:00

Updates: Check remote hash against locally computed hash

This commit is contained in:
Valentin Radu 2022-10-02 22:49:43 +03:00
parent 50f3a709c0
commit 4cfc2cea4b

View File

@ -240,7 +240,47 @@ BOOL IsUpdateAvailableHelper(
DWORD dwLocalSecondLeft = 0;
DWORD dwLocalSecondRight = 0;
DWORD dwLocalRightMost = 0;
BOOL bExtractedFromHash = FALSE;
CHAR hashCopy[100];
strcpy_s(hashCopy, 100, szCheckAgainst);
char* szLocalLeftMost = NULL, *szLocalSecondLeft = NULL, *szLocalSecondRight = NULL, *szLocalRightMost = NULL, *szLocalRealHash = NULL;
if (strchr(hashCopy, '.'))
{
szLocalLeftMost = hashCopy;
if (szLocalSecondLeft = strchr(szLocalLeftMost, '.'))
{
*szLocalSecondLeft = 0;
szLocalSecondLeft++;
if (szLocalSecondRight = strchr(szLocalSecondLeft, '.'))
{
*szLocalSecondRight = 0;
szLocalSecondRight++;
if (szLocalRightMost = strchr(szLocalSecondRight, '.'))
{
*szLocalRightMost = 0;
szLocalRightMost++;
if (szLocalRealHash = strchr(szLocalRightMost, '.'))
{
*szLocalRealHash = 0;
szLocalRealHash++;
bExtractedFromHash = TRUE;
dwLocalLeftMost = atoi(szLocalLeftMost);
dwLocalSecondLeft = atoi(szLocalSecondLeft);
dwLocalSecondRight = atoi(szLocalSecondRight);
dwLocalRightMost = atoi(szLocalRightMost);
#ifdef UPDATES_VERBOSE_OUTPUT
printf("[Updates] Local version obtained from hash is %d.%d.%d.%d.\n", dwLocalLeftMost, dwLocalSecondLeft, dwLocalSecondRight, dwLocalRightMost);
#endif
}
}
}
}
}
if (!bExtractedFromHash)
{
QueryVersionInfo(hModule, VS_VERSION_INFO, &dwLocalLeftMost, &dwLocalSecondLeft, &dwLocalSecondRight, &dwLocalRightMost);
}
int res = 0;
if (!res)