Remote function call, calling convention? menu

Shout-Out

User Tag List

Results 1 to 12 of 12
  1. #1
    lweid's Avatar Corporal
    Reputation
    1
    Join Date
    Mar 2011
    Posts
    27
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Remote function call, calling convention?

    First of all I understand that I am new to this community, and if you do not want to answer my question because I have not given anything back to this community as of yet, I understand. However hopefully in time, and learning, I can give something back

    Yesterday I was able to (first time for me) inject a dll into a target process, at first I played around with a 'hackme' test dummy application before I jumped right in to messing with World of Warcraft.

    Upon injecting code into my test dummy application, I used the MessageBox() api to let me know that DLL_PROCESS_ATTATCH was currently in execution flow, then I had a test function inside of my test dummy app, which for the sake of simplicity we will say the call procedure lies at 0xDEADBEEF.

    I used this method to call the function


    DWORD location=0xDEADBEEF;

    __asm
    {
    CALL location
    }
    that was the best I could come up with, and it worked. The function was called in the target application, with no deadlocks and no crashes.

    Its a different story with WoW however.

    I have a certain function that I chose from TOM_RUS' post of 4.0.6 static data.

    I know that my injection works, it gets to the the MessageBox() api, however it crashes out after that, which is where the asm function call is located.


    so basically what I need to know here is, am I using the proper calling convention? What am I missing and what am I doing wrong?

    Remote function call, calling convention?
  2. #2
    IceFire32's Avatar Active Member
    Reputation
    47
    Join Date
    Feb 2009
    Posts
    33
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I didn't read ur post very carefully now (sorry :b), but maybe it would be helpful if you'd say us which function u want to call. It's not the same for all the functions.

    /edit:
    To give you a short example (untested and YES, it IS dirty code-style :b)
    Code:
    #define ChatFrame_AddMessage 0x00455F80
    
    void AddChatMessage(std::string text)
    {
       char *szPTR = (char*)text.c_str() ;
       DWORD dwFunc = (DWORD)GetModuleHandle(NULL) + ChatFrame_AddMessage ;
       __asm
       {
          push 0
          push 0
          push szPTR
          mov eax, dwFunc
          call eax
          add esp, 0x0C
       }
    }
    Btw you can also use function pointers to call remote functions.
    Last edited by IceFire32; 03-22-2011 at 02:37 PM.

  3. #3
    lweid's Avatar Corporal
    Reputation
    1
    Join Date
    Mar 2011
    Posts
    27
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by IceFire32 View Post
    I didn't read ur post very carefully now (sorry :b), but maybe it would be helpful if you'd say us which function u want to call. It's not the same for all the functions.

    /edit:
    To give you a short example (untested and YES, it IS dirty code-style :b)
    Code:
    #define ChatFrame_AddMessage 0x00455F80
    
    void AddChatMessage(std::string text)
    {
       char *szPTR = (char*)text.c_str() ;
       DWORD dwFunc = (DWORD)GetModuleHandle(NULL) + ChatFrame_AddMessage ;
       __asm
       {
          push 0
          push 0
          push szPTR
          mov eax, dwFunc
          call eax
          add esp, 0x0C
       }
    }
    Btw you can also use function pointers to call remote functions.
    Wow thanks for the fast reply

    is it necessary to use the eax register? like you did in your sample?

  4. #4
    IceFire32's Avatar Active Member
    Reputation
    47
    Join Date
    Feb 2009
    Posts
    33
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nope, you can also use "call dwFunc" directly, don't ask my why I did it like that ;p

    /edit:
    Code:
    #define ChatFrame_AddMessage 0x00455F80
    typedef DWORD(__cdecl *pFunc_t)(char *szText, DWORD dwUnk, DWORD dwUnk2) ;
    
    void AddChatMessage(std::string text)
    {
       pFunc_t pFunc = (pFunc_t)((DWORD)GetModuleHandle(NULL) + ChatFrame_AddMessage) ;
       pFunc((char*)text.c_str(), 0, 0) ;  
    }
    With a typedef it'd look like this
    Last edited by IceFire32; 03-22-2011 at 02:48 PM.

  5. #5
    lweid's Avatar Corporal
    Reputation
    1
    Join Date
    Mar 2011
    Posts
    27
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh I should post the function I was trying to call "which I chose at random" is

    617320 CGUnit_C::PlayEmoteSound
    Not entirely sure how you pass arguments with asm, but you dont need to tell me, I can figure that out on my own.

    Was just wondering if I need to call that function by name directly or not.

  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)
    Originally Posted by lweid View Post
    617320 CGUnit_C::PlayEmoteSound
    Do note that CGUnit_C is a C++ class, so you have to use thiscall convention and feed it with a valid class pointer.
    You might want to start with a "normal" cdecl function first if you're trying to learn the basics. Oh, and I wouldn't call it _remote_ function calling if you're calling it from within the same process

    Originally Posted by lweid View Post
    Not entirely sure how you pass arguments with asm, but you dont need to tell me, I can figure that out on my own.
    Don't. Function pointers are there for a reason.

    And read x86 calling conventions - Wikipedia, the free encyclopedia if you haven't already.

  7. #7
    lweid's Avatar Corporal
    Reputation
    1
    Join Date
    Mar 2011
    Posts
    27
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by _Mike View Post
    Do note that CGUnit_C is a C++ class, so you have to use thiscall convention and feed it with a valid class pointer.
    You might want to start with a "normal" cdecl function first if you're trying to learn the basics. Oh, and I wouldn't call it _remote_ function calling if you're calling it from within the same process


    Don't. Function pointers are there for a reason.

    And read x86 calling conventions - Wikipedia, the free encyclopedia if you haven't already.
    thank you _Mike

    I will definitely read that.

    IceFire32, thank you much for the example

  8. #8
    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)
    Please be aware that there are a number of customcall functions in WoW, which you're simply not going to ever be able to call correctly using standard calling conventions. With customcall (don't know if there's an "official" name for this calling convention that, really, ISN'T a calling convention...) you have to reverse the function and look at its usage to know how to handle params, which registers are volatile, etc. Pray you don't run into these functions

    I don't believe, however, that any of the "usual" offsets found per patch use customcall.
    Don't believe everything you think.

  9. #9
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1358
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by amadmonk View Post
    Please be aware that there are a number of customcall functions in WoW, which you're simply not going to ever be able to call correctly using standard calling conventions. With customcall (don't know if there's an "official" name for this calling convention that, really, ISN'T a calling convention...) you have to reverse the function and look at its usage to know how to handle params, which registers are volatile, etc. Pray you don't run into these functions

    I don't believe, however, that any of the "usual" offsets found per patch use customcall.
    Pray also that Blizzard don't decide to start setting their compiler to use IPO/PGO/etc more aggressively.

  10. #10
    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)
    Yeah, I'm kinda hoping that too.
    Don't believe everything you think.

  11. #11
    lweid's Avatar Corporal
    Reputation
    1
    Join Date
    Mar 2011
    Posts
    27
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Another question, in most cases of the injected module being (far lack of a better term) kicked back out after an attempted call to a function, but WoW does not crash. Would this most likely mean I have messed up the params/return type? Or is it because my function pointer is pointing to something that isnt the beginning of a procedure?

    thanks

    edit-

    i should add. I usually stick to cdecl, most of the time it just kicks my library back out. but i fear its because I have messed up the parameters.
    Last edited by lweid; 03-23-2011 at 10:51 PM.

  12. #12
    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)
    Seriously, if you don't know the calling convention, you're doing it wrong. Either stick to offsets that other people have reversed (and for which you know the cconv), or reverse it yourself.

    Just wildly flailing around trying different random cconv's is a non-starter.
    Don't believe everything you think.

Similar Threads

  1. Replies: 11
    Last Post: 11-21-2011, 12:25 AM
  2. GCC "thiscall" calling convention [Linux/Win32 MinGW]
    By Sednogmah in forum WoW Memory Editing
    Replies: 19
    Last Post: 04-13-2011, 07:22 PM
  3. CEGUI - EndScene Hook - DLL Function Call
    By Orix in forum WoW Memory Editing
    Replies: 5
    Last Post: 02-12-2011, 03:51 PM
  4. detection of engine function calls
    By mnbvc in forum WoW Memory Editing
    Replies: 10
    Last Post: 03-28-2010, 03:06 PM
  5. ASM function call?
    By akh in forum WoW Memory Editing
    Replies: 15
    Last Post: 09-02-2008, 12:31 AM
All times are GMT -5. The time now is 10:16 AM. 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