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. Windows Hook

Windows Hook

Scheduled Pinned Locked Moved C / C++ / MFC
comtoolsperformancequestion
4 Posts 4 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.
  • N Offline
    N Offline
    Nick Parker
    wrote on last edited by
    #1

    Just looking for a little clarification here. We have a third party application that we don't control the codebase to, however we do provide the calculation engines it uses. What I am looking to do is time how long it takes from when someone clicks a button within their application to when the report it creates is subsequently displayed. I thought we could use a Windows Hook but from the bit I have read about them, it requires you to have a handle to the process loaded in memory, with the examples I have seen they typically have control over this simply by calling LoadLibrary(). I don't want to load another instance of the executable into memory to get a HANDLE to it. Does anyone have any comments to point me in the right direction? Thanks in advance. - Nick Parker
    My Blog | My Articles

    P A J 3 Replies Last reply
    0
    • N Nick Parker

      Just looking for a little clarification here. We have a third party application that we don't control the codebase to, however we do provide the calculation engines it uses. What I am looking to do is time how long it takes from when someone clicks a button within their application to when the report it creates is subsequently displayed. I thought we could use a Windows Hook but from the bit I have read about them, it requires you to have a handle to the process loaded in memory, with the examples I have seen they typically have control over this simply by calling LoadLibrary(). I don't want to load another instance of the executable into memory to get a HANDLE to it. Does anyone have any comments to point me in the right direction? Thanks in advance. - Nick Parker
      My Blog | My Articles

      P Offline
      P Offline
      palbano
      wrote on last edited by
      #2

      >> however we do provide the calculation engines it uses. So it's a DLL? If so you can change your DLL to get the handle to the current process. Your in. If they link to your lib staticaly that won't work of course. However you can enject DLL into a process. There are articles on MSDN and maybe even here at CP about doing that.

      "No matter where you go, there your are." - Buckaroo Banzai

      -pete

      1 Reply Last reply
      0
      • N Nick Parker

        Just looking for a little clarification here. We have a third party application that we don't control the codebase to, however we do provide the calculation engines it uses. What I am looking to do is time how long it takes from when someone clicks a button within their application to when the report it creates is subsequently displayed. I thought we could use a Windows Hook but from the bit I have read about them, it requires you to have a handle to the process loaded in memory, with the examples I have seen they typically have control over this simply by calling LoadLibrary(). I don't want to load another instance of the executable into memory to get a HANDLE to it. Does anyone have any comments to point me in the right direction? Thanks in advance. - Nick Parker
        My Blog | My Articles

        A Offline
        A Offline
        Antti Keskinen
        wrote on last edited by
        #3

        Depending on what all things the calculation engine does, a timer approach might be useful. If the calculation engine doesn't format the end report, then consider creating a timer that calculates the elapsed time, and one timer that polls for the existence of the report window. I know the latter approach is more or less a hack, but being unable to access the actual codebase it becomes quite difficult to measure the time it takes for a code fragment to execute. So, I would go with one or two timers, if I needed the functionality you describe. Additionally, if you need to determine when the button is pressed, it becomes even more difficult. The only option would be to monitor the messages posted to the program window, and capturing the WM_COMMAND message send by the button click to start the timer. All in all, the whole idea sounds like a waste of time and resources. Why not ask the developer of the third party app to implement a timer ? -Antti Keskinen ---------------------------------------------- The definition of impossible is strictly dependant on what we think is possible.

        1 Reply Last reply
        0
        • N Nick Parker

          Just looking for a little clarification here. We have a third party application that we don't control the codebase to, however we do provide the calculation engines it uses. What I am looking to do is time how long it takes from when someone clicks a button within their application to when the report it creates is subsequently displayed. I thought we could use a Windows Hook but from the bit I have read about them, it requires you to have a handle to the process loaded in memory, with the examples I have seen they typically have control over this simply by calling LoadLibrary(). I don't want to load another instance of the executable into memory to get a HANDLE to it. Does anyone have any comments to point me in the right direction? Thanks in advance. - Nick Parker
          My Blog | My Articles

          J Offline
          J Offline
          Jeremy Falcon
          wrote on last edited by
          #4

          If the 3rd party app is not a multithread app, you should be fairly safe with using a combination of FindWindow() for the HWND and GetWindowThreadProcessId() for the process identifier when you have the HWND and lastly OpenProcess() to get its HANDLE once you have the process identifier. And there's EnumProcesses(), but that's NT only. Jeremy Falcon

          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