Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 46 additions & 14 deletions Services/RdpBridgeClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,11 @@ public void Connect(
if (nativeApiVersion >= GfxApiVersion && (nativeCapabilities & GfxCapability) != 0)
{
var gfxRequested = GraphicsPipelineForcedOn || session.RdpGraphicsPipelineEnabled;
var gfxResult = NativeMethods.cxrdp_set_graphics_pipeline(_handle, gfxRequested ? 1 : 0);
DebugLog($"graphics pipeline requested={gfxRequested} session={session.RdpGraphicsPipelineEnabled} env={GraphicsPipelineForcedOn} result={gfxResult}");
TryInvokeOptionalNative("cxrdp_set_graphics_pipeline", () =>
{
var gfxResult = NativeMethods.cxrdp_set_graphics_pipeline(_handle, gfxRequested ? 1 : 0);
DebugLog($"graphics pipeline requested={gfxRequested} session={session.RdpGraphicsPipelineEnabled} env={GraphicsPipelineForcedOn} result={gfxResult}");
});
}
else
{
Expand All @@ -258,8 +261,14 @@ public void Connect(
var useFrameMarkers = _frameMode != RdpFramePresentationMode.Legacy;
if (_frameMarkerSupported)
{
var markerResult = NativeMethods.cxrdp_set_frame_marker_enabled(_handle, useFrameMarkers ? 1 : 0);
DebugLog($"frame markers enabled={useFrameMarkers} result={markerResult}");
if (!TryInvokeOptionalNative("cxrdp_set_frame_marker_enabled", () =>
{
var markerResult = NativeMethods.cxrdp_set_frame_marker_enabled(_handle, useFrameMarkers ? 1 : 0);
DebugLog($"frame markers enabled={useFrameMarkers} result={markerResult}");
}))
{
_frameMarkerSupported = false;
}
}
else if (useFrameMarkers)
{
Expand All @@ -273,16 +282,22 @@ public void Connect(
var cachedProfile = RdpSecurityProfileCache.Get(_profileCacheHost, _profileCachePort);
if (!string.IsNullOrEmpty(cachedProfile))
{
var profileResult = NativeMethods.cxrdp_set_security_profile(_handle, cachedProfile);
DebugLog($"security profile hint={cachedProfile} result={profileResult}");
TryInvokeOptionalNative("cxrdp_set_security_profile", () =>
{
var profileResult = NativeMethods.cxrdp_set_security_profile(_handle, cachedProfile);
DebugLog($"security profile hint={cachedProfile} result={profileResult}");
});
}

// Environment override CXSHELL_RDP_CLIPBOARD_CHANNEL=0 still wins
// inside the bridge, so it remains a global troubleshooting switch.
var clipboardResult = NativeMethods.cxrdp_set_clipboard_channel(
_handle,
session.RdpClipboardEnabled ? 1 : 0);
DebugLog($"clipboard channel requested={session.RdpClipboardEnabled} result={clipboardResult}");
TryInvokeOptionalNative("cxrdp_set_clipboard_channel", () =>
{
var clipboardResult = NativeMethods.cxrdp_set_clipboard_channel(
_handle,
session.RdpClipboardEnabled ? 1 : 0);
DebugLog($"clipboard channel requested={session.RdpClipboardEnabled} result={clipboardResult}");
});
}
else
{
Expand All @@ -292,10 +307,13 @@ public void Connect(
if (nativeApiVersion >= PerformanceFlagsApiVersion &&
(nativeCapabilities & PerformanceFlagsCapability) != 0)
{
var wallpaperResult = NativeMethods.cxrdp_set_disable_wallpaper(
_handle,
session.RdpDisableWallpaper ? 1 : 0);
DebugLog($"disable wallpaper requested={session.RdpDisableWallpaper} result={wallpaperResult}");
TryInvokeOptionalNative("cxrdp_set_disable_wallpaper", () =>
{
var wallpaperResult = NativeMethods.cxrdp_set_disable_wallpaper(
_handle,
session.RdpDisableWallpaper ? 1 : 0);
DebugLog($"disable wallpaper requested={session.RdpDisableWallpaper} result={wallpaperResult}");
});
}
else
{
Expand Down Expand Up @@ -1165,6 +1183,20 @@ private void OnStatus(IntPtr userData, IntPtr message)
StatusChanged?.Invoke(text);
}

private static bool TryInvokeOptionalNative(string exportName, Action action)
{
try
{
action();
return true;
}
catch (EntryPointNotFoundException)
{
DebugLog($"native bridge export missing: {exportName}; falling back.");
return false;
}
}

private void OnDisconnected(IntPtr userData)
{
DebugLog("disconnected callback");
Expand Down
6 changes: 6 additions & 0 deletions native/CxRdpBridge/cxrdp_bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
#include <vector>

#if defined(_WIN32)
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <winsock2.h>
#include <windows.h>
#else
Expand Down