Problems with Detours v1.5 menu

User Tag List

Results 1 to 12 of 12
  1. #1
    lanman92's Avatar Active Member
    Reputation
    50
    Join Date
    Mar 2007
    Posts
    1,033
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problems with Detours v1.5

    Okay, I'm trying to detour the SendPacket function. All I'm trying to do at the moment is detour it to my function and call the trampoline. I keep getting a error when I compile. Here's the code I'm using:

    Code:
     
    DWORD __cdecl my_Detour(DWORD *pData);
    DWORD(*orig_Func)(DWORD *pData);
     
    .....
     
    orig_Func= DetourFunction((PBYTE)__FuncAddy__, (PBYTE)my_Detour);
     
    ...
     
    DWORD __cdecl my_Detour(DWORD *pData)
    {
    DWORD rtn = orig_Func(pData);
    return rtn;
    }
    

    Problems with Detours v1.5
  2. #2
    Shynd's Avatar Contributor
    Reputation
    97
    Join Date
    May 2008
    Posts
    393
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Gee, including the error(s) you're getting wouldn't be helpful at all.

  3. #3
    lanman92's Avatar Active Member
    Reputation
    50
    Join Date
    Mar 2007
    Posts
    1,033
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    error C2440: '=' : cannot convert from 'PBYTE' to 'DWORD (__cdecl *)(DWORD *)'

    EDIT: And yes, I tried casting the DetourFunction() to (orig_Func)
    Last edited by lanman92; 11-30-2008 at 03:27 PM.

  4. #4
    galpha's Avatar Member
    Reputation
    5
    Join Date
    Nov 2007
    Posts
    48
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
     
    DWORD __cdecl my_Detour(DWORD *pData);
    DWORD(*orig_Func)(DWORD *pData);
     
    .....
     
    orig_Func= DetourFunction((PBYTE)__FuncAddy__, (PBYTE)my_Detour);
     
    ...
     
    DWORD __cdecl my_Detour(DWORD *pData)
    {
    DWORD rtn = orig_Func(pData);
    return rtn;
    }
    

    DWORD(*orig_Func)(DWORD *pData);

    should be

    DWORD(__cdecl *orig_Func)(DWORD *pData);

    and

    orig_Func= DetourFunction((PBYTE)__FuncAddy__, (PBYTE)my_Detour);

    should be

    orig_Func= (DWORD (__cdecl *)(DWORD*))DetourFunction((PBYTE)__FuncAddy__, (PBYTE)my_Detour);

  5. #5
    lanman92's Avatar Active Member
    Reputation
    50
    Join Date
    Mar 2007
    Posts
    1,033
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay, I see now. Thanks for the help.

    EDIT: Could I use a typedef for that so there's not a big mess of parentheses' next to my DetourFunction()?
    Last edited by lanman92; 11-30-2008 at 04:31 PM.

  6. #6
    lanman92's Avatar Active Member
    Reputation
    50
    Join Date
    Mar 2007
    Posts
    1,033
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay, this Detour was supposed to be for SendPacket, but it doesn't seem to work. WoW crashes whenever I inject and move. It says that an address is pointing to 0x2B4 or something. I looked at the code in IDA, and it looks like I'm using the wrong call type. Do I have to pass something in the ecx register(the reference is: mov esi, ecx; cmp [esi + 2b4], 6). I know there is one previous thread about this, but I'm missing something. Also, I can't seem to find the CurrentConnection address.

  7. #7
    kynox's Avatar Account not activated by Email
    Reputation
    830
    Join Date
    Dec 2006
    Posts
    888
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Because SendPacket is part of the CNetClient class. This results in it being a __thiscall convention. You need to preserve ECX!

  8. #8
    lanman92's Avatar Active Member
    Reputation
    50
    Join Date
    Mar 2007
    Posts
    1,033
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah, okay. Have you released your code for this class? Or is there a simpler alternative?

  9. #9
    kynox's Avatar Account not activated by Email
    Reputation
    830
    Join Date
    Dec 2006
    Posts
    888
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    From my teleport hack:
    Code:
    void __declspec(naked) hkSendPacketStub( )
    {
        __asm
        {
            push ecx ; CDataStore*
            push [esp+8]
            call mySendPacket
            add esp, 4
            pop ecx
            jmp pSendPacket
        }    
    }

  10. #10
    lanman92's Avatar Active Member
    Reputation
    50
    Join Date
    Mar 2007
    Posts
    1,033
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay, here is my code:

    Code:
     
    #include "includes.h"
    DWORD __SendPacket__ = 0x005843A0;
    DWORD __GetCurrentConnection__ = 0xDEADBEEF;
    DWORD __RecvPacket__ = 0xDEADBEEF;
    void main(void);
    void SendPacket(DWORD *pData);
    void(*orig_SendPacket)(DWORD *pData);
    BOOL bWantsExit = false;
    BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
    {
    switch( fdwReason ) 
    { 
    case DLL_PROCESS_ATTACH:
    DisableThreadLibraryCalls(hinstDLL);
    CreateThread(0, 0, (LPTHREAD_START_ROUTINE)main, 0, 0, 0);
    break;
    case DLL_PROCESS_DETACH:
    break;
    }
    return TRUE; 
    }
    void main(void)
    {
    while(!bWantsExit)
    {
    if(GetAsyncKeyState(VK_F11))
    {
    orig_SendPacket = (void(*)(DWORD*))DetourFunction((PBYTE)__SendPacket__, (PBYTE)SendPacket);
    }
    if(GetAsyncKeyState(VK_F12))
    {
    DetourRemove((PBYTE)orig_SendPacket, (PBYTE)SendPacket);
    bWantsExit = true;
    }
    Sleep(500);
    }
    }
    void SendPacket(DWORD *pDataStore)
    {
    orig_SendPacket(pDataStore);
    }
    I have to preserve ECX even for something like this? For now, at least...

  11. #11
    galpha's Avatar Member
    Reputation
    5
    Join Date
    Nov 2007
    Posts
    48
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You aren't doing anything in your DLL_PROCESS_DETACH. You should remove your detour in there IMO... way better coding and smarter IMO.

  12. #12
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1356
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by galpha View Post
    You aren't doing anything in your DLL_PROCESS_DETACH. You should remove your detour in there IMO... way better coding and smarter IMO.

    Only if you intend to allow detatching of the DLL. Often this is not desirable, or not an option at all. Then when the process is killed all memory is freed and so you don't really need to do anything.

Similar Threads

  1. Problem with Detours
    By unbekannt1 in forum WoW Memory Editing
    Replies: 15
    Last Post: 03-18-2010, 02:52 AM
  2. Problem with WPE
    By weedlord in forum World of Warcraft General
    Replies: 0
    Last Post: 08-14-2006, 03:35 AM
  3. Problem with BWH 1.11.2
    By gwl15 in forum World of Warcraft General
    Replies: 3
    Last Post: 08-11-2006, 05:37 PM
  4. Problem with CE.
    By Eldretch in forum World of Warcraft General
    Replies: 1
    Last Post: 08-08-2006, 06:49 PM
  5. I have problem with BHW 3.0
    By sunrize1 in forum World of Warcraft General
    Replies: 1
    Last Post: 07-17-2006, 08:49 AM
All times are GMT -5. The time now is 03:43 AM. 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