From b65f624d58d867d9fe7ac10fd325924856588064 Mon Sep 17 00:00:00 2001 From: n-a-c-h Date: Tue, 20 May 2008 12:38:15 +0000 Subject: [PATCH] Fixed bug in defines, and tighten stuff up with an adler! --- src/win32/protect.c | 9 ++++++++- src/win32/protect.h | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/win32/protect.c b/src/win32/protect.c index 900daf18..0e4ba268 100644 --- a/src/win32/protect.c +++ b/src/win32/protect.c @@ -83,9 +83,16 @@ int ExecutableValid(const char *executable_filename) crc3 = crc32(crc3, (const Bytef *)p+sizeof(data), file_size-(length_till_data+sizeof(data))); crc4 = crc32(crc4, (const Bytef *)(data+1), sizeof(data)-sizeof(uint32_t)); + crc1 = crc32_combine(crc1, crc3, file_size-(length_till_data+sizeof(data))); + crc2 = crc32_combine(crc2, crc3, file_size-(length_till_data+sizeof(data))); + + crc3 = adler32(0L, Z_NULL, 0); + crc3 = adler32(crc3, (const Bytef *)buffer, length_till_data); + crc3 = adler32(crc3, (const Bytef *)p+sizeof(data), file_size-(length_till_data+sizeof(data))); + if ((data[sizeof(data)/sizeof(uint32_t)-4] == crc1) && (data[sizeof(data)/sizeof(uint32_t)-3] == crc3) && - (data[sizeof(data)/sizeof(uint32_t)-2] == crc32_combine(crc2, crc3, file_size-(length_till_data+sizeof(data)))) && + (data[sizeof(data)/sizeof(uint32_t)-2] == crc2) && (data[sizeof(data)/sizeof(uint32_t)-1] == crc4) && (file_size == data[2]) && (data[3] == ((uint32_t *)(buffer+file_size))[-2]) && diff --git a/src/win32/protect.h b/src/win32/protect.h index 3344b047..0b895d73 100644 --- a/src/win32/protect.h +++ b/src/win32/protect.h @@ -1,4 +1,4 @@ -#ifdef ___PROTECT_H_ +#ifndef ___PROTECT_H_ #define ___PROTECT_H_ #if defined(__cplusplus)