Results 1 to 9 of 9

Hybrid View

  1. #1
    MerkurAlex's Avatar
    Join Date
    Mar 2009
    Gender
    male
    Posts
    4
    Reputation
    10
    Thanks
    0

    C++ Detours "DetourFunction" issue.

    Using the "detours library" I have a message box when someone logs into a server and selects a character:

    Code:
    //the function
    void NewUser(void)
    {
    	MessageBox(0, "User Logged On.", "Function Called", MB_OK);
    }
    
    NewUserHook = (int (__stdcall*)(void))DetourFunction((PBYTE)0x004BA74D, (PBYTE)NewUser); //the hook line im calling on DLL_PROCESS_ATTACH
    NOTE: this is just small snippets

    Now on to the problem I get the messagebox when a user logs on but after I close the box and they load the map they are unable to move or do anything so I guess I need a way to return properly and allow the server to continue running normally(if someone else connects it acts fine until of course they load the map and cannot load not sure if that is from threading probably is)

  2. #2
    ilovecookies's Avatar
    Join Date
    Oct 2009
    Gender
    male
    Location
    In the C++ Section
    Posts
    321
    Reputation
    10
    Thanks
    67
    My Mood
    Shocked
    Quote Originally Posted by MerkurAlex View Post
    Using the "detours library" I have a message box when someone logs into a server and selects a character:

    Code:
    //the function
    void NewUser(void)
    {
    	MessageBox(0, "User Logged On.", "Function Called", MB_OK);
    }
    
    NewUserHook = (int (__stdcall*)(void))DetourFunction((PBYTE)0x004BA74D, (PBYTE)NewUser); //the hook line im calling on DLL_PROCESS_ATTACH
    NOTE: this is just small snippets

    Now on to the problem I get the messagebox when a user logs on but after I close the box and they load the map they are unable to move or do anything so I guess I need a way to return properly and allow the server to continue running normally(if someone else connects it acts fine until of course they load the map and cannot load not sure if that is from threading probably is)
    I personally can't help you, but I THINK this is problem that DavidM44 was running into, he was trying to hook a function, jmp the function, then execute the rest of the code normally(Which would require calling the function that was jumped. Correct me if i'm wrong) So someone here may be able to help you. Depending on whether or not he figured out the answer.
    Quote Originally Posted by Jules Winnfield View Post
    I am the tyranny of evil men, and you are all the weak. But i'm trying Ringo,i'm trying real hard, to become the shepherd.
    excuse me miss, would you kindly reflect some photons off the epidermis covering your sternum directly into the camera iris or vacate the proximity immediately
    [IMG]https://i882.photobucke*****m/albums/ac23/miki_d420/RealizingYoureALeecher2copy.jpg[/IMG]









  3. #3
    Hell_Demon's Avatar
    Join Date
    Mar 2008
    Gender
    male
    Location
    I love causing havoc
    Posts
    3,976
    Reputation
    343
    Thanks
    4,320
    My Mood
    Cheeky
    NewUser is of a different type then NewUserHook
    And you'll want to return the original function
    Code:
    int __stdcall NewUser(void)
    {
        MessageBox(0, "User Logged On.", "Function Called", MB_OK);
        return NewUserHook();
    }
    Ah we-a blaze the fyah, make it bun dem!

  4. #4
    MerkurAlex's Avatar
    Join Date
    Mar 2009
    Gender
    male
    Posts
    4
    Reputation
    10
    Thanks
    0
    Quote Originally Posted by Hell_Demon View Post
    NewUser is of a different type then NewUserHook
    And you'll want to return the original function
    Code:
    int __stdcall NewUser(void)
    {
        MessageBox(0, "User Logged On.", "Function Called", MB_OK);
        return NewUserHook();
    }
    Hmm I tried this and now the server just gets stuck right after my message box(I have to end the process) as if its in an endless loop.

  5. #5
    Mr.Magicman's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Sitting in my cave full of thoughts learning Asembly
    Posts
    2,102
    Reputation
    16
    Thanks
    649
    My Mood
    Cold
    this looks like a complicated problem and i think you have to ask dave or some one to get this working

  6. #6
    why06's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    IBM
    Posts
    4,304
    Reputation
    170
    Thanks
    2,203
    My Mood
    Flirty
    Try running it in VS debugger, and find the point where it freezes. Seems like its local.

    "Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."
    - Dwight D. Eisenhower

  7. #7
    MerkurAlex's Avatar
    Join Date
    Mar 2009
    Gender
    male
    Posts
    4
    Reputation
    10
    Thanks
    0
    Quote Originally Posted by why06 View Post
    Try running it in VS debugger, and find the point where it freezes. Seems like its local.
    Are you suggesting I run my dll(that I normally inject into the game) in VS debugger?

    Im probably missing something please explain.

  8. #8
    why06's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    IBM
    Posts
    4,304
    Reputation
    170
    Thanks
    2,203
    My Mood
    Flirty
    Quote Originally Posted by MerkurAlex View Post
    Are you suggesting I run my dll(that I normally inject into the game) in VS debugger?

    Im probably missing something please explain.
    I was under the impression that this was a game you were making. In that case, idk, it really depends exactly what the code does. Something about what ur .dll does is causing adverse effects in the game. Just make sure you don't have any loose ends. =/

    It could be a combination of your .dll and the game causing the loop.

    "Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."
    - Dwight D. Eisenhower

  9. #9
    MerkurAlex's Avatar
    Join Date
    Mar 2009
    Gender
    male
    Posts
    4
    Reputation
    10
    Thanks
    0
    With my current code (see below) the hook(detour) works the first time(just like before) and then the process seems to continue but if I try to close the process it stops responding.

    I ran the program with IDA pro injected the dll and then went through the steps to make that hook run when it did IDA said it caused an unknown exception.

    Current code(basically the same thing but for a different address point):
    Code:
    #include <windows.h>
    #include "detours.h"
    #include <iostream>
    #include <fstream>
    using namespace std;
    
    int (__stdcall* DemoBugFixPoint)(void);
    int __stdcall DemoBugFixPoint(void)
    {
    	ofstream myfile;
    	  myfile.open ("legends.log");
    	  myfile << "SetRights(demo bug fix) applied to new logon.\n";
    	  myfile.close();
    
    	  return DemoBugFixPointHook();
    }
    
    BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
    {
    switch (ul_reason_for_call)
    {
    	case DLL_PROCESS_ATTACH:
    		DemoBugFixPointHook = (int (__stdcall*)(void))DetourFunction((PBYTE)0x004B8ABF, (PBYTE)DemoBugFixPoint);
    		break;
    	case DLL_THREAD_ATTACH:
    		break;
    	case DLL_THREAD_DETACH:
    		break;
    	case DLL_PROCESS_DETACH:
    		DetourRemove((PBYTE)0x004B8ABF, (PBYTE)DemoBugFixPointHook); //Remove hook
    		break;
    }
    return TRUE;
    }
    btw the assembly of "0x004B8ABF" is just NOP im not sure if that is an issue if it is can someone explain an easier way to run my function when the program reaches that address point?

Similar Threads

  1. Favorite Quote
    By EleMentX in forum Spammers Corner
    Replies: 13
    Last Post: 01-04-2020, 04:36 PM
  2. MPGH PM Chat Quote Thread
    By arunforce in forum Entertainment
    Replies: 39
    Last Post: 05-12-2013, 08:24 PM
  3. MPGH AIM Chat Quote Thread
    By ace76543 in forum Entertainment
    Replies: 30
    Last Post: 09-25-2011, 12:14 PM
  4. MPGH IRC Chat Quote Thread
    By i eat trees in forum Entertainment
    Replies: 746
    Last Post: 07-02-2011, 10:07 PM
  5. Quotes & Lists
    By radnomguywfq3 in forum General
    Replies: 15
    Last Post: 01-17-2008, 05:14 PM