Solved

System wide hooking and IShellExecuteHook.execute

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
EvenOdd challenge 10 83
Problem to setup 18 80
My 2003 Land Rover discovery 2 key for code for car alarm 7 82
wordappend challenge 8 88
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…
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

744 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now