Recently i wrote a couple of hooking functions...But Wow always stopped working frequently, about 1 or 2 times during the whole Dragon Soul encounter...Since it's not an error so i don't know what to do, but i finally find the function which cause this problem...so i need some help, what's wrong with this function ??
Code:
__declspec(naked) unsigned int __cdecl CHack::Lua::AddSpellVisualKitEffectHook ()
{
__asm
{
pushad //esp will decrease by 32
}
//unsigned int unKnownVisualKitID = 0;
unsigned int srcPointer;
int **SpellId;
int *SpellVisualId;
__asm
{
mov ebp,esp
sub esp,60 //make enough memory for local varibles
mov esi,[ebp + 32 + 4]
mov SpellId,esi
mov srcPointer,ecx
}
if (!IsBadReadPtr((void *)srcPointer,4) && !IsBadReadPtr(SpellId, 4) && !IsBadReadPtr(*SpellId, 4) && !IsBadReadPtr(*(SpellId + 1), 4))
{
char srcGUID[19];
SpellVisualId = *(SpellId + 1);
WowObject Obj = WowObject(srcPointer);
sprintf_s(srcGUID,"%#018llX",Obj.guid);
srcGUID[1] == 88 ? srcGUID[1] = 120:0 ;
reinterpret_cast<void (__cdecl*)(lua_State *L, char *s)>(CHack::WoWBase + l_pushstring)(*CHack::Lua::L,"SPELL_VISUALKIT_APPLIED");
reinterpret_cast<void (__cdecl*)(lua_State *L, char *s)>(CHack::WoWBase + l_pushstring)(*CHack::Lua::L,srcGUID);
reinterpret_cast<void (__cdecl*)(lua_State * a1, double a2)>(CHack::WoWBase + l_pushnumber)(*CHack::Lua::L, **SpellId);
reinterpret_cast<void (__cdecl*)(lua_State * a1, double a2)>(CHack::WoWBase + l_pushnumber)(*CHack::Lua::L, *SpellVisualId);
reinterpret_cast<int (__cdecl*)(int EventsID, lua_State *L, int NuArg)>(CHack::WoWBase + FrameScript_SignalEvent2)(480, *CHack::Lua::L, 4);
}
static unsigned int Address = WoWBase + AddEffectRelate + 0x9;
__asm
{
mov esp,ebp
popad
push ebp
mov ebp, esp
sub esp, 0FCh
jmp Address
}
}
i hooked the SpellVisualKit related function by this , and once a spellvisualkit is applied to a object, it will raise a lua Event to tell me ....it works well most of time....but why would this cause Wow stopped working?