I wish to make a hack in order to add a function called to target unit by GUID, taking the place of an WoW API Function. So that my in-game addon can call it(The API Name but the new effect just as targetbyguid)! Is it possible? and how?
I wish to make a hack in order to add a function called to target unit by GUID, taking the place of an WoW API Function. So that my in-game addon can call it(The API Name but the new effect just as targetbyguid)! Is it possible? and how?
I cannot decipher your post. Do you want to create a new lua function or replace an existing one? The actual implementation should be pretty trivial, CGGameUI__Target's only parameter is a GUID. Your only issue should be passing the GUID properly, can lua functions take longs as parameters or do you have to pass it as a string?
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - Martin Golding
"I cried a little earlier when I had to poop" - Sku
thx for explanations... my english isnt very good sry... I mean is there a way to implement "targetunitbyguid" in addons? no matter whether to replace exisiting ones or to create new ones...
You mentioned "CGGameUI__Target", but how can i call it in LUA Addons?
You would have to register a function into the lua engine. The functions are all in the 3.3.0 dump. It's completely straight-forward. The only catch would be parsing the guid from lua->C. You could do a string, or pass the upper and lower 4-bytes separately.
Or you could rape à existing lua function (not à important one) and make it call the SetTarget function then you could call it from your addon;
overwriting opcodes ftw!
Lol. That's a ridiculous solution. BUT. It just might work.
I thought the LUA set target could only take a few strings (aka, "player" , "last target").. I think you would need to inject into another targeting function?
I think this might be a very good topic... To "extend" many lua functions to support "GUID params", that'll will be magnificant.
i'm trying to reverse this function CGGameUI_Target but i can't find how it works
here the functin (at 004CA150)
there are 2 arg , but i exepted only one arg ( for the guid)Code:sub_4CA150 proc near ; CODE XREF: sub_4CA510+2E2p .text:004CA150 ; sub_4CA820+236p ... .text:004CA150 .text:004CA150 var_2C4 = byte ptr -2C4h .text:004CA150 var_4 = dword ptr -4 .text:004CA150 arg_0 = dword ptr 8 .text:004CA150 arg_4 = dword ptr 0Ch .text:004CA150 .text:004CA150 push ebp .text:004CA151 mov ebp, esp .text:004CA153 sub esp, 2C4h .text:004CA159 push esi .text:004CA15A mov esi, [ebp+arg_4] .text:004CA15D push edi .text:004CA15E mov edi, [ebp+arg_0] .text:004CA161 mov eax, edi .text:004CA163 or eax, esi .text:004CA165 jnz short loc_4CA1B5 .text:004CA167 mov ecx, dword_B68584 .text:004CA16D mov dword_B6869C, eax .text:004CA172 mov eax, dword_B68580 .text:004CA177 mov edx, eax .text:004CA179 or edx, ecx .text:004CA17B jz loc_4CA507 .text:004CA181 push 1 .text:004CA183 push ecx .text:004CA184 push eax .text:004CA185 mov dword_B68588, eax .text:004CA18A mov dword_B6858C, ecx .text:004CA190 call sub_4C8E50 .text:004CA195 add esp, 0Ch .text:004CA198 call sub_7D6E20 .text:004CA19D test eax, eax .text:004CA19F jz loc_4CA507 .text:004CA1A5 push 1 .text:004CA1A7 call sub_7E0280 .text:004CA1AC add esp, 4 .text:004CA1AF pop edi .text:004CA1B0 pop esi .text:004CA1B1 mov esp, ebp .text:004CA1B3 pop ebp .text:004CA1B4 retn
can i have some help ?
Would you mind to give me some explanations ?
Did I misunderstand something ?
How many bytes long is a GUID? How many bytes does each register contain on an IA-32 machine? You can't have the GUID in one register, it requires two. Therefore, 'two' parameters are passed. It's an 8-byte(two DWORDs) struct passed on the stack.
So, find out how UnitGUID works (the lua function to take a unit name (e.g. 'player', 'target', and so on), and hook the underlying function (which is in the 3.3.0a info dumps) so that strings that "look like" a guid (16 hex digits, optionally w/ "0x" in front) simply convert directly into the guid (no lookup in the objmgr lists).
Once you've done this, any existing function that takes a unit name will accept a unit guid (as a string, which is the only way your addon will see them anyway without other hooked code, since there's no lua "to ulong" method AFAIK) and "just work."
I had this working a few months ago. Unfortunately, I dumped the code since, with injection, I no longer need it.
Edit: actually, this might not work w/unit types that require special highlighting code, ie mouseover (try just poking a guid into mouseover and then, eg, CastSpellByName on 'mouseover'... no joy without the "secret magic").
Hmm, I need to dig up my old code and see how I used to do it....
Last edited by amadmonk; 12-29-2009 at 03:38 PM.
Don't believe everything you think.
You can "Wrap" GetGUIDByKeyword
and use something likeCode:LONG WINAPI GetGUIDByKeyword(struct _EXCEPTION_POINTERS *ExceptionInfo) { char* UnitID; WGUID** pGUID; UnitID = (char*)ExceptionInfo->ContextRecord->Eax; pGUID = (WGUID**)(ExceptionInfo->ContextRecord->Ebp + 0xC); if(UnitID) //DBGLOG( "Unit ID " << std::string(UnitID) << " pGuid:" << pGUID ); if((UnitID != 0) && (UnitID[0] == '0') && (UnitID[1] == 'x')) //is the string start with 0x it's assumed that it is an hex string { //DBGLOG( "Unit ID " << std::string(UnitID) << " pGuid:" << pGUID ); if(from_string<WGUID>((**pGUID),std::string(UnitID),std::hex)) //if Hex string is well formed we store it and go to end procedure { ExceptionInfo->ContextRecord->Esp += 0x14; ExceptionInfo->ContextRecord->Eip = 0x005A154A; /*3.2.2a .text:005900DB mov al, 1 <-- return true .text:005900DD pop edi .text:005900DE mov esp, ebp .text:005900E0 pop ebp .text:005900E1 retn */ return EXCEPTION_CONTINUE_EXECUTION; } } ExceptionInfo->ContextRecord->Esp += 0x14; ExceptionInfo->ContextRecord->Eip += 0x03; return EXCEPTION_CONTINUE_EXECUTION; }
TargetUnit("0x??????");
Nice, I like your method of selectively wrapping functions that you're hooking with EH. That's sleek.
Mind if I steal the idea? My DRx hooks could use some love...
Don't believe everything you think.