What all dlls to be included to main application for hooking

c++ / delphi package - dll injection and api hooking
Sanjeev
Posts: 16
Joined: Wed Jun 09, 2004 3:51 pm

What all dlls to be included to main application for hooking

Post by Sanjeev »

Hello,

I have downloaded the demo application and package as well. Now I want to hook some function in my programm. Do I need to run madcodehook setup before running my application or I can include some dlls in my setup file. If dlls are enough for hooking what all dlls need to be installed on the target system. Thanks in advance.

Sanjeev
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Which development system are you using? Delphi? BCB? MSVC?
Sanjeev
Posts: 16
Joined: Wed Jun 09, 2004 3:51 pm

Post by Sanjeev »

Right now we are using MSVC. One more question can we use this in VB also?

Thanks and Regards
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

When using MSVC there are 2 options: You can use the dynamic lib file or the static lib file. When using the dynamic lib file you need to distribute the madCHook.dll with your application. On the target PC this dll must be copied to the system folder. When using the static lib file there's nothing at all which you need to distribute with your application. The static lib file is only available in the commercial version of madCodeHook, though.

VB can perhaps be used for your application which starts the hooking/dll injection. But the hook dll itself can not be written in VB, since VB doesn't properly support pointers and function variables (AFAIK).
Sanjeev
Posts: 16
Joined: Wed Jun 09, 2004 3:51 pm

Post by Sanjeev »

Thanks a lot for your information. Just need one another favour. Do you have any VB code which will do hooking/dll injection.

Best Regards
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

No, I don't have any VB code. But if you know VB well, you should be able to make it work yourself. Here's the C++ code:

// (un)inject the specified dll into (from) all current and future processes
// these flags can be used for both UninjectLibrary + InjectLibrary
#define ALL_SESSIONS 0xFFFFFFED // apps of all sessions
#define CURRENT_SESSION 0xFFFFFFEC // apps of current session
#define CURRENT_USER 0xFFFFFFEB // apps of current user

// the following flags may only be used in combination with the first 3 flags
#define SYSTEM_PROCESSES 0x10 // include this flag to include system processes + services
#define CURRENT_PROCESS 0x08 // exclude this flag to exclude injection into yourself

// same as LoadLibrary, but is able to load the library in any process
madCHookApi(BOOL) InjectLibraryA(
DWORD dwProcessHandleOrSpecialFlags,
LPCSTR pLibFileName,
DWORD dwTimeOut = 7000
);

That API is exported by "madCHook.dll" under the name "InjectLibraryA". You should be able to call this from VB. However, the hook dll must be created by using Delphi or MSVC.
Sanjeev
Posts: 16
Joined: Wed Jun 09, 2004 3:51 pm

Post by Sanjeev »

Thanks a lot for the information. I have one more question about licencing. I want to buy the sorce code. But before buying this we want to test this in our application. For this we will buy commercial licence before. Now can we upgrade from commercial licence to source code licence? Also for source code do you send updates/Support ? If yes then upto when.

Thanks
Sanjeev
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Please contact me via mail about the source code license. I prefer to not discuss this publically. Thanks!

Minor updates and bugfixes are always free for any license type. Major upgrades are free in the first 12 months after your purchase. After that major upgrades might cost an upgrade price.
Sanjeev
Posts: 16
Joined: Wed Jun 09, 2004 3:51 pm

Post by Sanjeev »

Ok,

Thanks, I'll get in touch with you via email. One more thing I was trying to convert this code in VB. I was able to sucessfully call the function InjectLibraryW in VB but hooking is not working. In VB we need to pass integer/long value for any constant. I converted #define ALL_SESSIONS 0xFFFFFFED and the long value is -19. I passed this value. It would be great if you can tell me the long value for 0xFFFFFFED. I am using dynamic library for testing. I tried standerd dll HookProcessCreation.dll for hooking in VB but its not working. InjectLibraryW returns true.


Sanjeev
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Did you recompile the HookProcessCreation.dll or did you use the precompiled dll which ships with madCodeHook? I think -19 should be correct, so I don't see why injection should fail! Do the precompiled demos work on your PC?
Sanjeev
Posts: 16
Joined: Wed Jun 09, 2004 3:51 pm

Post by Sanjeev »

I used precompiled dlls. I gave value -19 and full path from VB in InjectLibraryW function. on win 2k it returned true but did not do hooking. but on XP it returned false. I tried -20 (CURRENT_SESSION) and -21 (CURRENT_USER) also but all fails. Please advice....
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

What happens if you use the precompiled DllInjector to inject the precompiled HookProcessTermination.dll? Does that work?
Sanjeev
Posts: 16
Joined: Wed Jun 09, 2004 3:51 pm

Help needed for win 98

Post by Sanjeev »

Hello,

I recently bought the commercial version. I compiled the dll with static library. It is working on NT system but not working on 98. It gives runtime error and searches for madCHook.dll. If this dll file is present on 98 it workes fine if I remove the dll then it gives error. On 2k, XP it is working fine without madCHook.dll. Is there anything I did in wrong way. Or I need to do some settings in my dll project which is written in VC using the given sample code (HookProcessCreation).

Thanks
Sanjeev
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Now that is strange! Could you please mail your hook dll to me?
Sanjeev
Posts: 16
Joined: Wed Jun 09, 2004 3:51 pm

Post by Sanjeev »

Just sent you the dll with full source code. Please have a look at it and let me know (I know I may be making some silly mistake) :oops: .
Post Reply