0

I have both a client DLL and a server-side application, as according to the WinAPI virtual channel documentation:

hVirtChannel = WTSVirtualChannelOpenEx(dwSessionId,
    const_cast<LPSTR>(CHANNELNAME), 0);
if (hVirtChannel == nullptr)
    DisplayError(TEXT("WTSVirtualChannelOpen"));

That is the server code to open the channel. dwSessionId is equal to 2, which is the correct session id for my running remote desktop session. CHANNELNAME is equal to sysinf. DisplayError() is my own custom function, all it does is use the Windows API to tell me the most recent error.

Server Registry File:

REGEDIT4

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\AddIns\tssysinfo]
"Name"="sysinf"
"Type"=dword:00000003

Client Registry File:

REGEDIT4

[HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client\Default\AddIns\tssysinfo]
"Name" = "C:\TSAddInDLL\ClientCPP.dll"

Does anyone have any ideas why this is not working?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Aiden
  • 11
  • 4
  • Does your server app have the "Virtual Channels" permission enabled? Since your client appears to be implemented as a DVC, have you tried using `WTS_CHANNEL_OPTION_DYNAMIC` instead of `0` in the `flags` parameter of `WTSVirtualChannelOpenEx()`? – Remy Lebeau Jul 25 '23 at 17:41
  • How would I tell whether or not it has the permission enabled? I have not tried making it dynamic. Would that possible fix my issue? – Aiden Jul 25 '23 at 17:44
  • "*How would I tell ...*" - that is your responsibility in your server configuration. Per the documentation: "*To be able to open a virtual channel on another user's session, you must have the Virtual Channels permission. For more information, see [Remote Desktop Services Permissions](https://learn.microsoft.com/en-us/windows/desktop/TermServ/terminal-services-permissions). To modify permissions on a session, use the Remote Desktop Services Configuration administrative tool.*" Does your server actually run in session 2, or is it just trying to access session 2? – Remy Lebeau Jul 25 '23 at 17:50
  • I misunderstood the question.. I'm connecting to the administrator account which does indeed have those permissions. I am directly connecting to the server then running the program. – Aiden Jul 25 '23 at 18:23
  • That doesn't answer my question. You said you are passing session ID 2 to `WTSVirtualChannelOpenEx()`. Is the calling app **running** in session 2 to begin with? Or, is it running in another session (like, maybe, session 0 for services) and is trying to *open a channel* to session 2? – Remy Lebeau Jul 25 '23 at 18:28
  • Ah. Using the process to id function, it is also running in session 2. – Aiden Jul 25 '23 at 18:36
  • It could also be a problem with my client dll, but I'm 99% sure it's not. Edit: Using process monitor it does say it's using the dll. – Aiden Jul 25 '23 at 18:38

0 Answers0