Windows Hook
-
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 aHANDLE
to it. Does anyone have any comments to point me in the right direction? Thanks in advance. - Nick Parker
My Blog | My Articles -
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 aHANDLE
to it. Does anyone have any comments to point me in the right direction? Thanks in advance. - Nick Parker
My Blog | My Articles>> 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
-
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 aHANDLE
to it. Does anyone have any comments to point me in the right direction? Thanks in advance. - Nick Parker
My Blog | My ArticlesDepending 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.
-
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 aHANDLE
to it. Does anyone have any comments to point me in the right direction? Thanks in advance. - Nick Parker
My Blog | My ArticlesIf the 3rd party app is not a multithread app, you should be fairly safe with using a combination of
FindWindow()
for the HWND andGetWindowThreadProcessId()
for the process identifier when you have the HWND and lastlyOpenProcess()
to get its HANDLE once you have the process identifier. And there'sEnumProcesses()
, but that's NT only. Jeremy Falcon