Skip to content

Commit

Permalink
These changes make it hooking work better!
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanKoell committed Apr 15, 2024
1 parent e114ca6 commit 61249c0
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/RoyalApps.Community.Rdp.WinForms/Controls/RdpControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -562,9 +562,10 @@ private void CreateRdpClient()

this.ApplyRdpClientConfiguration(RdpConfiguration);

var msTscAxLibrary = Environment.ExpandEnvironmentVariables("%SystemRoot%\\System32\\mstscax.dll");

if (RdpConfiguration.UseMsRdc)
{
var msTscAxLibrary = Environment.ExpandEnvironmentVariables("%SystemRoot%\\System32\\mstscax.dll");

string? msRdcAxLibrary = null;
if (!string.IsNullOrWhiteSpace(RdpConfiguration.MsRdcPath) && File.Exists(RdpConfiguration.MsRdcPath))
Expand Down Expand Up @@ -600,11 +601,22 @@ private void CreateRdpClient()
Logger.LogInformation("Microsoft Remote Desktop Client will be used");

Environment.SetEnvironmentVariable("MSRDPEX_RDCLIENTAX_DLL", msRdcAxLibrary);
Environment.SetEnvironmentVariable("MSRDPEX_AXNAME", "msrdc");

RdpClient.AxName = "msrdc";
}
}
else
{
if (MsRdpExManager.Instance.AxHookEnabled)
RdpClient.RdpExDll = MsRdpExManager.Instance.CoreApi.MsRdpExDllPath;

Logger.LogWarning("Microsoft Remote Desktop Client cannot be used, rdclientax.dll was not found");

Environment.SetEnvironmentVariable("MSRDPEX_MSTSCAX_DLL", msTscAxLibrary);

RdpConfiguration.UseMsRdc = false;
RdpClient.AxName = "mstsc";
}

// workaround to ensure msrdcax.dll can be used even when hooking not enabled:
// https://github.com/Devolutions/MsRdpEx/blob/01995487f22fd697262525ece2e0a6f02908715b/dotnet/MsRdpEx_App/MainDlg.cs#L307
Expand Down

0 comments on commit 61249c0

Please sign in to comment.