Blizzhackers

Return of the Jedi

* Login   * Register    * FAQ    * Search

Join us on IRC: #bh@irc.synirc.net (or Mibbit Web IRC)


MuleFactory


It is currently Wed Jun 19, 2013 3:23 pm


All times are UTC [ DST ]





Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: [C] External overlays ontop of game screens
PostPosted: Fri Dec 31, 2010 8:19 pm 
 
User
User
User avatar

Joined: Thu Mar 16, 2006 8:29 am
Location: Oklahoma, United States
How do people write these, what API is used in them, where can I find information on them and possible some source code?
I'd like to add a crosshair onto FPS game that I play.

Top
 Profile  
 Post subject: Re: [C] External overlays ontop of game screens
PostPosted: Fri Dec 31, 2010 9:24 pm 
 
User Gold
User Gold
User avatar

Joined: Wed Sep 22, 2004 11:55 pm
Location: The Wired
Most of these are implemented using either Direct3D (if the program is rendering using D3D) or OpenGL (if the program is rendering using OpenGL) hooks. The hook function would be called by the program, then it would use the same Direct3D or OpenGL rendering context to draw the crosshair (or in the case of game overlays, usually some text on the screen), and then it'd call its original unhooked function.

The way PIX and FRAPS run their overlays in D3D mode is by implementing a v-table hook on the IDirect3DDevice9::Present() function (or D3D10 or D3D11, depends on which version you're running). This style of hooking D3D must be done immediately when the program starts (otherwise patching the v-table becomes much trickier and you might as well just use the other method).

If the overlay is not available to be installed in the program immediately when it starts (like how you can attach and detach FRAPS from a program while it's running) then you'd probably have to do a function hook on the Present() member function itself. IMO, the MS-Detours API is probably the most pain-free thing to use in this situation.

I am not entirely sure how I'd implement an OpenGL hook (I've never had to do one before), but you may be able to get away with using a proxy DLL (easiest method), or you might have to use DLL-injection + function hooking (suckier method).

_________________
Image
Lewis Carroll wrote:
Still she haunts me, phantom-wise, Alice moving under skies; Never seen by waking eyes...
Name origins

Top
 Profile  
 Post subject: Re: [C] External overlays ontop of game screens
PostPosted: Fri Dec 31, 2010 9:52 pm 
 
User
User
User avatar

Joined: Thu Mar 16, 2006 8:29 am
Location: Oklahoma, United States
I'm not great with dll injeciton, I've never beable to eject the DLL after loading it.
Specifically, it's a game that uses OpenGL. It's there any examples available? I've searched google but I only receive PHP and jQuery stuff.

I've never used hooks before, where can I learn about them?

Top
 Profile  
 Post subject: Re: [C] External overlays ontop of game screens
PostPosted: Fri Dec 31, 2010 10:22 pm 
 
User Gold
User Gold
User avatar

Joined: Wed Sep 22, 2004 11:55 pm
Location: The Wired
Well this site has an explanation of how to do OpenGL function hooking in assembly. I would personally just use MS-Detours though.

_________________
Image
Lewis Carroll wrote:
Still she haunts me, phantom-wise, Alice moving under skies; Never seen by waking eyes...
Name origins

Top
 Profile  
 Post subject: Re: [C] External overlays ontop of game screens
PostPosted: Fri Dec 31, 2010 10:58 pm 
 
User
User
User avatar

Joined: Thu Mar 16, 2006 8:29 am
Location: Oklahoma, United States
What MS Api are you talking about?

Top
 Profile  
 Post subject: Re: [C] External overlays ontop of game screens
PostPosted: Fri Dec 31, 2010 11:28 pm 
 
User Gold
User Gold
User avatar

Joined: Wed Sep 22, 2004 11:55 pm
Location: The Wired
ogg_vorbis wrote:
What MS Api are you talking about?
This one:
http://research.microsoft.com/en-us/projects/detours/

_________________
Image
Lewis Carroll wrote:
Still she haunts me, phantom-wise, Alice moving under skies; Never seen by waking eyes...
Name origins

Top
 Profile  
 Post subject: Re: [C] External overlays ontop of game screens
PostPosted: Tue Jan 04, 2011 1:24 am 
 
User
User
User avatar

Joined: Thu Mar 16, 2006 8:29 am
Location: Oklahoma, United States
How the hell do you compile this?!
Do I need to use Visual Studio or something? (I am using Dev-C++)

Top
 Profile  
 Post subject: Re: [C] External overlays ontop of game screens
PostPosted: Tue Jan 04, 2011 2:59 am 
 
User Gold
User Gold
User avatar

Joined: Wed Sep 22, 2004 11:55 pm
Location: The Wired
You will probably need Visual Studio to compile it without having to perform major headaches in Dev-C++

_________________
Image
Lewis Carroll wrote:
Still she haunts me, phantom-wise, Alice moving under skies; Never seen by waking eyes...
Name origins

Top
 Profile  
 Post subject: Re: [C] External overlays ontop of game screens
PostPosted: Tue Jan 04, 2011 3:54 am 
 
User
User
User avatar

Joined: Thu Mar 16, 2006 8:29 am
Location: Oklahoma, United States
I've managed to only create a static library of it. My DLL fails to compile.

1>------ Build started: Project: detourdll2, Configuration: Release Win32 ------
1>  stdafx.cpp
1>  creatwth.cpp
1>..\..\..\..\..\..\..\Program Files\Microsoft Research\Detours Express 2.1\src\creatwth.cpp(11): warning C4627: '#include <stddef.h>': skipped when looking for precompiled header use
1>          Add directive to 'StdAfx.h' or rebuild precompiled header
1>..\..\..\..\..\..\..\Program Files\Microsoft Research\Detours Express 2.1\src\creatwth.cpp(17): warning C4627: '#include <strsafe.h>': skipped when looking for precompiled header use
1>          Add directive to 'StdAfx.h' or rebuild precompiled header
1>..\..\..\..\..\..\..\Program Files\Microsoft Research\Detours Express 2.1\src\creatwth.cpp(23): warning C4627: '#include "detours.h"': skipped when looking for precompiled header use
1>          Add directive to 'StdAfx.h' or rebuild precompiled header
1>..\..\..\..\..\..\..\Program Files\Microsoft Research\Detours Express 2.1\src\creatwth.cpp(880): fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "StdAfx.h"' to your source?
1>  detoured.cpp
1>..\..\..\..\..\..\..\Program Files\Microsoft Research\Detours Express 2.1\src\detoured.cpp(11): warning C4627: '#include "detoured.h"': skipped when looking for precompiled header use
1>          Add directive to 'StdAfx.h' or rebuild precompiled header
1>..\..\..\..\..\..\..\Program Files\Microsoft Research\Detours Express 2.1\src\detoured.cpp(12): error C2001: newline in constant
1>..\..\..\..\..\..\..\Program Files\Microsoft Research\Detours Express 2.1\src\detoured.cpp(12): warning C4627: '#include "d"': skipped when looking for precompiled header use
1>          Add directive to 'StdAfx.h' or rebuild precompiled header
1>..\..\..\..\..\..\..\Program Files\Microsoft Research\Detours Express 2.1\src\detoured.cpp(33): fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "StdAfx.h"' to your source?
1>  detours.cpp
1>..\..\..\..\..\..\..\Program Files\Microsoft Research\Detours Express 2.1\src\detours.cpp(18): warning C4627: '#include "detours.h"': skipped when looking for precompiled header use
1>          Add directive to 'StdAfx.h' or rebuild precompiled header
1>..\..\..\..\..\..\..\Program Files\Microsoft Research\Detours Express 2.1\src\detours.cpp(19): warning C4627: '#include "detoured.h"': skipped when looking for precompiled header use
1>          Add directive to 'StdAfx.h' or rebuild precompiled header
1>..\..\..\..\..\..\..\Program Files\Microsoft Research\Detours Express 2.1\src\detours.cpp(1410): fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "StdAfx.h"' to your source?
1>  disasm.cpp
1>..\..\..\..\..\..\..\Program Files\Microsoft Research\Detours Express 2.1\src\disasm.cpp(11): warning C4627: '#include <limits.h>': skipped when looking for precompiled header use
1>          Add directive to 'StdAfx.h' or rebuild precompiled header
1>..\..\..\..\..\..\..\Program Files\Microsoft Research\Detours Express 2.1\src\disasm.cpp(16): warning C4627: '#include "detours.h"': skipped when looking for precompiled header use
1>          Add directive to 'StdAfx.h' or rebuild precompiled header
1>..\..\..\..\..\..\..\Program Files\Microsoft Research\Detours Express 2.1\src\disasm.cpp(1601): fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "StdAfx.h"' to your source?
1>  image.cpp
1>..\..\..\..\..\..\..\Program Files\Microsoft Research\Detours Express 2.1\src\image.cpp(15): warning C4627: '#include <strsafe.h>': skipped when looking for precompiled header use
1>          Add directive to 'StdAfx.h' or rebuild precompiled header
1>..\..\..\..\..\..\..\Program Files\Microsoft Research\Detours Express 2.1\src\image.cpp(26): warning C4627: '#include "detours.h"': skipped when looking for precompiled header use
1>          Add directive to 'StdAfx.h' or rebuild precompiled header
1>..\..\..\..\..\..\..\Program Files\Microsoft Research\Detours Express 2.1\src\image.cpp(2188): fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "StdAfx.h"' to your source?
1>  modules.cpp
1>..\..\..\..\..\..\..\Program Files\Microsoft Research\Detours Express 2.1\src\modules.cpp(15): warning C4627: '#include <strsafe.h>': skipped when looking for precompiled header use
1>          Add directive to 'StdAfx.h' or rebuild precompiled header
1>..\..\..\..\..\..\..\Program Files\Microsoft Research\Detours Express 2.1\src\modules.cpp(20): warning C4627: '#include "detours.h"': skipped when looking for precompiled header use
1>          Add directive to 'StdAfx.h' or rebuild precompiled header
1>..\..\..\..\..\..\..\Program Files\Microsoft Research\Detours Express 2.1\src\modules.cpp(725): fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "StdAfx.h"' to your source?
1>  detourdll2.cpp
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


I don't even know... :facepalm:

Top
 Profile  
 Post subject: Re: [C] External overlays ontop of game screens
PostPosted: Tue Jan 04, 2011 6:04 am 
 
User Gold
User Gold
User avatar

Joined: Wed Sep 22, 2004 11:55 pm
Location: The Wired
Did you add createwth.cpp to the project? You are not supposed to.

_________________
Image
Lewis Carroll wrote:
Still she haunts me, phantom-wise, Alice moving under skies; Never seen by waking eyes...
Name origins

Top
 Profile  
 Post subject: Re: [C] External overlays ontop of game screens
PostPosted: Tue Jan 04, 2011 6:43 am 
 
User
User
User avatar

Joined: Thu Mar 16, 2006 8:29 am
Location: Oklahoma, United States
I'm getting undeclared identifier errors like crazy with and without createwth.cpp. Ugh, I've never used Visual Studio and never really got into C++. dfhjsdgf

Top
 Profile  
 Post subject: Re: [C] External overlays ontop of game screens
PostPosted: Tue Jan 04, 2011 8:49 am 
 
User Gold
User Gold
User avatar

Joined: Wed Sep 22, 2004 11:55 pm
Location: The Wired
Oh I forgot that Detours is a project that is supposed to be built from the Makefile rather than from Visual Studio itself. My mistake. Just open up the Visual Studio Command Prompt from the start menu. Navigate to where you installed Detours. Go into the src folder, and do nmake Makefile

_________________
Image
Lewis Carroll wrote:
Still she haunts me, phantom-wise, Alice moving under skies; Never seen by waking eyes...
Name origins

Top
 Profile  
 Post subject: Re: [C] External overlays ontop of game screens
PostPosted: Tue Jan 04, 2011 9:14 am 
 
User
User
User avatar

Joined: Thu Mar 16, 2006 8:29 am
Location: Oklahoma, United States
Oddly enough, I've done this too and I still receive some errors. :-?

Top
 Profile  
 Post subject: Re: [C] External overlays ontop of game screens
PostPosted: Tue Jan 04, 2011 9:37 am 
 
User Gold
User Gold
User avatar

Joined: Wed Sep 22, 2004 11:55 pm
Location: The Wired
ogg_vorbis wrote:
Oddly enough, I've done this too and I still receive some errors. :-?
Which ones?

_________________
Image
Lewis Carroll wrote:
Still she haunts me, phantom-wise, Alice moving under skies; Never seen by waking eyes...
Name origins

Top
 Profile  
 Post subject: Re: [C] External overlays ontop of game screens
PostPosted: Wed Jan 05, 2011 11:06 pm 
 
User
User
User avatar

Joined: Thu Mar 16, 2006 8:29 am
Location: Oklahoma, United States
I finally got it. It was Visual C++ Express that was the problem.

Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron