Service - OpenProcess() - Access is denied.
-
Hi all, I am trying to write a simple program which would be able to give me a list of running processes. I am using OpenProcess(PROCESS_ALL_ACCESS, false, pid); But I always get Access is denied - because it is a service. Can you give me a hint how can I get service name when I know its PID? Is it possible? Thanks.
-
Hi all, I am trying to write a simple program which would be able to give me a list of running processes. I am using OpenProcess(PROCESS_ALL_ACCESS, false, pid); But I always get Access is denied - because it is a service. Can you give me a hint how can I get service name when I know its PID? Is it possible? Thanks.
daavena wrote:
But I always get Access is denied - because it is a service.
More likely because the account the service is running under. What account does your service run in? Do you really need PROCESS_ALL_ACCESS rights?
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
daavena wrote:
But I always get Access is denied - because it is a service.
More likely because the account the service is running under. What account does your service run in? Do you really need PROCESS_ALL_ACCESS rights?
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
Hi, "What account does your service run in?" under System or Network service "Do you really need PROCESS_ALL_ACCESS rights?" I tried PROCESS_QUERY_INFORMATION but it didn't work so I tried PROCESS_ALL_ACCESS. Thanks.
You may want to search for links like this one[^]. More info: Service User Accounts[^] Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
Hi all, I am trying to write a simple program which would be able to give me a list of running processes. I am using OpenProcess(PROCESS_ALL_ACCESS, false, pid); But I always get Access is denied - because it is a service. Can you give me a hint how can I get service name when I know its PID? Is it possible? Thanks.
Hello, please have a look to Nibu Babu Thomas's Process Viewer[^]. I learned a lot from that article. Best regards, Mihai Moga
-
Hi all, I am trying to write a simple program which would be able to give me a list of running processes. I am using OpenProcess(PROCESS_ALL_ACCESS, false, pid); But I always get Access is denied - because it is a service. Can you give me a hint how can I get service name when I know its PID? Is it possible? Thanks.
Thank you all for replay, This piece of code solves my problem. HANDLE hToken; LUID seDebug; TOKEN_PRIVILEGES tkp; OpenProcessToken( GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES |TOKEN_QUERY, &hToken ); LookupPrivilegeValue( NULL, SE_DEBUG_NAME, &seDebug ); tkp.PrivilegeCount = 1; tkp.Privileges[0].Luid = seDebug; tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; AdjustTokenPrivileges( hToken, FALSE, &tkp, sizeof tkp, NULL, NULL ); CloseHandle( hToken ); I have to find out what it exactly does. Thanks.