Solved

System wide hooking and IShellExecuteHook.execute

Posted on 2006-06-28
4
723 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

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…
This is about my first experience with programming Arduino.
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…
Six Sigma Control Plans

691 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