SendChatMessage Hook Problem menu

Shout-Out

User Tag List

Results 1 to 4 of 4
  1. #1
    oldmanofmen's Avatar Member
    Reputation
    12
    Join Date
    Jan 2010
    Posts
    104
    Thanks G/R
    4/3
    Trade Feedback
    3 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    SendChatMessage Hook Problem

    I am trying to install a hook in the Script_SendChatMessage function so that I can intercept text written by the user. Here is the code:
    Code:
    .text:008CB82C                 mov     edi, [ebp-14h]
    .text:008CB82F                 mov     esi, [ebp-10h]
    .text:008CB832                 push    ebx
    .text:008CB833                 push    0
    .text:008CB835                 push    dword ptr [ebp-4]
    .text:008CB838                 call    SendChatMessage -- HOOK LOCATION; 5 bytes replaced here with a jmp to my code cave (5 byte instruction)
    .text:008CB83D                 add     esp, 0Ch
    .text:008CB840                 jmp     short loc_8CB851
    //skipped some code because of the jmp above
    .text:008CB851                 pop     edi
    .text:008CB852                 pop     esi
    .text:008CB853                 pop     ebx
    .text:008CB854                 xor     eax, eax
    .text:008CB856                 leave
    .text:008CB857                 retn
    I have successfully got it so that it won't interfere with normal messages and no crash will occur, I use the following code in case anyone is interested (at the exit point of my code cave for normal messages):
    Code:
    				popfd
    				popad
    				call SendChatMessage
    				add esp, 0xC
    				jmp dword ptr Return ; Return here is instruction 8CB840 which can be seen above
    The broken part of my code which will basically end all execution if a message with an ! at the start is found here:
    Code:
    				popfd
    				popad
    				pop edi
    				pop esi
    				pop ebx
    				xor eax, eax
    				mov esp, ebp
    				pop ebp
    				retn
    Does anyone here understand why this segment crashes my WoW client? What is the correct way to leave this code cave given the state of the stack at this point in execution? There is some code missing but all changes to registers in the code I use before this piece of code is reverted with 'popad, popfd' so it wouldn't make much difference if I posted that.

    SendChatMessage Hook Problem
  2. #2
    SKU's Avatar Contributor
    Reputation
    306
    Join Date
    May 2007
    Posts
    565
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The 3 argument pushes happen before you jump to your hook. If you detect a '!', you skip the SendChatMessage call as well as the add esp, 0xc, eventually filling up edi, esi and ebx with garbage.
    Last edited by SKU; 09-13-2013 at 01:39 PM.

  3. #3
    wootie1337's Avatar Member
    Reputation
    1
    Join Date
    May 2009
    Posts
    1
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is much more cleaner and stylish:

    Code:
    void __cdecl SendChatMessage(arg1, arg2, arg3)
    {
       if (msg[0] != '!')
          SendChatMessage_I(arg1, arg2, arg3);
    }

  4. #4
    oldmanofmen's Avatar Member
    Reputation
    12
    Join Date
    Jan 2010
    Posts
    104
    Thanks G/R
    4/3
    Trade Feedback
    3 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I appreciate the advice both of you have offered but I actually managed to solve this myself using a different method to the ones you suggested. Your help was greatly appreciated even though I did not get to make use of it.

Similar Threads

  1. [C++] EndScene Hook Problems
    By ejt in forum WoW Memory Editing
    Replies: 2
    Last Post: 10-07-2013, 09:29 AM
  2. [C#]Hook problem
    By avizer in forum WoW Memory Editing
    Replies: 4
    Last Post: 08-13-2013, 10:53 AM
  3. WndProc (Mouse Input Hook) Problem
    By Amrok in forum WoW Memory Editing
    Replies: 10
    Last Post: 10-30-2011, 07:30 AM
  4. D3D Hook problem
    By Master674 in forum WoW Memory Editing
    Replies: 5
    Last Post: 09-20-2011, 12:04 PM
  5. Problem applying end scene hook
    By wag321 in forum WoW Memory Editing
    Replies: 6
    Last Post: 07-10-2011, 12:56 PM
All times are GMT -5. The time now is 06:12 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