0

Here is my scenario....I am logging in citrix (server)xenapp desktop as user1 with session id say 7 , and also I am having access to the published applications of the server. Among such application I am launching MsPaint, which is launched under username user1 but with a different session id say 3. Now I want to get the window handle of the msPaint window using an exe , which is in my citrix xenapp desktop.

How can this issue be solved?

debanka
  • 187
  • 1
  • 4
  • 13
  • There is no way to use GUI functions cross-session. You'll have to launch a process in the context of the target session (or inject code into an existing process in that session) to do the work on your behalf. – Harry Johnston Feb 26 '15 at 22:34
  • @Harry Johnson -ok but can I do api hooking across sessions for all GUI applications. Let say I want to hook the CreateWindow OR the CreateWindowEx function for all the processes maintained by different sessions. – debanka Feb 27 '15 at 12:20
  • That depends on what method you're using to hook the API. AppInits_Dll would do the trick, but [it's incredibly dangerous](http://blogs.msdn.com/b/oldnewthing/archive/2007/12/13/6648400.aspx) and [doesn't work if secure boot is enabled](http://support.microsoft.com/kb/2853424/en-us). If you have a specific executable that you're interested in, you could [use a compatibility fix](http://support.microsoft.com/kb/317510/en-us) (there's a fix that loads an arbitrary DLL). Sounds like [an XY problem](http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem) to me. – Harry Johnston Feb 27 '15 at 22:58
  • @Harry OK so my task was to calculate the startup time for any GUI application launched. But since my process (which will run as a service) is under a session it cant observe all the other app's getting launched in other sessions. I used ETW to capture pid's that are getting launched and marked the time-as the startup time and thought when the window – debanka Mar 02 '15 at 05:41
  • A call to CreateWindow is not a reliable indication that an application has started in any case. Have you tried WaitForInputIdle? I'm not sure whether that works cross-session or not. But basically if you need to do GUI work in every session you need to have a process in every session. It isn't all that hard to do, and the service can coordinate them. – Harry Johnston Mar 02 '15 at 06:24
  • I tried with WaitForInputidle but it fails always if ran from a service application with return code wait_failed. – debanka Mar 02 '15 at 06:49
  • Harry ..I am still confused maybe I am not articulating right..If admin user wants to monitor the startup time for all applications launched in different sessions, what can be done? Even If I launch a console process for each user login sessions , which will monitor the startup time of app's launched in that session , how will the administrator be able to get a hold of that information? The admin in residing on the a different session , and so my confusion is on the line - "you need to have a process in every session. It isn't all that hard to do, and the service can coordinate them". – debanka Mar 02 '15 at 07:45
  • https://msdn.microsoft.com/en-us/library/windows/desktop/aa365574%28v=vs.85%29.aspx – Harry Johnston Mar 02 '15 at 20:28

0 Answers0