From 596778f3f2c8f8bab875650c5aa9662614ec7ec3 Mon Sep 17 00:00:00 2001 From: n-a-c-h Date: Tue, 20 May 2008 03:39:14 +0000 Subject: [PATCH] Better protection. git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@518 a31d4220-a93d-0410-bf67-fe4944624d44 --- src/win32/protect.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/win32/protect.c b/src/win32/protect.c index 18a412bf..900daf18 100644 --- a/src/win32/protect.c +++ b/src/win32/protect.c @@ -81,14 +81,12 @@ int ExecutableValid(const char *executable_filename) crc1 = crc32(crc1, (const Bytef *)buffer, length_till_data); crc2 = crc32(crc1, (const Bytef *)data, sizeof(data)); 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)); - data[sizeof(data)/sizeof(uint32_t)-1] += sizeof(data); //Seriously "what the heck", right? ;-) - crc4 = crc32(crc4, (const Bytef *)(data+2), sizeof(data)-sizeof(uint32_t)*2); - - if ((crc1 == data[sizeof(data)/sizeof(uint32_t)-4]) && - (crc3 == data[sizeof(data)/sizeof(uint32_t)-3]) && - (crc4 == data[1]) && - (crc32_combine(crc2, crc3, file_size-(length_till_data+sizeof(data))) == data[sizeof(data)/sizeof(uint32_t)-2]) && + 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)-1] == crc4) && (file_size == data[2]) && (data[3] == ((uint32_t *)(buffer+file_size))[-2]) && (data[4] == ((uint32_t *)(buffer+file_size))[-1]))