From aefae9d91af2d55d1982446c5ad090282fba460b Mon Sep 17 00:00:00 2001 From: n-a-c-h Date: Tue, 27 May 2008 23:13:26 +0000 Subject: [PATCH] Should compile now with MSVC (yeah, I actually broke out MSVC and did some testing, not that I could figure out how to build the whole project). git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@537 a31d4220-a93d-0410-bf67-fe4944624d44 --- src/win32/VBA.cpp | 8 ++++---- src/win32/VBA.h | 6 +++--- src/win32/protect.c | 30 +++++++++++++++--------------- src/win32/protect.h | 2 +- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/win32/VBA.cpp b/src/win32/VBA.cpp index 1c42dda3..d8165544 100644 --- a/src/win32/VBA.cpp +++ b/src/win32/VBA.cpp @@ -482,9 +482,9 @@ static int parseCommandLine(char *cmdline, char **argv) return(argc); } -static char kernel_encoded[] = { 0x14, 0xef, 0xe1, 0xe3, 0x18, 0x1c, 0xd1, 0x1f, 0xdd, 0x21, 0x25, 0x21, 0x00 }; -static char getname_encoded[] = { 0xc8, 0x33, 0x3f, 0xdc, 0xdd, 0x21, 0x2a, 0x2e, 0xd5, 0x0f, 0x08, 0x0c, 0xf7, 0x15, 0xea, 0xe9, 0x12, 0xcd, 0x00 }; -static char exit_encoded[] = { 0xca, 0xd2, 0xd5, 0xd9, 0x29, 0x27, 0x26, 0xdb, 0x20, 0x2d, 0x20, 0x00 }; +static unsigned char kernel_encoded[] = { 0x14, 0xef, 0xe1, 0xe3, 0x18, 0x1c, 0xd1, 0x1f, 0xdd, 0x21, 0x25, 0x21, 0x00 }; +static unsigned char getname_encoded[] = { 0xc8, 0x33, 0x3f, 0xdc, 0xdd, 0x21, 0x2a, 0x2e, 0xd5, 0x0f, 0x08, 0x0c, 0xf7, 0x15, 0xea, 0xe9, 0x12, 0xcd, 0x00 }; +static unsigned char exit_encoded[] = { 0xca, 0xd2, 0xd5, 0xd9, 0x29, 0x27, 0x26, 0xdb, 0x20, 0x2d, 0x20, 0x00 }; static lpExitProcess protectHelp[2] = { (lpExitProcess)srand, (lpExitProcess)0 }; int VBA::doProtection() @@ -511,7 +511,7 @@ int VBA::doProtection() static BOOL doStuffGood(VBA *vba, int num) { - protectHelp[vba->securityCheck2](time(0)); + protectHelp[vba->securityCheck2]((UINT)time(0)); num ^= 1; return((BOOL)num); } diff --git a/src/win32/VBA.h b/src/win32/VBA.h index c4b40bc8..fa4c7307 100644 --- a/src/win32/VBA.h +++ b/src/win32/VBA.h @@ -68,6 +68,9 @@ enum pixelFilterType class AVIWrite; class WavWriter; +typedef DWORD (WINAPI* lpGetModuleFileNameA)(HINSTANCE, LPSTR, DWORD); +typedef VOID (WINAPI* lpExitProcess)(UINT); + class VBA : public CWinApp { public: @@ -220,9 +223,6 @@ class VBA : public CWinApp CString wndClass; - typedef DWORD (WINAPI* lpGetModuleFileNameA)(HINSTANCE, LPSTR, DWORD); - typedef VOID (WINAPI* lpExitProcess)(UINT); - lpGetModuleFileNameA pGetModuleFileNameA; lpExitProcess pExitProcess; diff --git a/src/win32/protect.c b/src/win32/protect.c index 696d4883..165a575c 100644 --- a/src/win32/protect.c +++ b/src/win32/protect.c @@ -6,6 +6,21 @@ #include #include "protect.h" +char *unprotect_buffer(unsigned char *buffer, size_t buffer_len) +{ + unsigned char *p = buffer, *end_p = p+buffer_len-1, previous = 0x11; + while (p < end_p) + { + unsigned char current = *p; + *p ^= previous; + previous = current; + *p -= 25; + *p ^= 0x87; + ++p; + } + return((char *)buffer); +} + #ifdef _DEBUG //For building debug builds, no security ever @@ -16,21 +31,6 @@ int ExecutableValid(const char *executable_filename) #else -char *unprotect_buffer(char *buffer, size_t buffer_len) -{ - char *p = buffer, *end_p = p+buffer_len-1, previous = 0x11; - while (p < end_p) - { - char current = *p; - *p ^= previous; - previous = current; - *p -= 25; - *p ^= 0x87; - ++p; - } - return(buffer); -} - static uint8_t *memmem(const uint8_t *haystack, size_t haystacklen, const uint8_t *needle, size_t needlelen) { if (needlelen) diff --git a/src/win32/protect.h b/src/win32/protect.h index 2393cbae..3cd156ec 100644 --- a/src/win32/protect.h +++ b/src/win32/protect.h @@ -8,7 +8,7 @@ extern "C" { //Returns 0 on success, 1 on failure, and <0 when an error occured //Note, can only be called once per execution int ExecutableValid(const char *executable_filename); -char *unprotect_buffer(char *buffer, size_t buffer_len); +char *unprotect_buffer(unsigned char *buffer, size_t buffer_len); #if defined(__cplusplus) }