Solved

System wide hooking and IShellExecuteHook.execute

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Math Equation 23 147
ASP/VB email question 4 72
BATCH to EXE Converter 2 98
Looking for reading material 2 40
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
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…

734 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