Results 1 to 5 of 5
  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

    [Tutorial(C++)]How to call functions within another process

    Calling another processes functions
    By : [MPGH] Jetamay\ Jeremy

    Requirements
    A debugger(Ollydbg)
    Target Application(Download in attachments)
    A C++ Compiler

    Requested knowledge
    Some debugging knowledge
    How to program in asm(Basics of the Basics)
    C++ (Quite familiar with the language)
    InjecTOR
    familiar with how DLLs work, and what they are.

    Locating the function

    Well, since we have the source-code to this target application, where going to use a string search, just so you know for the future, avoid string searching as much as possible. As you do not want to begin to lean on the strings for the answers.

    So first lets take a look at the source code of our target(C++) :

    #include "stdafx.h"
    #include <iostream.h>
    #include "dos.h"
    void Write()
    {
    cout<<"You called a function n";
    }

    int main(int argc, char* argv[])
    {
    while(true);
    return 0;
    }
    Quite simple. Now we have to locate the Write function in the debugger. How could we do this? Well its quite obvious as the function contains the string "You called a function \n". So there's out first clue. And probably the only one we need. So lets open it in a debugger. Lets perform a quick ASCII string search through the HEX dump for
    "You called a function". You should find it at 00408040 Select the whole sentence, and press Find References to that address. Just as I thought, theres only one result at 00401000 . Now obviously thats the function. So what we need to do now is call 00401000.


    Calling The Function

    This is where your C++ knowledge comes in. What we need to do is program a DLL to go into our target and call the function at 00401000 . I will now explain to you what __asm is, and what its for.

    __asm
    {
    mov eax,eax
    }
    Theres a really simple example of what it does, basically is executes any asm commands.

    Lets take a look at this DLL.

    #include "stdafx.h"
    #include "dos.h"
    void MainLoop()
    {
    void *addyres = (void*)0x00401000;
    MessageBox(0,"About to call the function..","Calling",MB_OK);
    __asm
    {
    call [addyres]
    }
    return;

    }


    BOOL APIENTRY DllMain( HMODULE hModule,
    DWORD ul_reason_for_call,
    LPVOID lpReserved
    )
    {
    switch(ul_reason_for_call)
    {
    case DLL_PROCESS_ATTACH:
    DisableThreadLibraryCalls(hModule);
    CreateThread(NULL, 0, (unsigned long(__stdcall*)(void*))MainLoop, NULL, 0, NULL);
    }
    return TRUE;
    }
    Then inject the DLL. I'll do one one calling functions with parameters later -_-

    By examining that, you should be able to understand how the whole process works, however I am writing this tutorial over remote assist, and its really inconvenient for me.
    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. #2
    angerist's Avatar
    Join Date
    Jun 2008
    Gender
    male
    Posts
    7
    Reputation
    10
    Thanks
    0
    c:\documents and settings\julianana\my documents\visual studio 2008\projects\test hackk\test hackk\source.cpp(1) : fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory

  3. #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
    Try removing that line =X Your probably don't have a precompiled header



    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?


  4. #4
    angerist's Avatar
    Join Date
    Jun 2008
    Gender
    male
    Posts
    7
    Reputation
    10
    Thanks
    0
    =X It works in vs6 lol.

    Nothing happens when I inject it to MapleStory.exe. Im using this addy 0x0046EC10.
    Last edited by angerist; 07-03-2008 at 11:31 PM.

  5. #5
    boom342's Avatar
    Join Date
    Apr 2007
    Posts
    7
    Reputation
    10
    Thanks
    0
    Why not.

    [php]
    typedef void(__cdecl* ChatOutputFunc)();
    ChatOutputFunc ChatOutput = (ChatOutputFunc)0x00401000;[/php]

    Then call it like this.

    [php]ChatOutput();[/php]


    so it would look like.

    [php]#include "stdafx.h"
    #include "dos.h"

    typedef void(__cdecl* ChatOutputFunc)();
    ChatOutputFunc ChatOutput = (ChatOutputFunc)0x00401000;

    void MainLoop()
    {
    ChatOutput();
    return;

    }


    BOOL APIENTRY DllMain( HMODULE hModule,
    DWORD ul_reason_for_call,
    LPVOID lpReserved
    )
    {
    switch(ul_reason_for_call)
    {
    case DLL_PROCESS_ATTACH:
    DisableThreadLibraryCalls(hModule);
    CreateThread(NULL, 0, (unsigned long(__stdcall*)(void*))MainLoop, NULL, 0, NULL);
    }
    return TRUE;
    } [/php]

Similar Threads

  1. Calling functions?
    By Void in forum C++/C Programming
    Replies: 6
    Last Post: 11-29-2009, 09:34 AM
  2. [Tutorial Request] How to join a clan
    By iHack in forum WarRock Korea Hacks
    Replies: 1
    Last Post: 07-30-2007, 06:59 AM
  3. Replies: 8
    Last Post: 07-09-2007, 03:15 PM
  4. (Request) A tutorial on how to extract addresses from trainers
    By englishpom in forum WarRock - International Hacks
    Replies: 9
    Last Post: 05-19-2007, 10:14 PM
  5. Replies: 13
    Last Post: 02-09-2006, 10:25 PM

Tags for this Thread