Browse Source

Updates: Check remote hash against locally computed hash

pull/1138/head
Valentin Radu 3 years ago
parent
commit
4cfc2cea4b
  1. 42
      ExplorerPatcher/updates.c

42
ExplorerPatcher/updates.c

@ -240,7 +240,47 @@ BOOL IsUpdateAvailableHelper(
DWORD dwLocalSecondLeft = 0; DWORD dwLocalSecondLeft = 0;
DWORD dwLocalSecondRight = 0; DWORD dwLocalSecondRight = 0;
DWORD dwLocalRightMost = 0; DWORD dwLocalRightMost = 0;
QueryVersionInfo(hModule, VS_VERSION_INFO, &dwLocalLeftMost, &dwLocalSecondLeft, &dwLocalSecondRight, &dwLocalRightMost); 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; int res = 0;
if (!res) if (!res)

Loading…
Cancel
Save