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. missing DLL_PROCESS_DETACH

missing DLL_PROCESS_DETACH

Scheduled Pinned Locked Moved C / C++ / MFC
designperformancehelpquestionannouncement
5 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.
  • K Offline
    K Offline
    Kurotora
    wrote on last edited by
    #1

    Hi, I've been writing DLL that attaches to any process by using global hook, and I need to handle attach/detach operation. It is working fine except when I abort debugging program with msdev. I'm using Japanese version of msdev so I can't tell you the exact name of menu title to ABORT debugging, but we sometimes do that for various reasons. In that case, DllMain was not called with DLL_PROCESS_DETACH. And it seems DLL is left loaded. (The reason I think so is: I can't delete that DLL file even after I ended my application which unloads all DLLs from memory.) I'm doing this on Win2K. And not that program being debugged with msdev is not a program that loads the DLL and let attach to processes. Is that a problem by design? If someone knows any documents describing this, please let me know. Thanks. Kurotora

    T C 2 Replies Last reply
    0
    • K Kurotora

      Hi, I've been writing DLL that attaches to any process by using global hook, and I need to handle attach/detach operation. It is working fine except when I abort debugging program with msdev. I'm using Japanese version of msdev so I can't tell you the exact name of menu title to ABORT debugging, but we sometimes do that for various reasons. In that case, DllMain was not called with DLL_PROCESS_DETACH. And it seems DLL is left loaded. (The reason I think so is: I can't delete that DLL file even after I ended my application which unloads all DLLs from memory.) I'm doing this on Win2K. And not that program being debugged with msdev is not a program that loads the DLL and let attach to processes. Is that a problem by design? If someone knows any documents describing this, please let me know. Thanks. Kurotora

      T Offline
      T Offline
      Tomasz Sowinski
      wrote on last edited by
      #2

      There may be a hint in the TerminateProcess API docs: TerminateProcess causes all threads within a process to terminate, and causes a process to exit, but DLLs attached to the process are not notified that the process is terminating. So, if 'End debugging' command is implemented with a call to TerminateProcess, your DLL won't be nofified. Tomasz Sowinski -- http://www.shooltz.com

      K 1 Reply Last reply
      0
      • K Kurotora

        Hi, I've been writing DLL that attaches to any process by using global hook, and I need to handle attach/detach operation. It is working fine except when I abort debugging program with msdev. I'm using Japanese version of msdev so I can't tell you the exact name of menu title to ABORT debugging, but we sometimes do that for various reasons. In that case, DllMain was not called with DLL_PROCESS_DETACH. And it seems DLL is left loaded. (The reason I think so is: I can't delete that DLL file even after I ended my application which unloads all DLLs from memory.) I'm doing this on Win2K. And not that program being debugged with msdev is not a program that loads the DLL and let attach to processes. Is that a problem by design? If someone knows any documents describing this, please let me know. Thanks. Kurotora

        C Offline
        C Offline
        Carlos Antollini
        wrote on last edited by
        #3

        Stupid Question but.... Did you use, the FreeLibrary() function in your Aplication? Regards ;) Carlos Antollini.

        K 1 Reply Last reply
        0
        • T Tomasz Sowinski

          There may be a hint in the TerminateProcess API docs: TerminateProcess causes all threads within a process to terminate, and causes a process to exit, but DLLs attached to the process are not notified that the process is terminating. So, if 'End debugging' command is implemented with a call to TerminateProcess, your DLL won't be nofified. Tomasz Sowinski -- http://www.shooltz.com

          K Offline
          K Offline
          Kurotora
          wrote on last edited by
          #4

          Tomasz, Thank you giving me hint. Can you/anyone let me clear that DLLs are unloaded but not just notified to it? Basically it should I hope though I had a problem with never-unloading-dll. Thanks. I love Code Project, do you? Kurotora

          1 Reply Last reply
          0
          • C Carlos Antollini

            Stupid Question but.... Did you use, the FreeLibrary() function in your Aplication? Regards ;) Carlos Antollini.

            K Offline
            K Offline
            Kurotora
            wrote on last edited by
            #5

            Carlos, Yes. My application unloads my DLLs with FreeLibrary() and do this up to 100 times until GetModuleFileName() returns 0 which means my DLLs are unloaded from memory. Normaly it's working fine. Can anyone know how to unload DLL perfectly without rebooting system? Thanks. I love Code Project, do you? Kurotora

            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