sourcehook/test/testhookmangen.cpp
branchhookman_autogen
changeset 531 0180319136ba
parent 479 b43ebc944319
child 532 9729de2d7551
     1.1 --- a/sourcehook/test/testhookmangen.cpp	Sun Nov 25 01:22:41 2007 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,1229 +0,0 @@
     1.4 -#include <string>
     1.5 -#include "sourcehook.h"
     1.6 -#include "sourcehook_test.h"
     1.7 -#include "testevents.h"
     1.8 -#include "sh_memory.h"
     1.9 -#include "sh_pagealloc.h"
    1.10 -#include "sourcehook_pibuilder.h"
    1.11 -
    1.12 -// TESTHOOKMANGEN
    1.13 -// Test automatic hookman generation
    1.14 -//  Tests void and non-void functions
    1.15 -//  0 to 6 params:
    1.16 -//   integer-type, float-type, plain-old-data struct and objects with ctors/dtors
    1.17 -//   both byval and byref
    1.18 -//  also tests ignore/supercede
    1.19 -//  also tests recalls
    1.20 -
    1.21 -// :TODO: test override as well
    1.22 -
    1.23 -namespace
    1.24 -{
    1.25 -	StateList g_States;
    1.26 -	SourceHook::ISourceHook *g_SHPtr;
    1.27 -	SourceHook::Plugin g_PLID;
    1.28 -
    1.29 -	SourceHook::IHookManagerAutoGen *g_HMAGPtr;
    1.30 -
    1.31 -	// PtrBuf(ptr) gives ptrs unique numbers
    1.32 -	// in the order they appear
    1.33 -	SourceHook::List<const void*> g_PtrHash;
    1.34 -
    1.35 -	bool g_Inside_LeafFunc = false;			// inside a hook or a func
    1.36 -	bool g_Silent_CtorDtor = false;			// inside a hook or a func
    1.37 -
    1.38 -
    1.39 -	// POD / Object types
    1.40 -	template <int MYSIZE>
    1.41 -	struct POD
    1.42 -	{
    1.43 -		char x[MYSIZE];
    1.44 -
    1.45 -		bool operator==(const POD<MYSIZE> &other)
    1.46 -		{
    1.47 -			return memcmp(reinterpret_cast<void*>(x), reinterpret_cast<const void*>(other.x), MYSIZE) == 0;
    1.48 -		}
    1.49 -
    1.50 -		bool operator==(char other)
    1.51 -		{
    1.52 -			for (int i = 0; i < MYSIZE; ++i)
    1.53 -			{
    1.54 -				if (x[i] != other)
    1.55 -					return false;
    1.56 -			}
    1.57 -			return true;
    1.58 -		}
    1.59 -	};
    1.60 -
    1.61 -	template <int MYSIZE>
    1.62 -		std::ostream& operator <<(std::ostream &os, const POD<MYSIZE> &obj)
    1.63 -	{
    1.64 -		os << "Some POD!";
    1.65 -		return os;
    1.66 -	}
    1.67 -
    1.68 -	MAKE_STATE_1(State_ObjOCtor_Called, int /*MYSIZE*/);
    1.69 -	MAKE_STATE_1(State_ObjCCtor_Called, int /*MYSIZE*/);
    1.70 -	MAKE_STATE_1(State_ObjODtor_Called, int /*MYSIZE*/);
    1.71 -	MAKE_STATE_1(State_ObjAssignOp_Called, int /*MYSIZE*/);
    1.72 -
    1.73 -	template <int MYSIZE>
    1.74 -	struct Object
    1.75 -	{
    1.76 -		char x[MYSIZE];
    1.77 -
    1.78 -		Object(char initch)
    1.79 -		{
    1.80 -			memset(reinterpret_cast<void*>(x), initch, MYSIZE);
    1.81 -			if (!g_Inside_LeafFunc && !g_Silent_CtorDtor)
    1.82 -				ADD_STATE(State_ObjOCtor_Called(MYSIZE));
    1.83 -		}
    1.84 -
    1.85 -		Object()
    1.86 -		{
    1.87 -			if (!g_Inside_LeafFunc && !g_Silent_CtorDtor)
    1.88 -				ADD_STATE(State_ObjOCtor_Called(MYSIZE));
    1.89 -		}
    1.90 -
    1.91 -		Object(const Object<MYSIZE> & other)
    1.92 -		{
    1.93 -			memcpy(reinterpret_cast<void*>(x), reinterpret_cast<const void*>(other.x), MYSIZE);
    1.94 -			if (!g_Inside_LeafFunc && !g_Silent_CtorDtor)
    1.95 -				ADD_STATE(State_ObjCCtor_Called(MYSIZE));
    1.96 -		}
    1.97 -
    1.98 -		~Object()
    1.99 -		{
   1.100 -			if (!g_Inside_LeafFunc && !g_Silent_CtorDtor)
   1.101 -				ADD_STATE(State_ObjODtor_Called(MYSIZE));
   1.102 -		}
   1.103 -
   1.104 -		Object & operator = (const Object &other)
   1.105 -		{
   1.106 -			if (!g_Inside_LeafFunc && !g_Silent_CtorDtor)
   1.107 -				ADD_STATE(State_ObjAssignOp_Called(MYSIZE));
   1.108 -
   1.109 -			memcpy(reinterpret_cast<void*>(x), reinterpret_cast<const void*>(other.x), MYSIZE);
   1.110 -
   1.111 -			return *this;
   1.112 -		}
   1.113 -
   1.114 -		bool operator==(const Object<MYSIZE> &other)
   1.115 -		{
   1.116 -			return memcmp(reinterpret_cast<void*>(x), reinterpret_cast<const void*>(other.x), MYSIZE) == 0;
   1.117 -		}
   1.118 -	};
   1.119 -
   1.120 -	template <int MYSIZE>
   1.121 -	std::ostream& operator <<(std::ostream &os, const Object<MYSIZE> &obj)
   1.122 -	{
   1.123 -		os << "Some Obj" << static_cast<int>(obj.x[0]);
   1.124 -		return os;
   1.125 -	}
   1.126 -
   1.127 -	// Because of some weird bug in MSVC < 1400
   1.128 -#define MAKE_PODRET(size) \
   1.129 -	struct PodRet##size \
   1.130 -	{ \
   1.131 -		POD<size> actPod; \
   1.132 -		bool operator==(const PodRet##size &other) { return actPod == other.actPod; } \
   1.133 -		bool operator==(char other) { return actPod == other; } \
   1.134 -	}; \
   1.135 -	std::ostream& operator <<(std::ostream &os, const PodRet##size &obj) \
   1.136 -	{ \
   1.137 -		os << obj.actPod; \
   1.138 -		return os; \
   1.139 -	} \
   1.140 -	template <> struct MakeRet< PodRet##size > \
   1.141 -	{ \
   1.142 -		static PodRet##size Do(int a) \
   1.143 -		{ \
   1.144 -			PodRet##size x; \
   1.145 -			memset(reinterpret_cast<void*>(x.actPod.x), a, size); \
   1.146 -			return x; \
   1.147 -		} \
   1.148 -	};
   1.149 -
   1.150 -#define MAKE_OBJRET(size) \
   1.151 -	struct ObjRet##size \
   1.152 -	{ \
   1.153 -		Object<size> actObj; \
   1.154 -		bool operator==(const ObjRet##size &other) { return actObj == other.actObj; } \
   1.155 -		bool operator==(char other) { return actObj == other; } \
   1.156 -	}; \
   1.157 -	std::ostream& operator <<(std::ostream &os, const ObjRet##size &obj) \
   1.158 -	{ \
   1.159 -		os << obj.actObj; \
   1.160 -		return os; \
   1.161 -	} \
   1.162 -	template <> struct MakeRet< ObjRet##size > \
   1.163 -	{ \
   1.164 -		static ObjRet##size Do(int a) NO_OPTIMIZE \
   1.165 -		{ \
   1.166 -			ObjRet##size *x = new ObjRet##size; /* ptr: otherwise gcc optimizes away the temp obj */ \
   1.167 -			CAutoPtrDestruction< ObjRet##size > apd(x); \
   1.168 -			memset(reinterpret_cast<void*>(x->actObj.x), a, size); \
   1.169 -			return *x; \
   1.170 -		} \
   1.171 -	};
   1.172 -
   1.173 -
   1.174 -
   1.175 -	// "Increment" something:  (reproducible change for recall tests)
   1.176 -	//  integer: ++
   1.177 -	//  float: += 1.3
   1.178 -	//  pod/object: x[i]++, 0 <= i < MYSIZE
   1.179 -	template <class T>
   1.180 -	struct Increment
   1.181 -	{
   1.182 -		static void Incr(T &what)	
   1.183 -		{
   1.184 -			++what;
   1.185 -		}
   1.186 -	};
   1.187 -
   1.188 -	template<>
   1.189 -	struct Increment<float>
   1.190 -	{
   1.191 -		static void Incr(float &what)	
   1.192 -		{
   1.193 -			what += 1.3f;
   1.194 -		}
   1.195 -	};
   1.196 -
   1.197 -	template<>
   1.198 -	struct Increment<double>
   1.199 -	{
   1.200 -		static void Incr(double &what)	
   1.201 -		{
   1.202 -			what += 1.3;
   1.203 -		}
   1.204 -	};
   1.205 -
   1.206 -	template<int MYSIZE>
   1.207 -	struct Increment< POD<MYSIZE> >
   1.208 -	{
   1.209 -		static void Incr(POD<MYSIZE> &what)	
   1.210 -		{
   1.211 -			for (int i = 0; i < MYSIZE; ++i)
   1.212 -				++ what.x[i];
   1.213 -		}
   1.214 -	};
   1.215 -
   1.216 -	template<int MYSIZE>
   1.217 -	struct Increment< Object<MYSIZE> >
   1.218 -	{
   1.219 -		static void Incr(Object<MYSIZE> &what)	
   1.220 -		{
   1.221 -			for (int i = 0; i < MYSIZE; ++i)
   1.222 -				++ what.x[i];
   1.223 -		}
   1.224 -	};
   1.225 -
   1.226 -	template<>
   1.227 -	struct Increment<std::string>
   1.228 -	{
   1.229 -		static void Incr(std::string &what)
   1.230 -		{
   1.231 -			what += "!";
   1.232 -		}
   1.233 -	};
   1.234 -
   1.235 -	#include "testhookmangen.h"
   1.236 -
   1.237 -	template <class T>
   1.238 -	int PtrBuf(T ptr)
   1.239 -	{
   1.240 -		int a = 0;
   1.241 -
   1.242 -		const void *vptr = reinterpret_cast<const void*>(ptr);
   1.243 -		for (SourceHook::List<const void*>::iterator iter = g_PtrHash.begin(); iter != g_PtrHash.end(); ++iter)
   1.244 -		{
   1.245 -			if (*iter == vptr)
   1.246 -				return a;
   1.247 -			else
   1.248 -				++a;
   1.249 -		}
   1.250 -		g_PtrHash.push_back(vptr);
   1.251 -		return static_cast<int>(g_PtrHash.size()) - 1;
   1.252 -	}
   1.253 -
   1.254 -	template <class T>
   1.255 -	T PtrBufPtr(T ptr)
   1.256 -	{
   1.257 -		PtrBuf(ptr);
   1.258 -		return ptr;
   1.259 -	}
   1.260 -
   1.261 -	void PtrBuf_Clear(int leave_in = 0)
   1.262 -	{
   1.263 -		for (SourceHook::List<const void*>::iterator iter = g_PtrHash.begin(); iter != g_PtrHash.end();)
   1.264 -		{
   1.265 -			if (--leave_in < 0)
   1.266 -				iter = g_PtrHash.erase(iter);
   1.267 -			else
   1.268 -				++iter;
   1.269 -		}
   1.270 -	}
   1.271 -
   1.272 -	// MyDelegate base class for other delegates
   1.273 -	class MyDelegate : public SourceHook::ISHDelegate
   1.274 -	{
   1.275 -		// Unneeded
   1.276 -		//  because we don't use old SH_REMOVE_HOOK syntax
   1.277 -		virtual bool IsEqual(SourceHook::ISHDelegate *pOtherDeleg)
   1.278 -		{
   1.279 -			return false;
   1.280 -		}
   1.281 -
   1.282 -		virtual void DeleteThis()
   1.283 -		{
   1.284 -			delete this;
   1.285 -		}
   1.286 -	};
   1.287 -
   1.288 -	THGM_MAKE_TEST0_void(0);
   1.289 -	THGM_SETUP_PI0(0);
   1.290 -
   1.291 -	THGM_MAKE_TEST1_void(1, char);
   1.292 -	THGM_SETUP_PI1(1, char, SourceHook::PassInfo::PassType_Basic, SourceHook::PassInfo::PassFlag_ByVal);
   1.293 -
   1.294 -	THGM_MAKE_TEST1_void(2, short);
   1.295 -	THGM_SETUP_PI1(2, short, SourceHook::PassInfo::PassType_Basic, SourceHook::PassInfo::PassFlag_ByVal);
   1.296 -
   1.297 -	THGM_MAKE_TEST1_void(3, int);
   1.298 -	THGM_SETUP_PI1(3, int, SourceHook::PassInfo::PassType_Basic, SourceHook::PassInfo::PassFlag_ByVal);
   1.299 -
   1.300 -	THGM_MAKE_TEST1_void(4, float);
   1.301 -	THGM_SETUP_PI1(4, float, SourceHook::PassInfo::PassType_Float, SourceHook::PassInfo::PassFlag_ByVal);
   1.302 -
   1.303 -	THGM_MAKE_TEST1_void(5, double);
   1.304 -	THGM_SETUP_PI1(5, double, SourceHook::PassInfo::PassType_Float, SourceHook::PassInfo::PassFlag_ByVal);
   1.305 -	
   1.306 -	THGM_MAKE_TEST5_void(6, char, short, int, float, double);
   1.307 -	THGM_SETUP_PI5(6,
   1.308 -		char, SourceHook::PassInfo::PassType_Basic, SourceHook::PassInfo::PassFlag_ByVal,
   1.309 -		short, SourceHook::PassInfo::PassType_Basic, SourceHook::PassInfo::PassFlag_ByVal,
   1.310 -		int, SourceHook::PassInfo::PassType_Basic, SourceHook::PassInfo::PassFlag_ByVal,
   1.311 -		float, SourceHook::PassInfo::PassType_Float, SourceHook::PassInfo::PassFlag_ByVal,
   1.312 -		double, SourceHook::PassInfo::PassType_Float, SourceHook::PassInfo::PassFlag_ByVal
   1.313 -		);
   1.314 -
   1.315 -	THGM_MAKE_TEST2_void(7, char&, double&);
   1.316 -	THGM_SETUP_PI2(7,
   1.317 -		char&, SourceHook::PassInfo::PassType_Basic, SourceHook::PassInfo::PassFlag_ByRef,
   1.318 -		double&, SourceHook::PassInfo::PassType_Float, SourceHook::PassInfo::PassFlag_ByRef
   1.319 -		);
   1.320 -
   1.321 -	THGM_MAKE_TEST1_void(8, POD<7>);
   1.322 -	THGM_SETUP_PI1(8, POD<7>, SourceHook::PassInfo::PassType_Object, SourceHook::PassInfo::PassFlag_ByVal);
   1.323 -
   1.324 -	THGM_MAKE_TEST1_void(9, POD<600>);
   1.325 -	THGM_SETUP_PI1(9, POD<600>, SourceHook::PassInfo::PassType_Object, SourceHook::PassInfo::PassFlag_ByVal);
   1.326 -
   1.327 -	THGM_MAKE_TEST1_void(10, POD<600> &);
   1.328 -	THGM_SETUP_PI1(10, POD<600> &, SourceHook::PassInfo::PassType_Object, SourceHook::PassInfo::PassFlag_ByRef);
   1.329 -
   1.330 -	THGM_MAKE_TEST2_void(11, Object<3>, Object<600>&);
   1.331 -	THGM_SETUP_PI2(11,
   1.332 -		Object<3>, SourceHook::PassInfo::PassType_Object, SourceHook::PassInfo::PassFlag_ByVal | SourceHook::PassInfo::PassFlag_OCtor | SourceHook::PassInfo::PassFlag_ODtor | SourceHook::PassInfo::PassFlag_CCtor,
   1.333 -		Object<600> &, SourceHook::PassInfo::PassType_Object, SourceHook::PassInfo::PassFlag_ByRef | SourceHook::PassInfo::PassFlag_OCtor | SourceHook::PassInfo::PassFlag_ODtor | SourceHook::PassInfo::PassFlag_CCtor
   1.334 -		);
   1.335 -
   1.336 -	THGM_MAKE_TEST0(101, char);
   1.337 -	THGM_SETUP_PI0(101);
   1.338 -	THGM_SETUP_RI(101, char, SourceHook::PassInfo::PassType_Basic, SourceHook::PassInfo::PassFlag_ByVal);
   1.339 -
   1.340 -	THGM_MAKE_TEST0(102, short);
   1.341 -	THGM_SETUP_PI0(102);
   1.342 -	THGM_SETUP_RI(102, short, SourceHook::PassInfo::PassType_Basic, SourceHook::PassInfo::PassFlag_ByVal);
   1.343 -
   1.344 -	THGM_MAKE_TEST0(103, int);
   1.345 -	THGM_SETUP_PI0(103);
   1.346 -	THGM_SETUP_RI(103, int, SourceHook::PassInfo::PassType_Basic, SourceHook::PassInfo::PassFlag_ByVal);
   1.347 -
   1.348 -	THGM_MAKE_TEST0(104, float);
   1.349 -	THGM_SETUP_PI0(104);
   1.350 -	THGM_SETUP_RI(104, float, SourceHook::PassInfo::PassType_Float, SourceHook::PassInfo::PassFlag_ByVal);
   1.351 -
   1.352 -	THGM_MAKE_TEST0(105, double);
   1.353 -	THGM_SETUP_PI0(105);
   1.354 -	THGM_SETUP_RI(105, double, SourceHook::PassInfo::PassType_Float, SourceHook::PassInfo::PassFlag_ByVal);
   1.355 -
   1.356 -	// pod 1-13
   1.357 -	MAKE_PODRET(1);
   1.358 -	THGM_MAKE_TEST1(106, PodRet1, int);
   1.359 -	THGM_SETUP_PI1(106,
   1.360 -		int, SourceHook::PassInfo::PassType_Basic, SourceHook::PassInfo::PassFlag_ByVal
   1.361 -		);
   1.362 -	THGM_SETUP_RI(106, PodRet1, SourceHook::PassInfo::PassType_Object, SourceHook::PassInfo::PassFlag_ByVal);
   1.363 -
   1.364 -	MAKE_PODRET(4);
   1.365 -	THGM_MAKE_TEST1(107, PodRet4, int);
   1.366 -	THGM_SETUP_PI1(107,
   1.367 -		int, SourceHook::PassInfo::PassType_Basic, SourceHook::PassInfo::PassFlag_ByVal
   1.368 -		);
   1.369 -	THGM_SETUP_RI(107, PodRet4, SourceHook::PassInfo::PassType_Object, SourceHook::PassInfo::PassFlag_ByVal);
   1.370 -
   1.371 -	MAKE_PODRET(8);
   1.372 -	THGM_MAKE_TEST1(108, PodRet8, int);
   1.373 -	THGM_SETUP_PI1(108,
   1.374 -		int, SourceHook::PassInfo::PassType_Basic, SourceHook::PassInfo::PassFlag_ByVal
   1.375 -		);
   1.376 -	THGM_SETUP_RI(108, PodRet8, SourceHook::PassInfo::PassType_Object, SourceHook::PassInfo::PassFlag_ByVal);
   1.377 -
   1.378 -	MAKE_PODRET(13);
   1.379 -	THGM_MAKE_TEST1(109, PodRet13, int);
   1.380 -	THGM_SETUP_PI1(109,
   1.381 -		int, SourceHook::PassInfo::PassType_Basic, SourceHook::PassInfo::PassFlag_ByVal
   1.382 -		);
   1.383 -	THGM_SETUP_RI(109, PodRet13, SourceHook::PassInfo::PassType_Object, SourceHook::PassInfo::PassFlag_ByVal);
   1.384 -
   1.385 -	MAKE_OBJRET(13);
   1.386 -	THGM_MAKE_TEST1(110, ObjRet13, int);
   1.387 -	THGM_SETUP_PI1(110,
   1.388 -		int, SourceHook::PassInfo::PassType_Basic, SourceHook::PassInfo::PassFlag_ByVal
   1.389 -		);
   1.390 -	THGM_SETUP_RI(110, ObjRet13, SourceHook::PassInfo::PassType_Object,
   1.391 -		SourceHook::PassInfo::PassFlag_ByVal | SourceHook::PassInfo::PassFlag_OCtor | SourceHook::PassInfo::PassFlag_ODtor |
   1.392 -		SourceHook::PassInfo::PassFlag_CCtor | SourceHook::PassInfo::PassFlag_AssignOp);
   1.393 -
   1.394 -	MAKE_OBJRET(111);
   1.395 -	ObjRet111 g_O111_0;
   1.396 -	ObjRet111 g_O111_1;
   1.397 -	ObjRet111 g_O111_2;
   1.398 -	ObjRet111 g_O111_3;
   1.399 -	ObjRet111 g_O111_4;
   1.400 -
   1.401 -	template <>
   1.402 -	struct MakeRet< ObjRet111& >
   1.403 -	{
   1.404 -		static ObjRet111 &Do(int a)
   1.405 -		{
   1.406 -			switch (a)
   1.407 -			{
   1.408 -			case 0:
   1.409 -				return g_O111_0;
   1.410 -			case 1:
   1.411 -				return g_O111_1;
   1.412 -			case 2:
   1.413 -				return g_O111_2;
   1.414 -			case 3:
   1.415 -				return g_O111_3;
   1.416 -			default:
   1.417 -				return g_O111_4;
   1.418 -			}
   1.419 -		}
   1.420 -	};
   1.421 -
   1.422 -	THGM_MAKE_TEST0(111, ObjRet111& );
   1.423 -	THGM_SETUP_PI0(111);
   1.424 -	THGM_SETUP_RI(111, ObjRet111& , SourceHook::PassInfo::PassType_Object,
   1.425 -		SourceHook::PassInfo::PassFlag_ByRef | SourceHook::PassInfo::PassFlag_OCtor | SourceHook::PassInfo::PassFlag_ODtor |
   1.426 -		SourceHook::PassInfo::PassFlag_CCtor | SourceHook::PassInfo::PassFlag_AssignOp);
   1.427 -
   1.428 -
   1.429 -	THGM_MAKE_TEST3_void(150, int, double, int);
   1.430 -	THGM_SETUP_PI3(150,
   1.431 -		int, SourceHook::PassInfo::PassType_Basic, SourceHook::PassInfo::PassFlag_ByVal,
   1.432 -		double, SourceHook::PassInfo::PassType_Float, SourceHook::PassInfo::PassFlag_ByVal,
   1.433 -		int, SourceHook::PassInfo::PassType_Basic, SourceHook::PassInfo::PassFlag_ByVal);
   1.434 -
   1.435 -	// vafmt tests
   1.436 -	THGM_MAKE_TEST0_vafmt_void(200);
   1.437 -	THGM_SETUP_PI0(200);
   1.438 -
   1.439 -	THGM_MAKE_TEST1_vafmt_void(201, char);
   1.440 -	THGM_SETUP_PI1(201, char, SourceHook::PassInfo::PassType_Basic, SourceHook::PassInfo::PassFlag_ByVal);
   1.441 -
   1.442 -	THGM_MAKE_TEST1_vafmt_void(203, int);
   1.443 -	THGM_SETUP_PI1(203, int, SourceHook::PassInfo::PassType_Basic, SourceHook::PassInfo::PassFlag_ByVal);
   1.444 -	
   1.445 -	THGM_MAKE_TEST5_vafmt_void(206, char, short, int, float, double);
   1.446 -	THGM_SETUP_PI5(206,
   1.447 -		char, SourceHook::PassInfo::PassType_Basic, SourceHook::PassInfo::PassFlag_ByVal,
   1.448 -		short, SourceHook::PassInfo::PassType_Basic, SourceHook::PassInfo::PassFlag_ByVal,
   1.449 -		int, SourceHook::PassInfo::PassType_Basic, SourceHook::PassInfo::PassFlag_ByVal,
   1.450 -		float, SourceHook::PassInfo::PassType_Float, SourceHook::PassInfo::PassFlag_ByVal,
   1.451 -		double, SourceHook::PassInfo::PassType_Float, SourceHook::PassInfo::PassFlag_ByVal
   1.452 -		);
   1.453 -
   1.454 -	THGM_MAKE_TEST2_vafmt_void(207, char&, double&);
   1.455 -	THGM_SETUP_PI2(207,
   1.456 -		char&, SourceHook::PassInfo::PassType_Basic, SourceHook::PassInfo::PassFlag_ByRef,
   1.457 -		double&, SourceHook::PassInfo::PassType_Float, SourceHook::PassInfo::PassFlag_ByRef
   1.458 -		);
   1.459 -
   1.460 -	THGM_MAKE_TEST1_vafmt_void(208, POD<7>);
   1.461 -	THGM_SETUP_PI1(208, POD<7>, SourceHook::PassInfo::PassType_Object, SourceHook::PassInfo::PassFlag_ByVal);
   1.462 -
   1.463 -	THGM_MAKE_TEST1_vafmt_void(210, POD<600> &);
   1.464 -	THGM_SETUP_PI1(210, POD<600> &, SourceHook::PassInfo::PassType_Object, SourceHook::PassInfo::PassFlag_ByRef)
   1.465 -	
   1.466 -	THGM_MAKE_TEST1_vafmt(211, int, int);
   1.467 -	THGM_SETUP_PI1(211,
   1.468 -		int, SourceHook::PassInfo::PassType_Basic, SourceHook::PassInfo::PassFlag_ByVal
   1.469 -		);
   1.470 -	THGM_SETUP_RI(211, int, SourceHook::PassInfo::PassType_Basic, SourceHook::PassInfo::PassFlag_ByVal);
   1.471 -
   1.472 -	THGM_MAKE_TEST1_vafmt(212, double, int);
   1.473 -	THGM_SETUP_PI1(212,
   1.474 -		int, SourceHook::PassInfo::PassType_Basic, SourceHook::PassInfo::PassFlag_ByVal
   1.475 -		);
   1.476 -	THGM_SETUP_RI(212, double, SourceHook::PassInfo::PassType_Float, SourceHook::PassInfo::PassFlag_ByVal);
   1.477 -
   1.478 -	THGM_MAKE_TEST1_vafmt(213, PodRet8, int);
   1.479 -	THGM_SETUP_PI1(213,
   1.480 -		int, SourceHook::PassInfo::PassType_Basic, SourceHook::PassInfo::PassFlag_ByVal
   1.481 -		);
   1.482 -	THGM_SETUP_RI(213, PodRet8, SourceHook::PassInfo::PassType_Object, SourceHook::PassInfo::PassFlag_ByVal);
   1.483 -
   1.484 -	THGM_MAKE_TEST1_vafmt_void(214, Object<133>);
   1.485 -	THGM_SETUP_PI1(214, Object<133>, SourceHook::PassInfo::PassType_Object,
   1.486 -		SourceHook::PassInfo::PassFlag_ByVal | SourceHook::PassInfo::PassFlag_OCtor | SourceHook::PassInfo::PassFlag_ODtor |
   1.487 -		SourceHook::PassInfo::PassFlag_CCtor | SourceHook::PassInfo::PassFlag_AssignOp);
   1.488 -
   1.489 -
   1.490 -	MAKE_STATE(State_Hello_Func4_Called);
   1.491 -	MAKE_STATE(State_Hello_Func79_Called);
   1.492 -
   1.493 -	MAKE_STATE(State_Hello_Func4_PreHook);
   1.494 -	MAKE_STATE(State_Hello_Func79_PreHook);
   1.495 -
   1.496 -	// Test for larger vtable indices
   1.497 -	class Hello
   1.498 -	{
   1.499 -	public:
   1.500 -		virtual void Func0() {}
   1.501 -		virtual void Func1() {}
   1.502 -		virtual void Func2() {}
   1.503 -		virtual void Func3() {}
   1.504 -		virtual void Func4()
   1.505 -		{
   1.506 -			ADD_STATE(State_Hello_Func4_Called);
   1.507 -		}
   1.508 -		virtual void Func5() {}
   1.509 -		virtual void Func6() {}
   1.510 -		virtual void Func7() {}
   1.511 -		virtual void Func8() {}
   1.512 -		virtual void Func9() {}
   1.513 -		virtual void Func10() {}
   1.514 -		virtual void Func11() {}
   1.515 -		virtual void Func12() {}
   1.516 -		virtual void Func13() {}
   1.517 -		virtual void Func14() {}
   1.518 -		virtual void Func15() {}
   1.519 -		virtual void Func16() {}
   1.520 -		virtual void Func17() {}
   1.521 -		virtual void Func18() {}
   1.522 -		virtual void Func19() {}
   1.523 -		virtual void Func20() {}
   1.524 -		virtual void Func21() {}
   1.525 -		virtual void Func22() {}
   1.526 -		virtual void Func23() {}
   1.527 -		virtual void Func24() {}
   1.528 -		virtual void Func25() {}
   1.529 -		virtual void Func26() {}
   1.530 -		virtual void Func27() {}
   1.531 -		virtual void Func28() {}
   1.532 -		virtual void Func29() {}
   1.533 -		virtual void Func30() {}
   1.534 -		virtual void Func31() {}
   1.535 -		virtual void Func32() {}
   1.536 -		virtual void Func33() {}
   1.537 -		virtual void Func34() {}
   1.538 -		virtual void Func35() {}
   1.539 -		virtual void Func36() {}
   1.540 -		virtual void Func37() {}
   1.541 -		virtual void Func38() {}
   1.542 -		virtual void Func39() {}
   1.543 -		virtual void Func40() {}
   1.544 -		virtual void Func41() {}
   1.545 -		virtual void Func42() {}
   1.546 -		virtual void Func43() {}
   1.547 -		virtual void Func44() {}
   1.548 -		virtual void Func45() {}
   1.549 -		virtual void Func46() {}
   1.550 -		virtual void Func47() {}
   1.551 -		virtual void Func48() {}
   1.552 -		virtual void Func49() {}
   1.553 -		virtual void Func50() {}
   1.554 -		virtual void Func51() {}
   1.555 -		virtual void Func52() {}
   1.556 -		virtual void Func53() {}
   1.557 -		virtual void Func54() {}
   1.558 -		virtual void Func55() {}
   1.559 -		virtual void Func56() {}
   1.560 -		virtual void Func57() {}
   1.561 -		virtual void Func58() {}
   1.562 -		virtual void Func59() {}
   1.563 -		virtual void Func60() {}
   1.564 -		virtual void Func61() {}
   1.565 -		virtual void Func62() {}
   1.566 -		virtual void Func63() {}
   1.567 -		virtual void Func64() {}
   1.568 -		virtual void Func65() {}
   1.569 -		virtual void Func66() {}
   1.570 -		virtual void Func67() {}
   1.571 -		virtual void Func68() {}
   1.572 -		virtual void Func69() {}
   1.573 -		virtual void Func70() {}
   1.574 -		virtual void Func71() {}
   1.575 -		virtual void Func72() {}
   1.576 -		virtual void Func73() {}
   1.577 -		virtual void Func74() {}
   1.578 -		virtual void Func75() {}
   1.579 -		virtual void Func76() {}
   1.580 -		virtual void Func77() {}
   1.581 -		virtual void Func78() {}
   1.582 -		virtual void Func79()
   1.583 -		{
   1.584 -			ADD_STATE(State_Hello_Func79_Called);
   1.585 -		}
   1.586 -	};
   1.587 -	class Hello_Func4_Deleg : public MyDelegate
   1.588 -	{
   1.589 -		virtual void Func()
   1.590 -		{
   1.591 -			ADD_STATE(State_Hello_Func4_PreHook);
   1.592 -		}
   1.593 -	};
   1.594 -	class Hello_Func79_Deleg : public MyDelegate
   1.595 -	{
   1.596 -		int a;
   1.597 -		virtual void Func()
   1.598 -		{
   1.599 -			ADD_STATE(State_Hello_Func79_PreHook);
   1.600 -		}
   1.601 -	};
   1.602 -
   1.603 -	bool Tests1(std::string &error)
   1.604 -	{
   1.605 -		THGM_DO_TEST_void(0, ());
   1.606 -
   1.607 -		THGM_DO_TEST_void(1, (100));
   1.608 -		
   1.609 -		THGM_DO_TEST_void(2, (0x1F00));
   1.610 -
   1.611 -		THGM_DO_TEST_void(3, (0x1F000000));
   1.612 -
   1.613 -		THGM_DO_TEST_void(4, (0.5f));
   1.614 -
   1.615 -		THGM_DO_TEST_void(5, (5.5));
   1.616 -
   1.617 -		THGM_DO_TEST_void(6, (100, 0x1f00, 0x1f000000, 0.5f, 5.5));
   1.618 -
   1.619 -		return true;
   1.620 -	}
   1.621 -
   1.622 -	bool Tests2(std::string &error)
   1.623 -	{
   1.624 -		char a = 5;
   1.625 -		double b = 233.33;
   1.626 -		THGM_DO_TEST_void(7, (a, b));
   1.627 -
   1.628 -		POD<7> pod7 = MakeRet< POD<7> >::Do(78);
   1.629 -		THGM_DO_TEST_void(8, (pod7));
   1.630 -
   1.631 -		POD<600> pod600 = MakeRet< POD<600> >::Do(34);
   1.632 -		THGM_DO_TEST_void(9, (pod600));
   1.633 -		
   1.634 -		THGM_DO_TEST_void(10, (pod600));
   1.635 -
   1.636 -		// Test11: Special: constructors/destructors
   1.637 -		PtrBuf_Clear();
   1.638 -		Object<3> *obj3_real = new Object<3>(33);
   1.639 -		Object<600> *obj600_real = new Object<600>(21);
   1.640 -
   1.641 -		Object<3> & obj3 = *obj3_real;
   1.642 -		Object<600> & obj600 = *obj600_real;
   1.643 -
   1.644 -		CHECK_STATES((&g_States,
   1.645 -			new State_ObjOCtor_Called(3),
   1.646 -			new State_ObjOCtor_Called(600),
   1.647 -			NULL), "Test11 Part0");
   1.648 -
   1.649 -		setuppi_11();
   1.650 -		SourceHook::HookManagerPubFunc myhookman11 = g_HMAGPtr->MakeHookMan(protoinfo_11, 0, 0); \
   1.651 -		CAutoReleaseHookMan arhm_11(myhookman11); \
   1.652 -		int hook1_11, hook2_11, hook3_11, hook4_11;
   1.653 -		
   1.654 -		TestClass11 *pTest11 = new TestClass11;
   1.655 -		CAutoPtrDestruction<TestClass11> apd11(pTest11);
   1.656 -		
   1.657 -		/* no hooks - no hooks */
   1.658 -		PtrBuf_Clear();
   1.659 -		pTest11->Func(obj3, obj600);
   1.660 -
   1.661 -		g_Inside_LeafFunc = true;
   1.662 -		CHECK_STATES((&g_States,
   1.663 -			new State_ObjCCtor_Called(3),
   1.664 -			new State_Func11(pTest11, ParamState_m11 (obj3, obj600)),
   1.665 -			new State_ObjODtor_Called(3),
   1.666 -			NULL), "Test" "11" " Part1");
   1.667 -		g_Inside_LeafFunc = false;
   1.668 -
   1.669 -		/* hook1 - no hooks */
   1.670 -		THGM_ADD_HOOK(11, 1);
   1.671 -		
   1.672 -		PtrBuf_Clear();
   1.673 -		pTest11->Func(obj3, obj600);
   1.674 -		g_Inside_LeafFunc = true;
   1.675 -		CHECK_STATES((&g_States,
   1.676 -			new State_ObjCCtor_Called(3),
   1.677 -
   1.678 -			new State_ObjCCtor_Called(3),
   1.679 -			new State_Deleg_11(1, pTest11, 0, ParamState_m11 (obj3, obj600)),
   1.680 -			new State_ObjODtor_Called(3),
   1.681 -
   1.682 -			new State_ObjCCtor_Called(3),
   1.683 -			new State_Func11(pTest11, ParamState_m11 (obj3, obj600)),
   1.684 -			new State_ObjODtor_Called(3),
   1.685 -
   1.686 -			new State_ObjODtor_Called(3),
   1.687 -			NULL), "Test" "11" " Part2");
   1.688 -		g_Inside_LeafFunc = false;
   1.689 -
   1.690 -		THGM_REMOVE_HOOK(11, 1);
   1.691 -
   1.692 -		/* hook1, hook2 - hook3, hook4 */
   1.693 -		THGM_ADD_HOOK(11, 1);
   1.694 -		THGM_ADD_HOOK(11, 2);
   1.695 -		THGM_ADD_HOOK(11, 3);
   1.696 -		THGM_ADD_HOOK(11, 4);
   1.697 -		PtrBuf_Clear();
   1.698 -		pTest11->Func(obj3, obj600);
   1.699 -		g_Inside_LeafFunc = true;
   1.700 -		CHECK_STATES((&g_States,
   1.701 -			new State_ObjCCtor_Called(3),
   1.702 -
   1.703 -			new State_ObjCCtor_Called(3),
   1.704 -			new	State_Deleg_11(1, pTest11, 0, ParamState_m11 (obj3, obj600)),
   1.705 -			new State_ObjODtor_Called(3),
   1.706 -
   1.707 -			new State_ObjCCtor_Called(3),
   1.708 -			new State_Deleg_11(2, pTest11, 1, ParamState_m11 (obj3, obj600)),
   1.709 -			new State_ObjODtor_Called(3),
   1.710 -
   1.711 -			new State_ObjCCtor_Called(3),
   1.712 -			new State_Deleg_11(3, pTest11, 2, ParamState_m11 (obj3, obj600)),
   1.713 -			new State_ObjODtor_Called(3),
   1.714 -
   1.715 -			new State_ObjCCtor_Called(3),
   1.716 -			new State_Deleg_11(4, pTest11, 3, ParamState_m11 (obj3, obj600)),
   1.717 -			new State_ObjODtor_Called(3),
   1.718 -
   1.719 -			new State_ObjODtor_Called(3),
   1.720 -		NULL), "Test" "11" " Part3");
   1.721 -		g_Inside_LeafFunc = false;
   1.722 -
   1.723 -		/* hook1 - hook3, hook4 WITH RECALLS */
   1.724 -		THGM_REMOVE_HOOK(11, 2);
   1.725 -		PtrBuf_Clear();
   1.726 -		TestClass11::ms_DoRecall = true;
   1.727 -		pTest11->Func(obj3, obj600);
   1.728 -		g_Inside_LeafFunc = true;
   1.729 -		CHECK_STATES((&g_States,
   1.730 -			new State_ObjCCtor_Called(3),
   1.731 -
   1.732 -			new State_ObjCCtor_Called(3),
   1.733 -			new	State_Deleg_11(1, pTest11, 0 /* first deleg ptr */, ParamState_m11 (obj3, obj600)),
   1.734 -
   1.735 -			// recall !
   1.736 -				// second hookfunc -> new copy
   1.737 -				new State_ObjCCtor_Called(3),
   1.738 -
   1.739 -				// in second hookfunc now
   1.740 -				//   -> calls orig func
   1.741 -
   1.742 -				new State_ObjCCtor_Called(3),
   1.743 -				new State_Func11(pTest11, ParamState_m11 (obj3, obj600)(1)),
   1.744 -				new State_ObjODtor_Called(3),
   1.745 -
   1.746 -				// calls first posthook
   1.747 -				new State_ObjCCtor_Called(3),
   1.748 -				new State_Deleg_11(3, pTest11, 1 /* second deleg ptr */, ParamState_m11 (obj3, obj600)(1)),
   1.749 -
   1.750 -				// recall!
   1.751 -					// third hookfunc -> new copy
   1.752 -					new State_ObjCCtor_Called(3),
   1.753 -
   1.754 -					// calls second posthook
   1.755 -
   1.756 -					new State_ObjCCtor_Called(3),
   1.757 -					new State_Deleg_11(4, pTest11, 2 /* third deleg ptr */, ParamState_m11 (obj3, obj600)(2)),
   1.758 -
   1.759 -					// recall!
   1.760 -						// fourth hookfunc -> new copy
   1.761 -						new State_ObjCCtor_Called(3),
   1.762 -
   1.763 -						// has nothing to do though!
   1.764 -
   1.765 -						// fourth hookfunc done -> ret
   1.766 -						new State_ObjODtor_Called(3),
   1.767 -
   1.768 -					// third hookfunc done -> ret
   1.769 -					new State_ObjODtor_Called(3),
   1.770 -					// ret from hookhandler which did the recall
   1.771 -					new State_ObjODtor_Called(3),
   1.772 -
   1.773 -				// second hookfunc done -> ret
   1.774 -				new State_ObjODtor_Called(3),
   1.775 -				// ret from hookhandler which did the recall
   1.776 -				new State_ObjODtor_Called(3),
   1.777 -
   1.778 -			// deleg1's instance
   1.779 -			new State_ObjODtor_Called(3),
   1.780 -			// first hookfunc done -> ret
   1.781 -			new State_ObjODtor_Called(3),
   1.782 -			NULL), "Test" "11" " Part4");
   1.783 -		g_Inside_LeafFunc = false;
   1.784 -
   1.785 -		THGM_REMOVE_HOOK(11, 1);
   1.786 -		THGM_REMOVE_HOOK(11, 3);
   1.787 -		THGM_REMOVE_HOOK(11, 4);
   1.788 -
   1.789 -		delete obj3_real;
   1.790 -		delete obj600_real;
   1.791 -
   1.792 -		CHECK_STATES((&g_States,
   1.793 -			new State_ObjODtor_Called(3),
   1.794 -			new State_ObjODtor_Called(600),
   1.795 -			NULL), "Test11 Part100");
   1.796 -
   1.797 -		return true;
   1.798 -	}
   1.799 -
   1.800 -	bool Tests3(std::string &error)
   1.801 -	{
   1.802 -		THGM_DO_TEST(101, ());
   1.803 -
   1.804 -		THGM_DO_TEST(102, ());
   1.805 -
   1.806 -		THGM_DO_TEST(103, ());
   1.807 -
   1.808 -		THGM_DO_TEST(104, ());
   1.809 -
   1.810 -		THGM_DO_TEST(105, ());
   1.811 -
   1.812 -		// pod returns
   1.813 -		THGM_DO_TEST(106, (5));
   1.814 -		THGM_DO_TEST(107, (5));
   1.815 -		THGM_DO_TEST(108, (5));
   1.816 -		THGM_DO_TEST(109, (5));
   1.817 -
   1.818 -		return true;
   1.819 -	}
   1.820 -
   1.821 -	bool Tests4(std::string &error)
   1.822 -	{
   1.823 -		// Test110: Special: constructors/destructors on return
   1.824 -		PtrBuf_Clear();
   1.825 -		ObjRet13 *obj13_real = new ObjRet13;
   1.826 -		ObjRet13 &obj13 = *obj13_real;
   1.827 -
   1.828 -		CHECK_STATES((&g_States,
   1.829 -			new State_ObjOCtor_Called(13),
   1.830 -			NULL), "Test110 Part0");
   1.831 -
   1.832 -		setuppi_110();
   1.833 -		setupri_110();
   1.834 -
   1.835 -		SourceHook::HookManagerPubFunc myhookman110 = g_HMAGPtr->MakeHookMan(protoinfo_110, 0, 0); \
   1.836 -		CAutoReleaseHookMan arhm_110(myhookman110); \
   1.837 -		int hook1_110, hook2_110, hook3_110, hook4_110;
   1.838 -
   1.839 -		TestClass110 *pTest110 = new TestClass110;
   1.840 -		CAutoPtrDestruction<TestClass110> apd110(pTest110);
   1.841 -
   1.842 -		/* no hooks - no hooks */
   1.843 -		PtrBuf_Clear();
   1.844 -		obj13 = pTest110->Func(5);
   1.845 -
   1.846 -		g_Inside_LeafFunc = true;
   1.847 -		CHECK_STATES((&g_States,
   1.848 -			new State_Func110(pTest110, ParamState_m110 (5)),
   1.849 -			new State_ObjOCtor_Called(13),			// MakeRet: Construction of x
   1.850 -			new State_ObjCCtor_Called(13),			// Return from MakeRet	-> construct temporary object in our stack
   1.851 -			new State_ObjODtor_Called(13),			// MakeRet: Destruction of x
   1.852 -
   1.853 -			new State_ObjAssignOp_Called(13),		// assign: obj13 = temporary object in our stack
   1.854 -			new State_ObjODtor_Called(13),			// Func110: destruction of temporary object
   1.855 -			NULL), "Test" "110" " Part1");
   1.856 -		g_Inside_LeafFunc = false;
   1.857 -
   1.858 -		/* hook1 - no hooks */
   1.859 -		THGM_ADD_HOOK(110, 1);
   1.860 -
   1.861 -		PtrBuf_Clear();
   1.862 -		obj13 = pTest110->Func(5);
   1.863 -		g_Inside_LeafFunc = true;
   1.864 -		CHECK_STATES((&g_States,
   1.865 -			// HookFunc: construct orig_ret/override_ret/plugin_ret objects
   1.866 -			new State_ObjOCtor_Called(13),
   1.867 -			new State_ObjOCtor_Called(13),
   1.868 -			new State_ObjOCtor_Called(13),
   1.869 -
   1.870 -			// Calling delegate
   1.871 -				new State_Deleg_110(1, pTest110, 0, ParamState_m110 (5)),
   1.872 -
   1.873 -				new State_ObjOCtor_Called(13),	// MakeRet: Construction of x
   1.874 -				new State_ObjCCtor_Called(13),	// Return from MakeRet	-> construct temporary object in HookFunc's stack
   1.875 -				new State_ObjODtor_Called(13),	// MakeRet: Destruction of x
   1.876 -
   1.877 -			// back in hookfunc
   1.878 -			new State_ObjAssignOp_Called(13),	// assign: plugin_ret = temporary object in HookFunc's stack
   1.879 -			new State_ObjODtor_Called(13),		// destruction of temporary object in HookFunc's stack
   1.880 -
   1.881 -			// Calling orig function Func110
   1.882 -				new State_Func110(pTest110, ParamState_m110 (5)),
   1.883 -				new State_ObjOCtor_Called(13),	// MakeRet: Construction of x
   1.884 -				new State_ObjCCtor_Called(13),	// Return from MakeRet	-> construct temporary object in HookFunc's stack
   1.885 -				new State_ObjODtor_Called(13),	// MakeRet: Destruction of x
   1.886 -
   1.887 -			// back in hookfunc
   1.888 -			new State_ObjAssignOp_Called(13),	// assign: orig_ret = temporary object in HookFunc's stack
   1.889 -			new State_ObjODtor_Called(13),		// destruction of temporary object in HookFunc's stack
   1.890 -
   1.891 -			// hookfunc is returning:
   1.892 -			new State_ObjCCtor_Called(13),		// copy to temp object in our stack
   1.893 -
   1.894 -			// hookfunc cleans up its stack -> destroys plugin_ret/override_ret/orig_ret
   1.895 -			new State_ObjODtor_Called(13),
   1.896 -			new State_ObjODtor_Called(13),
   1.897 -			new State_ObjODtor_Called(13),
   1.898 -			
   1.899 -			// we are in our function: assign 
   1.900 -			new State_ObjAssignOp_Called(13),	// assign: obj13 = temporary object in our stack
   1.901 -			new State_ObjODtor_Called(13),		// Func110: destruction of temporary object
   1.902 -
   1.903 -			NULL), "Test" "11" " Part2");
   1.904 -		
   1.905 -		CHECK_COND(obj13 == 0, "Test" "11" " Part 2.1");
   1.906 -		g_Inside_LeafFunc = false;
   1.907 -
   1.908 -		THGM_REMOVE_HOOK(110, 1);
   1.909 -
   1.910 -		/* hook1, hook2 - hook3, hook4 */
   1.911 -		THGM_ADD_HOOK(110, 1);
   1.912 -		THGM_ADD_HOOK(110, 2);
   1.913 -		THGM_ADD_HOOK(110, 3);
   1.914 -		THGM_ADD_HOOK(110, 4);
   1.915 -
   1.916 -		PtrBuf_Clear();
   1.917 -		obj13 = pTest110->Func(5);
   1.918 -		g_Inside_LeafFunc = true;
   1.919 -		CHECK_STATES((&g_States,
   1.920 -			// HookFunc: construct orig_ret/override_ret/plugin_ret objects
   1.921 -			new State_ObjOCtor_Called(13),
   1.922 -			new State_ObjOCtor_Called(13),
   1.923 -			new State_ObjOCtor_Called(13),
   1.924 -
   1.925 -			// Calling delegate1
   1.926 -				new State_Deleg_110(1, pTest110, 0, ParamState_m110 (5)),
   1.927 -
   1.928 -				new State_ObjOCtor_Called(13),	// MakeRet: Construction of x
   1.929 -				new State_ObjCCtor_Called(13),	// Return from MakeRet	-> construct temporary object in HookFunc's stack
   1.930 -				new State_ObjODtor_Called(13),	// MakeRet: Destruction of x
   1.931 -
   1.932 -			// back in hookfunc
   1.933 -			new State_ObjAssignOp_Called(13),	// assign: plugin_ret = temporary object in HookFunc's stack
   1.934 -			new State_ObjODtor_Called(13),		// destruction of temporary object in HookFunc's stack
   1.935 -
   1.936 -
   1.937 -			// Calling delegate2
   1.938 -				new State_Deleg_110(2, pTest110, 1, ParamState_m110 (5)),
   1.939 -
   1.940 -				new State_ObjOCtor_Called(13),	// MakeRet: Construction of x
   1.941 -				new State_ObjCCtor_Called(13),	// Return from MakeRet	-> construct temporary object in HookFunc's stack
   1.942 -				new State_ObjODtor_Called(13),	// MakeRet: Destruction of x
   1.943 -
   1.944 -			// back in hookfunc
   1.945 -			new State_ObjAssignOp_Called(13),	// assign: plugin_ret = temporary object in HookFunc's stack
   1.946 -			new State_ObjODtor_Called(13),		// destruction of temporary object in HookFunc's stack
   1.947 -
   1.948 -			// hookfunc finds out that the hook wanted to SUPERCEDE --> copy to override_Ret
   1.949 -			new State_ObjAssignOp_Called(13),
   1.950 -
   1.951 -			// SUPERCEDE -> orig function is not called
   1.952 -			// instead: orig_ret = override_ret
   1.953 -			new State_ObjAssignOp_Called(13),
   1.954 -
   1.955 -			// Calling delegate3
   1.956 -				new State_Deleg_110(3, pTest110, 2, ParamState_m110 (5)),
   1.957 -
   1.958 -				new State_ObjOCtor_Called(13),	// MakeRet: Construction of x
   1.959 -				new State_ObjCCtor_Called(13),	// Return from MakeRet	-> construct temporary object in HookFunc's stack
   1.960 -				new State_ObjODtor_Called(13),	// MakeRet: Destruction of x
   1.961 -
   1.962 -			// back in hookfunc
   1.963 -			new State_ObjAssignOp_Called(13),	// assign: plugin_ret = temporary object in HookFunc's stack
   1.964 -			new State_ObjODtor_Called(13),		// destruction of temporary object in HookFunc's stack
   1.965 -
   1.966 -			// Calling delegate4
   1.967 -				new State_Deleg_110(4, pTest110, 3, ParamState_m110 (5)),
   1.968 -
   1.969 -				new State_ObjOCtor_Called(13),	// MakeRet: Construction of x
   1.970 -				new State_ObjCCtor_Called(13),	// Return from MakeRet	-> construct temporary object in HookFunc's stack
   1.971 -				new State_ObjODtor_Called(13),	// MakeRet: Destruction of x
   1.972 -
   1.973 -			// back in hookfunc
   1.974 -			new State_ObjAssignOp_Called(13),	// assign: plugin_ret = temporary object in HookFunc's stack
   1.975 -			new State_ObjODtor_Called(13),		// destruction of temporary object in HookFunc's stack
   1.976 -
   1.977 -			// hookfunc finds out that the hook wanted to SUPERCEDE --> copy to override_Ret (yes really, we overwrite the old value!)
   1.978 -			new State_ObjAssignOp_Called(13),
   1.979 -
   1.980 -			// hookfunc is returning:
   1.981 -			new State_ObjCCtor_Called(13),		// copy to temp object in our stack
   1.982 -
   1.983 -			// hookfunc cleans up its stack -> destroys plugin_ret/override_ret/orig_ret
   1.984 -			new State_ObjODtor_Called(13),
   1.985 -			new State_ObjODtor_Called(13),
   1.986 -			new State_ObjODtor_Called(13),
   1.987 -
   1.988 -			// we are in our function: assign 
   1.989 -			new State_ObjAssignOp_Called(13),	// assign: obj13 = temporary object in our stack
   1.990 -			new State_ObjODtor_Called(13),		// Func110: destruction of temporary object
   1.991 -
   1.992 -			NULL), "Test" "11" " Part3");
   1.993 -
   1.994 -		CHECK_COND(obj13 == 4, "Test" "11" " Part 3.1");
   1.995 -		g_Inside_LeafFunc = false;
   1.996 -
   1.997 -		THGM_REMOVE_HOOK(110, 1);
   1.998 -		THGM_REMOVE_HOOK(110, 2);
   1.999 -		THGM_REMOVE_HOOK(110, 3);
  1.1000 -		THGM_REMOVE_HOOK(110, 4);
  1.1001 -
  1.1002 -		delete obj13_real;
  1.1003 -
  1.1004 -		CHECK_STATES((&g_States,
  1.1005 -			new State_ObjODtor_Called(13),
  1.1006 -			NULL), "Test110 Part100");
  1.1007 -
  1.1008 -
  1.1009 -		THGM_DO_TEST_void(150, (5, 5.5, 6));
  1.1010 -
  1.1011 -		return true;
  1.1012 -	}
  1.1013 -
  1.1014 -	bool Tests5(std::string &error)
  1.1015 -	{
  1.1016 -		// RefRet
  1.1017 -		THGM_DO_TEST(111, ());
  1.1018 -
  1.1019 -		// Vafmt
  1.1020 -
  1.1021 -		THGM_DO_TEST_void(200, ("Hello %s%d%s", "BA", 1, "L!"));
  1.1022 -
  1.1023 -		THGM_DO_TEST_void(201, (100, "Hello %s%d%s", "BA", 1, "L!"));
  1.1024 -		
  1.1025 -		THGM_DO_TEST_void(203, (0x1F000000, "Hello %s%d%s", "BA", 1, "L!"));
  1.1026 -
  1.1027 -		THGM_DO_TEST_void(206, (100, 0x1f00, 0x1f000000, 0.5f, 5.5, "Hello %s%d%s", "BA", 1, "L!"));
  1.1028 -
  1.1029 -		char a = 5;
  1.1030 -		double b = 233.33;
  1.1031 -		THGM_DO_TEST_void(207, (a, b, "Hello %s%d%s", "BA", 1, "L!"));
  1.1032 -
  1.1033 -		POD<7> pod7 = MakeRet< POD<7> >::Do(78);
  1.1034 -		THGM_DO_TEST_void(208, (pod7, "Hello %s%d%s", "BA", 1, "L!"));
  1.1035 -	
  1.1036 -		POD<600> pod600 = MakeRet< POD<600> >::Do(34);
  1.1037 -		THGM_DO_TEST_void(210, (pod600, "Hello %s%d%s", "BA", 1, "L!"));
  1.1038 -		
  1.1039 -
  1.1040 -		THGM_DO_TEST(211, (5, "Hello %s%d%s", "BA", 1, "L!"));
  1.1041 -		THGM_DO_TEST(212, (5, "Hello %s%d%s", "BA", 1, "L!"));
  1.1042 -		THGM_DO_TEST(213, (5, "Hello %s%d%s", "BA", 1, "L!"));
  1.1043 -
  1.1044 -		// Silence Object's ctors/dtors: we only want a forced byref param
  1.1045 -		g_Silent_CtorDtor = true;
  1.1046 -		Object<133> *myobj133 = new Object<133>;
  1.1047 -		THGM_DO_TEST_void(214, (*myobj133, "Hello %s%d%s", "BA", 1, "L!"));
  1.1048 -		delete myobj133;
  1.1049 -		g_Silent_CtorDtor = false;
  1.1050 -
  1.1051 -		// Test for high vtable indices
  1.1052 -		Hello *pHello = new Hello;
  1.1053 -		SourceHook::CProtoInfoBuilder helloPi(SourceHook::ProtoInfo::CallConv_ThisCall);
  1.1054 -		SourceHook::HookManagerPubFunc helloHM_4 = g_HMAGPtr->MakeHookMan(helloPi, 0, 4);
  1.1055 -		SourceHook::HookManagerPubFunc helloHM_79 = g_HMAGPtr->MakeHookMan(helloPi, 0, 79);
  1.1056 -
  1.1057 -		pHello->Func4();
  1.1058 -		pHello->Func79();
  1.1059 -		SH_CALL(pHello, &Hello::Func4)();
  1.1060 -		SH_CALL(pHello, &Hello::Func79)();
  1.1061 -		CHECK_STATES((&g_States,
  1.1062 -			new State_Hello_Func4_Called,
  1.1063 -			new State_Hello_Func79_Called,
  1.1064 -			new State_Hello_Func4_Called,
  1.1065 -			new State_Hello_Func79_Called,
  1.1066 -			NULL), "Test" "Hello" " Part1");
  1.1067 -
  1.1068 -		int helloHook4 = g_SHPtr->AddHook(g_PLID, SourceHook::ISourceHook::Hook_Normal, reinterpret_cast<void*>(pHello),
  1.1069 -			0, helloHM_4, new Hello_Func4_Deleg, false);
  1.1070 -
  1.1071 -		int helloHook79 = g_SHPtr->AddHook(g_PLID, SourceHook::ISourceHook::Hook_Normal, reinterpret_cast<void*>(pHello),
  1.1072 -			0, helloHM_79, new Hello_Func79_Deleg, false);
  1.1073 -
  1.1074 -		pHello->Func4();
  1.1075 -		pHello->Func79();
  1.1076 -		SH_CALL(pHello, &Hello::Func4)();
  1.1077 -		SH_CALL(pHello, &Hello::Func79)();
  1.1078 -
  1.1079 -		CHECK_STATES((&g_States,
  1.1080 -			new State_Hello_Func4_PreHook,
  1.1081 -			new State_Hello_Func4_Called,
  1.1082 -			new State_Hello_Func79_PreHook,
  1.1083 -			new State_Hello_Func79_Called,
  1.1084 -			new State_Hello_Func4_Called,
  1.1085 -			new State_Hello_Func79_Called,
  1.1086 -			NULL), "Test" "Hello" " Part2");
  1.1087 -
  1.1088 -		g_SHPtr->RemoveHookByID(helloHook4);
  1.1089 -		g_SHPtr->RemoveHookByID(helloHook79);
  1.1090 -
  1.1091 -		g_HMAGPtr->ReleaseHookMan(helloHM_4);
  1.1092 -		g_HMAGPtr->ReleaseHookMan(helloHM_79);
  1.1093 -
  1.1094 -		return true;
  1.1095 -	}
  1.1096 -}
  1.1097 -
  1.1098 -
  1.1099 -bool TestHookManGen(std::string &error)
  1.1100 -{
  1.1101 -	GET_SHPTR(g_SHPtr);
  1.1102 -	GET_HMAG(g_HMAGPtr, g_SHPtr);
  1.1103 -	g_PLID = 1337;
  1.1104 -
  1.1105 -	// 5 Global constructors (g_O111_*)
  1.1106 -	CHECK_STATES((&g_States,
  1.1107 -		new State_ObjOCtor_Called(111),
  1.1108 -		new State_ObjOCtor_Called(111),
  1.1109 -		new State_ObjOCtor_Called(111),
  1.1110 -		new State_ObjOCtor_Called(111),
  1.1111 -		new State_ObjOCtor_Called(111),
  1.1112 -		NULL), "GlobCtors");
  1.1113 -
  1.1114 -	if (!Tests1(error))
  1.1115 -		return false;
  1.1116 -	if (!Tests2(error))
  1.1117 -		return false;
  1.1118 -	if (!Tests3(error))
  1.1119 -		return false;
  1.1120 -	if (!Tests4(error))
  1.1121 -		return false;
  1.1122 -	if (!Tests5(error))
  1.1123 -		return false;
  1.1124 -
  1.1125 -	// Shutdown now!
  1.1126 -	// If we don't SH will auto-shutdown _after_ genc's destructor is called
  1.1127 -	//  -> crash
  1.1128 -
  1.1129 -	Test_CompleteShutdown(g_SHPtr);
  1.1130 -
  1.1131 -	CHECK_COND(sizeof(PodRet1) == 1, "WTF!");
  1.1132 -	CHECK_COND(sizeof(PodRet4) == 4, "WTF!");
  1.1133 -	CHECK_COND(sizeof(PodRet8) == 8, "WTF!");
  1.1134 -	CHECK_COND(sizeof(PodRet13) == 13, "WTF!");
  1.1135 -
  1.1136 -	return true;
  1.1137 -}
  1.1138 -
  1.1139 -bool TestCPageAlloc(std::string &error)
  1.1140 -{
  1.1141 -	using namespace SourceHook;
  1.1142 -
  1.1143 -	CPageAlloc alloc;
  1.1144 -	int i;
  1.1145 -	size_t ps = alloc.GetPageSize();
  1.1146 -
  1.1147 -	char *test1[8];
  1.1148 -
  1.1149 -	for (i = 0; i < 8; ++i)
  1.1150 -		test1[i] = (char*) alloc.Alloc(ps / 4);
  1.1151 -
  1.1152 -	CHECK_COND(test1[1] == test1[0] + ps/4, "Part 1.1");
  1.1153 -	CHECK_COND(test1[2] == test1[1] + ps/4, "Part 1.2");
  1.1154 -	CHECK_COND(test1[3] == test1[2] + ps/4, "Part 1.3");
  1.1155 -
  1.1156 -	CHECK_COND(test1[5] == test1[4] + ps/4, "Part 1.4");
  1.1157 -	CHECK_COND(test1[6] == test1[5] + ps/4, "Part 1.5");
  1.1158 -	CHECK_COND(test1[7] == test1[6] + ps/4, "Part 1.6");
  1.1159 -
  1.1160 -	void *test2 = alloc.Alloc(ps * 3);
  1.1161 -
  1.1162 -	alloc.SetRW(test2);
  1.1163 -	memset(test2, 0, ps * 3);			// should not crash :)
  1.1164 -	alloc.SetRE(test2);
  1.1165 -
  1.1166 -	alloc.Free(test2);
  1.1167 -
  1.1168 -	// Dealloc a ps/4 block and place two ps/8 blocks into it
  1.1169 -	alloc.Free(test1[2]);
  1.1170 -
  1.1171 -	char *test3[2];
  1.1172 -	test3[0] = (char*) alloc.Alloc(ps / 8);
  1.1173 -	test3[1] = (char*) alloc.Alloc(ps / 8);
  1.1174 -
  1.1175 -	CHECK_COND(test3[0] == test1[2], "Part 2.1");
  1.1176 -	CHECK_COND(test3[1] == test1[2] + ps/8, "Part 2.2");
  1.1177 -
  1.1178 -	// Isolated
  1.1179 -	char *test4[8];
  1.1180 -	for (i = 0; i < 8; ++i)
  1.1181 -		test4[i] = (char*) alloc.AllocIsolated(ps / 4);
  1.1182 -
  1.1183 -	// -> The difference is at least one page
  1.1184 -	CHECK_COND(static_cast<size_t>(abs(test4[1] - test4[0])) >= ps, "Part 3.1");
  1.1185 -	CHECK_COND(static_cast<size_t>(abs(test4[2] - test4[1])) >= ps, "Part 3.2");
  1.1186 -	CHECK_COND(static_cast<size_t>(abs(test4[3] - test4[2])) >= ps, "Part 3.3");
  1.1187 -
  1.1188 -	CHECK_COND(static_cast<size_t>(abs(test4[5] - test4[4])) >= ps, "Part 3.4");
  1.1189 -	CHECK_COND(static_cast<size_t>(abs(test4[6] - test4[5])) >= ps, "Part 3.5");
  1.1190 -	CHECK_COND(static_cast<size_t>(abs(test4[7] - test4[6])) >= ps, "Part 3.6");
  1.1191 -
  1.1192 -	// Thus i can set everything except for test4[2] to RE and still write to test4[2]
  1.1193 -
  1.1194 -	alloc.SetRW(test4[2]);
  1.1195 -
  1.1196 -	alloc.SetRE(test4[0]);
  1.1197 -	alloc.SetRE(test4[1]);
  1.1198 -	alloc.SetRE(test4[3]);
  1.1199 -	alloc.SetRE(test4[4]);
  1.1200 -	alloc.SetRE(test4[5]);
  1.1201 -	alloc.SetRE(test4[6]);
  1.1202 -	alloc.SetRE(test4[7]);
  1.1203 -
  1.1204 -	memset((void*)test4[2], 0, ps / 4);
  1.1205 -
  1.1206 -	// alignement tests
  1.1207 -	CPageAlloc alloc1(1);
  1.1208 -	CPageAlloc alloc4(4);
  1.1209 -	CPageAlloc alloc16(16);
  1.1210 -
  1.1211 -	void *last1 = alloc1.Alloc(1);
  1.1212 -	void *last4 = alloc4.Alloc(4);
  1.1213 -	void *last16 = alloc16.Alloc(16);
  1.1214 -	void *cur;
  1.1215 -	for (int i = 0; i < 20; ++i)
  1.1216 -	{
  1.1217 -		cur = alloc1.Alloc(1);
  1.1218 -		CHECK_COND(reinterpret_cast<intptr_t>(cur) == reinterpret_cast<intptr_t>(last1) + 1, "Part 4.1");
  1.1219 -		last1 = cur;
  1.1220 -
  1.1221 -		cur = alloc4.Alloc(1);
  1.1222 -		CHECK_COND(reinterpret_cast<intptr_t>(cur) == reinterpret_cast<intptr_t>(last4) + 4, "Part 4.2");
  1.1223 -		last4 = cur;
  1.1224 -
  1.1225 -		cur = alloc16.Alloc(1);
  1.1226 -		CHECK_COND(reinterpret_cast<intptr_t>(cur) == reinterpret_cast<intptr_t>(last16) + 16, "Part 4.3");
  1.1227 -		last16 = cur;
  1.1228 -	}
  1.1229 -
  1.1230 -	alloc16.Free(alloc16.Alloc(1));
  1.1231 -	return true;
  1.1232 -}