Question: Target Unit By GUID in Addons, Possible? menu

User Tag List

Results 1 to 15 of 15
  1. #1
    zys924's Avatar Active Member
    Reputation
    20
    Join Date
    Nov 2009
    Posts
    113
    Thanks G/R
    0/7
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question: Target Unit By GUID in Addons, Possible?

    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?

    Question: Target Unit By GUID in Addons, Possible?
  2. #2
    Robske's Avatar Contributor
    Reputation
    305
    Join Date
    May 2007
    Posts
    1,062
    Thanks G/R
    3/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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

  3. #3
    zys924's Avatar Active Member
    Reputation
    20
    Join Date
    Nov 2009
    Posts
    113
    Thanks G/R
    0/7
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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?

  4. #4
    lanman92's Avatar Active Member
    Reputation
    50
    Join Date
    Mar 2007
    Posts
    1,033
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  5. #5
    Nesox's Avatar ★ Elder ★
    Reputation
    1280
    Join Date
    Mar 2007
    Posts
    1,238
    Thanks G/R
    0/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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!

  6. #6
    lanman92's Avatar Active Member
    Reputation
    50
    Join Date
    Mar 2007
    Posts
    1,033
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Lol. That's a ridiculous solution. BUT. It just might work.

  7. #7
    mongoosed's Avatar Member
    Reputation
    1
    Join Date
    Feb 2007
    Posts
    55
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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?

  8. #8
    zys924's Avatar Active Member
    Reputation
    20
    Join Date
    Nov 2009
    Posts
    113
    Thanks G/R
    0/7
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think this might be a very good topic... To "extend" many lua functions to support "GUID params", that'll will be magnificant.

  9. #9
    youmew's Avatar Member
    Reputation
    13
    Join Date
    Feb 2007
    Posts
    28
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i'm trying to reverse this function CGGameUI_Target but i can't find how it works
    here the functin (at 004CA150)
    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
    there are 2 arg , but i exepted only one arg ( for the guid)
    can i have some help ?

  10. #10
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1356
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by youmew View Post
    i'm trying to reverse this function CGGameUI_Target but i can't find how it works
    here the functin (at 004CA150)
    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
    there are 2 arg , but i exepted only one arg ( for the guid)
    can i have some help ?
    Sigh... I'm so sick of this shit.

  11. #11
    youmew's Avatar Member
    Reputation
    13
    Join Date
    Feb 2007
    Posts
    28
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Would you mind to give me some explanations ?
    Did I misunderstand something ?

  12. #12
    lanman92's Avatar Active Member
    Reputation
    50
    Join Date
    Mar 2007
    Posts
    1,033
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  13. #13
    amadmonk's Avatar Active Member
    Reputation
    124
    Join Date
    Apr 2008
    Posts
    772
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  14. #14
    berserk85's Avatar Member
    Reputation
    8
    Join Date
    Apr 2008
    Posts
    35
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can "Wrap" GetGUIDByKeyword

    Code:
    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;
    
    }
    and use something like
    TargetUnit("0x??????");

  15. #15
    amadmonk's Avatar Active Member
    Reputation
    124
    Join Date
    Apr 2008
    Posts
    772
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

Similar Threads

  1. Zygor's Ingame Leveling Guide - Ingame Addon - Horde + Alliance + Bonus
    By Dragonshadow in forum World of Warcraft Guides
    Replies: 680
    Last Post: 11-02-2008, 07:32 AM
  2. [Question / Help] My Gold Guide
    By joho in forum World of Warcraft General
    Replies: 8
    Last Post: 04-09-2008, 02:40 AM
  3. [Question] Anyone got any guide about chaning your weapon sheet?
    By Kakan1337 in forum WoW ME Questions and Requests
    Replies: 1
    Last Post: 07-30-2007, 03:58 PM
  4. Questions about Kopp's Guide (not about downloading it)
    By kc0716 in forum World of Warcraft General
    Replies: 6
    Last Post: 02-28-2007, 04:08 PM
All times are GMT -5. The time now is 04:42 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search