Solved

System wide hooking and IShellExecuteHook.execute

Posted on 2006-06-28
4
699 Views
Last Modified: 2012-08-14
Hi All,

I am trying to find a way to do the following:

Get notified by windows when a new application starts to launch and either allow or deny the application to start.

IShellExecuteHook seems to be what i need to acheive this (from what I can understand) - see http://windowssdk.msdn.microsoft.com/en-us/library/ms632981.aspx

This is great BUT according to the MS KB (http://support.microsoft.com/default.aspx?scid=kb;en-us;319524):  "Global hooks are not supported in the .NET Framework"

My problems are these then:  

1) I no longer have a copy of VB6 available (which I could do it with) so I am stuck with VB.net 2005 (dotnet v2).
2) DotNet does not support Global Hooks.
3) I don't understand C.

What I'm after then is either:
A) A smartass response that will tell me a way to do it with dotnet 2005 (which is impossible so far as I know - except for keyboard and mouse hooks).
B) A C++ exe that will hook into windows, pass the launching applications path and processname to my Windows Service and receive a boolean reponse of whether or not to allow it to start.

Thank you all for any help you can give.

James.



0
Comment
Question by:Codestone
4 Comments
 
LVL 22

Accepted Solution

by:
cookre earned 250 total points
ID: 17005071
It's not so much global hooks aren't supported, they're a royal pain and MS would rather not get into it.

The stumbling block - whenever a global hook is specified, the OS requires the callback be in a DLL.  Said DLL can then be kept in memory by the OS as a protection against the hooking process terminating without releasing the hook (it might make MS look bad should they try to do a callback to somewhere, the contents of which is now unknown).

In any case, you still have to come up with an external, unmanaged DLL to get the callbacks (doesn't 2005 do MFC dlls?), then come up with a way to communicate back to you c# app.  I'm partial to custom messages for that sort of thing(see RegisterWindowsMessage().
0
 
LVL 16

Assisted Solution

by:JohnBPrice
JohnBPrice earned 250 total points
ID: 17019871
You can get a C++ exe with source that shows how to hook into any and every app, but you will have to modify it to get it to pass the info to your app.

http://www.madshi.net/madCodeHookDescription.htm
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This is an explanation of a simple data model to help parse a JSON feed
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question