Inject code
Posted: Thu Aug 05, 2004 2:44 pm
Does anyone know a tutorial or something about how to inject code to D3D dll instead of OpenGl processes?
Why are you trying to hook to the game? Are you having problems that a simple debugger can't handle?Tredo wrote:Yes! I have tried several deassamblers, like Resource analyser. LOL, Im a nOOb at thinks like this. Im working on it You have to start somewhere... A deassambler must work to....Ass i Sad, Im working on It but I want tips and trix you know.....the code we are talking about Is for the game Painkiller.
Two things hereTredo wrote:For an example, If you want to hook at OpenGL you use something like this.....
FARPROC WINAPI myGetProcAddress(HMODULE hModule,LPCSTR lpProcName)
{
if(HIWORD(lpProcName))
{
// Your GlHooking Code Goes Here
}
return GetProcAddress(hModule,lpProcName);
}
Now what this does is now that you have hooked GetProcAddress everytime the target application calls it, it will use your function instead, this enables you to return whatever function address you like, weather it be your custom fucntion or the real one.
Note: This is usually something for advanced coders, not noobs. Beginners and Intermediates usually have a hard time in grasping these kinds of concepts.Tredo wrote:So you ask, what goes in // your glhooking code here well it shuld look something like this:
typedef void(APIENTRY *func_glBegin)(GLvoid);
func_glBegin org_glBegin;
void APIENTRY my_glBegin(GLvoid)
{
// Your Stuff Here
org_glBegin();
}
and so on.....
Has someone extract the painkiller.exe and so on and looked at It?
Im learning to code to so have undertanding to me at my nOOb questions.....
I know there are a tool out there with the name Evilhack, I cant find It Its help you to inject code....
Its really not that much different from other functions, except you can only get the function Direct3DCreate8/Direct3DCreate9 with the GetProcAddress, everything else you have to get using the methods. It depends on what functions you wanna hook to though.Tredo wrote:BUT! My question GetProcAddress for OpenGL, what Is for D3D?
If you read the theories, you should know how to hook into D3D then.Tredo wrote:Hey! Yes thats thrue. If you read my thread againg you will understand that I havent hooked IT yet. Its ha hookfunction. Forcelibrary, you can read more about It Thanks for your teori, lol I have already read them.
Code: Select all
var
X: IDirect3D9;
Y: Pointer;
begin
X := Direct3DCreate9(D3D_SDK_VERSION);
Y := Addr(X.GetAdapterCount);
// Now Y = Address of GetAdapterCount
end;
A good reason to do this is to make a game compatible with Windows 9X. More games are starting to use functions which only exist in Windows NT-based DLL's which would otherwise work in Windows 9X, like GlobalMemoryStatusEx. Hooking would fix this in a better and more universal way than trying to path the game's executables especially since many games use copy-protection.Anonymous wrote:Why are you trying to hook to the game? Are you having problems that a simple debugger can't handle?
Well you are intercepting calls to the original DLL and passing everying else to it that you don't rewrite. Functions you modify from the original DLL are existing so that is hooking. Functions which you add that don't exist in the original of course wouldn't be.Rahly wrote:Then your not really "hooking" because, hooking means your attaching yourself to an already existing function.
I disagree. For example, many programs which would otherwise run on Windows 9X will not simply because the developer chose to use "GlobalMemoryStatusEx" instead of "GlobalMemoryStatus". Hooking Kernel32.dll on Windows 9X systems to handle the slight differences between these two functions would seem trivial.Rahly wrote:Sounds like a lot more work than its worth. There are so many functions you'd have to hook to
True, but how do you write a DLL to pass all function calls that you don't want to modify (or possibly don't even know exist since some functions in Windows DLL's like Kernel32.dll are undocumented) to the real DLL when you don't have the source code to the original DLL?It would be easier, and faster to replace the system dlls that it uses.
Such as?Then again, there are alright projects out there that does this for you.