mirror of
https://github.com/immense/Remotely.git
synced 2025-10-26 11:27:15 +00:00
Rebranding.
This commit is contained in:
parent
61fa16de4c
commit
30dbfb5ac9
Binary file not shown.
@ -26,12 +26,7 @@ namespace Remotely_Agent.Services
|
||||
ConnectionInfo = Utilities.GetConnectionInfo();
|
||||
|
||||
HubConnection = new HubConnectionBuilder()
|
||||
.WithUrl(ConnectionInfo.Host + "/DeviceHub", options=> {
|
||||
if (!string.IsNullOrWhiteSpace(ConnectionInfo.ProxyUrl))
|
||||
{
|
||||
options.Proxy = new WebProxy(ConnectionInfo.ProxyUrl, ConnectionInfo.ProxyPort);
|
||||
}
|
||||
})
|
||||
.WithUrl(ConnectionInfo.Host + "/DeviceHub")
|
||||
.Build();
|
||||
HubConnection.Closed += HubConn_Closed;
|
||||
|
||||
@ -160,7 +155,7 @@ namespace Remotely_Agent.Services
|
||||
return;
|
||||
}
|
||||
// Cleanup old files.
|
||||
foreach (var file in Directory.GetFiles(Path.GetTempPath(), "Remotely_ScreenCast"))
|
||||
foreach (var file in Directory.GetFiles(Path.GetTempPath(), "Remotely_ScreenCast*"))
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -192,7 +187,7 @@ namespace Remotely_Agent.Services
|
||||
if (OSUtils.IsWindows)
|
||||
{
|
||||
#if DEBUG
|
||||
Process.Start(filePath);
|
||||
Process.Start(filePath, $"-mode unattended -requester {requesterID} -serviceid {serviceID} -hostname {Utilities.GetConnectionInfo().Host.Split("//").Last()}");
|
||||
#else
|
||||
var procInfo = new ADVAPI32.PROCESS_INFORMATION();
|
||||
var result = Win32Interop.OpenInteractiveProcess(filePath + $" -mode unattended -requester {requesterID} -serviceid {serviceID} -hostname {Utilities.GetConnectionInfo().Host.Split("//").Last()}", "default", true, out procInfo);
|
||||
|
||||
@ -24,8 +24,6 @@ namespace Remotely_Library.Models
|
||||
}
|
||||
}
|
||||
public string OrganizationID { get; set; }
|
||||
public string ProxyUrl { get; set; }
|
||||
public int ProxyPort { get; set; }
|
||||
public string ServerVerificationToken { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,16 +12,25 @@ using System.Collections.Generic;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using Remotely_ScreenCapture.Utilities;
|
||||
|
||||
namespace Remotely_ScreenCast
|
||||
namespace Remotely_ScreenCast.Capture
|
||||
{
|
||||
public class BitBltCapture : ICapturer
|
||||
{
|
||||
public Bitmap CurrentFrame { get; set; }
|
||||
public Size CurrentScreenSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return CurrentBounds.Size;
|
||||
}
|
||||
}
|
||||
public Bitmap PreviousFrame { get; set; }
|
||||
public bool IsCapturing { get; set; }
|
||||
public bool CaptureFullscreen { get; set; } = true;
|
||||
public int PauseForMilliseconds { get; set; }
|
||||
public EventHandler<Size> ScreenChanged { get; set; }
|
||||
public int SelectedScreen
|
||||
{
|
||||
get
|
||||
@ -30,6 +39,10 @@ namespace Remotely_ScreenCast
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == selectedScreen)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (Screen.AllScreens.Length >= value + 1)
|
||||
{
|
||||
selectedScreen = value;
|
||||
@ -39,6 +52,7 @@ namespace Remotely_ScreenCast
|
||||
selectedScreen = 0;
|
||||
}
|
||||
CurrentBounds = Screen.AllScreens[selectedScreen].Bounds;
|
||||
ScreenChanged(this, CurrentBounds.Size);
|
||||
}
|
||||
}
|
||||
public Rectangle CurrentBounds { get; set; } = Screen.PrimaryScreen.Bounds;
|
||||
@ -80,7 +94,7 @@ namespace Remotely_ScreenCast
|
||||
|
||||
public void Capture()
|
||||
{
|
||||
Console.WriteLine($"Using Capturer.");
|
||||
Console.WriteLine($"Using BitBlt Capturer.");
|
||||
var currentDesktop = Win32Interop.GetCurrentDesktop();
|
||||
Console.WriteLine($"Current Desktop: {currentDesktop}");
|
||||
if (currentDesktop != desktopName)
|
||||
@ -89,7 +103,7 @@ namespace Remotely_ScreenCast
|
||||
var inputDesktop = Win32Interop.OpenInputDesktop();
|
||||
var success = User32.SetThreadDesktop(inputDesktop);
|
||||
User32.CloseDesktop(inputDesktop);
|
||||
Console.WriteLine($"Set thread desktop: {success}");
|
||||
Logger.Write($"Set thread desktop: {success}");
|
||||
}
|
||||
|
||||
|
||||
@ -101,7 +115,7 @@ namespace Remotely_ScreenCast
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//Utilities.WriteToLog(ex);
|
||||
Logger.Write(ex);
|
||||
}
|
||||
}
|
||||
|
||||
14
Remotely_ScreenCast/Capture/CaptureMode.cs
Normal file
14
Remotely_ScreenCast/Capture/CaptureMode.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Remotely_ScreenCapture.Capture
|
||||
{
|
||||
public enum CaptureMode
|
||||
{
|
||||
BitBtl,
|
||||
DirectX
|
||||
}
|
||||
}
|
||||
@ -9,7 +9,7 @@ using System.Timers;
|
||||
using System.Windows.Forms;
|
||||
using Win32;
|
||||
|
||||
namespace Remotely_ScreenCast
|
||||
namespace Remotely_ScreenCast.Capture
|
||||
{
|
||||
/// <summary>
|
||||
/// A class that can be used to watch for cursor icon changes.
|
||||
@ -1,4 +1,5 @@
|
||||
using SharpDX;
|
||||
using Remotely_ScreenCapture.Utilities;
|
||||
using SharpDX;
|
||||
using SharpDX.Direct3D11;
|
||||
using SharpDX.DXGI;
|
||||
using SharpDX.Mathematics.Interop;
|
||||
@ -14,7 +15,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Win32;
|
||||
|
||||
namespace Remotely_ScreenCast
|
||||
namespace Remotely_ScreenCast.Capture
|
||||
{
|
||||
public class DXCapture : ICapturer
|
||||
{
|
||||
@ -22,10 +23,17 @@ namespace Remotely_ScreenCast
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
public Bitmap PreviousFrame { get; set; }
|
||||
public Bitmap CurrentFrame { get; set; }
|
||||
public Size CurrentScreenSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Size(width, height);
|
||||
}
|
||||
}
|
||||
public bool CaptureFullscreen { get; set; } = true;
|
||||
public EventHandler<Size> ScreenChanged { get; set; }
|
||||
public int SelectedScreen
|
||||
{
|
||||
get
|
||||
@ -34,6 +42,10 @@ namespace Remotely_ScreenCast
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == selectedScreen)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (adapter == null)
|
||||
{
|
||||
selectedScreen = 0;
|
||||
@ -48,8 +60,8 @@ namespace Remotely_ScreenCast
|
||||
{
|
||||
selectedScreen = 0;
|
||||
}
|
||||
NeedsInit = true;
|
||||
}
|
||||
NeedsInit = true;
|
||||
}
|
||||
}
|
||||
public bool NeedsInit { get; set; }
|
||||
@ -86,8 +98,14 @@ namespace Remotely_ScreenCast
|
||||
output1 = output.QueryInterface<Output1>();
|
||||
|
||||
// Width/Height of desktop to capture
|
||||
width = output.Description.DesktopBounds.Right - output.Description.DesktopBounds.Left;
|
||||
height = output.Description.DesktopBounds.Bottom - output.Description.DesktopBounds.Top;
|
||||
var newWidth = output.Description.DesktopBounds.Right - output.Description.DesktopBounds.Left;
|
||||
var newHeight = output.Description.DesktopBounds.Bottom - output.Description.DesktopBounds.Top;
|
||||
if (newWidth != width || newHeight != height)
|
||||
{
|
||||
ScreenChanged(this, new Size(newWidth, newHeight));
|
||||
}
|
||||
width = newWidth;
|
||||
height = newHeight;
|
||||
|
||||
CurrentFrame = new Bitmap(width, height);
|
||||
PreviousFrame = new Bitmap(width, height);
|
||||
@ -128,7 +146,7 @@ namespace Remotely_ScreenCast
|
||||
var inputDesktop = Win32Interop.OpenInputDesktop();
|
||||
var success = User32.SetThreadDesktop(inputDesktop);
|
||||
User32.CloseDesktop(inputDesktop);
|
||||
Console.WriteLine($"Set thread desktop: {success}");
|
||||
Logger.Write($"Set thread desktop: {success}");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -185,16 +203,14 @@ namespace Remotely_ScreenCast
|
||||
{
|
||||
if (e.ResultCode.Code != SharpDX.DXGI.ResultCode.WaitTimeout.Result.Code)
|
||||
{
|
||||
Trace.TraceError(e.Message);
|
||||
Trace.TraceError(e.StackTrace);
|
||||
Console.WriteLine($"Error: {e.Message}{Environment.NewLine}{e.StackTrace}");
|
||||
Logger.Write(e);
|
||||
Init();
|
||||
Capture();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine($"Error: {e.Message}{Environment.NewLine}{e.StackTrace}");
|
||||
Logger.Write(e);
|
||||
Init();
|
||||
Capture();
|
||||
}
|
||||
@ -5,13 +5,17 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Remotely_ScreenCast
|
||||
namespace Remotely_ScreenCast.Capture
|
||||
{
|
||||
public interface ICapturer
|
||||
{
|
||||
Bitmap CurrentFrame { get; set; }
|
||||
Bitmap PreviousFrame { get; set; }
|
||||
Size CurrentScreenSize { get; }
|
||||
|
||||
Bitmap PreviousFrame { get; set; }
|
||||
bool CaptureFullscreen { get; set; }
|
||||
void Capture();
|
||||
}
|
||||
EventHandler<Size> ScreenChanged { get; set; }
|
||||
int SelectedScreen { get; set; }
|
||||
}
|
||||
}
|
||||
@ -9,7 +9,7 @@ using System.Runtime.Serialization.Formatters.Binary;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Remotely_ScreenCast
|
||||
namespace Remotely_ScreenCast.Capture
|
||||
{
|
||||
public class ImageDiff
|
||||
{
|
||||
@ -1,88 +1,98 @@
|
||||
using Microsoft.AspNetCore.SignalR.Client;
|
||||
using Remotely_ScreenCapture;
|
||||
using Remotely_ScreenCapture.Capture;
|
||||
using Remotely_ScreenCapture.Sockets;
|
||||
using Remotely_ScreenCapture.Utilities;
|
||||
using Remotely_ScreenCast.Capture;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Win32;
|
||||
|
||||
namespace Remotely_ScreenCast
|
||||
{
|
||||
class Program
|
||||
public class Program
|
||||
{
|
||||
static Stopwatch stopwatch;
|
||||
static CaptureMode captureMode;
|
||||
public static ICapturer Capturer { get; set; }
|
||||
public static CaptureMode CaptureMode { get; set; }
|
||||
public static bool DisconnectRequested { get; set; }
|
||||
public static string Mode { get; set; }
|
||||
public static string RequesterID { get; set; }
|
||||
public static string HostName { get; set; }
|
||||
public static HubConnection Connection { get; set; }
|
||||
private static OutgoingMessages OutgoingMessages { get; set; }
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
var argDict = ProcessArgs(args);
|
||||
var mode = argDict["mode"];
|
||||
var requesterID = argDict["requester"];
|
||||
var hostname = argDict["hostname"];
|
||||
Mode = argDict["mode"];
|
||||
RequesterID = argDict["requester"];
|
||||
HostName = argDict["hostname"];
|
||||
|
||||
var hubConnection = new HubConnectionBuilder()
|
||||
.WithUrl($"https://{argDict["hostname"]}/DeviceHub")
|
||||
Connection = new HubConnectionBuilder()
|
||||
.WithUrl($"http://{HostName}/RCDeviceHub")
|
||||
.Build();
|
||||
|
||||
hubConnection.Closed += (ex) =>
|
||||
{
|
||||
Logger.Write($"Error: {ex.Message}");
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
MessageHandlers.ApplyConnectionHandlers(Connection);
|
||||
|
||||
hubConnection.StartAsync().Wait();
|
||||
Connection.StartAsync().Wait();
|
||||
|
||||
var screenshotPath = $@"{Path.GetTempPath()}Screens\";
|
||||
if (!Directory.Exists(screenshotPath))
|
||||
{
|
||||
Directory.CreateDirectory(screenshotPath);
|
||||
}
|
||||
OutgoingMessages = new OutgoingMessages(Connection);
|
||||
|
||||
|
||||
ICapturer capturer;
|
||||
try
|
||||
{
|
||||
capturer = new DXCapture();
|
||||
captureMode = CaptureMode.DirectX;
|
||||
Capturer = new DXCapture();
|
||||
CaptureMode = CaptureMode.DirectX;
|
||||
}
|
||||
catch
|
||||
{
|
||||
capturer = new BitBltCapture();
|
||||
captureMode = CaptureMode.BitBtl;
|
||||
Capturer = new BitBltCapture();
|
||||
CaptureMode = CaptureMode.BitBtl;
|
||||
}
|
||||
|
||||
while (true)
|
||||
|
||||
OutgoingMessages.SendScreenCount(
|
||||
Screen.AllScreens.ToList().IndexOf(Screen.PrimaryScreen),
|
||||
Screen.AllScreens.Length,
|
||||
RequesterID).Wait();
|
||||
|
||||
Capturer.ScreenChanged += HandleScreenChanged;
|
||||
|
||||
OutgoingMessages.SendScreenSize(Capturer.CurrentScreenSize.Width, Capturer.CurrentScreenSize.Height).Wait();
|
||||
|
||||
while (!DisconnectRequested)
|
||||
{
|
||||
try
|
||||
{
|
||||
capturer.Capture();
|
||||
var newImage = ImageDiff.GetImageDiff(capturer.CurrentFrame, capturer.PreviousFrame, capturer.CaptureFullscreen);
|
||||
Capturer.Capture();
|
||||
var newImage = ImageDiff.GetImageDiff(Capturer.CurrentFrame, Capturer.PreviousFrame, Capturer.CaptureFullscreen);
|
||||
var img = ImageDiff.EncodeBitmap(newImage);
|
||||
if (capturer.CaptureFullscreen)
|
||||
if (Capturer.CaptureFullscreen)
|
||||
{
|
||||
capturer.CaptureFullscreen = false;
|
||||
Capturer.CaptureFullscreen = false;
|
||||
}
|
||||
if (img?.Length > 0)
|
||||
{
|
||||
File.WriteAllBytes($@"{screenshotPath}{Path.GetRandomFileName()}.png", img);
|
||||
OutgoingMessages.SendScreenCapture(img).Wait();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Write($"Outer Error: {ex.Message}{Environment.NewLine}{ex.StackTrace}");
|
||||
}
|
||||
System.Threading.Thread.Sleep(3000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
enum CaptureMode
|
||||
private static async void HandleScreenChanged(object sender, Size size)
|
||||
{
|
||||
BitBtl,
|
||||
DirectX
|
||||
await OutgoingMessages.SendScreenSize(size.Width, size.Height);
|
||||
}
|
||||
|
||||
private static Dictionary<string, string> ProcessArgs(string[] args)
|
||||
@ -105,5 +115,7 @@ namespace Remotely_ScreenCast
|
||||
}
|
||||
return argDict;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -140,12 +140,15 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="BitBltCapture.cs" />
|
||||
<Compile Include="CursorIconWatcher.cs" />
|
||||
<Compile Include="DXCapture.cs" />
|
||||
<Compile Include="ICapturer.cs" />
|
||||
<Compile Include="ImageDiff.cs" />
|
||||
<Compile Include="Logger.cs" />
|
||||
<Compile Include="Capture\BitBltCapture.cs" />
|
||||
<Compile Include="Capture\CaptureMode.cs" />
|
||||
<Compile Include="Capture\CursorIconWatcher.cs" />
|
||||
<Compile Include="Capture\DXCapture.cs" />
|
||||
<Compile Include="Capture\ICapturer.cs" />
|
||||
<Compile Include="Capture\ImageDiff.cs" />
|
||||
<Compile Include="Sockets\MessageHandlers.cs" />
|
||||
<Compile Include="Sockets\OutgoingMessages.cs" />
|
||||
<Compile Include="Utilities\Logger.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Win32\ADVAPI32.cs" />
|
||||
@ -162,6 +165,7 @@
|
||||
<ItemGroup>
|
||||
<Content Include="FodyWeavers.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>
|
||||
|
||||
24
Remotely_ScreenCast/Sockets/MessageHandlers.cs
Normal file
24
Remotely_ScreenCast/Sockets/MessageHandlers.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using Microsoft.AspNetCore.SignalR.Client;
|
||||
using Remotely_ScreenCapture.Utilities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Remotely_ScreenCapture.Sockets
|
||||
{
|
||||
public class MessageHandlers
|
||||
{
|
||||
public static void ApplyConnectionHandlers(HubConnection hubConnection)
|
||||
{
|
||||
hubConnection.Closed += (ex) =>
|
||||
{
|
||||
Logger.Write($"Error: {ex.Message}");
|
||||
Environment.Exit(1);
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
33
Remotely_ScreenCast/Sockets/OutgoingMessages.cs
Normal file
33
Remotely_ScreenCast/Sockets/OutgoingMessages.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using Microsoft.AspNetCore.SignalR.Client;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Remotely_ScreenCapture.Sockets
|
||||
{
|
||||
public class OutgoingMessages
|
||||
{
|
||||
public OutgoingMessages(HubConnection hubConnection)
|
||||
{
|
||||
Connection = hubConnection;
|
||||
}
|
||||
|
||||
private HubConnection Connection { get; }
|
||||
public async Task SendScreenSize(int width, int height)
|
||||
{
|
||||
await Connection.SendAsync("ScreenSize", width, height);
|
||||
}
|
||||
|
||||
public async Task SendScreenCapture(byte[] captureBytes)
|
||||
{
|
||||
await Connection.SendAsync("ScreenCapture", captureBytes);
|
||||
}
|
||||
|
||||
internal async Task SendScreenCount(int primaryScreenIndex, int screenCount, string requesterID)
|
||||
{
|
||||
await Connection.SendAsync("SendScreenCountToBrowser", primaryScreenIndex, screenCount, requesterID);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6,7 +6,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Remotely_ScreenCapture
|
||||
namespace Remotely_ScreenCapture.Utilities
|
||||
{
|
||||
public static class Logger
|
||||
{
|
||||
@ -116,6 +116,12 @@ namespace Remotely_Server
|
||||
|
||||
app.UseCookiePolicy();
|
||||
|
||||
// Uncomment to run .NET Core behind a reverse proxy.
|
||||
//app.UseForwardedHeaders(new ForwardedHeadersOptions
|
||||
//{
|
||||
// ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
|
||||
//});
|
||||
|
||||
app.UseAuthentication();
|
||||
|
||||
app.UseSignalR(routes =>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user