2 // = calling hooks from hook handlers, etc
5 #include "sourcehook_test.h"
6 #include "testevents.h"
11 SourceHook::ISourceHook *g_SHPtr;
12 SourceHook::Plugin g_PLID;
32 // param1: This pointer
33 MAKE_STATE_1(State_C1_F, C1*);
34 MAKE_STATE_1(State_C2_F, C2*);
35 MAKE_STATE_1(State_C3_F, C3*);
36 MAKE_STATE_1(State_C4_F, C4*);
37 MAKE_STATE_1(State_C5_F, C5*);
38 MAKE_STATE_1(State_C6_F, C6*);
39 MAKE_STATE_1(State_C7_F, C7*);
40 MAKE_STATE_1(State_C8_F, C8*);
42 MAKE_STATE_1(State_C1_G, C1*);
43 MAKE_STATE_1(State_C2_G, C2*);
44 MAKE_STATE_1(State_C3_G, C3*);
45 MAKE_STATE_1(State_C4_G, C4*);
46 MAKE_STATE_1(State_C5_G, C5*);
47 MAKE_STATE_1(State_C6_G, C6*);
48 MAKE_STATE_1(State_C7_G, C7*);
49 MAKE_STATE_1(State_C8_G, C8*);
51 MAKE_STATE_1(State_H_C1_F, C1*);
52 MAKE_STATE_1(State_H_C2_F, C2*);
53 MAKE_STATE_1(State_H_C3_F, C3*);
54 MAKE_STATE_1(State_H_C4_F, C4*);
55 MAKE_STATE_1(State_H_C5_F, C5*);
56 MAKE_STATE_1(State_H_C6_F, C6*);
57 MAKE_STATE_1(State_H_C7_F, C7*);
58 MAKE_STATE_1(State_H_C8_F, C8*);
60 MAKE_STATE_1(State_H_C1_G, C1*);
61 MAKE_STATE_1(State_H_C2_G, C2*);
62 MAKE_STATE_1(State_H_C3_G, C3*);
63 MAKE_STATE_1(State_H_C4_G, C4*);
64 MAKE_STATE_1(State_H_C5_G, C5*);
65 MAKE_STATE_1(State_H_C6_G, C6*);
66 MAKE_STATE_1(State_H_C7_G, C7*);
67 MAKE_STATE_1(State_H_C8_G, C8*);
69 MAKE_STATE_1(State_H2_C4_G, C4*);
77 ADD_STATE(State_C1_F(this));
81 ADD_STATE(State_C1_G(this));
90 ADD_STATE(State_C2_F(this));
94 ADD_STATE(State_C2_G(this));
102 ADD_STATE(State_C3_F(this));
106 ADD_STATE(State_C3_G(this));
114 ADD_STATE(State_C4_F(this));
118 ADD_STATE(State_C4_G(this));
126 ADD_STATE(State_C5_F(this));
130 ADD_STATE(State_C5_G(this));
138 ADD_STATE(State_C6_F(this));
142 ADD_STATE(State_C6_G(this));
150 ADD_STATE(State_C7_F(this));
154 ADD_STATE(State_C7_G(this));
162 ADD_STATE(State_C8_F(this));
166 ADD_STATE(State_C8_G(this));
171 struct C1_Derived : public C1 {};
172 struct C2_Derived : public C2 {};
173 struct C3_Derived : public C3 {};
174 struct C4_Derived : public C4 {};
175 struct C5_Derived : public C5 {};
176 struct C6_Derived : public C6 {};
177 struct C7_Derived : public C7 {};
178 struct C8_Derived : public C8 {};
180 SH_DECL_HOOK0_void(C1, F, SH_NOATTRIB, 0);
181 SH_DECL_HOOK0(C1, G, SH_NOATTRIB, 0, int);
182 SH_DECL_HOOK0_void(C2, F, SH_NOATTRIB, 0);
183 SH_DECL_HOOK0(C2, G, SH_NOATTRIB, 0, int);
184 SH_DECL_HOOK0_void(C3, F, SH_NOATTRIB, 0);
185 SH_DECL_HOOK0(C3, G, SH_NOATTRIB, 0, int);
186 SH_DECL_HOOK0_void(C4, F, SH_NOATTRIB, 0);
187 SH_DECL_HOOK0(C4, G, SH_NOATTRIB, 0, int);
188 SH_DECL_HOOK0_void(C5, F, SH_NOATTRIB, 0);
189 SH_DECL_HOOK0(C5, G, SH_NOATTRIB, 0, int);
190 SH_DECL_HOOK0_void(C6, F, SH_NOATTRIB, 0);
191 SH_DECL_HOOK0(C6, G, SH_NOATTRIB, 0, int);
192 SH_DECL_HOOK0_void(C7, F, SH_NOATTRIB, 0);
193 SH_DECL_HOOK0(C7, G, SH_NOATTRIB, 0, int);
194 SH_DECL_HOOK0_void(C8, F, SH_NOATTRIB, 0);
195 SH_DECL_HOOK0(C8, G, SH_NOATTRIB, 0, int);
199 ADD_STATE(State_H_C1_F(META_IFACEPTR(C1)));
204 ADD_STATE(State_H_C1_G(META_IFACEPTR(C1)));
210 ADD_STATE(State_H_C2_F(META_IFACEPTR(C2)));
215 ADD_STATE(State_H_C2_G(META_IFACEPTR(C2)));
221 ADD_STATE(State_H_C3_F(META_IFACEPTR(C3)));
226 ADD_STATE(State_H_C3_G(META_IFACEPTR(C3)));
232 ADD_STATE(State_H_C4_F(META_IFACEPTR(C4)));
237 ADD_STATE(State_H_C4_G(META_IFACEPTR(C4)));
243 ADD_STATE(State_H2_C4_G(META_IFACEPTR(C4)));
248 ADD_STATE(State_H_C5_F(META_IFACEPTR(C5)));
253 ADD_STATE(State_H_C5_G(META_IFACEPTR(C5)));
259 ADD_STATE(State_H_C6_F(META_IFACEPTR(C6)));
264 ADD_STATE(State_H_C6_G(META_IFACEPTR(C6)));
270 if (g_TestID == 1 || g_TestID == 2)
271 SH_REMOVE_HOOK(C4, G, g_pC4, SH_STATIC(Handler2_C4_G), false);
273 SH_REMOVE_HOOK(C4, G, g_pC4, SH_STATIC(Handler_C4_G), false);
275 ADD_STATE(State_H_C7_F(META_IFACEPTR(C7)));
280 ADD_STATE(State_H_C7_G(META_IFACEPTR(C7)));
286 ADD_STATE(State_H_C8_F(META_IFACEPTR(C8)));
291 ADD_STATE(State_H_C8_G(META_IFACEPTR(C8)));
305 bool TestReentr(std::string &error)
319 SH_ADD_HOOK(C1, F, g_pC1, SH_STATIC(Handler_C1_F), false);
320 SH_ADD_HOOK(C1, G, g_pC1, SH_STATIC(Handler_C1_G), false);
321 SH_ADD_HOOK(C2, F, g_pC2, SH_STATIC(Handler_C2_F), false);
322 SH_ADD_HOOK(C2, G, g_pC2, SH_STATIC(Handler_C2_G), false);
323 SH_ADD_HOOK(C3, F, g_pC3, SH_STATIC(Handler_C3_F), false);
324 SH_ADD_HOOK(C3, G, g_pC3, SH_STATIC(Handler_C3_G), false);
325 SH_ADD_HOOK(C4, F, g_pC4, SH_STATIC(Handler_C4_F), false);
326 SH_ADD_HOOK(C4, G, g_pC4, SH_STATIC(Handler_C4_G), false);
327 SH_ADD_HOOK(C5, F, g_pC5, SH_STATIC(Handler_C5_F), false);
328 SH_ADD_HOOK(C5, G, g_pC5, SH_STATIC(Handler_C5_G), false);
329 SH_ADD_HOOK(C6, F, g_pC6, SH_STATIC(Handler_C6_F), false);
330 SH_ADD_HOOK(C6, G, g_pC6, SH_STATIC(Handler_C6_G), false);
331 SH_ADD_HOOK(C7, F, g_pC7, SH_STATIC(Handler_C7_F), false);
332 SH_ADD_HOOK(C7, G, g_pC7, SH_STATIC(Handler_C7_G), false);
333 SH_ADD_HOOK(C8, F, g_pC8, SH_STATIC(Handler_C8_F), false);
334 SH_ADD_HOOK(C8, G, g_pC8, SH_STATIC(Handler_C8_G), false);
338 CHECK_STATES((&g_States,
339 new State_H_C1_F(g_pC1),
340 new State_H_C1_G(g_pC1),
341 new State_H_C2_F(g_pC2),
342 new State_H_C2_G(g_pC2),
343 new State_H_C3_F(g_pC3),
344 new State_H_C3_G(g_pC3),
345 new State_H_C4_F(g_pC4),
346 new State_H_C4_G(g_pC4),
347 new State_H_C5_F(g_pC5),
348 new State_H_C5_G(g_pC5),
349 new State_H_C6_F(g_pC6),
350 new State_H_C6_G(g_pC6),
351 new State_H_C7_F(g_pC7),
352 new State_H_C7_G(g_pC7),
353 new State_H_C8_F(g_pC8),
354 new State_H_C8_G(g_pC8),
355 new State_C8_G(g_pC8),
356 new State_C8_F(g_pC8),
357 new State_C7_G(g_pC7),
358 new State_C7_F(g_pC7),
359 new State_C6_G(g_pC6),
360 new State_C6_F(g_pC6),
361 new State_C5_G(g_pC5),
362 new State_C5_F(g_pC5),
363 new State_C4_G(g_pC4),
364 new State_C4_F(g_pC4),
365 new State_C3_G(g_pC3),
366 new State_C3_F(g_pC3),
367 new State_C2_G(g_pC2),
368 new State_C2_F(g_pC2),
369 new State_C1_G(g_pC1),
370 new State_C1_F(g_pC1),
374 SH_ADD_HOOK(C4, G, g_pC4, SH_STATIC(Handler2_C4_G), false);
378 CHECK_STATES((&g_States,
379 new State_H_C1_F(g_pC1),
380 new State_H_C1_G(g_pC1),
381 new State_H_C2_F(g_pC2),
382 new State_H_C2_G(g_pC2),
383 new State_H_C3_F(g_pC3),
384 new State_H_C3_G(g_pC3),
385 new State_H_C4_F(g_pC4),
386 new State_H_C4_G(g_pC4),
387 new State_H_C5_F(g_pC5),
388 new State_H_C5_G(g_pC5),
389 new State_H_C6_F(g_pC6),
390 new State_H_C6_G(g_pC6),
391 new State_H_C7_F(g_pC7),
392 new State_H_C7_G(g_pC7),
393 new State_H_C8_F(g_pC8),
394 new State_H_C8_G(g_pC8),
395 new State_C8_G(g_pC8),
396 new State_C8_F(g_pC8),
397 new State_C7_G(g_pC7),
398 new State_C7_F(g_pC7),
399 new State_C6_G(g_pC6),
400 new State_C6_F(g_pC6),
401 new State_C5_G(g_pC5),
402 new State_C5_F(g_pC5),
403 new State_H2_C4_G(g_pC4),
404 new State_C4_G(g_pC4),
405 new State_C4_F(g_pC4),
406 new State_C3_G(g_pC3),
407 new State_C3_F(g_pC3),
408 new State_C2_G(g_pC2),
409 new State_C2_F(g_pC2),
410 new State_C1_G(g_pC1),
411 new State_C1_F(g_pC1),
416 CHECK_STATES((&g_States,
417 new State_H_C1_F(g_pC1),
418 new State_H_C1_G(g_pC1),
419 new State_H_C2_F(g_pC2),
420 new State_H_C2_G(g_pC2),
421 new State_H_C3_F(g_pC3),
422 new State_H_C3_G(g_pC3),
423 new State_H_C4_F(g_pC4),
424 new State_H_C4_G(g_pC4),
425 new State_H_C5_F(g_pC5),
426 new State_H_C5_G(g_pC5),
427 new State_H_C6_F(g_pC6),
428 new State_H_C6_G(g_pC6),
429 new State_H_C7_F(g_pC7),
430 new State_H_C7_G(g_pC7),
431 new State_H_C8_F(g_pC8),
432 new State_H_C8_G(g_pC8),
433 new State_C8_G(g_pC8),
434 new State_C8_F(g_pC8),
435 new State_C7_G(g_pC7),
436 new State_C7_F(g_pC7),
437 new State_C6_G(g_pC6),
438 new State_C6_F(g_pC6),
439 new State_C5_G(g_pC5),
440 new State_C5_F(g_pC5),
441 new State_H2_C4_G(g_pC4),
442 new State_C4_G(g_pC4),
443 new State_C4_F(g_pC4),
444 new State_C3_G(g_pC3),
445 new State_C3_F(g_pC3),
446 new State_C2_G(g_pC2),
447 new State_C2_F(g_pC2),
448 new State_C1_G(g_pC1),
449 new State_C1_F(g_pC1),
456 CHECK_STATES((&g_States,
457 new State_H_C1_F(g_pC1),
458 new State_H_C1_G(g_pC1),
459 new State_H_C2_F(g_pC2),
460 new State_H_C2_G(g_pC2),
461 new State_H_C3_F(g_pC3),
462 new State_H_C3_G(g_pC3),
463 new State_H_C4_F(g_pC4),
464 new State_H_C4_G(g_pC4),
465 new State_H_C5_F(g_pC5),
466 new State_H_C5_G(g_pC5),
467 new State_H_C6_F(g_pC6),
468 new State_H_C6_G(g_pC6),
469 new State_H_C7_F(g_pC7),
470 new State_H_C7_G(g_pC7),
471 new State_H_C8_F(g_pC8),
472 new State_H_C8_G(g_pC8),
473 new State_C8_G(g_pC8),
474 new State_C8_F(g_pC8),
475 new State_C7_G(g_pC7),
476 new State_C7_F(g_pC7),
477 new State_C6_G(g_pC6),
478 new State_C6_F(g_pC6),
479 new State_C5_G(g_pC5),
480 new State_C5_F(g_pC5),
481 new State_C4_G(g_pC4),
482 new State_C4_F(g_pC4),
483 new State_C3_G(g_pC3),
484 new State_C3_F(g_pC3),
485 new State_C2_G(g_pC2),
486 new State_C2_F(g_pC2),
487 new State_C1_G(g_pC1),
488 new State_C1_F(g_pC1),
493 CHECK_STATES((&g_States,
494 new State_H_C1_F(g_pC1),
495 new State_H_C1_G(g_pC1),
496 new State_H_C2_F(g_pC2),
497 new State_H_C2_G(g_pC2),
498 new State_H_C3_F(g_pC3),
499 new State_H_C3_G(g_pC3),
500 new State_H_C4_F(g_pC4),
501 new State_H_C4_G(g_pC4),
502 new State_H_C5_F(g_pC5),
503 new State_H_C5_G(g_pC5),
504 new State_H_C6_F(g_pC6),
505 new State_H_C6_G(g_pC6),
506 new State_H_C7_F(g_pC7),
507 new State_H_C7_G(g_pC7),
508 new State_H_C8_F(g_pC8),
509 new State_H_C8_G(g_pC8),
510 new State_C8_G(g_pC8),
511 new State_C8_F(g_pC8),
512 new State_C7_G(g_pC7),
513 new State_C7_F(g_pC7),
514 new State_C6_G(g_pC6),
515 new State_C6_F(g_pC6),
516 new State_C5_G(g_pC5),
517 new State_C5_F(g_pC5),
518 new State_C4_G(g_pC4),
519 new State_C4_F(g_pC4),
520 new State_C3_G(g_pC3),
521 new State_C3_F(g_pC3),
522 new State_C2_G(g_pC2),
523 new State_C2_F(g_pC2),
524 new State_C1_G(g_pC1),
525 new State_C1_F(g_pC1),
530 SH_ADD_HOOK(C4, G, g_pC4, SH_STATIC(Handler2_C4_G), false);
536 CHECK_STATES((&g_States,
537 new State_H_C1_F(g_pC1),
538 new State_H_C1_G(g_pC1),
539 new State_H_C2_F(g_pC2),
540 new State_H_C2_G(g_pC2),
541 new State_H_C3_F(g_pC3),
542 new State_H_C3_G(g_pC3),
543 new State_H_C4_F(g_pC4),
544 new State_H_C4_G(g_pC4),
545 new State_H_C5_F(g_pC5),
546 new State_H_C5_G(g_pC5),
547 new State_H_C6_F(g_pC6),
548 new State_H_C6_G(g_pC6),
549 new State_H_C7_F(g_pC7),
550 new State_H_C7_G(g_pC7),
551 new State_H_C8_F(g_pC8),
552 new State_H_C8_G(g_pC8),
553 new State_C8_G(g_pC8),
554 new State_C8_F(g_pC8),
555 new State_C7_G(g_pC7),
556 new State_C7_F(g_pC7),
557 new State_C6_G(g_pC6),
558 new State_C6_F(g_pC6),
559 new State_C5_G(g_pC5),
560 new State_C5_F(g_pC5),
561 new State_C4_G(g_pC4),
562 new State_C4_F(g_pC4),
563 new State_C3_G(g_pC3),
564 new State_C3_F(g_pC3),
565 new State_C2_G(g_pC2),
566 new State_C2_F(g_pC2),
567 new State_C1_G(g_pC1),
568 new State_C1_F(g_pC1),
573 CHECK_STATES((&g_States,
574 new State_H_C1_F(g_pC1),
575 new State_H_C1_G(g_pC1),
576 new State_H_C2_F(g_pC2),
577 new State_H_C2_G(g_pC2),
578 new State_H_C3_F(g_pC3),
579 new State_H_C3_G(g_pC3),
580 new State_H_C4_F(g_pC4),
581 new State_C4_G(g_pC4),
582 new State_C4_F(g_pC4),
583 new State_C3_G(g_pC3),
584 new State_C3_F(g_pC3),
585 new State_C2_G(g_pC2),
586 new State_C2_F(g_pC2),
587 new State_C1_G(g_pC1),
588 new State_C1_F(g_pC1),
591 SH_REMOVE_HOOK(C1, F, g_pC1, SH_STATIC(Handler_C1_F), false);
592 SH_REMOVE_HOOK(C1, G, g_pC1, SH_STATIC(Handler_C1_G), false);
593 SH_REMOVE_HOOK(C2, F, g_pC2, SH_STATIC(Handler_C2_F), false);
594 SH_REMOVE_HOOK(C2, G, g_pC2, SH_STATIC(Handler_C2_G), false);
595 SH_REMOVE_HOOK(C3, F, g_pC3, SH_STATIC(Handler_C3_F), false);
596 SH_REMOVE_HOOK(C3, G, g_pC3, SH_STATIC(Handler_C3_G), false);
597 SH_REMOVE_HOOK(C4, F, g_pC4, SH_STATIC(Handler_C4_F), false);
598 SH_REMOVE_HOOK(C4, G, g_pC4, SH_STATIC(Handler_C4_G), false);
599 SH_REMOVE_HOOK(C5, F, g_pC5, SH_STATIC(Handler_C5_F), false);
600 SH_REMOVE_HOOK(C5, G, g_pC5, SH_STATIC(Handler_C5_G), false);
601 SH_REMOVE_HOOK(C6, F, g_pC6, SH_STATIC(Handler_C6_F), false);
602 SH_REMOVE_HOOK(C6, G, g_pC6, SH_STATIC(Handler_C6_G), false);
603 SH_REMOVE_HOOK(C7, F, g_pC7, SH_STATIC(Handler_C7_F), false);
604 SH_REMOVE_HOOK(C7, G, g_pC7, SH_STATIC(Handler_C7_G), false);
605 SH_REMOVE_HOOK(C8, F, g_pC8, SH_STATIC(Handler_C8_F), false);
606 SH_REMOVE_HOOK(C8, G, g_pC8, SH_STATIC(Handler_C8_G), false);