madshi.net Forum Index madshi.net
high quality low level programming
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to InjectLibrary only for new processes

 
Post new topic   Reply to topic    madshi.net Forum Index -> madCodeHook
View previous topic :: View next topic  
Author Message
francoisr



Joined: 10 Jun 2008
Posts: 8

PostPosted: Thu Sep 10, 2009 10:16 am    Post subject: How to InjectLibrary only for new processes Reply with quote

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? confused Is it possible at all?
Back to top
View user's profile Send private message
iconic



Joined: 08 Jun 2005
Posts: 605

PostPosted: Thu Sep 10, 2009 12:47 pm    Post subject: Reply with quote

Introduced in madCodeHook 2.5.9 the flag DONT_TOUCH_RUNNING_PROCESSES does what you seek.


--Iconic
Back to top
View user's profile Send private message
francoisr



Joined: 10 Jun 2008
Posts: 8

PostPosted: Thu Sep 10, 2009 12:55 pm    Post subject: Reply with quote

Thanks a lot. It is exactly what I was looking for.
Back to top
View user's profile Send private message
dcsoft



Joined: 11 Dec 2004
Posts: 353
Location: San Francisco Bay Area, CA USA

PostPosted: Fri Sep 11, 2009 4:39 am    Post subject: Re: How to InjectLibrary only for new processes Reply with quote

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
View user's profile Send private message Visit poster's website
francoisr



Joined: 10 Jun 2008
Posts: 8

PostPosted: Fri Sep 11, 2009 7:54 am    Post subject: Reply with quote

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
View user's profile Send private message
ISantos



Joined: 11 Sep 2009
Posts: 1

PostPosted: Fri Sep 11, 2009 12:29 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
madshi
Site Admin


Joined: 21 Mar 2004
Posts: 5908

PostPosted: Tue Sep 15, 2009 5:42 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
francoisr



Joined: 10 Jun 2008
Posts: 8

PostPosted: Fri Mar 05, 2010 7:56 pm    Post subject: Reply with quote

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
View user's profile Send private message
madshi
Site Admin


Joined: 21 Mar 2004
Posts: 5908

PostPosted: Tue Mar 23, 2010 8:23 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    madshi.net Forum Index -> madCodeHook All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group