Welcome to Dream.In.Code
Become a C++ Expert!

Join 149,540 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,511 people online right now. Registration is fast and FREE... Join Now!




Hooking Functions From Another Application

 
Reply to this topicStart new topic

Hooking Functions From Another Application, Puzzled about most of the ordeal

RodgerB
20 Nov, 2007 - 01:27 AM
Post #1

D.I.C Lover
Group Icon

Joined: 21 Sep, 2007
Posts: 2,164



Thanked: 17 times
Dream Kudos: 2200
Expert In: Dot Net Technologies

My Contributions
I have been getting pretty interested in Reverse Engineering at the moment, and I would like to use this in order to create a fake player bot for a game I am associated with, in the community and such. I already have a solid foundation of the C++ language and I'd like to learn how to hook a function from another program.

The developers of the game have challenged the community to create it themselves as they are pretty darn lazy.

Any sort of tutorials, snippets, links and any sort of other help would be greatly appreciated. Also, some more practical information on finding the function's addresses would be appreciated also.

Thanks in advance. smile.gif
User is offlineProfile CardPM
+Quote Post

tlrobinson
RE: Hooking Functions From Another Application
20 Nov, 2007 - 11:13 AM
Post #2

New D.I.C Head
*

Joined: 10 Apr, 2007
Posts: 2


My Contributions
QUOTE(RodgerB @ 20 Nov, 2007 - 02:27 AM) *

I have been getting pretty interested in Reverse Engineering at the moment, and I would like to use this in order to create a fake player bot for a game I am associated with, in the community and such. I already have a solid foundation of the C++ language and I'd like to learn how to hook a function from another program.

The developers of the game have challenged the community to create it themselves as they are pretty darn lazy.

Any sort of tutorials, snippets, links and any sort of other help would be greatly appreciated. Also, some more practical information on finding the function's addresses would be appreciated also.

Thanks in advance. smile.gif


