From 413f28afadab689b57132a1e5b3834fe030fcb9d Mon Sep 17 00:00:00 2001 From: Jared Goodwin Date: Mon, 18 Mar 2019 18:34:07 -0700 Subject: [PATCH] Added app manifest. ImageDiff tweaks. --- README.md | 18 +-- Remotely_Desktop/Remotely_Desktop.csproj | 4 + Remotely_Desktop/app.manifest | 76 ++++++++++++ Remotely_ScreenCast/Capture/DXCapture.cs | 2 +- Remotely_ScreenCast/Capture/ImageUtils.cs | 110 ++++++++++-------- .../Services/RemoteControlSessionRecorder.cs | 2 +- .../wwwroot/Downloads/CurrentAgentVersion.txt | 2 +- Utilities/Remotely_Server_Install.sh | 4 +- 8 files changed, 156 insertions(+), 62 deletions(-) create mode 100644 Remotely_Desktop/app.manifest diff --git a/README.md b/README.md index b05bf340..f58a435e 100644 --- a/README.md +++ b/README.md @@ -6,22 +6,22 @@ Public Server: https://tryremotely.lucency.co ## Build Instructions (Windows 10) The following steps will configure your Windows 10 machine for building the Remotely server and clients. -* Install .NET Core SDK. +* Install Visual Studio 2019. + * Link: https://visualstudio.microsoft.com/downloads/ +* Install the latest .NET Core SDK. * Link: https://dotnet.microsoft.com/download +* Clone the git repository and open the solution in Visual Studio. +* Build (in Release configuration) the Remotely_Desktop and Remotely_ScreenCast projects. * Run Publish.ps1 in the Utilities folder. * Example: powershell -f [path]\Publish.ps1 -outdir C:\inetpub\remotely -rid win10-x86 * The output folder will now contain the server, with the clients in the Downloads folder. * Change values in appsettings.json for your environment. * Documentation for hosting in IIS can be found here: https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/index?view=aspnetcore-2.2 -## Build Instructions (Linux) -* Install .NET Core SDK. - * Link: https://dotnet.microsoft.com/download -* Install PowerShell Core. - * Link: https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-linux?view=powershell-6 -* Run Publish.ps1 in the Utilities folder. - * Example: pwsh -f [path]/Publish.ps1 -outdir /var/www/remotely -rid linux-x64 - * The output folder will now contain the server, with the clients in the Downloads folder. +## Hosting a Server (Windows) + +## Hosting a Server (Linux) +* Download and unzip the Linux server package. * Run Remotely_Server_Setup.sh (with sudo) in the Utilities folder. * App root will be the above output folder. * Change values in appsettings.json for your environment. diff --git a/Remotely_Desktop/Remotely_Desktop.csproj b/Remotely_Desktop/Remotely_Desktop.csproj index e46f00c3..3efa2b44 100644 --- a/Remotely_Desktop/Remotely_Desktop.csproj +++ b/Remotely_Desktop/Remotely_Desktop.csproj @@ -41,6 +41,9 @@ favicon.ico + + app.manifest + ..\packages\Costura.Fody.3.3.2\lib\net40\Costura.dll @@ -114,6 +117,7 @@ ResXFileCodeGenerator Resources.Designer.cs + SettingsSingleFileGenerator diff --git a/Remotely_Desktop/app.manifest b/Remotely_Desktop/app.manifest new file mode 100644 index 00000000..169e6185 --- /dev/null +++ b/Remotely_Desktop/app.manifest @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Remotely_ScreenCast/Capture/DXCapture.cs b/Remotely_ScreenCast/Capture/DXCapture.cs index 6fa0ef19..5c97eeeb 100644 --- a/Remotely_ScreenCast/Capture/DXCapture.cs +++ b/Remotely_ScreenCast/Capture/DXCapture.cs @@ -173,7 +173,7 @@ namespace Remotely_ScreenCast.Capture output1 = output.QueryInterface(); // Width/Height of desktop to capture - var bounds = output.Description.DesktopBounds; + var bounds = output1.Description.DesktopBounds; var newWidth = bounds.Right - bounds.Left; var newHeight = bounds.Bottom - bounds.Top; CurrentScreenBounds = new Rectangle(bounds.Left, bounds.Top, newWidth, newHeight); diff --git a/Remotely_ScreenCast/Capture/ImageUtils.cs b/Remotely_ScreenCast/Capture/ImageUtils.cs index 697eaf9f..41d3198f 100644 --- a/Remotely_ScreenCast/Capture/ImageUtils.cs +++ b/Remotely_ScreenCast/Capture/ImageUtils.cs @@ -45,66 +45,78 @@ namespace Remotely_ScreenCast.Capture int right = int.MinValue; int bottom = int.MinValue; - var bd1 = previousFrame.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadOnly, currentFrame.PixelFormat); - var bd2 = currentFrame.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadOnly, previousFrame.PixelFormat); + BitmapData bd1 = null; + BitmapData bd2 = null; - var bytesPerPixel = Bitmap.GetPixelFormatSize(currentFrame.PixelFormat) / 8; - var totalSize = bd1.Height * bd1.Width * bytesPerPixel; - - unsafe + try { - byte* scan1 = (byte*)bd1.Scan0.ToPointer(); - byte* scan2 = (byte*)bd2.Scan0.ToPointer(); + bd1 = previousFrame.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadOnly, currentFrame.PixelFormat); + bd2 = currentFrame.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadOnly, previousFrame.PixelFormat); - for (int counter = 0; counter < totalSize - bytesPerPixel; counter += bytesPerPixel) + var bytesPerPixel = Bitmap.GetPixelFormatSize(currentFrame.PixelFormat) / 8; + var totalSize = bd1.Height * bd1.Width * bytesPerPixel; + + unsafe { - byte* data1 = scan1 + counter; - byte* data2 = scan2 + counter; + byte* scan1 = (byte*)bd1.Scan0.ToPointer(); + byte* scan2 = (byte*)bd2.Scan0.ToPointer(); - if (data1[0] != data2[0] || - data1[1] != data2[1] || - data1[2] != data2[2] || - data1[3] != data2[3]) + for (int counter = 0; counter < totalSize - bytesPerPixel; counter += bytesPerPixel) { - // Change was found. - var pixel = counter / 4; - var row = (int)Math.Floor((double)pixel / bd1.Width); - var column = pixel % bd1.Width; - if (row < top) + byte* data1 = scan1 + counter; + byte* data2 = scan2 + counter; + + if (data1[0] != data2[0] || + data1[1] != data2[1] || + data1[2] != data2[2] || + data1[3] != data2[3]) { - top = row; - } - if (row > bottom) - { - bottom = row; - } - if (column < left) - { - left = column; - } - if (column > right) - { - right = column; + // Change was found. + var pixel = counter / 4; + var row = (int)Math.Floor((double)pixel / bd1.Width); + var column = pixel % bd1.Width; + if (row < top) + { + top = row; + } + if (row > bottom) + { + bottom = row; + } + if (column < left) + { + left = column; + } + if (column > right) + { + right = column; + } } } } + + if (left < right && top < bottom) + { + // Bounding box is valid. + + left = Math.Max(left - 20, 0); + top = Math.Max(top - 20, 0); + right = Math.Min(right + 20, width); + bottom = Math.Min(bottom + 20, height); + + currentFrame.UnlockBits(bd1); + previousFrame.UnlockBits(bd2); + + return new Rectangle(left, top, right - left, bottom - top); + } + else + { + currentFrame.UnlockBits(bd1); + previousFrame.UnlockBits(bd2); + return Rectangle.Empty; + } } - - if (left < right && top < bottom) - { - // Bounding box is valid. - - left = Math.Max(left - 20, 0); - top = Math.Max(top - 20, 0); - right = Math.Min(right + 20, width); - bottom = Math.Min(bottom + 20, height); - - currentFrame.UnlockBits(bd1); - previousFrame.UnlockBits(bd2); - - return new Rectangle(left, top, right - left, bottom - top); - } - else + catch { currentFrame.UnlockBits(bd1); previousFrame.UnlockBits(bd2); diff --git a/Remotely_Server/Services/RemoteControlSessionRecorder.cs b/Remotely_Server/Services/RemoteControlSessionRecorder.cs index 7cbd4042..0b5441a6 100644 --- a/Remotely_Server/Services/RemoteControlSessionRecorder.cs +++ b/Remotely_Server/Services/RemoteControlSessionRecorder.cs @@ -37,7 +37,7 @@ namespace Remotely_Server.Services if (!IsProcessing) { IsProcessing = true; - Task.Run(StartProcessing); + Task.Run(new Action(StartProcessing)); } } } diff --git a/Remotely_Server/wwwroot/Downloads/CurrentAgentVersion.txt b/Remotely_Server/wwwroot/Downloads/CurrentAgentVersion.txt index 7d0e94ed..8d1fb540 100644 --- a/Remotely_Server/wwwroot/Downloads/CurrentAgentVersion.txt +++ b/Remotely_Server/wwwroot/Downloads/CurrentAgentVersion.txt @@ -1 +1 @@ -2019.03.17.1951 +2019.03.18.1822 diff --git a/Utilities/Remotely_Server_Install.sh b/Utilities/Remotely_Server_Install.sh index a5edaeb1..2030d074 100644 --- a/Utilities/Remotely_Server_Install.sh +++ b/Utilities/Remotely_Server_Install.sh @@ -113,4 +113,6 @@ systemctl start remotely.service # Install Certbot and get SSL cert. apt-get install certbot python-certbot-nginx -certbot --nginx \ No newline at end of file +certbot --nginx + +apt-get install ffmpeg \ No newline at end of file