DLL that Exports functions and using HookAPI

c++ / delphi package - dll injection and api hooking
Post Reply
Claes
Posts: 52
Joined: Thu Apr 22, 2004 10:52 pm
Location: Denmark

DLL that Exports functions and using HookAPI

Post by Claes »

Hi,

I'm building a library that both Exports some functions that implement SetWindowsHookEx-hooks, and it also uses HookAPI. The main program imports these functions, and I also use InjectLibrary here. However this crashes the target app :( I do not use InjectLibrary the mad-hooks doesn't seem to be in action.

How can I do this? Is it better to use two DLLs? I would prefer having only one DLL...
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

I'm a bit confused. First you say: "I also use InjectLibrary here". Then you say: "I do not use InjectLibrary". What now? Also are you injecting that dll in one specific process only or system wide? Is your SetWindowsHookEx hook for one thread only or is it system wide? Basically if you use SetWindowsHookEx and if your hook dll gets injected this way into the target process(es), the madCodeHook API hooks should be in action, too.
Claes
Posts: 52
Joined: Thu Apr 22, 2004 10:52 pm
Location: Denmark

Post by Claes »

Oops - the word "if" is missing in front of "I do not use"... sorry for the misspelling...

mad-hooks works on ONE specific process. However, the SetWindowsHook is system-wide.
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

If you do SetWindowsHookEx, is your dll injected into that specific target process, which shall be madCodeHook-hooked? Have you checked that? You can in your initialization ask "GetModuleFileName(0)" to get the current exe name and then depending on that do your HookAPI calls (or not).
Post Reply