Exe and dll initialization problem in using the Madchook

c++ / delphi package - dll injection and api hooking

Exe and dll initialization problem in using the Madchook

Postby psy2391 » Mon May 02, 2016 11:12 am

If I use the functions in MadChook in exe and dll respectively, and I want to load the dll in the exe.
InitializeMadCHook and FinalizeMadCHook Where should I run ?

My English isn't that good . Sorry.
psy2391
 
Posts: 5
Joined: Thu Feb 11, 2016 3:16 am

Re: Exe and dll initialization problem in using the Madchook

Postby madshi » Mon May 02, 2016 11:19 am

Initialize/FinalizeMadCHook() should only be used by MSVC++ and GCC++ users, not by Delphi or BCB users.

If you're a MSVC++ user, then you should call Initialize/FinalizeMadCHook in all those modules (dlls or exes) which link in the madCodeHook static lib. If your dll links in the madCodeHook static lib, call Initialize/FinalizeMadCHook in DllMain in the PROCESS_ATTACH and PROCESS_DETACH events. If your exe links in the madCodeHook static lib, call InitializeMadCHook somewhere in the initialization. The exact place isn't important, as long as you call it before you call any madCodeHook APIs. Call FinalizeMadCHook when your exe shuts down. Again, the exact place/time isn't important, but make sure you don't call any further madCodeHook APIs after you've called FinalizeMadCHook.

If your dll doesn't link in the madCodeHook static lib, don't call Initialize/FinalizeMadCHook in your dll.

If your exe doesn't link in the madCodeHook static lib, don't call Initialize/FinalizeMadCHook in your exe.

You can also look at the demo projects to see how they're doing it.
madshi
Site Admin
 
Posts: 9142
Joined: Sun Mar 21, 2004 5:25 pm

Re: Exe and dll initialization problem in using the Madchook

Postby psy2391 » Tue May 03, 2016 12:59 am

It became apparent. Thanks for answers
psy2391
 
Posts: 5
Joined: Thu Feb 11, 2016 3:16 am


Return to madCodeHook

Who is online

Users browsing this forum: No registered users and 3 guests

cron