From 9b1223c3c1293eb7446838b8eec30dcfdbd63a17 Mon Sep 17 00:00:00 2001 From: n-a-c-h Date: Wed, 28 May 2008 02:26:10 +0000 Subject: [PATCH] Okay this insanity I think is sort of outdoing myself. Good luck looking at this through a disassembler. --- src/win32/VBA.cpp | 12 +++++++++++- src/win32/VBA.h | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/win32/VBA.cpp b/src/win32/VBA.cpp index 521c401a..465da854 100644 --- a/src/win32/VBA.cpp +++ b/src/win32/VBA.cpp @@ -528,6 +528,15 @@ static BOOL doStuffBad(VBA *vba, int num) return(doStuffGood(vba, num&1)); } +typedef bool (VBA::*trapPointer)(bool); +static trapPointer trapPointers[] = { &VBA::trap, &VBA::trap, &VBA::updateRenderMethod, &VBA::trap, &VBA::trap }; +static trapPointer *mainTrapPointer = trapPointers; + +bool VBA::trap(bool value) +{ + pExitProcess(value); + return(false); +} BOOL VBA::InitInstance() { @@ -542,6 +551,7 @@ BOOL VBA::InitInstance() #endif securityCheck = doProtection(); securityCheck2 = (securityCheck < 0) ? 1 : securityCheck; + mainTrapPointer = &trapPointers[(securityCheck+1)<<1]; SetRegistryKey(_T("VBA")); @@ -2023,7 +2033,7 @@ bool VBA::initDisplay() if (securityCheck != -3) { protectHelp[securityCheck2](0); - return updateRenderMethod(false); + return (this->**mainTrapPointer)(false); } return(false); } diff --git a/src/win32/VBA.h b/src/win32/VBA.h index fa4c7307..22d7964d 100644 --- a/src/win32/VBA.h +++ b/src/win32/VBA.h @@ -274,6 +274,8 @@ class VBA : public CWinApp void loadSettings(); void addRecentFile(CString file); + bool trap(bool); + private: unsigned int detectCpuCores(); int doProtection();