Proper method to hook a _usercall? menu

Shout-Out

User Tag List

Results 1 to 2 of 2
  1. #1
    Tanaris4's Avatar Contributor Authenticator enabled
    Reputation
    148
    Join Date
    Oct 2008
    Posts
    646
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Proper method to hook a _usercall?

    So I'm trying to hook this function:

    Code:
    void *__usercall WardenModule__Load<eax>(const void *modulePointer<eax>, unsigned int moduleSize<edx>, int a3<ecx>)
    I realize that the return value is actually stored in eax, and I can't simply just hook the function as above, i.e. I may need to save all the registers, then restore them before finishing my hook function. Is there a guide posted somewhere on this?

    Or should I literally just hook the function with NO arguments, and then read values from the registers via assembly to save, do some work, then restore to the previous value? And if so, are there certain registers I have to store?

    Thanks in advance!

    Edit: Found this thread: http://www.mmowned.com/forums/world-...ow-code-c.html

    So I'm assuming I just need to do:
    Code:
    	push 0xDEADBABE		//   Placeholder for the return address
    		pushfd				//   Save the flags and registers
    		pushad
    		//-- Something useful goes here :)
    		popad				//   Restore the registers and flags
    		popfd
    		ret					//   Return control to the hijacked thread
    Last edited by Tanaris4; 06-23-2010 at 09:50 AM.
    https://tanaris4.com

    Proper method to hook a _usercall?
  2. #2
    MaiN's Avatar Elite User
    Reputation
    335
    Join Date
    Sep 2006
    Posts
    1,047
    Thanks G/R
    0/10
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Tanaris4 View Post
    So I'm trying to hook this function:

    Code:
    void *__usercall WardenModule__Load<eax>(const void *modulePointer<eax>, unsigned int moduleSize<edx>, int a3<ecx>)
    I realize that the return value is actually stored in eax, and I can't simply just hook the function as above, i.e. I may need to save all the registers, then restore them before finishing my hook function. Is there a guide posted somewhere on this?

    Or should I literally just hook the function with NO arguments, and then read values from the registers via assembly to save, do some work, then restore to the previous value? And if so, are there certain registers I have to store?

    Thanks in advance!

    Edit: Found this thread: http://www.mmowned.com/forums/world-...ow-code-c.html

    So I'm assuming I just need to do:
    Code:
        push 0xDEADBABE        //   Placeholder for the return address
            pushfd                //   Save the flags and registers
            pushad
            //-- Something useful goes here :)
            popad                //   Restore the registers and flags
            popfd
            ret                    //   Return control to the hijacked thread
    Hex-Rays is wrong about those function signatures 99% of the time. I suggest you check how it looks in ASM. You will see the proper calling convention, and it's almost certainly a normal thiscall, stdcall or cdecl. I haven't seen any function in the new WoW that has another calling convention than one of those 3. Only place I have seen that is in the actual Warden module, and that's because of its polymorphism.

    To answer your actual question, I suggest you declare the hook as naked and use inline ASM to clean whatever you need to clean and call the original function. You won't almost never need to do this, except when you are going cross-compiler - for instance, if you are injecting a GCC compiled DLL into WoW, then some of the calling conventions will differ - for instance thiscall in GCC pushes the 'this' pointer onto the stack, while thiscall in MSVC hold 'this' in the ECX register.
    Last edited by MaiN; 06-23-2010 at 10:18 AM.
    [16:15:41] Cypher: caus the CPU is a dick
    [16:16:07] kynox: CPU is mad
    [16:16:15] Cypher: CPU is all like
    [16:16:16] Cypher: whatever, i do what i want

Similar Threads

  1. Replies: 8
    Last Post: 07-22-2013, 01:24 AM
  2. Recast/Detour - 16 tiles per ADT - Proper method to save/load?
    By Tanaris4 in forum WoW Memory Editing
    Replies: 5
    Last Post: 12-29-2011, 12:48 PM
  3. [Mage Only] 30k exp an hour - Best AOE Method
    By Matt in forum World of Warcraft Guides
    Replies: 12
    Last Post: 12-04-2006, 12:51 PM
  4. Dupe Method (takes quite some time)
    By Matt in forum World of Warcraft Exploits
    Replies: 4
    Last Post: 04-11-2006, 01:55 PM
  5. Double Loot Method
    By Matt in forum World of Warcraft Guides
    Replies: 3
    Last Post: 03-13-2006, 01:37 AM
All times are GMT -5. The time now is 06:55 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