473,768 Members | 8,326 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Capturing processes

SLE
Hi there,

I am writing a service which monitors processes on the local machine.
Currently I have implemented a System.Manageme nt.ManagementEv entWatcher
which raises events for processes being launched:

New WqlEventQuery(" SELECT * FROM __InstanceCreat ionEvent WITHIN 0.1
WHERE TargetInstance ISA 'Win32_Process' ")

So far so good but I need additional information (e.g. window title)
which I'm getting via the System.Diagnost ics.Process:

p = Process.GetProc essById(pid)

....

windowTitle = p.MainWindowTit le
Problems occur when a lot of (concurrent) processes are launched in a
*short* period of time:

1) There is no WMI event for some processes (some events seem to be sunk)
2) When the WMI event comes in, the process might already been
terminated so the subsequent GetProcessById( ) fails.

Question:

Can I avoid WMI for having an event-driven model? Is there a *fast*,
event-driven way to detect processes being started/stopped?
--
SLE
Nov 21 '05 #1
2 1924
Hi,

Windows hooks
http://msdn.microsoft.com/msdnmag/is...0/CuttingEdge/
Ken
--------------------------
"SLE" <in**@NOSPAM.da taworx.be> wrote in message
news:uS******** ******@TK2MSFTN GP12.phx.gbl...
Hi there,

I am writing a service which monitors processes on the local machine.
Currently I have implemented a System.Manageme nt.ManagementEv entWatcher
which raises events for processes being launched:

New WqlEventQuery(" SELECT * FROM __InstanceCreat ionEvent WITHIN 0.1
WHERE TargetInstance ISA 'Win32_Process' ")

So far so good but I need additional information (e.g. window title)
which I'm getting via the System.Diagnost ics.Process:

p = Process.GetProc essById(pid)

....

windowTitle = p.MainWindowTit le
Problems occur when a lot of (concurrent) processes are launched in a
*short* period of time:

1) There is no WMI event for some processes (some events seem to be sunk)
2) When the WMI event comes in, the process might already been
terminated so the subsequent GetProcessById( ) fails.

Question:

Can I avoid WMI for having an event-driven model? Is there a *fast*,
event-driven way to detect processes being started/stopped?
--
SLE
Nov 21 '05 #2
SLE
Ken Tucker [MVP] wrote:
Hi,

Windows hooks
http://msdn.microsoft.com/msdnmag/is...0/CuttingEdge/
Ken
--------------------------
"SLE" <in**@NOSPAM.da taworx.be> wrote in message
news:uS******** ******@TK2MSFTN GP12.phx.gbl...
Hi there,

I am writing a service which monitors processes on the local machine.
Currently I have implemented a System.Manageme nt.ManagementEv entWatcher
which raises events for processes being launched:

New WqlEventQuery(" SELECT * FROM __InstanceCreat ionEvent WITHIN 0.1
WHERE TargetInstance ISA 'Win32_Process' ")

So far so good but I need additional information (e.g. window title)
which I'm getting via the System.Diagnost ics.Process:

p = Process.GetProc essById(pid)

...

windowTitle = p.MainWindowTit le
Problems occur when a lot of (concurrent) processes are launched in a
*short* period of time:

1) There is no WMI event for some processes (some events seem to be sunk)
2) When the WMI event comes in, the process might already been
terminated so the subsequent GetProcessById( ) fails.

Question:

Can I avoid WMI for having an event-driven model? Is there a *fast*,
event-driven way to detect processes being started/stopped?


Ken,

Thanks but looking into hooks as an alternative for WMI, I already ran
into that article. It describes local hooks; I would need a system wide
hook.

Problem is that implementing such system wide hooks (aka global hooks)
with "pure" .NET is no sinecure if not impossible.
--
SLE
Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1004
by: SLE | last post by:
Hi there, I am writing a service which monitors processes on the local machine. Currently I have implemented a System.Management.ManagementEventWatcher which raises events for processes being launched: New WqlEventQuery("SELECT * FROM __InstanceCreationEvent WITHIN 0.1 WHERE TargetInstance ISA 'Win32_Process'") So far so good but I need additional information (e.g. window title)
4
12010
by: Jay Xx | last post by:
I have an IFrame in design mode. I've tried a bunch of things to capture key presses in that IFrame, but I can't seem to get it. I can capture key presses outside the IFrame fine. I have this problem in Firefox, not IE. I do know it's possible because Blogger.com's rich text editor does it, but their code is cryptic and separated into like 20 files, so I'm going through hell trying to decipher it. (I need to capture the keypress in order...
33
5642
by: Joerg Schuster | last post by:
Hello, Python regular expressions must not have more than 100 capturing groups. The source code responsible for this reads as follows: # XXX: <fl> get rid of this limitation! if p.pattern.groups > 100: raise AssertionError( "sorry, but this version only supports 100 named groups"
1
2675
by: SG | last post by:
Hello, I'm using _execvpe (Win32 console project in VS.NET) to spawn a child process. I would like to know if you have any pointers on how to capture the child's STDOUT and STDERR? Any help is greatly appreciated. Thanks, Sri
14
2549
by: Brent Burkart | last post by:
I am trying to capture the Windows Authenticated username, but I want to be able to capture the login name that exists in IIS, not Windows. In order to enter my company's intranet through the internet, they have to login. I want to be able to capture that login versus their Windows login because I need to know who they are from any computer rather than only their computer. Any ideas? Thanks
2
2696
by: Stampede | last post by:
Hi guys & girls, I would like to write some kind of "Head-Tracking-Software", which uses a WebCam to react to the movement of the head of the person sitting in front of the monitor. I searched the web and found some information on writing such a software with the help of the DirectShow library of DirectX9. But as it was all in C++ and as I'm not very good in C++ I thought someone here might give me a link or some other information on how...
1
1280
by: Ivan | last post by:
Hello. I’m trying to capture standard output of the other process which is launched from my win app. I tried to do it with freopen function which captured content of the printf functions, but not the output of the other processes (even if it used printf function and launched with system function). How can I perform my task? How should I run other processes?
6
2267
by: Ed Leafe | last post by:
I've been approached by a local business that has been advised that they need to start capturing and archiving their instant messaging in order to comply with Sarbanes-Oxley. The company is largely PC, but has a significant number of Macs running OS X, too. Googling around quickly turns up IM Grabber for the PC, which would seem to be just what they need. But there is no equivalent to be found for OS X. So if anyone knows of any such...
3
3304
by: danbrotherston | last post by:
Hello, I am trying to get the output from the win32 platform command OutputDebugString. I have used the following C++ code as a guideline: http://groups.google.com/group/microsoft.public.vc.utilities/browse_frm/thread/1434418cb968d053/1a3c957675242c7e?lnk=st&q=DBWIN_BUFFER&rnum=3#1a3c957675242c7e And I have been able to translate most things into python, but I have been unable to get it to work. I use the pywin extensions to call
0
9576
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10175
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10017
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9961
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7384
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5283
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5425
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3932
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2808
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.