correct ISO for scoping

--HG--
extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/trunk%40512
This commit is contained in:
Pavol Marko 2007-10-14 12:28:28 +00:00
parent 27066fbb99
commit 0a47015744
2 changed files with 143 additions and 141 deletions

View File

@ -749,7 +749,8 @@ namespace SourceHook
oldctx->m_State = CHookContext::State_Dead; oldctx->m_State = CHookContext::State_Dead;
List<CVfnPtr*> &vfnptr_list = static_cast<CHookManager*>(hi)->GetVfnPtrList(); List<CVfnPtr*> &vfnptr_list = static_cast<CHookManager*>(hi)->GetVfnPtrList();
for (List<CVfnPtr*>::iterator vfnptr_iter = vfnptr_list.begin(); List<CVfnPtr*>::iterator vfnptr_iter;
for (vfnptr_iter = vfnptr_list.begin();
vfnptr_iter != vfnptr_list.end(); ++vfnptr_iter) vfnptr_iter != vfnptr_list.end(); ++vfnptr_iter)
{ {
if (**vfnptr_iter == vfnptr) if (**vfnptr_iter == vfnptr)
@ -805,7 +806,8 @@ namespace SourceHook
pCtx->pIface = NULL; pCtx->pIface = NULL;
List<CVfnPtr*> &vfnptr_list = static_cast<CHookManager*>(hi)->GetVfnPtrList(); List<CVfnPtr*> &vfnptr_list = static_cast<CHookManager*>(hi)->GetVfnPtrList();
for (List<CVfnPtr*>::iterator vfnptr_iter = vfnptr_list.begin(); List<CVfnPtr*>::iterator vfnptr_iter;
for (vfnptr_iter = vfnptr_list.begin();
vfnptr_iter != vfnptr_list.end(); ++vfnptr_iter) vfnptr_iter != vfnptr_list.end(); ++vfnptr_iter)
{ {
if (**vfnptr_iter == vfnptr) if (**vfnptr_iter == vfnptr)

View File

@ -30,76 +30,76 @@ namespace
MAKE_STATE_2(State_Func3_Post, IBase *, int); MAKE_STATE_2(State_Func3_Post, IBase *, int);
class IBase class IBase
{ {
public: public:
virtual void Func1() = 0; virtual void Func1() = 0;
virtual void Func2() = 0; virtual void Func2() = 0;
virtual void Func3(int x) = 0; virtual void Func3(int x) = 0;
}; };
class CDerived1 : public IBase class CDerived1 : public IBase
{ {
public: public:
virtual void Func1() virtual void Func1()
{ {
ADD_STATE(State_D1_Func1(this)); ADD_STATE(State_D1_Func1(this));
} }
virtual void Func2() virtual void Func2()
{ {
ADD_STATE(State_D1_Func2(this)); ADD_STATE(State_D1_Func2(this));
} }
virtual void Func3(int x) virtual void Func3(int x)
{ {
ADD_STATE(State_D1_Func3(this, x)); ADD_STATE(State_D1_Func3(this, x));
} }
}; };
class CDerived2 : public IBase class CDerived2 : public IBase
{ {
public: public:
virtual void Func1() virtual void Func1()
{ {
ADD_STATE(State_D2_Func1(this)); ADD_STATE(State_D2_Func1(this));
} }
virtual void Func2() virtual void Func2()
{ {
ADD_STATE(State_D2_Func2(this)); ADD_STATE(State_D2_Func2(this));
} }
virtual void Func3(int x) virtual void Func3(int x)
{ {
ADD_STATE(State_D2_Func3(this, x)); ADD_STATE(State_D2_Func3(this, x));
} }
}; };
void Handler_Func1_Pre() void Handler_Func1_Pre()
{ {
ADD_STATE(State_Func1_Pre(META_IFACEPTR(IBase))); ADD_STATE(State_Func1_Pre(META_IFACEPTR(IBase)));
} }
void Handler_Func1_Post() void Handler_Func1_Post()
{ {
ADD_STATE(State_Func1_Post(META_IFACEPTR(IBase))); ADD_STATE(State_Func1_Post(META_IFACEPTR(IBase)));
} }
int g_F2_Pre_HookToRemove = 0; int g_F2_Pre_HookToRemove = 0;
void Handler_Func2_Pre() void Handler_Func2_Pre()
{ {
ADD_STATE(State_Func2_Pre(META_IFACEPTR(IBase))); ADD_STATE(State_Func2_Pre(META_IFACEPTR(IBase)));
SH_REMOVE_HOOK_ID(g_F2_Pre_HookToRemove); SH_REMOVE_HOOK_ID(g_F2_Pre_HookToRemove);
} }
void Handler_Func2_Post() void Handler_Func2_Post()
{ {
ADD_STATE(State_Func2_Post(META_IFACEPTR(IBase))); ADD_STATE(State_Func2_Post(META_IFACEPTR(IBase)));
} }
void Handler_Func3_Pre(int x) void Handler_Func3_Pre(int x)
{ {
ADD_STATE(State_Func3_Pre(META_IFACEPTR(IBase), x)); ADD_STATE(State_Func3_Pre(META_IFACEPTR(IBase), x));
RETURN_META_NEWPARAMS(MRES_IGNORED, &IBase::Func3, (x+1)); RETURN_META_NEWPARAMS(MRES_IGNORED, &IBase::Func3, (x+1));
} }
void Handler_Func3_Post(int x) void Handler_Func3_Post(int x)
{ {
ADD_STATE(State_Func3_Post(META_IFACEPTR(IBase), x)); ADD_STATE(State_Func3_Post(META_IFACEPTR(IBase), x));
} }
SH_DECL_HOOK0_void(IBase, Func1, SH_NOATTRIB, 0); SH_DECL_HOOK0_void(IBase, Func1, SH_NOATTRIB, 0);
@ -110,24 +110,24 @@ namespace
} }
bool TestVPHooks(std::string &error) bool TestVPHooks(std::string &error)
{ {
GET_SHPTR(g_SHPtr); GET_SHPTR(g_SHPtr);
g_PLID = 1337; g_PLID = 1337;
CDerived1 d1i1; CDerived1 d1i1;
CDerived1 d1i2; CDerived1 d1i2;
CDerived2 d2i1; CDerived2 d2i1;
IBase *p_d1i1 = &d1i1; IBase *p_d1i1 = &d1i1;
IBase *p_d1i2 = &d1i2; IBase *p_d1i2 = &d1i2;
IBase *p_d2i1 = &d2i1; IBase *p_d2i1 = &d2i1;
int hook1 = SH_ADD_VPHOOK(IBase, Func1, p_d1i1, SH_STATIC(Handler_Func1_Pre), false); int hook1 = SH_ADD_VPHOOK(IBase, Func1, p_d1i1, SH_STATIC(Handler_Func1_Pre), false);
p_d1i1->Func1(); p_d1i1->Func1();
p_d1i2->Func1(); p_d1i2->Func1();
p_d2i1->Func1(); p_d2i1->Func1();
CHECK_STATES((&g_States, CHECK_STATES((&g_States,
new State_Func1_Pre(p_d1i1), new State_Func1_Pre(p_d1i1),
new State_D1_Func1(p_d1i1), new State_D1_Func1(p_d1i1),
@ -136,33 +136,32 @@ bool TestVPHooks(std::string &error)
new State_D1_Func1(p_d1i2), new State_D1_Func1(p_d1i2),
new State_D2_Func1(p_d2i1), new State_D2_Func1(p_d2i1),
NULL), "Part 1"); NULL), "Part 1");
SH_REMOVE_HOOK_ID(hook1); SH_REMOVE_HOOK_ID(hook1);
p_d1i1->Func1(); p_d1i1->Func1();
p_d1i2->Func1(); p_d1i2->Func1();
p_d2i1->Func1(); p_d2i1->Func1();
CHECK_STATES((&g_States, CHECK_STATES((&g_States,
new State_D1_Func1(p_d1i1), new State_D1_Func1(p_d1i1),
new State_D1_Func1(p_d1i2), new State_D1_Func1(p_d1i2),
new State_D2_Func1(p_d2i1), new State_D2_Func1(p_d2i1),
NULL), "Part 2"); NULL), "Part 2");
// Normal hook, then vp hook
// Normal hook, then vp hook
int hook2 = SH_ADD_HOOK(IBase, Func1, p_d1i1, SH_STATIC(Handler_Func1_Pre), false);
int hook2 = SH_ADD_HOOK(IBase, Func1, p_d1i1, SH_STATIC(Handler_Func1_Pre), false); hook1 = SH_ADD_VPHOOK(IBase, Func1, p_d1i1, SH_STATIC(Handler_Func1_Pre), false);
hook1 = SH_ADD_VPHOOK(IBase, Func1, p_d1i1, SH_STATIC(Handler_Func1_Pre), false);
p_d1i1->Func1();
p_d1i1->Func1(); p_d1i2->Func1();
p_d1i2->Func1(); p_d2i1->Func1();
p_d2i1->Func1();
CHECK_STATES((&g_States, CHECK_STATES((&g_States,
new State_Func1_Pre(p_d1i1), new State_Func1_Pre(p_d1i1),
new State_Func1_Pre(p_d1i1), new State_Func1_Pre(p_d1i1),
@ -172,14 +171,14 @@ bool TestVPHooks(std::string &error)
new State_D1_Func1(p_d1i2), new State_D1_Func1(p_d1i2),
new State_D2_Func1(p_d2i1), new State_D2_Func1(p_d2i1),
NULL), "Part 3"); NULL), "Part 3");
SH_REMOVE_HOOK_ID(hook1); SH_REMOVE_HOOK_ID(hook1);
p_d1i1->Func1(); p_d1i1->Func1();
p_d1i2->Func1(); p_d1i2->Func1();
p_d2i1->Func1(); p_d2i1->Func1();
CHECK_STATES((&g_States, CHECK_STATES((&g_States,
new State_Func1_Pre(p_d1i1), new State_Func1_Pre(p_d1i1),
new State_D1_Func1(p_d1i1), new State_D1_Func1(p_d1i1),
@ -187,33 +186,33 @@ bool TestVPHooks(std::string &error)
new State_D1_Func1(p_d1i2), new State_D1_Func1(p_d1i2),
new State_D2_Func1(p_d2i1), new State_D2_Func1(p_d2i1),
NULL), "Part 4"); NULL), "Part 4");
SH_REMOVE_HOOK_ID(hook2); SH_REMOVE_HOOK_ID(hook2);
p_d1i1->Func1(); p_d1i1->Func1();
p_d1i2->Func1(); p_d1i2->Func1();
p_d2i1->Func1(); p_d2i1->Func1();
CHECK_STATES((&g_States, CHECK_STATES((&g_States,
new State_D1_Func1(p_d1i1), new State_D1_Func1(p_d1i1),
new State_D1_Func1(p_d1i2), new State_D1_Func1(p_d1i2),
new State_D2_Func1(p_d2i1), new State_D2_Func1(p_d2i1),
NULL), "Part 5"); NULL), "Part 5");
// Test this: // Test this:
// Normal hook AND vp hook on Func2 // Normal hook AND vp hook on Func2
// Func2's pre handler removes the VP hook. // Func2's pre handler removes the VP hook.
hook1 = SH_ADD_VPHOOK(IBase, Func2, p_d1i1, SH_STATIC(Handler_Func2_Pre), false); hook1 = SH_ADD_VPHOOK(IBase, Func2, p_d1i1, SH_STATIC(Handler_Func2_Pre), false);
hook2 = SH_ADD_HOOK(IBase, Func2, p_d1i1, SH_STATIC(Handler_Func2_Pre), false); hook2 = SH_ADD_HOOK(IBase, Func2, p_d1i1, SH_STATIC(Handler_Func2_Pre), false);
g_F2_Pre_HookToRemove = hook1; g_F2_Pre_HookToRemove = hook1;
p_d1i1->Func2(); p_d1i1->Func2();
p_d1i1->Func2(); p_d1i1->Func2();
CHECK_STATES((&g_States, CHECK_STATES((&g_States,
new State_Func2_Pre(p_d1i1), new State_Func2_Pre(p_d1i1),
new State_D1_Func2(p_d1i1), new State_D1_Func2(p_d1i1),
@ -221,22 +220,22 @@ bool TestVPHooks(std::string &error)
new State_Func2_Pre(p_d1i1), new State_Func2_Pre(p_d1i1),
new State_D1_Func2(p_d1i1), new State_D1_Func2(p_d1i1),
NULL), "Part 6"); NULL), "Part 6");
SH_REMOVE_HOOK_ID(hook1); SH_REMOVE_HOOK_ID(hook1);
// Hook function 3: // Hook function 3:
// Using manualhook, VP // Using manualhook, VP
hook1 = SH_ADD_MANUALVPHOOK(IBase_Func3_Manual, p_d1i1, SH_STATIC(Handler_Func3_Pre), false); hook1 = SH_ADD_MANUALVPHOOK(IBase_Func3_Manual, p_d1i1, SH_STATIC(Handler_Func3_Pre), false);
// Normally, VP // Normally, VP
hook2 = SH_ADD_VPHOOK(IBase, Func3, p_d1i1, SH_STATIC(Handler_Func3_Pre), false); hook2 = SH_ADD_VPHOOK(IBase, Func3, p_d1i1, SH_STATIC(Handler_Func3_Pre), false);
// Normally, no VP // Normally, no VP
int hook3 = SH_ADD_HOOK(IBase, Func3, p_d1i1, SH_STATIC(Handler_Func3_Pre), false); int hook3 = SH_ADD_HOOK(IBase, Func3, p_d1i1, SH_STATIC(Handler_Func3_Pre), false);
p_d1i1->Func3(1); p_d1i1->Func3(1);
CHECK_STATES((&g_States, CHECK_STATES((&g_States,
new State_Func3_Pre(p_d1i1, 1), // manual vp hook new State_Func3_Pre(p_d1i1, 1), // manual vp hook
new State_Func3_Pre(p_d1i1, 2), // normal vp hook new State_Func3_Pre(p_d1i1, 2), // normal vp hook
@ -244,17 +243,18 @@ bool TestVPHooks(std::string &error)
new State_D1_Func3(p_d1i1, 4), // function new State_D1_Func3(p_d1i1, 4), // function
NULL), "Part 7.1"); NULL), "Part 7.1");
p_d1i2->Func3(1); p_d1i2->Func3(1);
CHECK_STATES((&g_States, CHECK_STATES((&g_States,
new State_Func3_Pre(p_d1i2, 1), // manual vp hook new State_Func3_Pre(p_d1i2, 1), // manual vp hook
new State_Func3_Pre(p_d1i2, 2), // normal vp hook new State_Func3_Pre(p_d1i2, 2), // normal vp hook
new State_D1_Func3(p_d1i2, 3), // function new State_D1_Func3(p_d1i2, 3), // function
NULL), "Part 7.2"); NULL), "Part 7.2");
return true; return true;
} }