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. determining exit code of a process from a dll in that process

determining exit code of a process from a dll in that process

Scheduled Pinned Locked Moved C / C++ / MFC
jsonquestion
2 Posts 2 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.
  • J Offline
    J Offline
    JudyL_MD
    wrote on last edited by
    #1

    I've got a DLL that is injected into every process in my system. Among other things, it does a bit of process monitoring. As part of that, I'd like to track the exit code of each process. DllMain with a reason code of DLL_PROCESS_DETACH enables me to tell if the process is exiting nicely or not via the value of the reserved parameter. I'm obviously interested in the not nice case. Calling GetExitProcessCode isn't useful because the process has not completely exited yet and the code isn't available until it's truly dead . I know that for DLL_PROCESS_ATTACH, the reserved value is actually a CONTEXT pointer. Is there something similar for the _DETACH case - in other words, what does the reserved parameter point to? I'm hoping that it points to something that I can use to see what that exit code is - the system knows what it is since the process is in the act of exiting, but there isn't an API to get it. Any ideas? Thanks, Judy

    Be wary of strong drink. It can make you shoot at tax collectors - and miss. Lazarus Long, "Time Enough For Love" by Robert A. Heinlein

    R 1 Reply Last reply
    0
    • J JudyL_MD

      I've got a DLL that is injected into every process in my system. Among other things, it does a bit of process monitoring. As part of that, I'd like to track the exit code of each process. DllMain with a reason code of DLL_PROCESS_DETACH enables me to tell if the process is exiting nicely or not via the value of the reserved parameter. I'm obviously interested in the not nice case. Calling GetExitProcessCode isn't useful because the process has not completely exited yet and the code isn't available until it's truly dead . I know that for DLL_PROCESS_ATTACH, the reserved value is actually a CONTEXT pointer. Is there something similar for the _DETACH case - in other words, what does the reserved parameter point to? I'm hoping that it points to something that I can use to see what that exit code is - the system knows what it is since the process is in the act of exiting, but there isn't an API to get it. Any ideas? Thanks, Judy

      Be wary of strong drink. It can make you shoot at tax collectors - and miss. Lazarus Long, "Time Enough For Love" by Robert A. Heinlein

      R Offline
      R Offline
      rod naR
      wrote on last edited by
      #2

      Hi Judy, I know that if you call NtQueryInformationProcess with the PROCESSINFOCLASS of ProcessBasicInformation on a normally executing process... the ExitStatus member of the PROCESS_BASIC_INFORMATION struct should always return 0x103 which is STATUS_PENDING. You could try checking this value during DLL_PROCESS_DETACH, it should be safe to make calls into NTDLL. I cannot remember off the top of my head when ntoskrnl sets this exit code value during process termination so it may not be changed yet. I'm not in my normal office so I cannot test this. Let me know how it turns out. Best Wishes, -David an eluDe

      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