PLS HELP!!! Extend Security rights for Process class

M

MuZZy

Hi,

I'm facing a .NET security problem and hope someone could help me:
My app is using Process class to get some process info, in particular it calls GetProcessByName.
The problem comes when the user is logged in to Windows XP as a Power User, not an Admin, this
function fires a security exception. Is ther a way to extend the security for the whole application
(make it kind of "trusted" application for Windows) or at least for the call to GetProcessByName?

I am new to this security stuff so pls don't kill me if it's a stupid question :)

Any ideas/comments would be highly appreciated!

Thank you,
Andrey
 
W

Willy Denoyette [MVP]

MuZZy said:
Hi,

I'm facing a .NET security problem and hope someone could help me:
My app is using Process class to get some process info, in particular it
calls GetProcessByName.
The problem comes when the user is logged in to Windows XP as a Power
User, not an Admin, this function fires a security exception. Is ther a
way to extend the security for the whole application (make it kind of
"trusted" application for Windows) or at least for the call to
GetProcessByName?

I am new to this security stuff so pls don't kill me if it's a stupid
question :)

Any ideas/comments would be highly appreciated!

Thank you,
Andrey

Some Process methods require Debug privileges, but GetProcessesByName isn't
one of them.
What process are your trying to get?

Willy.
 
M

MuZZy

Willy said:
Some Process methods require Debug privileges, but GetProcessesByName isn't
one of them.
What process are your trying to get?

Hi Willy, thank you for replying!

In fact, it breaks for any process - in my case i check if ms word is running.
You can try this simple code, it works when run by Administrator login, but breaks under PowerUser
login.
//////////// CODE START

using System;
using System.Diagnostics;

public class Test1
{
public Test1() {}

public static void Main(string[] args)
{


Process[] p;

try
{
p = Process.GetProcessesByName("WINWORD");

foreach (Process pp in p)
{
Console.WriteLine("Process: "+ pp.ToString());
}
Console.WriteLine("All set");

}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
Console.ReadLine();
}
}
/////// CODE END


Is there a way to make the app kind of certified/trusted?

Thanak you,
Andrey
 
W

Willy Denoyette [MVP]

MuZZy said:
Willy said:
Some Process methods require Debug privileges, but GetProcessesByName
isn't one of them.
What process are your trying to get?

Hi Willy, thank you for replying!

In fact, it breaks for any process - in my case i check if ms word is
running.
You can try this simple code, it works when run by Administrator login,
but breaks under PowerUser login.
//////////// CODE START

using System;
using System.Diagnostics;

public class Test1
{
public Test1() {}

public static void Main(string[] args)
{


Process[] p;

try
{
p = Process.GetProcessesByName("WINWORD");

foreach (Process pp in p)
{
Console.WriteLine("Process: "+ pp.ToString());
}
Console.WriteLine("All set");
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
Console.ReadLine();
}
}
/////// CODE END


Is there a way to make the app kind of certified/trusted?

Thanak you,
Andrey

Sorry, works for me. Running v1.1 SP1 on XP SP2 as a normal user.
Could you post your OS version and the exception stack?

Willy.
 
M

MuZZy

Willy said:
Willy said:
Hi,

I'm facing a .NET security problem and hope someone could help me:
My app is using Process class to get some process info, in particular it
calls GetProcessByName.
The problem comes when the user is logged in to Windows XP as a Power
User, not an Admin, this function fires a security exception. Is ther a
way to extend the security for the whole application (make it kind of
"trusted" application for Windows) or at least for the call to
GetProcessByName?

I am new to this security stuff so pls don't kill me if it's a stupid
question :)

Any ideas/comments would be highly appreciated!

Thank you,
Andrey


Some Process methods require Debug privileges, but GetProcessesByName
isn't one of them.
What process are your trying to get?

Hi Willy, thank you for replying!

In fact, it breaks for any process - in my case i check if ms word is
running.
You can try this simple code, it works when run by Administrator login,
but breaks under PowerUser login.
//////////// CODE START

using System;
using System.Diagnostics;

