cea-sec / sanzu

Graphical remote desktop solution
GNU General Public License v3.0
182 stars 29 forks source link

[Windows] Investigate running sanzu as a headless service #281

Open JeremieSpiesser opened 6 months ago

JeremieSpiesser commented 6 months ago

Hello :wave: ,

I am investigating using sanzu as a headless remote desktop on a windows server. For that to work I would need to

Right now, when I create a service and connect to it, I get an error like this :

[2024-03-06T17:39:16.846625200Z ERROR sanzu_server] Server error
[2024-03-06T17:39:16.846672700Z ERROR sanzu_server]  - due to Cannot init d3d11
[2024-03-06T17:39:16.846695900Z ERROR sanzu_server]  - due to Cannot create d3d11 device

This errors stems from the EnumOutputs call here https://github.com/cea-sec/sanzu/blob/main/sanzu/src/server_windows.rs#L635 that fails when started this way.

Interestingly, Sunshine seem to use a similar approach https://github.com/LizardByte/Sunshine/blob/nightly/src/platform/windows/display_base.cpp#L484 but manages to handle the case where EnumOutputs fails (typically when not running from a logged in user session).

I tried to add the SetThreadExecutionState(ES_DISPLAY_REQUIRED); to sanzu like Sunshine does but it isn't enough apparently.

  1. Have you got any rough idea as to what would be necessary to make sanzu usable for headless remote desktop (including beeing able to log into windows remotely) ?
  2. If I were to make a PR that adds this feature, would you consider merging it or is it out of scope for the project ?

Thanks