Not sure if this is what you're looking for, but on Linux you can override dynamic library functions using LD_PRELOAD, and similarly on Mac OS X there's DYLD_INSERT_LIBRARIES (also on Mac OS X there's this neat package called mach-override and mach-inject). Not sure about Windows.
User is offlineProfile CardPM
+Quote Post

RodgerB
RE: Hooking Functions From Another Application
20 Nov, 2007 - 03:45 PM
Post #3

D.I.C Lover
Group Icon

Joined: 21 Sep, 2007
Posts: 2,164



Thanked: 17 times
Dream Kudos: 2200
Expert In: Dot Net Technologies

My Contributions
Thanks for your reply, tlrobinson.

I am unsure of what I am actually searching for, I'd like to be able to hook a function (a client connect function) by address to change the arguments and redirect the playerid, or alter the playerid. I'd like to be able to do this on Linux and Windows, as that is the platform the dedicated server is mostly used on.

I'm not looking for detouring the DLL Injection, rather modify the way the injected Dll Functions (its a multiplayer mod for Grand Theft Auto: San Andreas).

Thanks again. smile.gif
User is offlineProfile CardPM
+Quote Post

born2c0de
RE: Hooking Functions From Another Application
21 Nov, 2007 - 12:04 AM
Post #4

printf("I'm a %XR",195936478);
Group Icon

Joined: 26 Nov, 2004
Posts: 4,026



Thanked: 38 times
Dream Kudos: 2800
Expert In: 80x86 Assembly, C/C++, VB6, VB.NET, C#, J2SE, Win32 API, Reversing

My Contributions
Well, you can modify the way the function works using a detour.
What do you want to modify?
User is offlineProfile CardPM
+Quote Post

no2pencil
RE: Hooking Functions From Another Application
21 Nov, 2007 - 05:07 AM
Post #5

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 7,126



Thanked: 76 times
Dream Kudos: 2425
Expert In: Goofing Off

My Contributions
QUOTE(RodgerB @ 20 Nov, 2007 - 05:45 PM) *

I am unsure of what I am actually searching for,

You're looking for Windows API Hook.

QUOTE(RodgerB @ 20 Nov, 2007 - 05:45 PM) *

I'd like to be able to do this on Linux and Windows, as that is the platform the dedicated server is mostly used on.

You need to get the Process ID, & then intercept all calls(communication) from the Windows API to & from that Process. You'll return the API communication, but with your edited API instructions.
User is online!Profile CardPM
+Quote Post

RodgerB
RE: Hooking Functions From Another Application
21 Nov, 2007 - 10:50 PM
Post #6

D.I.C Lover
Group Icon

Joined: 21 Sep, 2007
Posts: 2,164



Thanked: 17 times
Dream Kudos: 2200
Expert In: Dot Net Technologies

My Contributions
Thanks for your replies.

born2code, I'd like to modify the connection function that the server uses to connect a player, store a playerid etc, so It would recognize it as a player, running from server-sided plugins (a feature of the server application). I'd also like to detour the ping function or re-route it to another playerid, so I don't have to waste my time having it accept them. This can't be made client side as the game uses a secret protocol for connections, as there were numerous DoS bots made in the past.

Thanks for your help, no2pencil.
User is offlineProfile CardPM
+Quote Post

no2pencil
RE: Hooking Functions From Another Application
21 Nov, 2007 - 11:44 PM
Post #7

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 7,126



Thanked: 76 times
Dream Kudos: 2425
Expert In: Goofing Off

My Contributions
Rather than hook the process, why don't you setup a dumby server on your network (even in VMware if you know how) & point your hosts file to that local ip. Then when Windows resolves the domain name, it'll resolve to your local server & interact with it that way.
User is online!Profile CardPM
+Quote Post

RodgerB
RE: Hooking Functions From Another Application
22 Nov, 2007 - 12:31 AM
Post #8

D.I.C Lover
Group Icon

Joined: 21 Sep, 2007
Posts: 2,164



Thanked: 17 times
Dream Kudos: 2200
Expert In: Dot Net Technologies

My Contributions
QUOTE(no2pencil @ 22 Nov, 2007 - 06:44 PM) *

Rather than hook the process, why don't you setup a dumby server on your network (even in VMware if you know how) & point your hosts file to that local ip. Then when Windows resolves the domain name, it'll resolve to your local server & interact with it that way.


I am not running a server. I am part of a major development project called PartyServer (http://www.partyserver.net) in the SA-MP community, which I generally code (well, scripting) and play on. I'd like to be able to hook the function server-sided, so I'd be able to create fake players. I don't have enough money to run a server of my own. smile.gif

And no, I don't have the ability to access the host or even remotely change the infrastructure of the server. All I wanted to do was give back to the community.

Thanks. smile.gif
User is offlineProfile CardPM
+Quote Post

no2pencil
RE: Hooking Functions From Another Application
22 Nov, 2007 - 12:37 AM
Post #9

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 7,126



Thanked: 76 times
Dream Kudos: 2425
Expert In: Goofing Off

My Contributions
QUOTE(RodgerB @ 22 Nov, 2007 - 02:31 AM) *

QUOTE(no2pencil @ 22 Nov, 2007 - 06:44 PM) *

Rather than hook the process, why don't you setup a dumby server on your network (even in VMware if you know how) & point your hosts file to that local ip. Then when Windows resolves the domain name, it'll resolve to your local server & interact with it that way.


I am not running a server. I am part of a major development project called PartyServer (http://www.partyserver.net) in the SA-MP community, which I generally code (well, scripting) and play on. I'd like to be able to hook the function server-sided, so I'd be able to create fake players. I don't have enough money to run a server of my own. smile.gif

And no, I don't have the ability to access the host or even remotely change the infrastructure of the server. All I wanted to do was give back to the community.

Thanks. smile.gif

No no no no... not hardware. You can launch the server (software) inside of a VMware sesson. Then that "server" will have an ip on your lan, & you can ping it & communicate with it. Then on your windows system, edit the host file (C:\windows\system32\drivers\etc\hosts if you use XP) & point the domain name to the local non-routable ip. Then your client can communicate with the server, even though it's on the same machine.

I would think this would be easier than hooking the process.
User is online!Profile CardPM
+Quote Post

RodgerB
RE: Hooking Functions From Another Application
22 Nov, 2007 - 01:34 AM
Post #10

D.I.C Lover
Group Icon

Joined: 21 Sep, 2007
Posts: 2,164



Thanked: 17 times
Dream Kudos: 2200
Expert In: Dot Net Technologies

My Contributions
QUOTE(no2pencil @ 22 Nov, 2007 - 07:37 PM) *

No no no no... not hardware. You can launch the server (software) inside of a VMware sesson. Then that "server" will have an ip on your lan, & you can ping it & communicate with it. Then on your windows system, edit the host file (C:\windows\system32\drivers\etc\hosts if you use XP) & point the domain name to the local non-routable ip. Then your client can communicate with the server, even though it's on the same machine.

I would think this would be easier than hooking the process.


I think I understand what you're trying to say now. I could already use the server software and the client software at the same time on the same machine. The problem being, you can only have one Grand Theft Auto: SA process running at the same time (on the same machine), and I wouldn't want to have more than one open anyhow (client), as it would lag the server beyond belief, and even more if it's in VMware.

I'm not looking for an easier alternative, I am looking for a challenge in which I can increment my knowledge in this area, whether it be RE or API hooking they'd be both good to know.

Thanks. smile.gif
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 1/7/09 09:21PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month