public class Test1
{
public Test1() {}

public static void Main(string[] args)
{


Process[] p;

try
{
p = Process.GetProcessesByName("WINWORD");

foreach (Process pp in p)
{
Console.WriteLine("Process: "+ pp.ToString());
}
Console.WriteLine("All set");
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
Console.ReadLine();
}
}
/////// CODE END


Is there a way to make the app kind of certified/trusted?

Thanak you,
Andrey


Sorry, works for me. Running v1.1 SP1 on XP SP2 as a normal user.
Could you post your OS version and the exception stack?

It's Windows 2003 Server Standard Edition with all latest windows updates installed.
User belongs to "Power Users" and "Remote Desktop Users" groups.

I removed try/catch and here is the exception stack:

//------------------------------------------------------------------------------
Unhandled Exception: System.InvalidOperationException: Couldn't get process info
rmation from remote machine. ---> System.ComponentModel.Win32Exception: Access i
s denied
at System.Diagnostics.PerformanceMonitor.GetData(String item)
at System.Diagnostics.PerformanceCounterLib.GetPerformanceData(String item)
at System.Diagnostics.PerformanceCounterLib.get_CategoryTable()
at System.Diagnostics.PerformanceCounterLib.GetPerformanceData(String[] categ
ories, Int32[] categoryIndexes)
at System.Diagnostics.NtProcessManager.GetProcessInfos(PerformanceCounterLib
library)
--- End of inner exception stack trace ---
at System.Diagnostics.NtProcessManager.GetProcessInfos(PerformanceCounterLib
library)
at System.Diagnostics.NtProcessManager.GetProcessInfos(String machineName, Bo
olean isRemoteMachine)
at System.Diagnostics.ProcessManager.GetProcessInfos(String machineName)
at System.Diagnostics.Process.GetProcessesByName(String processName, String m
achineName)
at System.Diagnostics.Process.GetProcessesByName(String processName)
at Test1.Main(String[] args)
//--------------------------------------------------------------------------------

Clearly, something's wrong with permissions... works fine when i'm logged as local admin.

Thank you,
Andrey
 
W

Willy Denoyette [MVP]

MuZZy said:
Sorry, works for me. Running v1.1 SP1 on XP SP2 as a normal user.
Could you post your OS version and the exception stack?

It's Windows 2003 Server Standard Edition with all latest windows updates
installed.
User belongs to "Power Users" and "Remote Desktop Users" groups.

I removed try/catch and here is the exception stack:

//------------------------------------------------------------------------------
Unhandled Exception: System.InvalidOperationException: Couldn't get
process info
rmation from remote machine. ---> System.ComponentModel.Win32Exception:
Access i
s denied
at System.Diagnostics.PerformanceMonitor.GetData(String item)
at System.Diagnostics.PerformanceCounterLib.GetPerformanceData(String
item)
at System.Diagnostics.PerformanceCounterLib.get_CategoryTable()
at System.Diagnostics.PerformanceCounterLib.GetPerformanceData(String[]
categ
ories, Int32[] categoryIndexes)
at
System.Diagnostics.NtProcessManager.GetProcessInfos(PerformanceCounterLib
library)
--- End of inner exception stack trace ---
at
System.Diagnostics.NtProcessManager.GetProcessInfos(PerformanceCounterLib
library)
at System.Diagnostics.NtProcessManager.GetProcessInfos(String
machineName, Bo
olean isRemoteMachine)
at System.Diagnostics.ProcessManager.GetProcessInfos(String
machineName)
at System.Diagnostics.Process.GetProcessesByName(String processName,
String m
achineName)
at System.Diagnostics.Process.GetProcessesByName(String processName)
at Test1.Main(String[] args)
//--------------------------------------------------------------------------------

Clearly, something's wrong with permissions... works fine when i'm logged
as local admin.

Thank you,
Andrey

Ah, On W2K3 you need to be a member of "Performance Monitor Users" group.

Willy.
 
M

MuZZy

Willy said:
MuZZy said:
Sorry, works for me. Running v1.1 SP1 on XP SP2 as a normal user.
Could you post your OS version and the exception stack?

It's Windows 2003 Server Standard Edition with all latest windows updates
installed.
User belongs to "Power Users" and "Remote Desktop Users" groups.

I removed try/catch and here is the exception stack:

//------------------------------------------------------------------------------
Unhandled Exception: System.InvalidOperationException: Couldn't get
process info
rmation from remote machine. ---> System.ComponentModel.Win32Exception:
Access i
s denied
at System.Diagnostics.PerformanceMonitor.GetData(String item)
at System.Diagnostics.PerformanceCounterLib.GetPerformanceData(String
item)
at System.Diagnostics.PerformanceCounterLib.get_CategoryTable()
at System.Diagnostics.PerformanceCounterLib.GetPerformanceData(String[]
categ
ories, Int32[] categoryIndexes)
at
System.Diagnostics.NtProcessManager.GetProcessInfos(PerformanceCounterLib
library)
--- End of inner exception stack trace ---
at
System.Diagnostics.NtProcessManager.GetProcessInfos(PerformanceCounterLib
library)
at System.Diagnostics.NtProcessManager.GetProcessInfos(String
machineName, Bo
olean isRemoteMachine)
at System.Diagnostics.ProcessManager.GetProcessInfos(String
machineName)
at System.Diagnostics.Process.GetProcessesByName(String processName,
String m
achineName)
at System.Diagnostics.Process.GetProcessesByName(String processName)
at Test1.Main(String[] args)
//--------------------------------------------------------------------------------

Clearly, something's wrong with permissions... works fine when i'm logged
as local admin.

Thank you,
Andrey


Ah, On W2K3 you need to be a member of "Performance Monitor Users" group.

Just tried that, doesn't help...
 
W

Willy Denoyette [MVP]

MuZZy said:
Willy said:
MuZZy said:
Sorry, works for me. Running v1.1 SP1 on XP SP2 as a normal user.
Could you post your OS version and the exception stack?

It's Windows 2003 Server Standard Edition with all latest windows updates
installed.
User belongs to "Power Users" and "Remote Desktop Users" groups.

I removed try/catch and here is the exception stack:

//------------------------------------------------------------------------------
Unhandled Exception: System.InvalidOperationException: Couldn't get
process info
rmation from remote machine. ---> System.ComponentModel.Win32Exception:
Access i
s denied
at System.Diagnostics.PerformanceMonitor.GetData(String item)
at System.Diagnostics.PerformanceCounterLib.GetPerformanceData(String
item)
at System.Diagnostics.PerformanceCounterLib.get_CategoryTable()
at
System.Diagnostics.PerformanceCounterLib.GetPerformanceData(String[]
categ
ories, Int32[] categoryIndexes)
at
System.Diagnostics.NtProcessManager.GetProcessInfos(PerformanceCounterLib
library)
--- End of inner exception stack trace ---
at
System.Diagnostics.NtProcessManager.GetProcessInfos(PerformanceCounterLib
library)
at System.Diagnostics.NtProcessManager.GetProcessInfos(String
machineName, Bo
olean isRemoteMachine)
at System.Diagnostics.ProcessManager.GetProcessInfos(String
machineName)
at System.Diagnostics.Process.GetProcessesByName(String processName,
String m
achineName)
at System.Diagnostics.Process.GetProcessesByName(String processName)
at Test1.Main(String[] args)
//--------------------------------------------------------------------------------

Clearly, something's wrong with permissions... works fine when i'm logged
as local admin.

Thank you,
Andrey


Ah, On W2K3 you need to be a member of "Performance Monitor Users" group.

Just tried that, doesn't help...

Did you logoff/logon after the change?

Willy.
 
M

MuZZy

Willy said:
Willy said:
Sorry, works for me. Running v1.1 SP1 on XP SP2 as a normal user.
Could you post your OS version and the exception stack?

It's Windows 2003 Server Standard Edition with all latest windows updates
installed.
User belongs to "Power Users" and "Remote Desktop Users" groups.

I removed try/catch and here is the exception stack:

//------------------------------------------------------------------------------
Unhandled Exception: System.InvalidOperationException: Couldn't get
process info
rmation from remote machine. ---> System.ComponentModel.Win32Exception:
Access i
s denied
at System.Diagnostics.PerformanceMonitor.GetData(String item)
at System.Diagnostics.PerformanceCounterLib.GetPerformanceData(String
item)
at System.Diagnostics.PerformanceCounterLib.get_CategoryTable()
at
System.Diagnostics.PerformanceCounterLib.GetPerformanceData(String[]
categ
ories, Int32[] categoryIndexes)
at
System.Diagnostics.NtProcessManager.GetProcessInfos(PerformanceCounterLib
library)
--- End of inner exception stack trace ---
at
System.Diagnostics.NtProcessManager.GetProcessInfos(PerformanceCounterLib
library)
at System.Diagnostics.NtProcessManager.GetProcessInfos(String
machineName, Bo
olean isRemoteMachine)
at System.Diagnostics.ProcessManager.GetProcessInfos(String
machineName)
at System.Diagnostics.Process.GetProcessesByName(String processName,
String m
achineName)
at System.Diagnostics.Process.GetProcessesByName(String processName)
at Test1.Main(String[] args)
//--------------------------------------------------------------------------------

Clearly, something's wrong with permissions... works fine when i'm logged
as local admin.

Thank you,
Andrey


Ah, On W2K3 you need to be a member of "Performance Monitor Users" group.

Just tried that, doesn't help...


Did you logoff/logon after the change?

Willy.

Hi Willy,
Actually it works when i add a user to "Perf Minitor Users".

Thanks a lot! You really helped me out here!!!

MuZZy
 
F

Family Tree Mike

pauline said:
My applicationthrows "InvalidOperationException" on this particular PC with XP and SP2. The same application runs fine in other PCs with also XP and SP2. I created "Disable Performance Counter" and enabled it. It didn't fix the problem. The User has Administrator access right. What is cause and solution? Please help....

From http://www.developmentnow.com/g/36_...-Extend-Security-rights-for-Process-class.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com/g/

The original post you are replying to is four years old, and doesn't seem to
describe the same problem you are having. Maybe you should post some code
and someone will be able to take a guess at what is happening in your code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top