locked
windows hook slowing down remote terminal session. RRS feed

  • Question

  • I have a MFC application.

    It is having Global hooks -> Global Message Hook and Global Mouse hook.

    Global hooks are needed because we need to capture all messages and mouse movements in this MFC application. In detail, this MFC application inserts its button on other application's title bars.

    When MFC Application run on Windows PC, there is no visible system slowness.


    Scenario: Now, there is a Citrix PC. There are some terminal sessions given out by Citrix. A user on terminal session when use this MFC application, visible slowness is observed.


    Please suggest some method to avoid slowness.


    Thanks

    Monday, January 8, 2018 7:09 AM

All replies

  • I have a MFC application.

    It is having Global hooks -> Global Message Hook and Global Mouse hook.

    Global hooks are needed because we need to capture all messages and mouse movements in this MFC application. In detail, this MFC application inserts its button on other application's title bars.

    When MFC Application run on Windows PC, there is no visible system slowness.


    Scenario: Now, there is a Citrix PC. There are some terminal sessions given out by Citrix. A user on terminal session when use this MFC application, visible slowness is observed.


    Please suggest some method to avoid slowness.


    Thanks

    • Merged by Hart Wang Wednesday, January 17, 2018 7:27 AM no desktop issue
    Monday, January 8, 2018 7:09 AM
  • I have a MFC application.

    It is having Global hooks -> Global Message Hook and Global Mouse hook.

    Global hooks are needed because we need to capture all messages and mouse movements in this MFC application. In detail, this MFC application inserts its button on other application's title bars.

    When MFC Application run on Windows PC, there is no visible system slowness.


    Scenario: Now, there is a Citrix PC. There are some terminal sessions given out by Citrix. A user on terminal session when use this MFC application, visible slowness is observed.


    Please suggest some method to avoid slowness.


    Thanks

    • Merged by Baron Bi Tuesday, January 9, 2018 1:21 AM duplicated case
    Monday, January 8, 2018 7:11 AM
  • You already asked this question two minutes earlier.

    https://social.msdn.microsoft.com/Forums/en-US/0092a216-c9ba-42ee-910c-ee64326fc2f5/windows-hook-slowing-down-remote-terminal-session?forum=vcgeneral

    Please post your question only once.

    Regards, Guido

    • Proposed as answer by Guido Franzke Monday, January 8, 2018 11:32 AM
    Monday, January 8, 2018 11:27 AM
  • Hello,

    maybe you should ask in this forum: https://discussions.citrix.com/

    Regards, Guido

    Monday, January 8, 2018 11:31 AM
  • Based on your description, you don't need a global hook. You say this is for just one application so you don't need a global hook.

    Reconsider the need to capture mouse movement. That will definitely cause performance problems. Probably all you need to do is to hook the messages being sent to the containing window.



    Sam Hobbs
    SimpleSamples.Info

    Monday, January 8, 2018 5:31 PM
  • Hi Anirudh Bhardwaj,

    thanks for posting here.

    Since you have posted duplicated cases in c++ forum, I will merge this case to them for better support.

    Your understanding and cooperation will be grateful.

    Best Regards,

    Baron Bi


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, January 9, 2018 6:06 AM
  • This just is the price of using global hooks.  Your code is getting invoked for every keystroke and every slightest motion of the mouse.  That's a lot of messages, and it is a resource-intensive operation.

    Are you injecting a DLL into the other processes to handle the button?  Can't you just intercept the window messages within the applications where you were injected?  That's less intensive than using a global hook.


    Tim Roberts, Driver MVP Providenza & Boekelheide, Inc.

    Tuesday, January 9, 2018 6:48 PM
  • Suggestion: Minimize the amount of work being done on the input hook's main thread. In the hook, simply cache the data received, then wake up a worker thread that performs any actual work on the data (from your description, updating caption bars). Doing this should help reduce the amount of time that input is blocked on your input hook.
    Friday, January 12, 2018 2:36 AM
  • On all applications that are opened we inject our dll. This dll catches all the messages and we uses those messages which we need.
    Tuesday, January 16, 2018 5:39 AM
  • Suggestion: Minimize the amount of work being done on the input hook's main thread. In the hook, simply cache the data received, then wake up a worker thread that performs any actual work on the data (from your description, updating caption bars). Doing this should help reduce the amount of time that input is blocked on your input hook.
    we have tried this. but its still causing issues.
    Tuesday, January 16, 2018 5:40 AM
  • This just is the price of using global hooks.  Your code is getting invoked for every keystroke and every slightest motion of the mouse.  That's a lot of messages, and it is a resource-intensive operation.

    Are you injecting a DLL into the other processes to handle the button?  Can't you just intercept the window messages within the applications where you were injected?  That's less intensive than using a global hook.


    Tim Roberts, Driver MVP Providenza & Boekelheide, Inc.


    On all applications that are opened we inject our dll. This dll catches all the messages and we uses those messages which we need.
    Tuesday, January 16, 2018 5:40 AM
  • Based on your description, you don't need a global hook. You say this is for just one application so you don't need a global hook.

    Reconsider the need to capture mouse movement. That will definitely cause performance problems. Probably all you need to do is to hook the messages being sent to the containing window.



    Sam Hobbs
    SimpleSamples.Info


    We need all mouse coordinates when it drags a application. So, we are capturing mouse movement.
    Tuesday, January 16, 2018 5:43 AM
  • We need all mouse coordinates when it drags a application. So, we are capturing mouse movement.

    Do you understand the difference between "an application" and "the application"? Those are very different; they do not mean the same thing. In this context if you mean "drags an application" (meaning any application executing in the system) then yes you probably need a global hook. If you mean "drag the application" (meaning only the application that installs the hook) then you do not need a global hook. Your original post says "this MFC application" and everything else implies you need to do this for just the one application except it says you need a global hook. Please think about this before answering.


    Sam Hobbs
    SimpleSamples.Info

    Tuesday, January 16, 2018 6:46 AM
  • We need all mouse coordinates when it drags a application. So, we are capturing mouse movement.

    Do you understand the difference between "an application" and "the application"? Those are very different; they do not mean the same thing. In this context if you mean "drags an application" (meaning any application executing in the system) then yes you probably need a global hook. If you mean "drag the application" (meaning only the application that installs the hook) then you do not need a global hook. Your original post says "this MFC application" and everything else implies you need to do this for just the one application except it says you need a global hook. Please think about this before answering.


    Sam Hobbs
    SimpleSamples.Info

    I am sorry, if my description creates confusion. I will explain more:

    MFC Application -> This is my application.

    Scenario -> When any other application (other than My Application) opens on windows, I inject one dll into it. Eg: MS Word opened. I injected dll into word. When user drags MS word or maximize, minimize it , My application will get coordinates and events.

    That is why I have global hook.

    Now this work smooth on Windows -PC (no slowness observed).

    Problem: On Citrix remote session (or terminal session), this process makes the terminal visibly slower.

    Please ask questions if there are some doubts.

    Thanks.

    Tuesday, January 16, 2018 7:22 AM
  • If the mouse move messages are going over the remote session then it is no surprise that it is a problem. When you try it locally (no terminal session) use Task Manager to watch the amount of processor utilization. You will probably see it go up when the mouse is moved around.


    Sam Hobbs
    SimpleSamples.Info

    Tuesday, January 16, 2018 8:35 PM