| View previous topic :: View next topic |
| Author |
Message |
francoisr
Joined: 10 Jun 2008 Posts: 8
|
Posted: Thu Sep 10, 2009 10:16 am Post subject: How to InjectLibrary only for new processes |
|
|
I would like to inject a DLL only into newly created processes.
I vaguely recall reading something somewhere about a (new?) flag that would signal this, but now I cannot find any info on this in either the help files or in the source code.
My DLL is lightweight, but it requires a number of other system DLLs (ie WinInet.dll) that I don't really want to load into every process. I know that I could change all the static references in my DLL to dynamic ones, but that would be a lot of work for little gain. Either way, I would prefer to only load my DLL into either a specific (user selected) process or any newly created process.
Is there an undocumented flag on InjectLibrary that can specify this or am I mistaken? Is it possible at all? |
|
| Back to top |
|
 |
iconic
Joined: 08 Jun 2005 Posts: 605
|
Posted: Thu Sep 10, 2009 12:47 pm Post subject: |
|
|
Introduced in madCodeHook 2.5.9 the flag DONT_TOUCH_RUNNING_PROCESSES does what you seek.
--Iconic |
|
| Back to top |
|
 |
francoisr
Joined: 10 Jun 2008 Posts: 8
|
Posted: Thu Sep 10, 2009 12:55 pm Post subject: |
|
|
| Thanks a lot. It is exactly what I was looking for. |
|
| Back to top |
|
 |
dcsoft
Joined: 11 Dec 2004 Posts: 353 Location: San Francisco Bay Area, CA USA
|
Posted: Fri Sep 11, 2009 4:39 am Post subject: Re: How to InjectLibrary only for new processes |
|
|
| francoisr wrote: | | My DLL is lightweight, but it requires a number of other system DLLs (ie WinInet.dll) that I don't really want to load into every process. I know that I could change all the static references in my DLL to dynamic ones, but that would be a lot of work for little gain. |
If your DLL is written in VC++, you could use the delay-load option which won't load WinInet until you actually call it the first time, and you don't need to use LoadLibrary/GetProcAddress to achieve this.
-- David |
|
| Back to top |
|
 |
francoisr
Joined: 10 Jun 2008 Posts: 8
|
Posted: Fri Sep 11, 2009 7:54 am Post subject: |
|
|
Hi David.
My code is unfortunately written in Delphi. It is small enough and doesn't require the VCL, so I could probably do a version 2 in VC someday.
Thanks for the tip.
Francois |
|
| Back to top |
|
 |
ISantos
Joined: 11 Sep 2009 Posts: 1
|
Posted: Fri Sep 11, 2009 12:29 pm Post subject: |
|
|
| iconic wrote: | Introduced in madCodeHook 2.5.9 the flag DONT_TOUCH_RUNNING_PROCESSES does what you seek.
--Iconic |
Hi Everyone,
I am using DONT_TOUCH_RUNNING_PROCESSES flag for InjectLibrary function, it's working ok,
But I would like to uninject every process.. How can I turn off the flag for UninjetcLibrary function ? |
|
| Back to top |
|
 |
madshi Site Admin
Joined: 21 Mar 2004 Posts: 5908
|
Posted: Tue Sep 15, 2009 5:42 pm Post subject: |
|
|
The latest version now always uninjects from all processes, regardless of whether the DONT_TOUCH_RUNNING_PROCESSES option was activated or not. Or in other words: The option now only affect injection, but not uninjection, anymore. Here's the download:
http://madshi.net/madCollection.exe (2.5.11.1) |
|
| Back to top |
|
 |
francoisr
Joined: 10 Jun 2008 Posts: 8
|
Posted: Fri Mar 05, 2010 7:56 pm Post subject: |
|
|
Is there any way that I can turn the DONT_TOUCH_RUNNING_PROCESSES option off after I had previously set it?
In other words, I need something like ClearMadCHookOption. |
|
| Back to top |
|
 |
madshi Site Admin
Joined: 21 Mar 2004 Posts: 5908
|
Posted: Tue Mar 23, 2010 8:23 pm Post subject: |
|
|
Hello,
and sorry for the late reply.
With madCodeHook 3.0 there are 2 new options called "INJECT_INTO_RUNNING_PROCESSES" and "UNINJECT_FROM_RUNNING_PROCESSES". For both the 2nd SetMadCHookOption parameter is defined to be a bool value (typecasted to LPCWSTR / PWideChar). So you can turn both options on/off. |
|
| Back to top |
|
 |
|