Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Service - OpenProcess() - Access is denied.

Service - OpenProcess() - Access is denied.

Scheduled Pinned Locked Moved C / C++ / MFC
question
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    daavena
    wrote on last edited by
    #1

    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.

    M stefanmihaimogaS D 3 Replies Last reply
    0
    • D daavena

      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.

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      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:

      D 1 Reply Last reply
      0
      • M Mark Salsbery

        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:

        D Offline
        D Offline
        daavena
        wrote on last edited by
        #3

        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.

        M 1 Reply Last reply
        0
        • D daavena

          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.

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #4

          You may want to search for links like this one[^]. More info: Service User Accounts[^] Mark

          Mark Salsbery Microsoft MVP - Visual C++ :java:

          1 Reply Last reply
          0
          • D daavena

            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.

            stefanmihaimogaS Offline
            stefanmihaimogaS Offline
            stefanmihaimoga
            wrote on last edited by
            #5

            Hello, please have a look to Nibu Babu Thomas's Process Viewer[^]. I learned a lot from that article. Best regards, Mihai Moga

            1 Reply Last reply
            0
            • D daavena

              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.

              D Offline
              D Offline
              daavena
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups