Fixed Remote Desktop Bug

Fixed a bug where changing resolutions while Remote Desktop is running
would crash both the client + server.  This fix ensures that the Remote
Desktop features continues to run accurately after changing resolutions
on the client.
This commit is contained in:
d3agle 2015-04-14 04:58:48 -05:00
parent b360e2d91f
commit abd31f9a94
2 changed files with 31 additions and 5 deletions

View File

@ -233,11 +233,19 @@ public static void HandleRemoteDesktop(Packets.ServerPackets.Desktop command, Cl
using (MemoryStream stream = new MemoryStream())
{
StreamCodec.CodeImage(bmpdata.Scan0,
new Rectangle(0, 0, LastDesktopScreenshot.Width, LastDesktopScreenshot.Height),
new Size(LastDesktopScreenshot.Width, LastDesktopScreenshot.Height), LastDesktopScreenshot.PixelFormat,
stream);
new Packets.ClientPackets.DesktopResponse(stream.ToArray(), StreamCodec.ImageQuality, StreamCodec.Monitor).Execute(client);
try
{
StreamCodec.CodeImage(bmpdata.Scan0,
new Rectangle(0, 0, LastDesktopScreenshot.Width, LastDesktopScreenshot.Height),
new Size(LastDesktopScreenshot.Width, LastDesktopScreenshot.Height), LastDesktopScreenshot.PixelFormat,
stream);
new Packets.ClientPackets.DesktopResponse(stream.ToArray(), StreamCodec.ImageQuality, StreamCodec.Monitor).Execute(client);
}
catch
{
new Packets.ClientPackets.DesktopResponse(null, StreamCodec.ImageQuality, StreamCodec.Monitor).Execute(client);
StreamCodec = null;
}
}
LastDesktopScreenshot.UnlockBits(bmpdata);

View File

@ -111,6 +111,24 @@ public static void HandleRemoteDesktopResponse(Client client, DesktopResponse pa
if (client.Value.FrmRdp == null)
return;
if (packet.Image == null)
{
try
{
client.Value.FrmRdp.Invoke((MethodInvoker)delegate
{
client.Value.FrmRdp.picDesktop.Image = (Bitmap)client.Value.LastDesktop;
});
}
catch
{ }
client.Value.LastDesktop = null;
client.Value.LastDesktopSeen = true;
return;
}
// we can not dispose all bitmaps here, cause they are later used again in `client.Value.LastDesktop`
if (client.Value.LastDesktop == null)
{