2005-05-27 23:39:30 +02:00
|
|
|
// TESTBAIL
|
|
|
|
// Test for a bug Bail has found
|
|
|
|
|
|
|
|
#include "testbail.h"
|
|
|
|
|
|
|
|
void *___testbail_gabgab;
|
|
|
|
|
2005-10-05 23:51:02 +02:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
class zomg_lolz
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void zomg()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
SH_DECL_HOOK0_void(zomg_lolz, zomg, SH_NOATTRIB, 0);
|
|
|
|
void Handler()
|
|
|
|
{
|
2005-10-14 19:45:36 +02:00
|
|
|
SH_REMOVE_HOOK_STATICFUNC(zomg_lolz, zomg, META_IFACEPTR(zomg_lolz),
|
2005-10-05 23:51:02 +02:00
|
|
|
Handler, false);
|
|
|
|
}
|
|
|
|
void Handler2()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-05-27 23:39:30 +02:00
|
|
|
bool TestBail(std::string &error)
|
|
|
|
{
|
|
|
|
SourceHook::CSourceHookImpl g_SHImpl;
|
|
|
|
g_SHPtr = &g_SHImpl;
|
|
|
|
g_PLID = 1;
|
|
|
|
|
|
|
|
g_Gabgab = new IGaben;
|
|
|
|
___testbail_gabgab = (void*)g_Gabgab;
|
|
|
|
|
|
|
|
g_Gabgab->EatYams();
|
|
|
|
|
|
|
|
SH_ADD_HOOK_STATICFUNC(IGaben, EatYams, g_Gabgab, EatYams0_Handler, false);
|
|
|
|
|
|
|
|
g_Gabgab->EatYams();
|
|
|
|
|
|
|
|
___TestBail2();
|
|
|
|
|
|
|
|
g_Gabgab->EatYams();
|
|
|
|
|
|
|
|
SH_REMOVE_HOOK_STATICFUNC(IGaben, EatYams, g_Gabgab, EatYams0_Handler, false);
|
|
|
|
|
|
|
|
g_Gabgab->EatYams();
|
|
|
|
|
|
|
|
delete g_Gabgab;
|
|
|
|
|
|
|
|
// If it didn't crash, it's ok
|
|
|
|
|
2005-10-05 23:51:02 +02:00
|
|
|
// NEW TEST: Remove hook from handler
|
|
|
|
zomg_lolz inst;
|
|
|
|
SH_ADD_HOOK_STATICFUNC(zomg_lolz, zomg, &inst, Handler, false);
|
|
|
|
SH_ADD_HOOK_STATICFUNC(zomg_lolz, zomg, &inst, Handler2, false);
|
|
|
|
|
|
|
|
zomg_lolz *mwah = &inst;
|
|
|
|
mwah->zomg();
|
|
|
|
mwah->zomg();
|
|
|
|
|
|
|
|
SH_ADD_HOOK_STATICFUNC(zomg_lolz, zomg, &inst, Handler, false);
|
|
|
|
SH_REMOVE_HOOK_STATICFUNC(zomg_lolz, zomg, &inst, Handler2, false);
|
|
|
|
|
|
|
|
mwah->zomg();
|
|
|
|
mwah->zomg();
|
|
|
|
|
|
|
|
// Shouldn't crash again...
|
|
|
|
|
2005-05-27 23:39:30 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|