How to interact Unit by GUID? menu

Shout-Out

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    singed420's Avatar Member
    Reputation
    5
    Join Date
    Jan 2018
    Posts
    26
    Thanks G/R
    0/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to interact Unit by GUID?

    On retail server, I wanna make a rotation bot that could cast spell based on target's buff etc. I am able to unlock protected lua right now, but have no idea what needs to be done in my unlocker to make all object interaction related lua functions such as TargetUnit() to addept object's GUID string as argument instead of just tokenID like "player","target","pet".
    Could any pioneer give any hints or direction on how to make interacting with Object's GUID string, like TargetUnit("Creature-0-3039-2570-8014-181494-000003E27E") works? Thx.

    How to interact Unit by GUID?
  2. #2
    goblin2kx's Avatar Member
    Reputation
    8
    Join Date
    Jun 2007
    Posts
    31
    Thanks G/R
    13/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think you'd need to treat GUID like an object rather than string:
    struct guid
    {
    uint64_t low;
    uint64_t high;
    }
    Ingame scripts use a function that's called that converts the input target string ("player", "target" or "pet") to GUID (can easily be found in IDA by searching for "arenapet" for example you'll see a function with "player", "target", etc). GUID is then used in ClntObjMgrObjectPtr to get the pointer to the object.

    Edit: If you just want to call the protected TargetUnit("unit"), the input parameter is not GUID string, it's one of the unit type strings.
    Last edited by goblin2kx; 10-08-2024 at 05:54 AM.

  3. #3
    singed420's Avatar Member
    Reputation
    5
    Join Date
    Jan 2018
    Posts
    26
    Thanks G/R
    0/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by goblin2kx View Post
    I think you'd need to treat GUID like an object rather than string:
    struct guid
    {
    uint64_t low;
    uint64_t high;
    }
    Ingame scripts use a function that's called that converts the input target string ("player", "target" or "pet") to GUID (can easily be found in IDA by searching for "arenapet" for example you'll see a function with "player", "target", etc). GUID is then used in ClntObjMgrObjectPtr to get the pointer to the object.

    Edit: If you just want to call the protected TargetUnit("unit"), the input parameter is not GUID string, it's one of the unit type strings.
    ehh, I am confused.So it is impossible to use GUID string as parameter to call the protected TargetUnit("unit")? Is it possible to select target by its GUID string using native WOW api, or do I need to register my own function in LUA engine to achieve that?

  4. #4
    goblin2kx's Avatar Member
    Reputation
    8
    Join Date
    Jun 2007
    Posts
    31
    Thanks G/R
    13/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by singed420 View Post
    ehh, I am confused.So it is impossible to use GUID string as parameter to call the protected TargetUnit("unit")? Is it possible to select target by its GUID string using native WOW api, or do I need to register my own function in LUA engine to achieve that?
    I personally don't use TargetUnit but I can tell you what I would do. For the entry into the function TargetUnit("unit"), you need to provide one of the unit type string (i.e. "player", "pet", etc). But if you explore how the Lua call is made in IDA, sometimes there is a way to bypass having to provide the unit type and provide the GUID directly and perform the same task.

    Sorry about your confusion earlier I was just trying to point out that you are using GUID incorrectly. I personally don't know any place in code that uses GUID as a string as an input.

  5. #5
    thateuler's Avatar Active Member
    Reputation
    24
    Join Date
    May 2019
    Posts
    39
    Thanks G/R
    24/17
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wow has an internal function Script_GetGUIDFromToken that most code calls to map something like `player` to the actual player guid. InteractUnit probably uses this. You could hook that function and in your hook, take the string guid `Creature-0-3039-2570-8014-181494-000003E27E` and convert it to the 128bit guid, and return that.

    But then you'll have to solve 2 problems. How to map from a text guid to a 128bit guid and how to hook that function in such a way that bliz doesn't detect it. If you replace the start of the code with a jmp, which is a common way to do this then the client will crash because it does crc scans periodically.

    An easier way is to write the guid to the global value for either mouseover or focus and then call InteractUnit('mouseover') (or InteractUnit('focus')).
    Last edited by thateuler; 10-09-2024 at 10:42 AM.

  6. #6
    qop1832's Avatar Active Member

    Reputation
    34
    Join Date
    Dec 2021
    Posts
    68
    Thanks G/R
    19/21
    Trade Feedback
    0 (0%)
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    CGGuidStruct Utils::GUID_from_str(const std::string& guid_str) {
    if (guid_str.empty()) {
    throw std::invalid_argument("Empty GUID string");
    }

    auto split = [](const std::string& str, char delim) {
    std::vector<std::string> tokens;
    std::stringstream ss(str);
    std::string item;
    while (std::getline(ss, item, delim)) {
    tokens.push_back(item);
    }
    return tokens;
    };

    auto guid_parts = split(guid_str, '-');
    std::map<std::string, GuidType> guid_type_map = {
    {"Pet", GuidType::Pet},
    {"Creature", GuidType::Creature},
    {"GameObject", GuidType::GameObject},
    {"Vehicle", GuidType::Vehicle}
    };

    CGGuidStruct guid_struct;
    uint64_t low = 0, high = 0;

    auto guid_type_it = guid_type_map.find(guid_parts[0]);
    if (guid_type_it != guid_type_map.end()) {
    GuidType guid_type = guid_type_it->second;

    low = (static_cast<uint64_t>(guid_type) << 5 | (std::stoull(guid_parts[2]) << 42) | (std::stoull(guid_parts[3]) << 29) | (std::stoull(guid_parts[5]) << 6);
    high = (std::stoull(guid_parts[4]) << 40) | std::stoull(guid_parts[6], nullptr, 16);
    }
    else if (guid_parts[0] == "Player") {
    low = (static_cast<uint64_t>(GuidType::Player) << 5 | (std::stoull(guid_parts[1]) << 42);
    high = std::stoull(guid_parts[2], nullptr, 16);
    }
    else {
    throw std::runtime_error("无法解析GUID_str: " + guid_str);
    }

    guid_struct.low = low;
    guid_struct.high = high;

    return guid_struct;
    }
    Try this, maybe it will work for you...
    叼毛

  7. #7
    scizzydo's Avatar Contributor
    Reputation
    182
    Join Date
    Oct 2019
    Posts
    121
    Thanks G/R
    5/76
    Trade Feedback
    0 (0%)
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by qop1832 View Post
    Try this, maybe it will work for you...
    ...or... you know... just call the StringToGUID or GUIDToString functions in the binary to avoid all that extra jazz you have?
    Code:
    inline void*(*GUIDToString)(WoWGUID* guid, char* buffer, size_t length) = nullptr;
    inline void*(*StringToGUID)(WoWGUID*,const char*,size_t) = nullptr;
    // Windows
    SETUP_PATTERN(GUIDToString, "48 8B C8 E8 X4 ? ? ? ? 48 8D 44 24 20 49 C7 C0 FF FF FF FF /d");
    SETUP_PATTERN(StringToGUID, "48 8B D0 E8 X4 ? ? ? ? 48 83 7C /d");
    // MacOS
    SETUP_PATTERN(GUIDToString, "E0 ? ? AA 02 ? ? 52 X ? ? ? ? 88 ? ? ? 80 /da");
    SETUP_PATTERN(StringToGUID, "AA ? ? ? AA ? ? ? 91 02 10 80 52 X ? ? ? ? E0 /d");

  8. #8
    singed420's Avatar Member
    Reputation
    5
    Join Date
    Jan 2018
    Posts
    26
    Thanks G/R
    0/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by qop1832 View Post
    Try this, maybe it will work for you...
    看到中文好亲切,铁子加个Q交流下?

  9. #9
    singed420's Avatar Member
    Reputation
    5
    Join Date
    Jan 2018
    Posts
    26
    Thanks G/R
    0/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by scizzydo View Post
    ...or... you know... just call the StringToGUID or GUIDToString functions in the binary to avoid all that extra jazz you have?
    Code:
    inline void*(*GUIDToString)(WoWGUID* guid, char* buffer, size_t length) = nullptr;
    inline void*(*StringToGUID)(WoWGUID*,const char*,size_t) = nullptr;
    // Windows
    SETUP_PATTERN(GUIDToString, "48 8B C8 E8 X4 ? ? ? ? 48 8D 44 24 20 49 C7 C0 FF FF FF FF /d");
    SETUP_PATTERN(StringToGUID, "48 8B D0 E8 X4 ? ? ? ? 48 83 7C /d");
    // MacOS
    SETUP_PATTERN(GUIDToString, "E0 ? ? AA 02 ? ? 52 X ? ? ? ? 88 ? ? ? 80 /da");
    SETUP_PATTERN(StringToGUID, "AA ? ? ? AA ? ? ? 91 02 10 80 52 X ? ? ? ? E0 /d");
    are these AOB for retail 11.0.2.56819? I cant find anything searching these AOB in windows.

  10. #10
    scizzydo's Avatar Contributor
    Reputation
    182
    Join Date
    Oct 2019
    Posts
    121
    Thanks G/R
    5/76
    Trade Feedback
    0 (0%)
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by singed420 View Post
    are these AOB for retail 11.0.2.56819? I cant find anything searching these AOB in windows.
    Yes, but using my pattern scanner features. Remove the X4 from it if you're using IDA or something

  11. #11
    qop1832's Avatar Active Member

    Reputation
    34
    Join Date
    Dec 2021
    Posts
    68
    Thanks G/R
    19/21
    Trade Feedback
    0 (0%)
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    加了你discord
    叼毛

  12. #12
    singed420's Avatar Member
    Reputation
    5
    Join Date
    Jan 2018
    Posts
    26
    Thanks G/R
    0/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by qop1832 View Post
    加了你discord
    哪个是你的DC?太多人加我了
    Last edited by singed420; 10-13-2024 at 02:59 AM.

  13. #13
    singed420's Avatar Member
    Reputation
    5
    Join Date
    Jan 2018
    Posts
    26
    Thanks G/R
    0/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by scizzydo View Post
    ...or... you know... just call the StringToGUID or GUIDToString functions in the binary to avoid all that extra jazz you have?
    Code:
    inline void*(*GUIDToString)(WoWGUID* guid, char* buffer, size_t length) = nullptr;
    inline void*(*StringToGUID)(WoWGUID*,const char*,size_t) = nullptr;
    // Windows
    SETUP_PATTERN(GUIDToString, "48 8B C8 E8 X4 ? ? ? ? 48 8D 44 24 20 49 C7 C0 FF FF FF FF /d");
    SETUP_PATTERN(StringToGUID, "48 8B D0 E8 X4 ? ? ? ? 48 83 7C /d");
    // MacOS
    SETUP_PATTERN(GUIDToString, "E0 ? ? AA 02 ? ? 52 X ? ? ? ? 88 ? ? ? 80 /da");
    SETUP_PATTERN(StringToGUID, "AA ? ? ? AA ? ? ? 91 02 10 80 52 X ? ? ? ? E0 /d");
    found it. but how should i use this? it seems like need to hook anyway, but wont that cause ez detection?

  14. #14
    qop1832's Avatar Active Member

    Reputation
    34
    Join Date
    Dec 2021
    Posts
    68
    Thanks G/R
    19/21
    Trade Feedback
    0 (0%)
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    你加我吧 跟论坛用户名同名..
    叼毛

  15. #15
    scizzydo's Avatar Contributor
    Reputation
    182
    Join Date
    Oct 2019
    Posts
    121
    Thanks G/R
    5/76
    Trade Feedback
    0 (0%)
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by singed420 View Post
    found it. but how should i use this? it seems like need to hook anyway, but wont that cause ez detection?
    The common old method was hooking the function that gets the token and turns it into a GUID. You'd check if the token is a GUID and just return the GUID from there... with retail this requires a lot of work and isn't that great of a solution with all the stuff behind it to be safe. Another option is to wrap the functions you want, check the arguments if they're a guid, replace it with a token and on the backend side make that token the guid you passed in, then call the function you're wrapping

  16. Thanks qop1832 (1 members gave Thanks to scizzydo for this useful post)
Page 1 of 2 12 LastLast

Similar Threads

  1. How to Solo Garr: A Guide for Warrior and Paladin Tanks
    By Kauppaneuvos in forum World of Warcraft Guides
    Replies: 12
    Last Post: 06-25-2008, 03:55 PM
  2. How-to Make Your Own Guide
    By Toxik the Spammer in forum World of Warcraft Guides
    Replies: 3
    Last Post: 04-26-2008, 11:40 AM
  3. How to make a server guide-nubfreindly-
    By cooper101 in forum WoW EMU Guides & Tutorials
    Replies: 12
    Last Post: 03-21-2008, 10:16 PM
  4. How to Make a portal guide
    By mager1794 in forum WoW EMU Guides & Tutorials
    Replies: 6
    Last Post: 02-13-2008, 04:40 PM
  5. [HOW TO] Post a Decent Guide
    By treyska in forum World of Warcraft Guides
    Replies: 16
    Last Post: 10-07-2007, 01:45 PM
All times are GMT -5. The time now is 01:43 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