Tech Support > Microsoft Windows > Development Resources > can't get handle to process zero
can't get handle to process zero
Posted by code_wrong on October 19th, 2004


Hi,
I am writing a cpu usage monitor for windows xp .. and so I need to get a
handle to all running processes .. This I have done successfully for all but
the first process (th32ProcessID == 0 )

I am following this article:
http://msdn.microsoft.com/library/de..._processes.asp

I have given my application the SE_DEBUG_NAME privelage.

The problem is the call to OpenProcess returns NULL for the first process
only
hProcess = OpenProcess( PROCESS_QUERY_INFORMATION, FALSE,
pe32.th32ProcessID );

How can I get the handle to the first process?

TIA
cw


Posted by code_wrong on October 19th, 2004



"code_wrong" <tac@tac.ouch.co.uk> wrote in message
news:1098202512.23437.0@ersa.uk.clara.net...
ps. OpenProcess fails with error 87 - (The parameter is incorrect)
and yet all of the subsequent calls are OK .. its the same call (looped)



Posted by Stephen Kellett on October 19th, 2004


In message <1098207083.26886.0@ersa.uk.clara.net>, code_wrong
<tac@tac.ouch.co.uk> writes
I think that Process 0 is a notional process that is used to assign the
Idle time to. It doesn't really exist - hence "The parameter is
incorrect" error message. I'm sure someone like Tim Robinson will
correct me if I remember this incorrectly. Its not something I've ever
looked at, just remember reading something about this quite some time
ago.

Either that or process 0 is the system process, which as a user, you
shouldn't be able to fiddle with anyway. But if that were the case I'd
expect you to get "Access Denied".

Stephen
--
Stephen Kellett
Object Media Limited http://www.objmedia.demon.co.uk
RSI Information: http://www.objmedia.demon.co.uk/rsi.html

Posted by code_wrong on October 20th, 2004



"Stephen Kellett" <snail@objmedia.demon.co.uk> wrote in message
news:PBwcdwC2BZdBFwmf@objmedia.demon.co.uk...
My monitor compares fairly well with the total cpu usage as displayed in the
Processes tab in Windows Task Manager (WTM) ...However I now see that a
strange thing occurs when I am online .. The cpu usage displayed on the
status bar and under the Monitor tab of Windows Task Manager do not agree
... they both fluctuate of course but disagree by up to 20%...

the process using the CPU is not visible in the Processes tab of WTM ... I
am thinking that it must be the first process ..

It is odd that WTM seems to monitor all processes in one tab ( and the
status bar) and not in the other .... hmm ..... the plot thickens



Posted by code_wrong on October 20th, 2004



"code_wrong" <tac@tac.ouch.co.uk> wrote in message
news:1098233621.79902.0@iris.uk.clara.net...
ah .. I see where the anomaly is occurring ... My monitor .. and Windows
Task Monitor : Processes tab ... do not monitor interrupts or differed
procedure calls