Is it possible to interact with desktop apps running in a container using the Desktop Sharing API?

  • Thread starter Thread starter Gabriel-Sztejnworcel
  • Start date Start date
G

Gabriel-Sztejnworcel

Guest
Hi,

I asked this question on the containers forum but I didn't get any answer, so I'm trying here as the answer might be related to the way display drivers are handled in Windows containers.

I understand that desktop/GUI apps are not supported in containers. They do run but there's no built-in way to interact with them. I had the following idea - maybe I could use the Desktop Sharing API (Windows Desktop Sharing - Win32 apps) for this purpose, the idea is to run a desktop app (I used notepad in my tests), then run a sharing program that uses the Desktop Sharing API, and connect to it using a Desktop Sharing API viewing program from the host.

I had to do some recap about window stations and desktops, and I noticed that when starting the container with cmd in interactive mode, I'm logged with ContainerAdministrator as a service (logon type 5). I tried running some WinAPI functions that deal with desktops and winstation and got some access denied results, so I switched to running cmd as local system.

The window station of the cmd process (and other child processes) is not the interactive WinSta0, but instead some other service window station, which makes sense since I'm logged on as a service, and I figured that I can't use this window station, so I used a little program I wrote to run notepad in Winsta0 in the Default desktop. Afterwards I ran another program that enumerates the windows on WinSta0\Default, and the notepad window does get enumerated and I also get it's title, so it's running somewhere.

So now I tried running the desktop sharing API program (also on WinSta0\Default). It runs and I can connect from the host, but I only get a black screen without anything in it. I also tried running a program that takes a screenshot of the windows but I get an empty bitmap.

So I thought maybe the Default desktop is not the active desktop, and by using the OpenInputDesktop function I could confirm it - the current desktop was the Winlogon desktop, so I used the SwitchDesktop function to switch to the Default desktop (I used OpenInputDesktop again to verify that it actually worked).

Unfortunately, this didn't change anything, I still get an empty screen and empty bitmaps.

I know that containers are built for micro services and are not supposed to run GUI apps and so, but please bear with me - is there a way to make this work? Or any ideas of what else I can check? Alternatively, if you know that it can't work - I would also be happy to hear a good technical explanation of why it doesn't work.

Thanks a lot :)
Gabriel

Continue reading...
 
Back
Top