Despite you can get information about all units from descriptors...But still it's trouble-some to write codes about all descriptors
So i write this,i noticed that most UnitXXX functions will call GetGUIDByKeyWord function ,transforming UID to GUID, So i hook it ...
After hooking... you can pass UID directly to UnitXXX functions...which means UnitHealth("target") and UnitHealth(UnitGUID("target")) return the same value
By the way,I need to abreact...... local varibles allocation on stack by myself is really annoyed
All offsets you need is in dump threads, So i won't list them here
Attention:All Asm codes will vary from Wow Version..You need to go into IDA and check them.. How to analyst IDA is beyond our discussion.So go to look it up in IDA-related books
Then Codes below:
Code:
// GetGuidByKeyWord Hook , Jump to my own function
Memory::Write<byte>(WoWBase + GetGUIDByKeyWord , 0xE9);
Memory::Write<int>(WoWBase + GetGUIDByKeyWord + 1, reinterpret_cast<unsigned int>(Lua::GetGuidByKeyHook) - (WoWBase + GetGUIDByKeyWord + 4 + 1));
Code:
__declspec(naked) unsigned int __cdecl CHack::Lua::GetGuidByKeyHook ()
{
__asm
{
pushad //esp will decrease by 32
}
char *s;
__int64* guid;
__asm
{
mov ebp,esp
sub esp,24 //make enough memory for local varibles
mov ecx,[ebp+36] //first argument of GetGuidByKeyWord ,since esp decreased 32, so you need plus 36 instead of 4
mov edx,[ebp+40] //second argument of GetGuidByKeyWord
mov s,ecx
mov guid,edx
}
if(IsBadReadPtr(s,100) || !checkGUID(s)) //Sometimes the caller will pass a invalid pointer....Damn it....
{
static unsigned int Address = WoWBase + GetGUIDByKeyWord + 0x5;
__asm
{
mov esp,ebp
popad
push ebp
mov ebp,esp
push ecx
push edi
jmp Address //argument is not a GUID , so does nothing and jump back
}
}
else
{
sscanf_s(s, "%llx", guid);
unsigned int ObjPtr = reinterpret_cast<unsigned int (__cdecl*)(__int64 guid,char mask,char * file,int line)>(CHack::WoWBase + ClntObjMgrObjectPtr)(guid,(char)0xFF,".\\ScriptEvents.cpp",348);
if (*(char *)(ObjPtr + ObjectType) != Type_Player && *(char *)(ObjPtr + ObjectType) != Type_NPC) //Since All UnitIDs such as "target" "focus" represent NPC or Player.. So i check here to avoid crash
{
static unsigned int Address = WoWBase + GetGUIDByKeyWord + 0x5;
__asm
{
mov esp,ebp
popad
push ebp
mov ebp,esp
push ecx
push edi
jmp Address //GUID doesn't represent a NPC or Player, so does nothing and jump back
}
}
else
{
static unsigned int Address = WoWBase + GetGUIDByKeyWord + 0x474;
__asm
{
mov esp,ebp
popad
mov al, 1
jmp Address
}
}
}
}