Solved

System wide hooking and IShellExecuteHook.execute

Posted on 2006-06-28
4
706 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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
split53 challenge 7 109
Looking for a network enabled locker remotely controlled like Amazon locker 2 92
Cygwin - GNU GPL License 1 37
Programming Codes 2 22
I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

821 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