Results 1 to 4 of 4
  1. #1
    radnomguywfq3's Avatar
    Join Date
    Jan 2007
    Gender
    male
    Location
    J:\E\T\A\M\A\Y.exe
    Posts
    8,858
    Reputation
    381
    Thanks
    1,823
    My Mood
    Sad

    [Tut(C++)] Hooking Functions

    Hooking Functions
    Requested Knowledge :
    - Quite a bit of C++ Programming knowledge
    - Debugging Knowledge
    - Know how DLLs work and inject
    - Knows what a function is.
    - Can locate functions in a debugger

    Required Tools :
    - C++ Compiler(NOT DEV-C++,does't compile DLLs that work)
    - OllyDbg(Or an alternative debugger)
    - Detour.h\detour.cpp files (Download in attachments)
    - DLL Injector
    - TargetApplication.exe(Download In Attachments)



    Whats is 'Hooking A Function"?

    Hooking a function is simply replacing a function with yours, or having your function called
    before\after the targeted function, you could also pass paramters to the targeted function when its called.

    Step one, locating the function of our target.

    Well, we can run the application and you will see that the text "Hello" pops up, and when you hit return, it adds another line with the text "Hello", eventually creating an array of lines with the text "Hello". Finding this function is quite easy to do, we could step through it and examine the program, or we could just search for the ASCII string "hello" in out hex dump. We will find it at 00401082. And a reference to it at 00401082. There you should see an array of pushes followed by a call.

    401080 PUSH ESI
    401081 PUSH EDI
    401082 PUSH 004120B0
    401087 PUSH 00413DF0
    40108C CALL 00401AA0


    and you can see that 00401080 is the start of our function, thus thats the one we need to hook.


    Step Two, Creating the hook.

    #include <windows.h>
    #include "detours.h"
    int (__stdcall* HelloFunction)(void);
    void HookHelloFunction(void)
    {
    MessageBox(0, "You called the function : \"Hello\"", "Function Called", MB_OK);
    return;
    }

    BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
    {
    switch (ul_reason_for_call)
    {
    case DLL_PROCESS_ATTACH:
    HelloFunction = (int (__stdcall*)(void))DetourFunction((PBYTE)0x0040108 0, (PBYTE)HookHelloFunction);
    break;
    case DLL_THREAD_ATTACH:
    break;
    case DLL_THREAD_DETACH:
    break;
    case DLL_PROCESS_DETACH:
    DetourRemove((PBYTE)0x00401080, (PBYTE)HelloFunction); //Remove hook
    break;
    }
    return TRUE;
    }

    A couple new things, first of all the :
    int (__stdcall* HelloFunction)(void);
    Thats basically the structure of our targeted function.

    Then you see void HookHelloFunction(void), thats basically the function where hooking.
    The rest should be quite strait forward.
    DetourFunction(FunctionWithinProcess, FunctionToReplaceItWith)
    and
    DetourRemove(HookedFunction,HelloFunction)
    Last edited by radnomguywfq3; 03-07-2009 at 07:59 PM.



    There are two types of tragedies in life. One is not getting what you want, the other is getting it.

    If you wake up at a different time in a different place, could you wake up as a different person?


  2. The Following 6 Users Say Thank You to radnomguywfq3 For This Useful Post:

    alisonragna (11-07-2018),elcapitan (03-24-2009),ExtremsX (10-25-2012),newgamor (02-22-2011),tete555 (04-06-2012),xDmaster (09-11-2010)

  3. #2
    Synns's Avatar
    Join Date
    May 2007
    Gender
    male
    Posts
    5,174
    Reputation
    170
    Thanks
    2,557
    My Mood
    Bitchy
    401080 Is the PBLC Address?

  4. #3
    radnomguywfq3's Avatar
    Join Date
    Jan 2007
    Gender
    male
    Location
    J:\E\T\A\M\A\Y.exe
    Posts
    8,858
    Reputation
    381
    Thanks
    1,823
    My Mood
    Sad
    Hooking functions doesn't mean making a bypass. Nor does detouring something.
    Last edited by radnomguywfq3; 05-10-2008 at 03:21 PM.



    There are two types of tragedies in life. One is not getting what you want, the other is getting it.

    If you wake up at a different time in a different place, could you wake up as a different person?


  5. #4
    olie122333's Avatar
    Join Date
    Oct 2007
    Gender
    male
    Posts
    438
    Reputation
    10
    Thanks
    20
    can you exlpain how to use this to detour War Rock's version of Punk Buster plz ?


    I can teach you 2 ways of making a bypass in return

Similar Threads

  1. [Help]Hooking Functions
    By aanthonyz in forum C++/C Programming
    Replies: 3
    Last Post: 02-05-2011, 07:59 AM
  2. finding and hooking an unknown function
    By JonnyD in forum General Game Hacking
    Replies: 1
    Last Post: 08-26-2010, 06:51 AM
  3. Hook Function for DIP?
    By ipwnuuaal5 in forum Combat Arms Hack Coding / Programming / Source Code
    Replies: 12
    Last Post: 08-06-2010, 03:52 AM
  4. Using GDI functions on hooked Direct3D applications?
    By ThePro in forum General Game Hacking
    Replies: 1
    Last Post: 07-22-2010, 04:46 PM
  5. tut How to hook tut 6
    By llvengancell in forum WarRock - International Hacks
    Replies: 1
    Last Post: 06-26-2007, 03:24 PM

Tags for this Thread