Add winpty support for Windows agents
This pull request adds winpty support to MeshAgent and is open for discussion.
Closes https://github.com/Ylianst/MeshCentral/issues/4327
winpty provides functionality similar to Windows Pseudo Console (ConPTY), when ConPTY is not available. See https://github.com/rprichard/winpty
In order for it to work, winpty.dll and winpty-agent.exe are installed alongside the agent binary. I included pre-built versions these two files as Visual Studio resources that are compiled into the meshagent binary, which are installed during MeshServer_ConnectEx using deployWinPtyDependencies (see modules/service-manager.js). The files are taken from the Microsoft VSCode release bundle, because it ships with these files too.
The most important changes are in modules/service-manager.js (installation of winpty deps) and modules/win-terminal.js (agent plugin replacement).
Some thoughts: Due to the fact, that the winpty dependencies are compiled into the agent binary, the overall file size of MeshService64.exe increases. Another idea would be to make a "legacy Windows MeshAgent" binary with winpty support and a smaller one without (that uses ConPTY). Another idea would be that MeshCentral sends these dependencies over the network after installation if needed to keep the file size small.
Note: We successfully tested this solution on Windows 10, version 1607 (64-bit). It should work on 32-bit Windows systems as well. I included the 32-bit binaries of winpty. But that still needs testing!
i will have to ask @Ylianst to have a look at is for me, as putting a dll and exe next to the binary would now mean the app is no longer portable AND it means we would have to create an installer which is another ball ake!?
Ok thanks!
For clarification: The dll (and winpty-agent.exe) would only be compiled into the binary for agents with compile target "Windows". There are compiler switches for that (see #ifdef WIN32).
The installation routine in service-manager.js would copy the dll from the binary using the win32 api FindResourceW and the like. So the agent is its own setup.
But I'm also not exactly happy with the design to have the dll and winpty-agent.exe as binary resource. So ideas are welcome.
@MartinMa oh right ok! got you! so the dll/exe would indeed be built into the exe, and when you run the exe it would extract it! thats perfectly fine! as we currently do that for the .msh! it adds the .msh info into the exe when you download from the web ui, then on run it extracts it and put into its own .msh file!
side note: would also be good to change the .msh method too so it to is a resource file then it allows for the windows signature bug to be fixed also! (but thats a different problem!)