[Question] Figured something out, then forgot how I did it.... menu

Shout-Out

User Tag List

Results 1 to 11 of 11
  1. #1
    nwg601's Avatar Member
    Reputation
    2
    Join Date
    Jul 2010
    Posts
    21
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [Question] Figured something out, then forgot how I did it....

    So I've managed to locate this subroutine:

    Code:
    int __thiscall unit::getHealth(void *this)
    {
      int health;
    
      if ( *(_DWORD *)(dword_ED7738 + 48) )         // Not even a clue
        health = *((_DWORD *)this + 1139);
      else
        health = *(_DWORD *)(*((_DWORD *)this + 62) + 72);
      return health;
    }
    I figured this can get me what I want, I might have mangled it a bit but I want to get a unit's health from its base address.

    I could swear I tried
    Code:
     CurrentObject+ 1139
    OR
    Code:
      *((_DWORD *)CurrentObject+ 62) + 72
    and one of them worked. I leave the room, come back and it's
    Code:
    CurrentObject+4556
    And it works, the other two values don't. Now I can't figure out where I got 4556 from.... What did I do?

    [Question] Figured something out, then forgot how I did it....
  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)
    You got it from the function at 0x5B4FD0 called in Script_UnitHealth (0x453420)

    I don't understand why you go through such lengths to get unit health, use the descriptors.
    "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
    nwg601's Avatar Member
    Reputation
    2
    Join Date
    Jul 2010
    Posts
    21
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Robske View Post
    You got it from the function at 0x5B4FD0 called in Script_UnitHealth (0x453420)

    I don't understand why you go through such lengths to get unit health, use the descriptors.
    Are those 4.3.4.15595?

    If your sub_5B4FD0 is what I've called unit::getHealth I can't see where I got the value 4556 from?

    This is the first part of a POC for a larger aspiration, I've got it working, but I can't figure out how I got here.

  4. #4
    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)
    Code:
    int __thiscall sub_5B4FD0(int this)
    {
      int result; // eax@2
    
      if ( *(dword_ED7594 + 48) )
        result = *(this + 4556);
      else
        result = *(*(this + 248) + 72);
      return result;
    }
    "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

  5. #5
    nwg601's Avatar Member
    Reputation
    2
    Join Date
    Jul 2010
    Posts
    21
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay, It seems I made some mistake in IDA, I've re-opened wow.exe and I can see your above.

    Thanks.

  6. #6
    _Mike's Avatar Contributor
    Reputation
    310
    Join Date
    Apr 2008
    Posts
    531
    Thanks G/R
    0/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In before OP figures out why 1139*4=4556

  7. #7
    Frosttall's Avatar Active Member
    Reputation
    64
    Join Date
    Feb 2011
    Posts
    261
    Thanks G/R
    16/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Robske View Post
    You got it from the function at 0x5B4FD0 called in Script_UnitHealth (0x453420)

    I don't understand why you go through such lengths to get unit health, use the descriptors.
    The descriptors take aaaaages to update.. Had that problem yesterday

    Originally Posted by _Mike View Post
    In before OP figures out why 1139*4=4556
    That's why you shouldn't trust HexRays in IDA.. It sometimes forgets to multiply the values with 4, but hey: What is the ASM-View for?!

  8. #8
    nwg601's Avatar Member
    Reputation
    2
    Join Date
    Jul 2010
    Posts
    21
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by _Mike View Post
    In before OP figures out why 1139*4=4556
    Not quite in before. Appreciate the help though

  9. #9
    Aftiagouras's Avatar Member
    Reputation
    2
    Join Date
    Mar 2008
    Posts
    22
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Frosttall View Post
    That's why you shouldn't trust HexRays in IDA.. It sometimes forgets to multiply the values with 4, but hey: What is the ASM-View for?!
    Nah, HexRays is fine.
    *((_DWORD *)this + 1139) means [this + 1139*4]
    while
    *(_DWORD *)(this + 1139) means [this + 1139]

    Its how pointers and casts work in C.

  10. #10
    Frosttall's Avatar Active Member
    Reputation
    64
    Join Date
    Feb 2011
    Posts
    261
    Thanks G/R
    16/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Aftiagouras View Post
    Nah, HexRays is fine.
    *((_DWORD *)this + 1139) means [this + 1139*4]
    while
    *(_DWORD *)(this + 1139) means [this + 1139]

    Its how pointers and casts work in C.
    Aaah got it, thank you

  11. #11
    _Mike's Avatar Contributor
    Reputation
    310
    Join Date
    Apr 2008
    Posts
    531
    Thanks G/R
    0/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Aftiagouras View Post
    Nah, HexRays is fine.
    *((_DWORD *)this + 1139) means [this + 1139*4]
    while
    *(_DWORD *)(this + 1139) means [this + 1139]

    Its how pointers and casts work in C.
    It's not just that though. The 2nd one could also mean 1139*4. Hexrays assumes you declare the types correctly. Notice the difference in the posted function declarations.
    Code:
    int __thiscall unit::getHealth(void *this)
    int __thiscall sub_5B4FD0(int this)

Similar Threads

  1. [Question]Rep if you can figure this out.
    By Corosive720 in forum World of Warcraft Emulator Servers
    Replies: 7
    Last Post: 01-10-2008, 01:09 AM
  2. Need help figuring something out
    By Conflag in forum Community Chat
    Replies: 7
    Last Post: 10-12-2007, 03:17 AM
  3. Question about something
    By [Kronus] in forum World of Warcraft General
    Replies: 0
    Last Post: 09-03-2007, 12:28 PM
  4. Figure this out and you will get a prize.
    By marick626 in forum Community Chat
    Replies: 36
    Last Post: 08-17-2007, 03:22 PM
  5. Pointing Something Out
    By Fault in forum Screenshot & Video Showoff
    Replies: 2
    Last Post: 07-11-2007, 03:01 PM
All times are GMT -5. The time now is 01:45 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search