From 59eec835dde9deab29ced1bd19a2e814ed782be0 Mon Sep 17 00:00:00 2001 From: MaxXor Date: Sun, 26 Jul 2015 00:10:59 +0200 Subject: [PATCH] Some refactoring and Remote Desktop improvements --- Client.Tests/Core/Encryption/AES.Tests.cs | 8 +- Client.Tests/Core/Encryption/SHA256.Tests.cs | 2 +- Client/Client.csproj | 15 ++- Client/Core/Commands/CommandHandler.cs | 41 +------ Client/Core/Commands/ConnectionHandler.cs | 7 +- Client/Core/Commands/FileHandler.cs | 5 +- Client/Core/Commands/MiscHandler.cs | 11 +- Client/Core/Commands/SurveillanceHandler.cs | 32 +++--- Client/Core/Commands/SystemHandler.cs | 6 +- Client/Core/Compression/JpgCompression.cs | 25 +++- Client/Core/Helper/FileHelper.cs | 20 ++++ Client/Core/Helper/FormatHelper.cs | 30 +++++ Client/Core/Helper/Helper.cs | 73 ------------ Client/Core/Helper/NativeMethodsHelper.cs | 37 ++++++ Client/Core/Helper/PlatformHelper.cs | 68 +++++++++++ Client/Core/Helper/RemoteDesktopHelper.cs | 20 ++++ .../Packets/ClientPackets/SetUserStatus.cs | 2 +- .../Packets/ServerPackets/DoPathDelete.cs | 2 +- .../Packets/ServerPackets/DoPathRename.cs | 2 +- .../Packets/ServerPackets/DoShutdownAction.cs | 2 +- .../Core/Packets/ServerPackets/GetDesktop.cs | 2 +- Client/Core/SystemCore.cs | 12 +- .../Core/{Helper => Utilities}/FileSplit.cs | 2 +- Client/Core/Utilities/NativeMethods.cs | 33 ++++++ .../UnsafeStreamCodec.cs | 107 ++++++++++-------- Client/Enums/PathType.cs | 9 ++ Client/Enums/RemoteDesktopAction.cs | 8 ++ Client/Enums/ShutdownAction.cs | 9 ++ Client/Enums/UserStatus.cs | 8 ++ Client/Program.cs | 3 +- Server.Tests/Core/Encryption/AES.Tests.cs | 8 +- Server/{Core/Misc => Controls}/InputBox.cs | 2 +- Server/Controls/ListViewEx.cs | 40 ++++++- Server/Core/Build/ClientBuilder.cs | 3 +- Server/Core/Commands/CommandHandler.cs | 23 ---- Server/Core/Commands/ConnectionHandler.cs | 3 +- Server/Core/Commands/MiscHandler.cs | 4 +- Server/Core/Commands/SurveillanceHandler.cs | 68 ++--------- Server/Core/Commands/SystemHandler.cs | 8 +- Server/Core/Extensions/ListViewExtensions.cs | 29 +---- .../Core/Helper/{Helper.cs => FileHelper.cs} | 35 +----- Server/Core/Helper/FormatHelper.cs | 30 +++++ Server/Core/Helper/NativeMethodsHelper.cs | 19 ++++ Server/Core/Helper/PlatformHelper.cs | 68 +++++++++++ Server/Core/Helper/RemoteDesktopHelper.cs | 20 ++++ Server/Core/Helper/WindowHelper.cs | 17 +++ Server/Core/Networking/UserState.cs | 55 +++++---- .../Packets/ClientPackets/SetUserStatus.cs | 2 +- .../Packets/ServerPackets/DoPathDelete.cs | 2 +- .../Packets/ServerPackets/DoPathRename.cs | 2 +- .../Packets/ServerPackets/DoShutdownAction.cs | 2 +- .../Core/Packets/ServerPackets/GetDesktop.cs | 2 +- .../Core/{Helper => Utilities}/FileSplit.cs | 2 +- .../{Helper => Utilities}/FrameCounter.cs | 2 +- .../ListViewColumnSorter.cs | 2 +- Server/Core/Utilities/NativeMethods.cs | 44 +++++++ .../Core/{Misc => Utilities}/NoIpUpdater.cs | 2 +- .../Core/{Misc => Utilities}/RemoteDrive.cs | 2 +- .../{Misc => Utilities}/SavedVariables.cs | 2 +- .../UnsafeStreamCodec.cs | 42 +++---- Server/Enums/PathType.cs | 9 ++ Server/Enums/RemoteDesktopAction.cs | 8 ++ Server/Enums/ShutdownAction.cs | 9 ++ Server/Enums/UserStatus.cs | 8 ++ Server/Forms/FrmAddToAutostart.cs | 6 +- Server/Forms/FrmBuilder.cs | 8 +- Server/Forms/FrmDownloadAndExecute.cs | 11 +- Server/Forms/FrmFileManager.Designer.cs | 8 +- Server/Forms/FrmFileManager.cs | 17 +-- Server/Forms/FrmKeylogger.cs | 4 +- Server/Forms/FrmMain.Designer.cs | 17 ++- Server/Forms/FrmMain.cs | 23 ++-- Server/Forms/FrmMain.resx | 2 +- Server/Forms/FrmRemoteDesktop.cs | 7 +- Server/Forms/FrmRemoteShell.cs | 2 +- Server/Forms/FrmReverseProxy.Designer.cs | 4 +- Server/Forms/FrmReverseProxy.cs | 6 +- Server/Forms/FrmSettings.cs | 2 +- Server/Forms/FrmShowMessagebox.cs | 11 +- Server/Forms/FrmStartupManager.Designer.cs | 4 +- Server/Forms/FrmStartupManager.cs | 4 +- Server/Forms/FrmStatistics.cs | 4 +- Server/Forms/FrmSystemInformation.Designer.cs | 4 +- Server/Forms/FrmSystemInformation.cs | 2 +- Server/Forms/FrmTaskManager.Designer.cs | 4 +- Server/Forms/FrmTaskManager.cs | 5 +- Server/Forms/FrmUpdate.cs | 14 +-- Server/Forms/FrmUploadAndExecute.cs | 9 +- Server/Forms/FrmVisitWebsite.cs | 11 +- Server/Server.csproj | 28 +++-- 90 files changed, 864 insertions(+), 528 deletions(-) create mode 100644 Client/Core/Helper/FileHelper.cs create mode 100644 Client/Core/Helper/FormatHelper.cs delete mode 100644 Client/Core/Helper/Helper.cs create mode 100644 Client/Core/Helper/NativeMethodsHelper.cs create mode 100644 Client/Core/Helper/PlatformHelper.cs create mode 100644 Client/Core/Helper/RemoteDesktopHelper.cs rename Client/Core/{Helper => Utilities}/FileSplit.cs (99%) create mode 100644 Client/Core/Utilities/NativeMethods.cs rename Client/Core/{Helper => Utilities}/UnsafeStreamCodec.cs (79%) create mode 100644 Client/Enums/PathType.cs create mode 100644 Client/Enums/RemoteDesktopAction.cs create mode 100644 Client/Enums/ShutdownAction.cs create mode 100644 Client/Enums/UserStatus.cs rename Server/{Core/Misc => Controls}/InputBox.cs (98%) rename Server/Core/Helper/{Helper.cs => FileHelper.cs} (74%) create mode 100644 Server/Core/Helper/FormatHelper.cs create mode 100644 Server/Core/Helper/NativeMethodsHelper.cs create mode 100644 Server/Core/Helper/PlatformHelper.cs create mode 100644 Server/Core/Helper/RemoteDesktopHelper.cs create mode 100644 Server/Core/Helper/WindowHelper.cs rename Server/Core/{Helper => Utilities}/FileSplit.cs (99%) rename Server/Core/{Helper => Utilities}/FrameCounter.cs (96%) rename Server/Core/{Misc => Utilities}/ListViewColumnSorter.cs (98%) create mode 100644 Server/Core/Utilities/NativeMethods.cs rename Server/Core/{Misc => Utilities}/NoIpUpdater.cs (97%) rename Server/Core/{Misc => Utilities}/RemoteDrive.cs (90%) rename Server/Core/{Misc => Utilities}/SavedVariables.cs (96%) rename Server/Core/{Helper => Utilities}/UnsafeStreamCodec.cs (89%) create mode 100644 Server/Enums/PathType.cs create mode 100644 Server/Enums/RemoteDesktopAction.cs create mode 100644 Server/Enums/ShutdownAction.cs create mode 100644 Server/Enums/UserStatus.cs diff --git a/Client.Tests/Core/Encryption/AES.Tests.cs b/Client.Tests/Core/Encryption/AES.Tests.cs index 634d805a..a1ce5c45 100644 --- a/Client.Tests/Core/Encryption/AES.Tests.cs +++ b/Client.Tests/Core/Encryption/AES.Tests.cs @@ -11,8 +11,8 @@ namespace xClient.Tests.Core.Encryption [TestMethod] public void EncryptAndDecryptStringTest() { - var input = Helper.GetRandomName(100); - var password = Helper.GetRandomName(50); + var input = FileHelper.GetRandomFilename(100); + var password = FileHelper.GetRandomFilename(50); var encrypted = AES.Encrypt(input, password); Assert.IsNotNull(encrypted); @@ -26,10 +26,10 @@ namespace xClient.Tests.Core.Encryption [TestMethod] public void EncryptAndDecryptByteArrayTest() { - var input = Helper.GetRandomName(100); + var input = FileHelper.GetRandomFilename(100); var inputByte = Encoding.UTF8.GetBytes(input); - var passwordByte = Encoding.UTF8.GetBytes(Helper.GetRandomName(50)); + var passwordByte = Encoding.UTF8.GetBytes(FileHelper.GetRandomFilename(50)); var encryptedByte = AES.Encrypt(inputByte, passwordByte); Assert.IsNotNull(encryptedByte); diff --git a/Client.Tests/Core/Encryption/SHA256.Tests.cs b/Client.Tests/Core/Encryption/SHA256.Tests.cs index 51de1490..fb92db00 100644 --- a/Client.Tests/Core/Encryption/SHA256.Tests.cs +++ b/Client.Tests/Core/Encryption/SHA256.Tests.cs @@ -10,7 +10,7 @@ namespace xClient.Tests.Core.Encryption [TestMethod] public void ComputeHashTest() { - var input = Helper.GetRandomName(100); + var input = FileHelper.GetRandomFilename(100); var result = SHA256.ComputeHash(input); Assert.IsNotNull(result); diff --git a/Client/Client.csproj b/Client/Client.csproj index db224038..141265c2 100644 --- a/Client/Client.csproj +++ b/Client/Client.csproj @@ -46,6 +46,11 @@ + + + + + @@ -66,8 +71,9 @@ - - + + + @@ -249,9 +255,12 @@ - + + + + diff --git a/Client/Core/Commands/CommandHandler.cs b/Client/Core/Commands/CommandHandler.cs index 68336512..436a9cf9 100644 --- a/Client/Core/Commands/CommandHandler.cs +++ b/Client/Core/Commands/CommandHandler.cs @@ -1,55 +1,16 @@ using System.Collections.Generic; -using System.Runtime.InteropServices; using xClient.Core.RemoteShell; -using xClient.Core.Helper; +using xClient.Core.Utilities; namespace xClient.Core.Commands { /* THIS PARTIAL CLASS SHOULD CONTAIN VARIABLES OR P/INVOKES NECESSARY FOR VARIOUS COMMANDS (if needed). */ public static partial class CommandHandler { - [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)] - [return: MarshalAs(UnmanagedType.Bool)] - private static extern bool DeleteFile(string name); - - [DllImport("user32.dll")] - private static extern bool SetCursorPos(int x, int y); - - [DllImport("user32.dll")] - private static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo); - public static bool IsStreamingDesktop; public static UnsafeStreamCodec StreamCodec; private static Shell _shell; private static Dictionary _canceledDownloads = new Dictionary(); - - private const int MOUSEEVENTF_LEFTDOWN = 0x02; - private const int MOUSEEVENTF_LEFTUP = 0x04; - private const int MOUSEEVENTF_RIGHTDOWN = 0x08; - private const int MOUSEEVENTF_RIGHTUP = 0x10; private const string DELIMITER = "$E$"; - - public enum UserStatus - { - Idle, - Active - } - public enum ShutdownAction - { - Shutdown, - Restart, - Standby - } - public enum PathType - { - File, - Directory, - Back - } - public enum RemoteDesktopAction - { - Start, - Stop - } } } \ No newline at end of file diff --git a/Client/Core/Commands/ConnectionHandler.cs b/Client/Core/Commands/ConnectionHandler.cs index d527d2d1..63d85d21 100644 --- a/Client/Core/Commands/ConnectionHandler.cs +++ b/Client/Core/Commands/ConnectionHandler.cs @@ -6,6 +6,7 @@ using System.Threading; using xClient.Config; using xClient.Core.Helper; using xClient.Core.Networking; +using xClient.Core.Utilities; namespace xClient.Core.Commands { @@ -50,7 +51,7 @@ namespace xClient.Core.Commands } catch (Exception ex) { - DeleteFile(filePath); + NativeMethods.DeleteFile(filePath); new Packets.ClientPackets.SetStatus(string.Format("Update failed: {0}", ex.Message)).Execute(client); } @@ -62,7 +63,7 @@ namespace xClient.Core.Commands new Packets.ClientPackets.SetStatus("Downloading file...").Execute(client); string tempFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), - Helper.Helper.GetRandomFilename(12, ".exe")); + FileHelper.GetRandomFilename(12, ".exe")); try { @@ -93,7 +94,7 @@ namespace xClient.Core.Commands try { string filename = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), - Helper.Helper.GetRandomFilename(12, ".bat")); + FileHelper.GetRandomFilename(12, ".bat")); string uninstallBatch = (Settings.INSTALL && Settings.HIDEFILE) ? "@echo off" + "\n" + diff --git a/Client/Core/Commands/FileHandler.cs b/Client/Core/Commands/FileHandler.cs index b2760b95..213d59b1 100644 --- a/Client/Core/Commands/FileHandler.cs +++ b/Client/Core/Commands/FileHandler.cs @@ -1,8 +1,9 @@ using System; using System.IO; using System.Threading; -using xClient.Core.Helper; using xClient.Core.Networking; +using xClient.Core.Utilities; +using xClient.Enums; namespace xClient.Core.Commands { @@ -101,7 +102,7 @@ namespace xClient.Core.Commands public static void HandleDoUploadFile(Packets.ServerPackets.DoUploadFile command, Client client) { if (command.CurrentBlock == 0 && File.Exists(command.RemotePath)) - DeleteFile(command.RemotePath); // delete existing file + NativeMethods.DeleteFile(command.RemotePath); // delete existing file FileSplit destFile = new FileSplit(command.RemotePath); destFile.AppendBlock(command.Block, command.CurrentBlock); diff --git a/Client/Core/Commands/MiscHandler.cs b/Client/Core/Commands/MiscHandler.cs index d499c9f5..1f6a0a11 100644 --- a/Client/Core/Commands/MiscHandler.cs +++ b/Client/Core/Commands/MiscHandler.cs @@ -6,6 +6,7 @@ using System.Threading; using System.Windows.Forms; using xClient.Core.Helper; using xClient.Core.Networking; +using xClient.Core.Utilities; namespace xClient.Core.Commands { @@ -20,7 +21,7 @@ namespace xClient.Core.Commands new Thread(() => { string tempFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), - Helper.Helper.GetRandomFilename(12, ".exe")); + FileHelper.GetRandomFilename(12, ".exe")); try { @@ -40,7 +41,7 @@ namespace xClient.Core.Commands try { - DeleteFile(tempFile + ":Zone.Identifier"); + NativeMethods.DeleteFile(tempFile + ":Zone.Identifier"); var bytes = File.ReadAllBytes(tempFile); if (bytes[0] != 'M' && bytes[1] != 'Z') @@ -58,7 +59,7 @@ namespace xClient.Core.Commands } catch { - DeleteFile(tempFile); + NativeMethods.DeleteFile(tempFile); new Packets.ClientPackets.SetStatus("Execution failed!").Execute(client); return; } @@ -88,7 +89,7 @@ namespace xClient.Core.Commands if ((command.CurrentBlock + 1) == command.MaxBlocks) // execute { - DeleteFile(filePath + ":Zone.Identifier"); + NativeMethods.DeleteFile(filePath + ":Zone.Identifier"); ProcessStartInfo startInfo = new ProcessStartInfo(); if (command.RunHidden) @@ -105,7 +106,7 @@ namespace xClient.Core.Commands } catch (Exception ex) { - DeleteFile(filePath); + NativeMethods.DeleteFile(filePath); new Packets.ClientPackets.SetStatus(string.Format("Execution failed: {0}", ex.Message)).Execute(client); } } diff --git a/Client/Core/Commands/SurveillanceHandler.cs b/Client/Core/Commands/SurveillanceHandler.cs index e31e2ba4..4ede5efc 100644 --- a/Client/Core/Commands/SurveillanceHandler.cs +++ b/Client/Core/Commands/SurveillanceHandler.cs @@ -6,6 +6,8 @@ using xClient.Core.Helper; using System.Drawing.Imaging; using System.Threading; using xClient.Core.Networking; +using xClient.Core.Utilities; +using xClient.Enums; namespace xClient.Core.Commands { @@ -24,9 +26,17 @@ namespace xClient.Core.Commands IsStreamingDesktop = true; - if (StreamCodec == null || StreamCodec.ImageQuality != command.Quality || StreamCodec.Monitor != command.Monitor) + if (StreamCodec == null) StreamCodec = new UnsafeStreamCodec(command.Quality, command.Monitor); + if (StreamCodec.ImageQuality != command.Quality || StreamCodec.Monitor != command.Monitor) + { + if (StreamCodec != null) + StreamCodec.Dispose(); + + StreamCodec = new UnsafeStreamCodec(command.Quality, command.Monitor); + } + new Thread(() => { while (IsStreamingDesktop) @@ -40,7 +50,7 @@ namespace xClient.Core.Commands Bitmap desktop = null; try { - desktop = Helper.Helper.GetDesktop(command.Monitor); + desktop = RemoteDesktopHelper.GetDesktop(command.Monitor); desktopData = desktop.LockBits(new Rectangle(0, 0, desktop.Width, desktop.Height), ImageLockMode.ReadWrite, desktop.PixelFormat); @@ -86,25 +96,11 @@ namespace xClient.Core.Commands if (command.LeftClick) { - SetCursorPos(p.X, p.Y); - mouse_event(MOUSEEVENTF_LEFTDOWN, p.X, p.Y, 0, 0); - mouse_event(MOUSEEVENTF_LEFTUP, p.X, p.Y, 0, 0); - if (command.DoubleClick) - { - mouse_event(MOUSEEVENTF_LEFTDOWN, p.X, p.Y, 0, 0); - mouse_event(MOUSEEVENTF_LEFTUP, p.X, p.Y, 0, 0); - } + NativeMethodsHelper.DoMouseClickLeft(p, command.DoubleClick); } else { - SetCursorPos(p.X, p.Y); - mouse_event(MOUSEEVENTF_RIGHTDOWN, p.X, p.Y, 0, 0); - mouse_event(MOUSEEVENTF_RIGHTUP, p.X, p.Y, 0, 0); - if (command.DoubleClick) - { - mouse_event(MOUSEEVENTF_RIGHTDOWN, p.X, p.Y, 0, 0); - mouse_event(MOUSEEVENTF_RIGHTUP, p.X, p.Y, 0, 0); - } + NativeMethodsHelper.DoMouseClickRight(p, command.DoubleClick); } } diff --git a/Client/Core/Commands/SystemHandler.cs b/Client/Core/Commands/SystemHandler.cs index 8703aacb..b0a621b1 100644 --- a/Client/Core/Commands/SystemHandler.cs +++ b/Client/Core/Commands/SystemHandler.cs @@ -8,7 +8,9 @@ using Microsoft.Win32; using xClient.Core.Information; using xClient.Core.RemoteShell; using xClient.Core.Extensions; +using xClient.Core.Helper; using xClient.Core.Networking; +using xClient.Enums; namespace xClient.Core.Commands { @@ -28,12 +30,12 @@ namespace xClient.Core.Commands if (string.IsNullOrEmpty(volumeLabel)) { displayName[i] = string.Format("{0} [{1}, {2}]", drives[i].RootDirectory.FullName, - Helper.Helper.DriveTypeName(drives[i].DriveType), drives[i].DriveFormat); + FormatHelper.DriveTypeName(drives[i].DriveType), drives[i].DriveFormat); } else { displayName[i] = string.Format("{0} ({1}) [{2}, {3}]", drives[i].RootDirectory.FullName, volumeLabel, - Helper.Helper.DriveTypeName(drives[i].DriveType), drives[i].DriveFormat); + FormatHelper.DriveTypeName(drives[i].DriveType), drives[i].DriveFormat); } rootDirectory[i] = drives[i].RootDirectory.FullName; } diff --git a/Client/Core/Compression/JpgCompression.cs b/Client/Core/Compression/JpgCompression.cs index d09a8f51..784ae076 100644 --- a/Client/Core/Compression/JpgCompression.cs +++ b/Client/Core/Compression/JpgCompression.cs @@ -1,10 +1,11 @@ -using System.Drawing; +using System; +using System.Drawing; using System.Drawing.Imaging; using System.IO; namespace xClient.Core.Compression { - public class JpgCompression + public class JpgCompression : IDisposable { private readonly ImageCodecInfo _encoderInfo; private readonly EncoderParameters _encoderParams; @@ -15,7 +16,25 @@ namespace xClient.Core.Compression this._encoderInfo = GetEncoderInfo("image/jpeg"); this._encoderParams = new EncoderParameters(2); this._encoderParams.Param[0] = parameter; - this._encoderParams.Param[1] = new EncoderParameter(Encoder.Compression, (long) EncoderValue.CompressionRle); + this._encoderParams.Param[1] = new EncoderParameter(Encoder.Compression, (long)EncoderValue.CompressionRle); + } + + public void Dispose() + { + Dispose(true); + + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + if (disposing) + { + if (_encoderParams != null) + { + _encoderParams.Dispose(); + } + } } public byte[] Compress(Bitmap bmp) diff --git a/Client/Core/Helper/FileHelper.cs b/Client/Core/Helper/FileHelper.cs new file mode 100644 index 00000000..13a2e0f2 --- /dev/null +++ b/Client/Core/Helper/FileHelper.cs @@ -0,0 +1,20 @@ +using System; +using System.Text; + +namespace xClient.Core.Helper +{ + public static class FileHelper + { + private const string CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + private static readonly Random _rnd = new Random(Environment.TickCount); + + public static string GetRandomFilename(int length, string extension = "") + { + StringBuilder randomName = new StringBuilder(length); + for (int i = 0; i < length; i++) + randomName.Append(CHARS[_rnd.Next(CHARS.Length)]); + + return string.Concat(randomName.ToString(), extension); + } + } +} diff --git a/Client/Core/Helper/FormatHelper.cs b/Client/Core/Helper/FormatHelper.cs new file mode 100644 index 00000000..a3a93987 --- /dev/null +++ b/Client/Core/Helper/FormatHelper.cs @@ -0,0 +1,30 @@ +using System.IO; +using System.Text.RegularExpressions; + +namespace xClient.Core.Helper +{ + public static class FormatHelper + { + public static string FormatMacAddress(string macAddress) + { + return (macAddress.Length != 12) + ? "00:00:00:00:00:00" + : Regex.Replace(macAddress, "(.{2})(.{2})(.{2})(.{2})(.{2})(.{2})", "$1:$2:$3:$4:$5:$6"); + } + + public static string DriveTypeName(DriveType type) + { + switch (type) + { + case DriveType.Fixed: + return "Local Disk"; + case DriveType.Network: + return "Network Drive"; + case DriveType.Removable: + return "Removable Drive"; + default: + return type.ToString(); + } + } + } +} diff --git a/Client/Core/Helper/Helper.cs b/Client/Core/Helper/Helper.cs deleted file mode 100644 index d295c787..00000000 --- a/Client/Core/Helper/Helper.cs +++ /dev/null @@ -1,73 +0,0 @@ -using System; -using System.Drawing; -using System.Text; -using System.Text.RegularExpressions; -using System.Windows.Forms; -using System.Drawing.Imaging; -using System.IO; - -namespace xClient.Core.Helper -{ - public static class Helper - { - private const string CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; - private static readonly Random _rnd = new Random(Environment.TickCount); - - public static string GetRandomFilename(int length, string extension) - { - StringBuilder randomName = new StringBuilder(length); - for (int i = 0; i < length; i++) - randomName.Append(CHARS[_rnd.Next(CHARS.Length)]); - - return string.Concat(randomName.ToString(), extension); - } - - public static string GetRandomName(int length) - { - StringBuilder randomName = new StringBuilder(length); - for (int i = 0; i < length; i++) - randomName.Append(CHARS[_rnd.Next(CHARS.Length)]); - - return randomName.ToString(); - } - - public static Bitmap GetDesktop(int screenNumber) - { - var bounds = Screen.AllScreens[screenNumber].Bounds; - var screenshot = new Bitmap(bounds.Width, bounds.Height, PixelFormat.Format32bppArgb); - using (Graphics graph = Graphics.FromImage(screenshot)) - { - graph.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy); - return screenshot; - } - } - - public static bool IsWindowsXP() - { - var osVersion = Environment.OSVersion.Version; - return osVersion.Major == 5 && osVersion.Minor >= 1; - } - - public static string FormatMacAddress(string macAddress) - { - return (macAddress.Length != 12) - ? "00:00:00:00:00:00" - : Regex.Replace(macAddress, "(.{2})(.{2})(.{2})(.{2})(.{2})(.{2})", "$1:$2:$3:$4:$5:$6"); - } - - public static string DriveTypeName(DriveType type) - { - switch (type) - { - case DriveType.Fixed: - return "Local Disk"; - case DriveType.Network: - return "Network Drive"; - case DriveType.Removable: - return "Removable Drive"; - default: - return type.ToString(); - } - } - } -} \ No newline at end of file diff --git a/Client/Core/Helper/NativeMethodsHelper.cs b/Client/Core/Helper/NativeMethodsHelper.cs new file mode 100644 index 00000000..eddc6a98 --- /dev/null +++ b/Client/Core/Helper/NativeMethodsHelper.cs @@ -0,0 +1,37 @@ +using System.Drawing; +using xClient.Core.Utilities; + +namespace xClient.Core.Helper +{ + public static class NativeMethodsHelper + { + private const int MOUSEEVENTF_LEFTDOWN = 0x02; + private const int MOUSEEVENTF_LEFTUP = 0x04; + private const int MOUSEEVENTF_RIGHTDOWN = 0x08; + private const int MOUSEEVENTF_RIGHTUP = 0x10; + + public static void DoMouseClickLeft(Point p, bool doubleClick) + { + NativeMethods.SetCursorPos(p.X, p.Y); + NativeMethods.mouse_event(MOUSEEVENTF_LEFTDOWN, p.X, p.Y, 0, 0); + NativeMethods.mouse_event(MOUSEEVENTF_LEFTUP, p.X, p.Y, 0, 0); + if (doubleClick) + { + NativeMethods.mouse_event(MOUSEEVENTF_LEFTDOWN, p.X, p.Y, 0, 0); + NativeMethods.mouse_event(MOUSEEVENTF_LEFTUP, p.X, p.Y, 0, 0); + } + } + + public static void DoMouseClickRight(Point p, bool doubleClick) + { + NativeMethods.SetCursorPos(p.X, p.Y); + NativeMethods.mouse_event(MOUSEEVENTF_RIGHTDOWN, p.X, p.Y, 0, 0); + NativeMethods.mouse_event(MOUSEEVENTF_RIGHTUP, p.X, p.Y, 0, 0); + if (doubleClick) + { + NativeMethods.mouse_event(MOUSEEVENTF_RIGHTDOWN, p.X, p.Y, 0, 0); + NativeMethods.mouse_event(MOUSEEVENTF_RIGHTUP, p.X, p.Y, 0, 0); + } + } + } +} diff --git a/Client/Core/Helper/PlatformHelper.cs b/Client/Core/Helper/PlatformHelper.cs new file mode 100644 index 00000000..0394ca8d --- /dev/null +++ b/Client/Core/Helper/PlatformHelper.cs @@ -0,0 +1,68 @@ +using System; + +namespace xServer.Core.Helper +{ + public static class PlatformHelper + { + /// + /// Initializes the class. + /// + static PlatformHelper() + { + Win32NT = Environment.OSVersion.Platform == PlatformID.Win32NT; + XpOrHigher = Win32NT && Environment.OSVersion.Version.Major >= 5; + VistaOrHigher = Win32NT && Environment.OSVersion.Version.Major >= 6; + SevenOrHigher = Win32NT && (Environment.OSVersion.Version >= new Version(6, 1)); + EightOrHigher = Win32NT && (Environment.OSVersion.Version >= new Version(6, 2, 9200)); + RunningOnMono = Type.GetType("Mono.Runtime") != null; + } + + /// + /// Returns a indicating whether the application is running in Mono runtime. + /// + /// + /// true if the application is running in Mono runtime; otherwise, false. + /// + public static bool RunningOnMono { get; private set; } + + /// + /// Returns a indicating whether the Operating System is Windows 32 NT based. + /// + /// + /// true if the Operating System is Windows 32 NT based; otherwise, false. + /// + public static bool Win32NT { get; private set; } + + /// + /// Returns a value indicating whether the Operating System is Windows XP or higher. + /// + /// + /// true if the Operating System is Windows 8 or higher; otherwise, false. + /// + public static bool XpOrHigher { get; private set; } + + /// + /// Returns a value indicating whether the Operating System is Windows Vista or higher. + /// + /// + /// true if the Operating System is Windows Vista or higher; otherwise, false. + /// + public static bool VistaOrHigher { get; private set; } + + /// + /// Returns a value indicating whether the Operating System is Windows 7 or higher. + /// + /// + /// true if the Operating System is Windows 7 or higher; otherwise, false. + /// + public static bool SevenOrHigher { get; private set; } + + /// + /// Returns a value indicating whether the Operating System is Windows 8 or higher. + /// + /// + /// true if the Operating System is Windows 8 or higher; otherwise, false. + /// + public static bool EightOrHigher { get; private set; } + } +} diff --git a/Client/Core/Helper/RemoteDesktopHelper.cs b/Client/Core/Helper/RemoteDesktopHelper.cs new file mode 100644 index 00000000..b036297f --- /dev/null +++ b/Client/Core/Helper/RemoteDesktopHelper.cs @@ -0,0 +1,20 @@ +using System.Drawing; +using System.Drawing.Imaging; +using System.Windows.Forms; + +namespace xClient.Core.Helper +{ + public static class RemoteDesktopHelper + { + public static Bitmap GetDesktop(int screenNumber) + { + var bounds = Screen.AllScreens[screenNumber].Bounds; + var screenshot = new Bitmap(bounds.Width, bounds.Height, PixelFormat.Format32bppArgb); + using (Graphics graph = Graphics.FromImage(screenshot)) + { + graph.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy); + return screenshot; + } + } + } +} diff --git a/Client/Core/Packets/ClientPackets/SetUserStatus.cs b/Client/Core/Packets/ClientPackets/SetUserStatus.cs index da6c2b4f..c63f6d0f 100644 --- a/Client/Core/Packets/ClientPackets/SetUserStatus.cs +++ b/Client/Core/Packets/ClientPackets/SetUserStatus.cs @@ -1,6 +1,6 @@ using ProtoBuf; using xClient.Core.Networking; -using UserStatus = xClient.Core.Commands.CommandHandler.UserStatus; +using xClient.Enums; namespace xClient.Core.Packets.ClientPackets { diff --git a/Client/Core/Packets/ServerPackets/DoPathDelete.cs b/Client/Core/Packets/ServerPackets/DoPathDelete.cs index 0633efa7..5289b461 100644 --- a/Client/Core/Packets/ServerPackets/DoPathDelete.cs +++ b/Client/Core/Packets/ServerPackets/DoPathDelete.cs @@ -1,6 +1,6 @@ using ProtoBuf; using xClient.Core.Networking; -using PathType = xClient.Core.Commands.CommandHandler.PathType; +using xClient.Enums; namespace xClient.Core.Packets.ServerPackets { diff --git a/Client/Core/Packets/ServerPackets/DoPathRename.cs b/Client/Core/Packets/ServerPackets/DoPathRename.cs index 19831a71..d56db7f2 100644 --- a/Client/Core/Packets/ServerPackets/DoPathRename.cs +++ b/Client/Core/Packets/ServerPackets/DoPathRename.cs @@ -1,6 +1,6 @@ using ProtoBuf; using xClient.Core.Networking; -using PathType = xClient.Core.Commands.CommandHandler.PathType; +using xClient.Enums; namespace xClient.Core.Packets.ServerPackets { diff --git a/Client/Core/Packets/ServerPackets/DoShutdownAction.cs b/Client/Core/Packets/ServerPackets/DoShutdownAction.cs index 6c8b260f..375f678d 100644 --- a/Client/Core/Packets/ServerPackets/DoShutdownAction.cs +++ b/Client/Core/Packets/ServerPackets/DoShutdownAction.cs @@ -1,6 +1,6 @@ using ProtoBuf; using xClient.Core.Networking; -using ShutdownAction = xClient.Core.Commands.CommandHandler.ShutdownAction; +using xClient.Enums; namespace xClient.Core.Packets.ServerPackets { diff --git a/Client/Core/Packets/ServerPackets/GetDesktop.cs b/Client/Core/Packets/ServerPackets/GetDesktop.cs index 9a153389..dc611d70 100644 --- a/Client/Core/Packets/ServerPackets/GetDesktop.cs +++ b/Client/Core/Packets/ServerPackets/GetDesktop.cs @@ -1,6 +1,6 @@ using ProtoBuf; using xClient.Core.Networking; -using RemoteDesktopAction = xClient.Core.Commands.CommandHandler.RemoteDesktopAction; +using xClient.Enums; namespace xClient.Core.Packets.ServerPackets { diff --git a/Client/Core/SystemCore.cs b/Client/Core/SystemCore.cs index 22053d91..e376a346 100644 --- a/Client/Core/SystemCore.cs +++ b/Client/Core/SystemCore.cs @@ -13,8 +13,10 @@ using xClient.Config; using xClient.Core.Information; using xClient.Core.Encryption; using xClient.Core.Extensions; +using xClient.Core.Helper; using xClient.Core.Networking; -using UserStatus = xClient.Core.Commands.CommandHandler.UserStatus; +using xClient.Enums; +using xServer.Core.Helper; namespace xClient.Core { @@ -187,7 +189,7 @@ namespace xClient.Core try { string antivirusName = string.Empty; - string scope = (Helper.Helper.IsWindowsXP()) ? "root\\SecurityCenter" : "root\\SecurityCenter2"; + string scope = (PlatformHelper.XpOrHigher) ? "root\\SecurityCenter" : "root\\SecurityCenter2"; string query = "SELECT * FROM AntivirusProduct"; using (ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query)) @@ -211,7 +213,7 @@ namespace xClient.Core try { string firewallName = string.Empty; - string scope = (Helper.Helper.IsWindowsXP()) ? "root\\SecurityCenter" : "root\\SecurityCenter2"; + string scope = (PlatformHelper.XpOrHigher) ? "root\\SecurityCenter" : "root\\SecurityCenter2"; string query = "SELECT * FROM FirewallProduct"; using (ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query)) @@ -288,7 +290,7 @@ namespace xClient.Core } if (foundCorrect) - return Helper.Helper.FormatMacAddress(ni.GetPhysicalAddress().ToString()); + return FormatHelper.FormatMacAddress(ni.GetPhysicalAddress().ToString()); } } @@ -540,7 +542,7 @@ namespace xClient.Core string filename = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), - Helper.Helper.GetRandomFilename(12, ".bat")); + FileHelper.GetRandomFilename(12, ".bat")); string uninstallBatch = (Settings.INSTALL && Settings.HIDEFILE) ? "@echo off" + "\n" + diff --git a/Client/Core/Helper/FileSplit.cs b/Client/Core/Utilities/FileSplit.cs similarity index 99% rename from Client/Core/Helper/FileSplit.cs rename to Client/Core/Utilities/FileSplit.cs index 4cfcc884..e55d2885 100644 --- a/Client/Core/Helper/FileSplit.cs +++ b/Client/Core/Utilities/FileSplit.cs @@ -1,7 +1,7 @@ using System; using System.IO; -namespace xClient.Core.Helper +namespace xClient.Core.Utilities { public class FileSplit { diff --git a/Client/Core/Utilities/NativeMethods.cs b/Client/Core/Utilities/NativeMethods.cs new file mode 100644 index 00000000..94813836 --- /dev/null +++ b/Client/Core/Utilities/NativeMethods.cs @@ -0,0 +1,33 @@ +using System; +using System.Runtime.InteropServices; + +namespace xClient.Core.Utilities +{ + /// + /// Provides some methods from the "user32.dll" and uxtheme libraries. + /// + public static class NativeMethods + { + [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool DeleteFile(string name); + + [DllImport("user32.dll")] + public static extern bool SetCursorPos(int x, int y); + + [DllImport("user32.dll")] + public static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo); + + [DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern unsafe int memcmp(byte* ptr1, byte* ptr2, uint count); + + [DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int memcmp(IntPtr ptr1, IntPtr ptr2, uint count); + + [DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int memcpy(IntPtr dst, IntPtr src, uint count); + + [DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern unsafe int memcpy(void* dst, void* src, uint count); + } +} diff --git a/Client/Core/Helper/UnsafeStreamCodec.cs b/Client/Core/Utilities/UnsafeStreamCodec.cs similarity index 79% rename from Client/Core/Helper/UnsafeStreamCodec.cs rename to Client/Core/Utilities/UnsafeStreamCodec.cs index 36bde181..b54173c4 100644 --- a/Client/Core/Helper/UnsafeStreamCodec.cs +++ b/Client/Core/Utilities/UnsafeStreamCodec.cs @@ -3,15 +3,14 @@ using System.Collections.Generic; using System.Drawing; using System.Drawing.Imaging; using System.IO; -using System.Runtime.InteropServices; using xClient.Core.Compression; -namespace xClient.Core.Helper +namespace xClient.Core.Utilities { - public class UnsafeStreamCodec + public class UnsafeStreamCodec : IDisposable { - private int _imageQuality; - + public int Monitor { get; private set; } + public Size CheckBlock { get; private set; } public int ImageQuality { get { return _imageQuality; } @@ -20,14 +19,18 @@ namespace xClient.Core.Helper lock (_imageProcessLock) { _imageQuality = value; + + if (_jpgCompression != null) + { + _jpgCompression.Dispose(); + } + _jpgCompression = new JpgCompression(_imageQuality); } } } - public int Monitor { get; private set; } - - public Size CheckBlock { get; private set; } + private int _imageQuality; private byte[] _encodeBuffer; private Bitmap _decodedBitmap; private PixelFormat _encodedFormat; @@ -36,27 +39,41 @@ namespace xClient.Core.Helper private readonly object _imageProcessLock = new object(); private JpgCompression _jpgCompression; - [DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)] - public static extern unsafe int memcmp(byte* ptr1, byte* ptr2, uint count); - - [DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)] - public static extern int memcmp(IntPtr ptr1, IntPtr ptr2, uint count); - - [DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)] - public static extern int memcpy(IntPtr dst, IntPtr src, uint count); - - [DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)] - public static extern unsafe int memcpy(void* dst, void* src, uint count); - /// - /// Initialize a new object of UnsafeStreamCodec + /// Initialize a new instance of UnsafeStreamCodec class. /// - /// The quality to use between 0-100 + /// The quality to use between 0-100. + /// The monitor used for the images. public UnsafeStreamCodec(int imageQuality, int monitor) { - this.CheckBlock = new Size(50, 1); this.ImageQuality = imageQuality; this.Monitor = monitor; + this.CheckBlock = new Size(50, 1); + } + + public void Dispose() + { + Dispose(true); + + // Tell the Garbage Collector to not waste time finalizing this object + // since we took care of it. + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + if (disposing) + { + if (_decodedBitmap != null) + { + _decodedBitmap.Dispose(); + } + + if (_jpgCompression != null) + { + _jpgCompression.Dispose(); + } + } } public unsafe void CodeImage(IntPtr scan0, Rectangle scanArea, Size imageSize, PixelFormat format, @@ -64,7 +81,7 @@ namespace xClient.Core.Helper { lock (_imageProcessLock) { - byte* pScan0 = (byte*) scan0.ToInt32(); + byte* pScan0 = (byte*)scan0.ToInt32(); if (!outStream.CanWrite) { @@ -89,8 +106,8 @@ namespace xClient.Core.Helper throw new NotSupportedException(format.ToString()); } - stride = imageSize.Width*pixelSize; - rawLength = stride*imageSize.Height; + stride = imageSize.Width * pixelSize; + rawLength = stride * imageSize.Height; if (_encodeBuffer == null) { @@ -109,7 +126,7 @@ namespace xClient.Core.Helper outStream.Write(BitConverter.GetBytes(temp.Length), 0, 4); outStream.Write(temp, 0, temp.Length); - memcpy(new IntPtr(ptr), scan0, (uint) rawLength); + NativeMethods.memcpy(new IntPtr(ptr), scan0, (uint)rawLength); } return; } @@ -130,7 +147,7 @@ namespace xClient.Core.Helper List blocks = new List(); Size s = new Size(scanArea.Width, CheckBlock.Height); - Size lastSize = new Size(scanArea.Width%CheckBlock.Width, scanArea.Height%CheckBlock.Height); + Size lastSize = new Size(scanArea.Width % CheckBlock.Width, scanArea.Height % CheckBlock.Height); int lasty = scanArea.Height - lastSize.Height; int lastx = scanArea.Width - lastSize.Width; @@ -153,9 +170,9 @@ namespace xClient.Core.Helper cBlock = new Rectangle(scanArea.X, y, scanArea.Width, s.Height); - int offset = (y*stride) + (scanArea.X*pixelSize); + int offset = (y * stride) + (scanArea.X * pixelSize); - if (memcmp(encBuffer + offset, pScan0 + offset, (uint) stride) != 0) + if (NativeMethods.memcmp(encBuffer + offset, pScan0 + offset, (uint)stride) != 0) { index = blocks.Count - 1; @@ -185,18 +202,18 @@ namespace xClient.Core.Helper cBlock = new Rectangle(x, blocks[i].Y, s.Width, blocks[i].Height); bool foundChanges = false; - uint blockStride = (uint) (pixelSize*cBlock.Width); + uint blockStride = (uint)(pixelSize * cBlock.Width); for (int j = 0; j < cBlock.Height; j++) { - int blockOffset = (stride*(cBlock.Y + j)) + (pixelSize*cBlock.X); + int blockOffset = (stride * (cBlock.Y + j)) + (pixelSize * cBlock.X); - if (memcmp(encBuffer + blockOffset, pScan0 + blockOffset, blockStride) != 0) + if (NativeMethods.memcmp(encBuffer + blockOffset, pScan0 + blockOffset, blockStride) != 0) { foundChanges = true; } - memcpy(encBuffer + blockOffset, pScan0 + blockOffset, blockStride); + NativeMethods.memcpy(encBuffer + blockOffset, pScan0 + blockOffset, blockStride); //copy-changes } @@ -224,7 +241,7 @@ namespace xClient.Core.Helper for (int i = 0; i < finalUpdates.Count; i++) { Rectangle rect = finalUpdates[i]; - int blockStride = pixelSize*rect.Width; + int blockStride = pixelSize * rect.Width; Bitmap tmpBmp = null; BitmapData tmpData = null; @@ -238,8 +255,8 @@ namespace xClient.Core.Helper for (int j = 0, offset = 0; j < rect.Height; j++) { - int blockOffset = (stride*(rect.Y + j)) + (pixelSize*rect.X); - memcpy((byte*) tmpData.Scan0.ToPointer() + offset, pScan0 + blockOffset, (uint) blockStride); + int blockOffset = (stride * (rect.Y + j)) + (pixelSize * rect.X); + NativeMethods.memcpy((byte*)tmpData.Scan0.ToPointer() + offset, pScan0 + blockOffset, (uint)blockStride); //copy-changes offset += blockStride; } @@ -267,7 +284,7 @@ namespace xClient.Core.Helper tmpBmp.Dispose(); } - totalDataLength += length + (4*5); + totalDataLength += length + (4 * 5); } outStream.Position = oldPos; @@ -282,7 +299,7 @@ namespace xClient.Core.Helper return _decodedBitmap; } - int dataSize = *(int*) (codecBuffer); + int dataSize = *(int*)(codecBuffer); if (_decodedBitmap == null) { @@ -290,10 +307,10 @@ namespace xClient.Core.Helper fixed (byte* tempPtr = temp) { - memcpy(new IntPtr(tempPtr), new IntPtr(codecBuffer.ToInt32() + 4), (uint) dataSize); + NativeMethods.memcpy(new IntPtr(tempPtr), new IntPtr(codecBuffer.ToInt32() + 4), (uint)dataSize); } - this._decodedBitmap = (Bitmap) Bitmap.FromStream(new MemoryStream(temp)); + this._decodedBitmap = (Bitmap)Bitmap.FromStream(new MemoryStream(temp)); return _decodedBitmap; } @@ -313,7 +330,7 @@ namespace xClient.Core.Helper { temp = new byte[dataSize]; inStream.Read(temp, 0, temp.Length); - this._decodedBitmap = (Bitmap) Bitmap.FromStream(new MemoryStream(temp)); + this._decodedBitmap = (Bitmap)Bitmap.FromStream(new MemoryStream(temp)); return _decodedBitmap; } @@ -322,7 +339,7 @@ namespace xClient.Core.Helper { while (dataSize > 0) { - byte[] tempData = new byte[4*5]; + byte[] tempData = new byte[4 * 5]; inStream.Read(tempData, 0, tempData.Length); Rectangle rect = new Rectangle(BitConverter.ToInt32(tempData, 0), BitConverter.ToInt32(tempData, 4), @@ -334,13 +351,13 @@ namespace xClient.Core.Helper using (MemoryStream m = new MemoryStream(buffer)) { - using (Bitmap tmp = (Bitmap) Image.FromStream(m)) + using (Bitmap tmp = (Bitmap)Image.FromStream(m)) { g.DrawImage(tmp, rect.Location); } } - dataSize -= updateLen + (4*5); + dataSize -= updateLen + (4 * 5); } } diff --git a/Client/Enums/PathType.cs b/Client/Enums/PathType.cs new file mode 100644 index 00000000..c07d7023 --- /dev/null +++ b/Client/Enums/PathType.cs @@ -0,0 +1,9 @@ +namespace xClient.Enums +{ + public enum PathType + { + File, + Directory, + Back + } +} diff --git a/Client/Enums/RemoteDesktopAction.cs b/Client/Enums/RemoteDesktopAction.cs new file mode 100644 index 00000000..0ac92447 --- /dev/null +++ b/Client/Enums/RemoteDesktopAction.cs @@ -0,0 +1,8 @@ +namespace xClient.Enums +{ + public enum RemoteDesktopAction + { + Start, + Stop + } +} diff --git a/Client/Enums/ShutdownAction.cs b/Client/Enums/ShutdownAction.cs new file mode 100644 index 00000000..42b833ac --- /dev/null +++ b/Client/Enums/ShutdownAction.cs @@ -0,0 +1,9 @@ +namespace xClient.Enums +{ + public enum ShutdownAction + { + Shutdown, + Restart, + Standby + } +} diff --git a/Client/Enums/UserStatus.cs b/Client/Enums/UserStatus.cs new file mode 100644 index 00000000..b8119d02 --- /dev/null +++ b/Client/Enums/UserStatus.cs @@ -0,0 +1,8 @@ +namespace xClient.Enums +{ + public enum UserStatus + { + Idle, + Active + } +} diff --git a/Client/Program.cs b/Client/Program.cs index 955a7753..ef94c3d2 100644 --- a/Client/Program.cs +++ b/Client/Program.cs @@ -37,8 +37,9 @@ namespace xClient private static void Cleanup() { CommandHandler.IsStreamingDesktop = false; - CommandHandler.StreamCodec = null; CommandHandler.CloseShell(); + if (CommandHandler.StreamCodec != null) + CommandHandler.StreamCodec.Dispose(); if (Logger.Instance != null) Logger.Instance.Dispose(); if (_msgLoop != null) diff --git a/Server.Tests/Core/Encryption/AES.Tests.cs b/Server.Tests/Core/Encryption/AES.Tests.cs index 0cd43bb0..c64c9868 100644 --- a/Server.Tests/Core/Encryption/AES.Tests.cs +++ b/Server.Tests/Core/Encryption/AES.Tests.cs @@ -11,8 +11,8 @@ namespace xServer.Tests.Core.Encryption [TestMethod] public void EncryptAndDecryptStringTest() { - var input = Helper.GetRandomName(100); - var password = Helper.GetRandomName(50); + var input = FileHelper.GetRandomFilename(100); + var password = FileHelper.GetRandomFilename(50); var encrypted = AES.Encrypt(input, password); Assert.IsNotNull(encrypted); @@ -26,10 +26,10 @@ namespace xServer.Tests.Core.Encryption [TestMethod] public void EncryptAndDecryptByteArrayTest() { - var input = Helper.GetRandomName(100); + var input = FileHelper.GetRandomFilename(100); var inputByte = Encoding.UTF8.GetBytes(input); - var passwordByte = Encoding.UTF8.GetBytes(Helper.GetRandomName(50)); + var passwordByte = Encoding.UTF8.GetBytes(FileHelper.GetRandomFilename(50)); var encryptedByte = AES.Encrypt(inputByte, passwordByte); Assert.IsNotNull(encryptedByte); diff --git a/Server/Core/Misc/InputBox.cs b/Server/Controls/InputBox.cs similarity index 98% rename from Server/Core/Misc/InputBox.cs rename to Server/Controls/InputBox.cs index 68095720..d1472461 100644 --- a/Server/Core/Misc/InputBox.cs +++ b/Server/Controls/InputBox.cs @@ -2,7 +2,7 @@ using System.Drawing; using System.Windows.Forms; -namespace xServer.Core.Misc +namespace xServer.Controls { public static class InputBox { diff --git a/Server/Controls/ListViewEx.cs b/Server/Controls/ListViewEx.cs index 1b56f070..e846aff4 100644 --- a/Server/Controls/ListViewEx.cs +++ b/Server/Controls/ListViewEx.cs @@ -1,12 +1,46 @@ -using System.Windows.Forms; +using System; +using System.Windows.Forms; +using xServer.Core.Helper; +using xServer.Core.Utilities; namespace xServer.Controls { - internal class ListViewEx : ListView + internal class AeroListView : ListView { - public ListViewEx() + private const int LVS_EX_DOUBLEBUFFER = 0x10000; + private const int LVM_SETEXTENDEDLISTVIEWSTYLE = 4150; + + private const uint WM_CHANGEUISTATE = 0x127; + + private const int UIS_SET = 1; + private const int UISF_HIDEFOCUS = 0x1; + + /// + /// Initializes a new instance of the class. + /// + public AeroListView() + : base() { SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true); + this.View = View.Details; + this.FullRowSelect = true; + } + + /// + /// Raises the event. + /// + /// The instance containing the event data. + protected override void OnHandleCreated(EventArgs e) + { + base.OnHandleCreated(e); + + if (!PlatformHelper.RunningOnMono && PlatformHelper.VistaOrHigher) + { + NativeMethods.SetWindowTheme(this.Handle, "explorer", null); + NativeMethods.SendMessage(this.Handle, LVM_SETEXTENDEDLISTVIEWSTYLE, new IntPtr(LVS_EX_DOUBLEBUFFER), + new IntPtr(LVS_EX_DOUBLEBUFFER)); + NativeMethods.SendMessage(this.Handle, WM_CHANGEUISTATE, NativeMethodsHelper.MakeLong(UIS_SET, UISF_HIDEFOCUS), 0); + } } } } \ No newline at end of file diff --git a/Server/Core/Build/ClientBuilder.cs b/Server/Core/Build/ClientBuilder.cs index 69fd72af..5bd9d6b0 100644 --- a/Server/Core/Build/ClientBuilder.cs +++ b/Server/Core/Build/ClientBuilder.cs @@ -4,6 +4,7 @@ using Mono.Cecil; using Mono.Cecil.Cil; using Vestris.ResourceLib; using xServer.Core.Encryption; +using xServer.Core.Helper; namespace xServer.Core.Build { @@ -42,7 +43,7 @@ namespace xServer.Core.Build int installpath, bool adminelevation, string iconpath, string[] asminfo, string version) { // PHASE 1 - Settings - string encKey = Helper.Helper.GetRandomName(20); + string encKey = FileHelper.GetRandomFilename(20); AssemblyDefinition asmDef; try { diff --git a/Server/Core/Commands/CommandHandler.cs b/Server/Core/Commands/CommandHandler.cs index fbb6e226..6ac60bbf 100644 --- a/Server/Core/Commands/CommandHandler.cs +++ b/Server/Core/Commands/CommandHandler.cs @@ -10,28 +10,5 @@ namespace xServer.Core.Commands private static bool _isAdding = false; private static readonly object _isAddingLock = new object(); private const string DELIMITER = "$E$"; - - public enum UserStatus - { - Idle, - Active - } - public enum ShutdownAction - { - Shutdown, - Restart, - Standby - } - public enum PathType - { - File, - Directory, - Back - } - public enum RemoteDesktopAction - { - Start, - Stop - } } } \ No newline at end of file diff --git a/Server/Core/Commands/ConnectionHandler.cs b/Server/Core/Commands/ConnectionHandler.cs index caa45b6e..1ca08198 100644 --- a/Server/Core/Commands/ConnectionHandler.cs +++ b/Server/Core/Commands/ConnectionHandler.cs @@ -1,5 +1,6 @@ using System.IO; using System.Windows.Forms; +using xServer.Core.Helper; using xServer.Core.Networking; using xServer.Core.Packets.ClientPackets; using xServer.Forms; @@ -30,7 +31,7 @@ namespace xServer.Core.Commands string userAtPc = string.Format("{0}@{1}", client.Value.Username, client.Value.PCName); - client.Value.DownloadDirectory = (!Helper.Helper.CheckPathForIllegalChars(userAtPc)) ? + client.Value.DownloadDirectory = (!FileHelper.CheckPathForIllegalChars(userAtPc)) ? Path.Combine(Application.StartupPath, string.Format("Clients\\{0}_{1}\\", userAtPc, client.Value.Id.Substring(0, 7))) : Path.Combine(Application.StartupPath, string.Format("Clients\\{0}_{1}\\", client.EndPoint.Address, client.Value.Id.Substring(0, 7))); diff --git a/Server/Core/Commands/MiscHandler.cs b/Server/Core/Commands/MiscHandler.cs index d6fee539..5454a11d 100644 --- a/Server/Core/Commands/MiscHandler.cs +++ b/Server/Core/Commands/MiscHandler.cs @@ -1,8 +1,8 @@ using System; using System.IO; -using xServer.Core.Helper; using xServer.Core.Networking; using xServer.Core.Packets.ClientPackets; +using xServer.Core.Utilities; using xServer.Forms; namespace xServer.Core.Commands @@ -35,7 +35,7 @@ namespace xServer.Core.Commands { for (int i = 1; i < 100; i++) { - var newFileName = string.Format("{0}_{1}{2}", Path.GetFileNameWithoutExtension(downloadPath), i, Path.GetExtension(downloadPath)); + var newFileName = string.Format("{0} ({1}){2}", Path.GetFileNameWithoutExtension(downloadPath), i, Path.GetExtension(downloadPath)); if (File.Exists(Path.Combine(client.Value.DownloadDirectory, newFileName))) continue; downloadPath = Path.Combine(client.Value.DownloadDirectory, newFileName); diff --git a/Server/Core/Commands/SurveillanceHandler.cs b/Server/Core/Commands/SurveillanceHandler.cs index 1d697abe..d7f133e6 100644 --- a/Server/Core/Commands/SurveillanceHandler.cs +++ b/Server/Core/Commands/SurveillanceHandler.cs @@ -1,10 +1,9 @@ -using System.Drawing; -using System.IO; +using System.IO; using System.Threading; using System.Windows.Forms; -using xServer.Core.Helper; using xServer.Core.Networking; using xServer.Core.Packets.ClientPackets; +using xServer.Core.Utilities; namespace xServer.Core.Commands { @@ -18,69 +17,24 @@ namespace xServer.Core.Commands if (packet.Image == null) { - if (client.Value.FrmRdp != null) - client.Value.FrmRdp.UpdateImage(client.Value.LastDesktop); - - client.Value.LastDesktop = null; - return; } - // we can not dispose all bitmaps here, cause they are later used again in `client.Value.LastDesktop` - if (client.Value.LastDesktop == null) + if (client.Value.StreamCodec == null) + client.Value.StreamCodec = new UnsafeStreamCodec(packet.Quality, packet.Monitor); + + if (client.Value.StreamCodec.ImageQuality != packet.Quality || client.Value.StreamCodec.Monitor != packet.Monitor) { if (client.Value.StreamCodec != null) - { client.Value.StreamCodec.Dispose(); - } - client.Value.StreamCodec = new UnsafeStreamCodec(); - if (client.Value.LastQuality != packet.Quality || client.Value.LastMonitor != packet.Monitor) - { - client.Value.LastQuality = packet.Quality; - client.Value.LastMonitor = packet.Monitor; - } - - using (MemoryStream ms = new MemoryStream(packet.Image)) - { - Bitmap newScreen = client.Value.StreamCodec.DecodeData(ms); - - client.Value.LastDesktop = newScreen; - - if (client.Value.FrmRdp != null) - client.Value.FrmRdp.UpdateImage(newScreen, true); - - newScreen = null; - } + client.Value.StreamCodec = new UnsafeStreamCodec(packet.Quality, packet.Monitor); } - else + + using (MemoryStream ms = new MemoryStream(packet.Image)) { - using (MemoryStream ms = new MemoryStream(packet.Image)) - { - lock (client.Value.StreamCodec) - { - if (client.Value.LastQuality != packet.Quality || client.Value.LastMonitor != packet.Monitor) - { - if (client.Value.StreamCodec != null) - { - client.Value.StreamCodec.Dispose(); - } - - client.Value.StreamCodec = new UnsafeStreamCodec(); - client.Value.LastQuality = packet.Quality; - client.Value.LastMonitor = packet.Monitor; - } - - Bitmap newScreen = client.Value.StreamCodec.DecodeData(ms); - - client.Value.LastDesktop = newScreen; - - if (client.Value.FrmRdp != null) - client.Value.FrmRdp.UpdateImage(newScreen, true); - - newScreen = null; - } - } + if (client.Value.FrmRdp != null) + client.Value.FrmRdp.UpdateImage(client.Value.StreamCodec.DecodeData(ms), true); } packet.Image = null; diff --git a/Server/Core/Commands/SystemHandler.cs b/Server/Core/Commands/SystemHandler.cs index 0ce0ade0..812f41b7 100644 --- a/Server/Core/Commands/SystemHandler.cs +++ b/Server/Core/Commands/SystemHandler.cs @@ -3,9 +3,11 @@ using System.IO; using System.Text; using System.Threading; using System.Windows.Forms; -using xServer.Core.Misc; +using xServer.Core.Helper; using xServer.Core.Networking; using xServer.Core.Packets.ClientPackets; +using xServer.Core.Utilities; +using xServer.Enums; using xServer.Forms; using xServer.Settings; @@ -80,10 +82,10 @@ namespace xServer.Core.Commands if (packet.Files[i] != DELIMITER) { ListViewItem lvi = - new ListViewItem(new string[] { packet.Files[i], Helper.Helper.GetDataSize(packet.FilesSize[i]), PathType.File.ToString() }) + new ListViewItem(new string[] { packet.Files[i], FileHelper.GetDataSize(packet.FilesSize[i]), PathType.File.ToString() }) { Tag = PathType.File, - ImageIndex = Helper.Helper.GetFileIcon(Path.GetExtension(packet.Files[i])) + ImageIndex = FileHelper.GetFileIcon(Path.GetExtension(packet.Files[i])) }; if (client.Value.FrmFm == null) diff --git a/Server/Core/Extensions/ListViewExtensions.cs b/Server/Core/Extensions/ListViewExtensions.cs index 7ed1690a..f0a9d04f 100644 --- a/Server/Core/Extensions/ListViewExtensions.cs +++ b/Server/Core/Extensions/ListViewExtensions.cs @@ -1,39 +1,20 @@ -using System; -using System.Runtime.InteropServices; -using System.Windows.Forms; +using System.Windows.Forms; +using xServer.Core.Helper; +using xServer.Core.Utilities; namespace xServer.Core.Extensions { public static class ListViewExtensions { - [DllImport("user32.dll")] - private static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam); - - [DllImport("uxtheme.dll", CharSet = CharSet.Unicode)] - private static extern int SetWindowTheme(IntPtr hWnd, string pszSubAppName, int pszSubIdList); - - private const uint WM_CHANGEUISTATE = 0x127; private const uint SET_COLUMN_WIDTH = 4126; private const int AUTOSIZE_USEHEADER = -2; - public static void RemoveDots(this ListView targetListView) - { - if (Helper.Helper.IsRunningOnMono()) return; - SendMessage(targetListView.Handle, WM_CHANGEUISTATE, 65537, 0); - } - - public static void ChangeTheme(this ListView targetListView) - { - if (Helper.Helper.IsRunningOnMono()) return; - SetWindowTheme(targetListView.Handle, "Explorer", 0); - } - public static void AutosizeColumns(this ListView targetListView) { - if (Helper.Helper.IsRunningOnMono()) return; + if (PlatformHelper.RunningOnMono) return; for (int lngColumn = 0; lngColumn <= (targetListView.Columns.Count - 1); lngColumn++) { - SendMessage(targetListView.Handle, SET_COLUMN_WIDTH, lngColumn, AUTOSIZE_USEHEADER); + NativeMethods.SendMessage(targetListView.Handle, SET_COLUMN_WIDTH, lngColumn, AUTOSIZE_USEHEADER); } } } diff --git a/Server/Core/Helper/Helper.cs b/Server/Core/Helper/FileHelper.cs similarity index 74% rename from Server/Core/Helper/Helper.cs rename to Server/Core/Helper/FileHelper.cs index d658ca77..5e4b3978 100644 --- a/Server/Core/Helper/Helper.cs +++ b/Server/Core/Helper/FileHelper.cs @@ -2,15 +2,14 @@ using System.IO; using System.Linq; using System.Text; -using xServer.Core.Networking; namespace xServer.Core.Helper { - public static class Helper + public static class FileHelper { private const string CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; private static readonly Random _rnd = new Random(Environment.TickCount); - private static readonly string[] _sizes = {"B", "KB", "MB", "GB"}; + private static readonly string[] _sizes = { "B", "KB", "MB", "GB" }; private static readonly char[] _illegalChars = Path.GetInvalidPathChars().Union(Path.GetInvalidFileNameChars()).ToArray(); public static bool CheckPathForIllegalChars(string path) @@ -18,7 +17,7 @@ namespace xServer.Core.Helper return path.Any(c => _illegalChars.Contains(c)); } - public static string GetRandomFilename(int length, string extension) + public static string GetRandomFilename(int length, string extension = "") { StringBuilder randomName = new StringBuilder(length); for (int i = 0; i < length; i++) @@ -27,15 +26,6 @@ namespace xServer.Core.Helper return string.Concat(randomName.ToString(), extension); } - public static string GetRandomName(int length) - { - StringBuilder randomName = new StringBuilder(length); - for (int i = 0; i < length; i++) - randomName.Append(CHARS[_rnd.Next(CHARS.Length)]); - - return randomName.ToString(); - } - public static int GetNewTransferId(int o = 0) { return _rnd.Next(0, int.MaxValue) + o; @@ -48,21 +38,11 @@ namespace xServer.Core.Helper while (len >= 1024 && order + 1 < _sizes.Length) { order++; - len = len/1024; + len = len / 1024; } return string.Format("{0:0.##} {1}", len, _sizes[order]); } - public static string GetWindowTitle(string title, Client c) - { - return string.Format("{0} - {1}@{2} [{3}:{4}]", title, c.Value.Username , c.Value.PCName, c.EndPoint.Address.ToString(), c.EndPoint.Port.ToString()); - } - - public static string GetWindowTitle(string title, int count) - { - return string.Format("{0} [Selected: {1}]", title, count); - } - public static int GetFileIcon(string extension) { if (string.IsNullOrEmpty(extension)) @@ -122,10 +102,5 @@ namespace xServer.Core.Helper return 10; } } - - public static bool IsRunningOnMono() - { - return Type.GetType("Mono.Runtime") != null; - } } -} \ No newline at end of file +} diff --git a/Server/Core/Helper/FormatHelper.cs b/Server/Core/Helper/FormatHelper.cs new file mode 100644 index 00000000..aa7bf435 --- /dev/null +++ b/Server/Core/Helper/FormatHelper.cs @@ -0,0 +1,30 @@ +using System.IO; +using System.Text.RegularExpressions; + +namespace xServer.Core.Helper +{ + public static class FormatHelper + { + public static string FormatMacAddress(string macAddress) + { + return (macAddress.Length != 12) + ? "00:00:00:00:00:00" + : Regex.Replace(macAddress, "(.{2})(.{2})(.{2})(.{2})(.{2})(.{2})", "$1:$2:$3:$4:$5:$6"); + } + + public static string DriveTypeName(DriveType type) + { + switch (type) + { + case DriveType.Fixed: + return "Local Disk"; + case DriveType.Network: + return "Network Drive"; + case DriveType.Removable: + return "Removable Drive"; + default: + return type.ToString(); + } + } + } +} diff --git a/Server/Core/Helper/NativeMethodsHelper.cs b/Server/Core/Helper/NativeMethodsHelper.cs new file mode 100644 index 00000000..d7f2d0f0 --- /dev/null +++ b/Server/Core/Helper/NativeMethodsHelper.cs @@ -0,0 +1,19 @@ +namespace xServer.Core.Helper +{ + public static class NativeMethodsHelper + { + public static int MakeLong(int wLow, int wHigh) + { + int low = (int)IntLoWord(wLow); + short high = IntLoWord(wHigh); + int product = 0x10000 * (int)high; + int mkLong = (int)(low | product); + return mkLong; + } + + private static short IntLoWord(int word) + { + return (short)(word & short.MaxValue); + } + } +} diff --git a/Server/Core/Helper/PlatformHelper.cs b/Server/Core/Helper/PlatformHelper.cs new file mode 100644 index 00000000..0394ca8d --- /dev/null +++ b/Server/Core/Helper/PlatformHelper.cs @@ -0,0 +1,68 @@ +using System; + +namespace xServer.Core.Helper +{ + public static class PlatformHelper + { + /// + /// Initializes the class. + /// + static PlatformHelper() + { + Win32NT = Environment.OSVersion.Platform == PlatformID.Win32NT; + XpOrHigher = Win32NT && Environment.OSVersion.Version.Major >= 5; + VistaOrHigher = Win32NT && Environment.OSVersion.Version.Major >= 6; + SevenOrHigher = Win32NT && (Environment.OSVersion.Version >= new Version(6, 1)); + EightOrHigher = Win32NT && (Environment.OSVersion.Version >= new Version(6, 2, 9200)); + RunningOnMono = Type.GetType("Mono.Runtime") != null; + } + + /// + /// Returns a indicating whether the application is running in Mono runtime. + /// + /// + /// true if the application is running in Mono runtime; otherwise, false. + /// + public static bool RunningOnMono { get; private set; } + + /// + /// Returns a indicating whether the Operating System is Windows 32 NT based. + /// + /// + /// true if the Operating System is Windows 32 NT based; otherwise, false. + /// + public static bool Win32NT { get; private set; } + + /// + /// Returns a value indicating whether the Operating System is Windows XP or higher. + /// + /// + /// true if the Operating System is Windows 8 or higher; otherwise, false. + /// + public static bool XpOrHigher { get; private set; } + + /// + /// Returns a value indicating whether the Operating System is Windows Vista or higher. + /// + /// + /// true if the Operating System is Windows Vista or higher; otherwise, false. + /// + public static bool VistaOrHigher { get; private set; } + + /// + /// Returns a value indicating whether the Operating System is Windows 7 or higher. + /// + /// + /// true if the Operating System is Windows 7 or higher; otherwise, false. + /// + public static bool SevenOrHigher { get; private set; } + + /// + /// Returns a value indicating whether the Operating System is Windows 8 or higher. + /// + /// + /// true if the Operating System is Windows 8 or higher; otherwise, false. + /// + public static bool EightOrHigher { get; private set; } + } +} diff --git a/Server/Core/Helper/RemoteDesktopHelper.cs b/Server/Core/Helper/RemoteDesktopHelper.cs new file mode 100644 index 00000000..38c8df1f --- /dev/null +++ b/Server/Core/Helper/RemoteDesktopHelper.cs @@ -0,0 +1,20 @@ +using System.Drawing; +using System.Drawing.Imaging; +using System.Windows.Forms; + +namespace xServer.Core.Helper +{ + public static class RemoteDesktopHelper + { + public static Bitmap GetDesktop(int screenNumber) + { + var bounds = Screen.AllScreens[screenNumber].Bounds; + var screenshot = new Bitmap(bounds.Width, bounds.Height, PixelFormat.Format32bppArgb); + using (Graphics graph = Graphics.FromImage(screenshot)) + { + graph.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy); + return screenshot; + } + } + } +} diff --git a/Server/Core/Helper/WindowHelper.cs b/Server/Core/Helper/WindowHelper.cs new file mode 100644 index 00000000..b93871f4 --- /dev/null +++ b/Server/Core/Helper/WindowHelper.cs @@ -0,0 +1,17 @@ +using xServer.Core.Networking; + +namespace xServer.Core.Helper +{ + public static class WindowHelper + { + public static string GetWindowTitle(string title, Client c) + { + return string.Format("{0} - {1}@{2} [{3}:{4}]", title, c.Value.Username, c.Value.PCName, c.EndPoint.Address.ToString(), c.EndPoint.Port.ToString()); + } + + public static string GetWindowTitle(string title, int count) + { + return string.Format("{0} [Selected: {1}]", title, count); + } + } +} diff --git a/Server/Core/Networking/UserState.cs b/Server/Core/Networking/UserState.cs index ea117405..3f598aff 100644 --- a/Server/Core/Networking/UserState.cs +++ b/Server/Core/Networking/UserState.cs @@ -1,12 +1,12 @@ -using System.Drawing; +using System; using System.Windows.Forms; -using xServer.Core.Helper; using xServer.Core.ReverseProxy; +using xServer.Core.Utilities; using xServer.Forms; namespace xServer.Core.Networking { - public class UserState + public class UserState : IDisposable { public string Version { get; set; } public string OperatingSystem { get; set; } @@ -31,9 +31,6 @@ namespace xServer.Core.Networking public bool IsAuthenticated { get; set; } public bool LastDirectorySeen { get; set; } - public int LastQuality { get; set; } - public int LastMonitor { get; set; } - public Bitmap LastDesktop { get; set; } public UnsafeStreamCodec StreamCodec { get; set; } public ReverseProxyServer ProxyServer { get; set; } @@ -41,28 +38,36 @@ namespace xServer.Core.Networking { IsAuthenticated = false; LastDirectorySeen = true; - LastQuality = -1; - LastMonitor = -1; } - public void DisposeForms() + public void Dispose() { - if (FrmRdp != null) - FrmRdp.Invoke((MethodInvoker)delegate { FrmRdp.Close(); }); - if (FrmTm != null) - FrmTm.Invoke((MethodInvoker)delegate { FrmTm.Close(); }); - if (FrmFm != null) - FrmFm.Invoke((MethodInvoker)delegate { FrmFm.Close(); }); - if (FrmSi != null) - FrmSi.Invoke((MethodInvoker)delegate { FrmSi.Close(); }); - if (FrmRs != null) - FrmRs.Invoke((MethodInvoker)delegate { FrmRs.Close(); }); - if (FrmStm != null) - FrmStm.Invoke((MethodInvoker)delegate { FrmStm.Close(); }); - if (FrmKl != null) - FrmKl.Invoke((MethodInvoker)delegate { FrmKl.Close(); }); - if (FrmProxy != null) - FrmProxy.Invoke((MethodInvoker)delegate { FrmProxy.Close(); }); + Dispose(true); + } + + protected virtual void Dispose(bool disposing) + { + if (disposing) + { + if (FrmRdp != null) + FrmRdp.Invoke((MethodInvoker)delegate { FrmRdp.Close(); }); + if (FrmTm != null) + FrmTm.Invoke((MethodInvoker)delegate { FrmTm.Close(); }); + if (FrmFm != null) + FrmFm.Invoke((MethodInvoker)delegate { FrmFm.Close(); }); + if (FrmSi != null) + FrmSi.Invoke((MethodInvoker)delegate { FrmSi.Close(); }); + if (FrmRs != null) + FrmRs.Invoke((MethodInvoker)delegate { FrmRs.Close(); }); + if (FrmStm != null) + FrmStm.Invoke((MethodInvoker)delegate { FrmStm.Close(); }); + if (FrmKl != null) + FrmKl.Invoke((MethodInvoker)delegate { FrmKl.Close(); }); + if (FrmProxy != null) + FrmProxy.Invoke((MethodInvoker)delegate { FrmProxy.Close(); }); + if (StreamCodec != null) + StreamCodec.Dispose(); + } } } } \ No newline at end of file diff --git a/Server/Core/Packets/ClientPackets/SetUserStatus.cs b/Server/Core/Packets/ClientPackets/SetUserStatus.cs index 3ad39f7d..1e345b59 100644 --- a/Server/Core/Packets/ClientPackets/SetUserStatus.cs +++ b/Server/Core/Packets/ClientPackets/SetUserStatus.cs @@ -1,6 +1,6 @@ using ProtoBuf; using xServer.Core.Networking; -using UserStatus = xServer.Core.Commands.CommandHandler.UserStatus; +using xServer.Enums; namespace xServer.Core.Packets.ClientPackets { diff --git a/Server/Core/Packets/ServerPackets/DoPathDelete.cs b/Server/Core/Packets/ServerPackets/DoPathDelete.cs index ea558502..9b38c0ce 100644 --- a/Server/Core/Packets/ServerPackets/DoPathDelete.cs +++ b/Server/Core/Packets/ServerPackets/DoPathDelete.cs @@ -1,6 +1,6 @@ using ProtoBuf; using xServer.Core.Networking; -using PathType = xServer.Core.Commands.CommandHandler.PathType; +using xServer.Enums; namespace xServer.Core.Packets.ServerPackets { diff --git a/Server/Core/Packets/ServerPackets/DoPathRename.cs b/Server/Core/Packets/ServerPackets/DoPathRename.cs index 7460e138..0eb22a60 100644 --- a/Server/Core/Packets/ServerPackets/DoPathRename.cs +++ b/Server/Core/Packets/ServerPackets/DoPathRename.cs @@ -1,6 +1,6 @@ using ProtoBuf; using xServer.Core.Networking; -using PathType = xServer.Core.Commands.CommandHandler.PathType; +using xServer.Enums; namespace xServer.Core.Packets.ServerPackets { diff --git a/Server/Core/Packets/ServerPackets/DoShutdownAction.cs b/Server/Core/Packets/ServerPackets/DoShutdownAction.cs index eb821a72..22edc951 100644 --- a/Server/Core/Packets/ServerPackets/DoShutdownAction.cs +++ b/Server/Core/Packets/ServerPackets/DoShutdownAction.cs @@ -1,6 +1,6 @@ using ProtoBuf; using xServer.Core.Networking; -using ShutdownAction = xServer.Core.Commands.CommandHandler.ShutdownAction; +using xServer.Enums; namespace xServer.Core.Packets.ServerPackets { diff --git a/Server/Core/Packets/ServerPackets/GetDesktop.cs b/Server/Core/Packets/ServerPackets/GetDesktop.cs index 83d0ebf2..aae06805 100644 --- a/Server/Core/Packets/ServerPackets/GetDesktop.cs +++ b/Server/Core/Packets/ServerPackets/GetDesktop.cs @@ -1,6 +1,6 @@ using ProtoBuf; using xServer.Core.Networking; -using RemoteDesktopAction = xServer.Core.Commands.CommandHandler.RemoteDesktopAction; +using xServer.Enums; namespace xServer.Core.Packets.ServerPackets { diff --git a/Server/Core/Helper/FileSplit.cs b/Server/Core/Utilities/FileSplit.cs similarity index 99% rename from Server/Core/Helper/FileSplit.cs rename to Server/Core/Utilities/FileSplit.cs index 6ef1ded8..c0ad20b4 100644 --- a/Server/Core/Helper/FileSplit.cs +++ b/Server/Core/Utilities/FileSplit.cs @@ -1,7 +1,7 @@ using System; using System.IO; -namespace xServer.Core.Helper +namespace xServer.Core.Utilities { public class FileSplit { diff --git a/Server/Core/Helper/FrameCounter.cs b/Server/Core/Utilities/FrameCounter.cs similarity index 96% rename from Server/Core/Helper/FrameCounter.cs rename to Server/Core/Utilities/FrameCounter.cs index 2ba01fad..541c5b45 100644 --- a/Server/Core/Helper/FrameCounter.cs +++ b/Server/Core/Utilities/FrameCounter.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Linq; -namespace xServer.Core.Helper +namespace xServer.Core.Utilities { public class FrameCounter { diff --git a/Server/Core/Misc/ListViewColumnSorter.cs b/Server/Core/Utilities/ListViewColumnSorter.cs similarity index 98% rename from Server/Core/Misc/ListViewColumnSorter.cs rename to Server/Core/Utilities/ListViewColumnSorter.cs index 35ee904f..0a8ff726 100644 --- a/Server/Core/Misc/ListViewColumnSorter.cs +++ b/Server/Core/Utilities/ListViewColumnSorter.cs @@ -1,7 +1,7 @@ using System.Collections; using System.Windows.Forms; -namespace xServer.Core.Misc +namespace xServer.Core.Utilities { public class ListViewColumnSorter : IComparer { diff --git a/Server/Core/Utilities/NativeMethods.cs b/Server/Core/Utilities/NativeMethods.cs new file mode 100644 index 00000000..d2eb059d --- /dev/null +++ b/Server/Core/Utilities/NativeMethods.cs @@ -0,0 +1,44 @@ +using System; +using System.Runtime.InteropServices; + +namespace xServer.Core.Utilities +{ + /// + /// Provides some methods from the "user32.dll" and uxtheme libraries. + /// + public static class NativeMethods + { + [DllImport("user32.dll", SetLastError = true)] + public static extern IntPtr SendMessage(IntPtr hWnd, uint msg, int wParam, int lParam); + + [DllImport("user32.dll", SetLastError = true)] + public static extern IntPtr SendMessage(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam); + + [DllImport("user32.dll", CharSet = CharSet.Unicode, SetLastError = true)] + public static extern IntPtr SendMessage(IntPtr hWnd, UInt32 msg, IntPtr wParam, string lParam); + + [DllImport("user32.dll", SetLastError = true)] + public static extern IntPtr LoadCursor(IntPtr hInstance, int lpCursorName); + + [DllImport("user32.dll", SetLastError = true)] + public static extern IntPtr SetCursor(IntPtr hCursor); + + [DllImport("user32.dll", SetLastError = true)] + public static extern IntPtr LoadImage(IntPtr hinst, string lpszName, uint uType, int cxDesired, int cyDesired, uint fuLoad); + + [DllImport("uxtheme.dll", CharSet = CharSet.Unicode, SetLastError = true)] + public extern static int SetWindowTheme(IntPtr hWnd, string pszSubAppName, string pszSubIdList); + + [DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern unsafe int memcmp(byte* ptr1, byte* ptr2, uint count); + + [DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int memcmp(IntPtr ptr1, IntPtr ptr2, uint count); + + [DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int memcpy(IntPtr dst, IntPtr src, uint count); + + [DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern unsafe int memcpy(void* dst, void* src, uint count); + } +} diff --git a/Server/Core/Misc/NoIpUpdater.cs b/Server/Core/Utilities/NoIpUpdater.cs similarity index 97% rename from Server/Core/Misc/NoIpUpdater.cs rename to Server/Core/Utilities/NoIpUpdater.cs index 2dc35d12..9f2a86bb 100644 --- a/Server/Core/Misc/NoIpUpdater.cs +++ b/Server/Core/Utilities/NoIpUpdater.cs @@ -4,7 +4,7 @@ using System.Text; using System.Threading; using xServer.Settings; -namespace xServer.Core.Misc +namespace xServer.Core.Utilities { public static class NoIpUpdater { diff --git a/Server/Core/Misc/RemoteDrive.cs b/Server/Core/Utilities/RemoteDrive.cs similarity index 90% rename from Server/Core/Misc/RemoteDrive.cs rename to Server/Core/Utilities/RemoteDrive.cs index 679c03b7..53d2f3c0 100644 --- a/Server/Core/Misc/RemoteDrive.cs +++ b/Server/Core/Utilities/RemoteDrive.cs @@ -1,4 +1,4 @@ -namespace xServer.Core.Misc +namespace xServer.Core.Utilities { public class RemoteDrive { diff --git a/Server/Core/Misc/SavedVariables.cs b/Server/Core/Utilities/SavedVariables.cs similarity index 96% rename from Server/Core/Misc/SavedVariables.cs rename to Server/Core/Utilities/SavedVariables.cs index ebb029f9..1abd93a4 100644 --- a/Server/Core/Misc/SavedVariables.cs +++ b/Server/Core/Utilities/SavedVariables.cs @@ -1,4 +1,4 @@ -namespace xServer.Core.Misc +namespace xServer.Core.Utilities { public static class Update { diff --git a/Server/Core/Helper/UnsafeStreamCodec.cs b/Server/Core/Utilities/UnsafeStreamCodec.cs similarity index 89% rename from Server/Core/Helper/UnsafeStreamCodec.cs rename to Server/Core/Utilities/UnsafeStreamCodec.cs index ce022e42..8c8f6155 100644 --- a/Server/Core/Helper/UnsafeStreamCodec.cs +++ b/Server/Core/Utilities/UnsafeStreamCodec.cs @@ -3,15 +3,14 @@ using System.Collections.Generic; using System.Drawing; using System.Drawing.Imaging; using System.IO; -using System.Runtime.InteropServices; using xServer.Core.Compression; -namespace xServer.Core.Helper +namespace xServer.Core.Utilities { public class UnsafeStreamCodec : IDisposable { - private int _imageQuality; - + public int Monitor { get; private set; } + public Size CheckBlock { get; private set; } public int ImageQuality { get { return _imageQuality; } @@ -31,7 +30,7 @@ namespace xServer.Core.Helper } } - public Size CheckBlock { get; private set; } + private int _imageQuality; private byte[] _encodeBuffer; private Bitmap _decodedBitmap; private PixelFormat _encodedFormat; @@ -40,24 +39,15 @@ namespace xServer.Core.Helper private readonly object _imageProcessLock = new object(); private JpgCompression _jpgCompression; - [DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)] - public static extern unsafe int memcmp(byte* ptr1, byte* ptr2, uint count); - - [DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)] - public static extern int memcmp(IntPtr ptr1, IntPtr ptr2, uint count); - - [DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)] - public static extern int memcpy(IntPtr dst, IntPtr src, uint count); - - [DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)] - public static extern unsafe int memcpy(void* dst, void* src, uint count); - /// - /// Initialize a new object of UnsafeStreamCodec + /// Initialize a new instance of UnsafeStreamCodec class. /// - /// The quality to use between 0-100 - public UnsafeStreamCodec(int imageQuality = 100) + /// The quality to use between 0-100. + /// The monitor used for the images. + public UnsafeStreamCodec(int imageQuality, int monitor) { + this.ImageQuality = imageQuality; + this.Monitor = monitor; this.CheckBlock = new Size(50, 1); } @@ -136,7 +126,7 @@ namespace xServer.Core.Helper outStream.Write(BitConverter.GetBytes(temp.Length), 0, 4); outStream.Write(temp, 0, temp.Length); - memcpy(new IntPtr(ptr), scan0, (uint) rawLength); + NativeMethods.memcpy(new IntPtr(ptr), scan0, (uint) rawLength); } return; } @@ -182,7 +172,7 @@ namespace xServer.Core.Helper int offset = (y*stride) + (scanArea.X*pixelSize); - if (memcmp(encBuffer + offset, pScan0 + offset, (uint) stride) != 0) + if (NativeMethods.memcmp(encBuffer + offset, pScan0 + offset, (uint)stride) != 0) { index = blocks.Count - 1; @@ -218,12 +208,12 @@ namespace xServer.Core.Helper { int blockOffset = (stride*(cBlock.Y + j)) + (pixelSize*cBlock.X); - if (memcmp(encBuffer + blockOffset, pScan0 + blockOffset, blockStride) != 0) + if (NativeMethods.memcmp(encBuffer + blockOffset, pScan0 + blockOffset, blockStride) != 0) { foundChanges = true; } - memcpy(encBuffer + blockOffset, pScan0 + blockOffset, blockStride); + NativeMethods.memcpy(encBuffer + blockOffset, pScan0 + blockOffset, blockStride); //copy-changes } @@ -266,7 +256,7 @@ namespace xServer.Core.Helper for (int j = 0, offset = 0; j < rect.Height; j++) { int blockOffset = (stride*(rect.Y + j)) + (pixelSize*rect.X); - memcpy((byte*) tmpData.Scan0.ToPointer() + offset, pScan0 + blockOffset, (uint) blockStride); + NativeMethods.memcpy((byte*)tmpData.Scan0.ToPointer() + offset, pScan0 + blockOffset, (uint)blockStride); //copy-changes offset += blockStride; } @@ -317,7 +307,7 @@ namespace xServer.Core.Helper fixed (byte* tempPtr = temp) { - memcpy(new IntPtr(tempPtr), new IntPtr(codecBuffer.ToInt32() + 4), (uint) dataSize); + NativeMethods.memcpy(new IntPtr(tempPtr), new IntPtr(codecBuffer.ToInt32() + 4), (uint)dataSize); } this._decodedBitmap = (Bitmap) Bitmap.FromStream(new MemoryStream(temp)); diff --git a/Server/Enums/PathType.cs b/Server/Enums/PathType.cs new file mode 100644 index 00000000..f21aa2f4 --- /dev/null +++ b/Server/Enums/PathType.cs @@ -0,0 +1,9 @@ +namespace xServer.Enums +{ + public enum PathType + { + File, + Directory, + Back + } +} diff --git a/Server/Enums/RemoteDesktopAction.cs b/Server/Enums/RemoteDesktopAction.cs new file mode 100644 index 00000000..78f0bf83 --- /dev/null +++ b/Server/Enums/RemoteDesktopAction.cs @@ -0,0 +1,8 @@ +namespace xServer.Enums +{ + public enum RemoteDesktopAction + { + Start, + Stop + } +} diff --git a/Server/Enums/ShutdownAction.cs b/Server/Enums/ShutdownAction.cs new file mode 100644 index 00000000..3923228a --- /dev/null +++ b/Server/Enums/ShutdownAction.cs @@ -0,0 +1,9 @@ +namespace xServer.Enums +{ + public enum ShutdownAction + { + Shutdown, + Restart, + Standby + } +} diff --git a/Server/Enums/UserStatus.cs b/Server/Enums/UserStatus.cs new file mode 100644 index 00000000..6232585d --- /dev/null +++ b/Server/Enums/UserStatus.cs @@ -0,0 +1,8 @@ +namespace xServer.Enums +{ + public enum UserStatus + { + Idle, + Active + } +} diff --git a/Server/Forms/FrmAddToAutostart.cs b/Server/Forms/FrmAddToAutostart.cs index f8947866..9702a5f2 100644 --- a/Server/Forms/FrmAddToAutostart.cs +++ b/Server/Forms/FrmAddToAutostart.cs @@ -2,7 +2,7 @@ using System.IO; using System.Windows.Forms; using xServer.Core.Helper; -using xServer.Core.Misc; +using xServer.Core.Utilities; namespace xServer.Forms { @@ -53,13 +53,13 @@ namespace xServer.Forms private void txtName_KeyPress(object sender, KeyPressEventArgs e) { - e.Handled = ((e.KeyChar == '\\' || Helper.CheckPathForIllegalChars(e.KeyChar.ToString())) && + e.Handled = ((e.KeyChar == '\\' || FileHelper.CheckPathForIllegalChars(e.KeyChar.ToString())) && !char.IsControl(e.KeyChar)); } private void txtPath_KeyPress(object sender, KeyPressEventArgs e) { - e.Handled = ((e.KeyChar == '\\' || Helper.CheckPathForIllegalChars(e.KeyChar.ToString())) && + e.Handled = ((e.KeyChar == '\\' || FileHelper.CheckPathForIllegalChars(e.KeyChar.ToString())) && !char.IsControl(e.KeyChar)); } } diff --git a/Server/Forms/FrmBuilder.cs b/Server/Forms/FrmBuilder.cs index 064e0d64..5fbcd005 100644 --- a/Server/Forms/FrmBuilder.cs +++ b/Server/Forms/FrmBuilder.cs @@ -102,7 +102,7 @@ namespace xServer.Forms { txtPort.Text = XMLSettings.ListenPort.ToString(); txtPassword.Text = XMLSettings.Password; - txtMutex.Text = Helper.GetRandomName(32); + txtMutex.Text = FileHelper.GetRandomFilename(32); } UpdateControlStates(); @@ -139,13 +139,13 @@ namespace xServer.Forms private void txtInstallname_KeyPress(object sender, KeyPressEventArgs e) { - e.Handled = ((e.KeyChar == '\\' || Helper.CheckPathForIllegalChars(e.KeyChar.ToString())) && + e.Handled = ((e.KeyChar == '\\' || FileHelper.CheckPathForIllegalChars(e.KeyChar.ToString())) && !char.IsControl(e.KeyChar)); } private void txtInstallsub_KeyPress(object sender, KeyPressEventArgs e) { - e.Handled = ((e.KeyChar == '\\' || Helper.CheckPathForIllegalChars(e.KeyChar.ToString())) && + e.Handled = ((e.KeyChar == '\\' || FileHelper.CheckPathForIllegalChars(e.KeyChar.ToString())) && !char.IsControl(e.KeyChar)); } @@ -153,7 +153,7 @@ namespace xServer.Forms { HasChanged(); - txtMutex.Text = Helper.GetRandomName(32); + txtMutex.Text = FileHelper.GetRandomFilename(32); } private void chkInstall_CheckedChanged(object sender, EventArgs e) diff --git a/Server/Forms/FrmDownloadAndExecute.cs b/Server/Forms/FrmDownloadAndExecute.cs index 71d45648..ba49552d 100644 --- a/Server/Forms/FrmDownloadAndExecute.cs +++ b/Server/Forms/FrmDownloadAndExecute.cs @@ -1,6 +1,7 @@ using System; using System.Windows.Forms; using xServer.Core.Helper; +using xServer.Core.Utilities; namespace xServer.Forms { @@ -16,8 +17,8 @@ namespace xServer.Forms private void btnDownloadAndExecute_Click(object sender, EventArgs e) { - Core.Misc.DownloadAndExecute.URL = txtURL.Text; - Core.Misc.DownloadAndExecute.RunHidden = chkRunHidden.Checked; + DownloadAndExecute.URL = txtURL.Text; + DownloadAndExecute.RunHidden = chkRunHidden.Checked; this.DialogResult = DialogResult.OK; this.Close(); @@ -25,9 +26,9 @@ namespace xServer.Forms private void FrmDownloadAndExecute_Load(object sender, EventArgs e) { - this.Text = Helper.GetWindowTitle("Download & Execute", _selectedClients); - txtURL.Text = Core.Misc.DownloadAndExecute.URL; - chkRunHidden.Checked = Core.Misc.DownloadAndExecute.RunHidden; + this.Text = WindowHelper.GetWindowTitle("Download & Execute", _selectedClients); + txtURL.Text = DownloadAndExecute.URL; + chkRunHidden.Checked = DownloadAndExecute.RunHidden; } } } \ No newline at end of file diff --git a/Server/Forms/FrmFileManager.Designer.cs b/Server/Forms/FrmFileManager.Designer.cs index 46aa9c92..61536111 100644 --- a/Server/Forms/FrmFileManager.Designer.cs +++ b/Server/Forms/FrmFileManager.Designer.cs @@ -52,7 +52,7 @@ namespace xServer.Forms this.imgListTransfers = new System.Windows.Forms.ImageList(this.components); this.TabControlFileManager = new xServer.Controls.DotNetBarTabControl(); this.tabFileExplorer = new System.Windows.Forms.TabPage(); - this.lstDirectory = new xServer.Controls.ListViewEx(); + this.lstDirectory = new xServer.Controls.AeroListView(); this.hName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.hSize = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.hType = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); @@ -60,7 +60,7 @@ namespace xServer.Forms this.cmbDrives = new System.Windows.Forms.ComboBox(); this.tabTransfers = new System.Windows.Forms.TabPage(); this.btnOpenDLFolder = new System.Windows.Forms.Button(); - this.lstTransfers = new xServer.Controls.ListViewEx(); + this.lstTransfers = new xServer.Controls.AeroListView(); this.hID = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.hStatus = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.hFilename = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); @@ -426,8 +426,8 @@ namespace xServer.Forms private System.Windows.Forms.ToolStripMenuItem ctxtCancel; private System.Windows.Forms.ToolStripMenuItem ctxtOpenDirectory; private System.Windows.Forms.ComboBox cmbDrives; - private ListViewEx lstDirectory; - private ListViewEx lstTransfers; + private AeroListView lstDirectory; + private AeroListView lstTransfers; private System.Windows.Forms.StatusStrip botStrip; private System.Windows.Forms.ToolStripMenuItem ctxtRemove; private System.Windows.Forms.ToolStripStatusLabel stripLblHint; diff --git a/Server/Forms/FrmFileManager.cs b/Server/Forms/FrmFileManager.cs index b6329c3d..6ec28618 100644 --- a/Server/Forms/FrmFileManager.cs +++ b/Server/Forms/FrmFileManager.cs @@ -5,12 +5,12 @@ using System.IO; using System.Linq; using System.Threading; using System.Windows.Forms; +using xServer.Controls; using xServer.Core.Commands; -using xServer.Core.Extensions; using xServer.Core.Helper; -using xServer.Core.Misc; using xServer.Core.Networking; -using PathType = xServer.Core.Commands.CommandHandler.PathType; +using xServer.Core.Utilities; +using xServer.Enums; namespace xServer.Forms { @@ -29,11 +29,6 @@ namespace xServer.Forms _lvwColumnSorter = new ListViewColumnSorter(); lstDirectory.ListViewItemSorter = _lvwColumnSorter; - - lstDirectory.RemoveDots(); - lstDirectory.ChangeTheme(); - lstTransfers.RemoveDots(); - lstTransfers.ChangeTheme(); } private string GetAbsolutePath(string item) @@ -45,7 +40,7 @@ namespace xServer.Forms { if (_connectClient != null) { - this.Text = Helper.GetWindowTitle("File Manager", _connectClient); + this.Text = WindowHelper.GetWindowTitle("File Manager", _connectClient); new Core.Packets.ServerPackets.GetDrives().Execute(_connectClient); } } @@ -105,7 +100,7 @@ namespace xServer.Forms { string path = GetAbsolutePath(files.SubItems[0].Text); - int id = Helper.GetNewTransferId(files.Index); + int id = FileHelper.GetNewTransferId(files.Index); if (_connectClient != null) { @@ -301,7 +296,7 @@ namespace xServer.Forms string path = filePath; new Thread(() => { - int id = Helper.GetNewTransferId(); + int id = FileHelper.GetNewTransferId(); if (string.IsNullOrEmpty(path)) return; diff --git a/Server/Forms/FrmKeylogger.cs b/Server/Forms/FrmKeylogger.cs index 7f8bf4a3..8d9edcac 100644 --- a/Server/Forms/FrmKeylogger.cs +++ b/Server/Forms/FrmKeylogger.cs @@ -2,8 +2,8 @@ using System.IO; using System.Windows.Forms; using xServer.Core.Helper; -using xServer.Core.Misc; using xServer.Core.Networking; +using xServer.Core.Utilities; namespace xServer.Forms { @@ -28,7 +28,7 @@ namespace xServer.Forms { if (_connectClient != null) { - this.Text = Helper.GetWindowTitle("Keylogger", _connectClient); + this.Text = WindowHelper.GetWindowTitle("Keylogger", _connectClient); if (!Directory.Exists(_path)) { diff --git a/Server/Forms/FrmMain.Designer.cs b/Server/Forms/FrmMain.Designer.cs index c203272e..5baa14a2 100644 --- a/Server/Forms/FrmMain.Designer.cs +++ b/Server/Forms/FrmMain.Designer.cs @@ -65,10 +65,10 @@ namespace xServer.Forms this.botListen = new System.Windows.Forms.ToolStripStatusLabel(); this.imgFlags = new System.Windows.Forms.ImageList(this.components); this.nIcon = new System.Windows.Forms.NotifyIcon(this.components); - this.lstClients = new xServer.Controls.ListViewEx(); - this.hUserPC = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.lstClients = new xServer.Controls.AeroListView(); this.hIP = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.hSocket = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.hUserPC = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.hVersion = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.hStatus = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.hUserStatus = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); @@ -636,7 +636,6 @@ namespace xServer.Forms this.hAccountType}); this.lstClients.ContextMenuStrip = this.ctxtMenu; this.lstClients.FullRowSelect = true; - this.lstClients.GridLines = true; this.lstClients.Location = new System.Drawing.Point(0, 0); this.lstClients.Name = "lstClients"; this.lstClients.ShowItemToolTips = true; @@ -648,11 +647,6 @@ namespace xServer.Forms this.lstClients.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.lstClients_ColumnClick); this.lstClients.SelectedIndexChanged += new System.EventHandler(this.lstClients_SelectedIndexChanged); // - // hUserPC - // - this.hUserPC.Text = "User@PC"; - this.hUserPC.Width = 175; - // // hIP // this.hIP.Text = "IP Address"; @@ -662,6 +656,11 @@ namespace xServer.Forms // this.hSocket.Text = "Socket"; // + // hUserPC + // + this.hUserPC.Text = "User@PC"; + this.hUserPC.Width = 175; + // // hVersion // this.hVersion.Text = "Version"; @@ -812,7 +811,7 @@ namespace xServer.Forms private System.Windows.Forms.ToolStripMenuItem ctxtKeylogger; private System.Windows.Forms.ToolStripMenuItem ctxtReverseProxy; private System.Windows.Forms.ToolStripMenuItem ctxtRegistryEditor; - private ListViewEx lstClients; + private AeroListView lstClients; private System.Windows.Forms.NotifyIcon nIcon; private System.Windows.Forms.ColumnHeader hUserPC; } diff --git a/Server/Forms/FrmMain.cs b/Server/Forms/FrmMain.cs index de781260..3d5c2da9 100644 --- a/Server/Forms/FrmMain.cs +++ b/Server/Forms/FrmMain.cs @@ -5,14 +5,12 @@ using System.Linq; using System.Threading; using System.Windows.Forms; using xServer.Core.Commands; -using xServer.Core.Extensions; +using xServer.Enums; using xServer.Core.Helper; -using xServer.Core.Misc; using xServer.Core.Networking; using xServer.Core.Networking.Utilities; +using xServer.Core.Utilities; using xServer.Settings; -using UserStatus = xServer.Core.Commands.CommandHandler.UserStatus; -using ShutdownAction = xServer.Core.Commands.CommandHandler.ShutdownAction; namespace xServer.Forms { @@ -76,9 +74,6 @@ namespace xServer.Forms _lvwColumnSorter = new ListViewColumnSorter(); lstClients.ListViewItemSorter = _lvwColumnSorter; - - lstClients.RemoveDots(); - lstClients.ChangeTheme(); } public void UpdateWindowTitle() @@ -176,7 +171,7 @@ namespace xServer.Forms { if (client.Value != null) { - client.Value.DisposeForms(); + client.Value.Dispose(); client.Value = null; } @@ -400,11 +395,11 @@ namespace xServer.Forms { if (frm.ShowDialog() == DialogResult.OK) { - if (Core.Misc.Update.UseDownload) + if (Core.Utilities.Update.UseDownload) { foreach (Client c in GetSelectedClients()) { - new Core.Packets.ServerPackets.DoClientUpdate(0, Core.Misc.Update.DownloadURL, string.Empty, new byte[0x00], 0, 0).Execute(c); + new Core.Packets.ServerPackets.DoClientUpdate(0, Core.Utilities.Update.DownloadURL, string.Empty, new byte[0x00], 0, 0).Execute(c); } } else @@ -417,8 +412,8 @@ namespace xServer.Forms if (c == null) continue; if (error) continue; - FileSplit srcFile = new FileSplit(Core.Misc.Update.UploadPath); - var fileName = Helper.GetRandomFilename(8, ".exe"); + FileSplit srcFile = new FileSplit(Core.Utilities.Update.UploadPath); + var fileName = FileHelper.GetRandomFilename(8, ".exe"); if (srcFile.MaxBlocks < 0) { MessageBox.Show(string.Format("Error reading file: {0}", srcFile.LastError), @@ -427,7 +422,7 @@ namespace xServer.Forms break; } - int id = Helper.GetNewTransferId(); + int id = FileHelper.GetNewTransferId(); CommandHandler.HandleSetStatus(c, new Core.Packets.ClientPackets.SetStatus("Uploading file...")); @@ -669,7 +664,7 @@ namespace xServer.Forms break; } - int id = Helper.GetNewTransferId(); + int id = FileHelper.GetNewTransferId(); CommandHandler.HandleSetStatus(c, new Core.Packets.ClientPackets.SetStatus("Uploading file...")); diff --git a/Server/Forms/FrmMain.resx b/Server/Forms/FrmMain.resx index b67f30f2..7b479121 100644 --- a/Server/Forms/FrmMain.resx +++ b/Server/Forms/FrmMain.resx @@ -408,7 +408,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAADY - sQAAAk1TRnQBSQFMAgEB+AEAAYgBBwGIAQcBEAEAAQsBAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + sQAAAk1TRnQBSQFMAgEB+AEAAZgBBwGYAQcBEAEAAQsBAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo AwABQAMAAbUBAgIAAQEBAAEIBQABQAGtGAABgAIAAYADAAKAAQABgAMAAYABAAGAAQACgAIAA8ABAAHA AdwBwAEAAfABygGmAQABMwUAATMBAAEzAQABMwEAAjMCAAMWAQADHAEAAyIBAAMpAQADVQEAA00BAANC AQADOQEAAYABfAH/AQACUAH/AQABkwEAAdYBAAH/AewBzAEAAcYB1gHvAQAB1gLnAQABkAGpAa0CAAH/ diff --git a/Server/Forms/FrmRemoteDesktop.cs b/Server/Forms/FrmRemoteDesktop.cs index 0f6f9758..31ad1d4d 100644 --- a/Server/Forms/FrmRemoteDesktop.cs +++ b/Server/Forms/FrmRemoteDesktop.cs @@ -4,7 +4,8 @@ using System.Drawing; using System.Windows.Forms; using xServer.Core.Helper; using xServer.Core.Networking; -using RemoteDesktopAction = xServer.Core.Commands.CommandHandler.RemoteDesktopAction; +using xServer.Core.Utilities; +using xServer.Enums; namespace xServer.Forms { @@ -25,7 +26,7 @@ namespace xServer.Forms private void FrmRemoteDesktop_Load(object sender, EventArgs e) { - this.Text = Helper.GetWindowTitle("Remote Desktop", _connectClient); + this.Text = WindowHelper.GetWindowTitle("Remote Desktop", _connectClient); panelTop.Left = (this.Width/2) - (panelTop.Width/2); @@ -77,7 +78,7 @@ namespace xServer.Forms { this.Invoke((MethodInvoker)delegate { - this.Text = string.Format("{0} - FPS: {1}", Helper.GetWindowTitle("Remote Desktop", _connectClient), fps.ToString("0.00")); + this.Text = string.Format("{0} - FPS: {1}", WindowHelper.GetWindowTitle("Remote Desktop", _connectClient), fps.ToString("0.00")); }); } catch (InvalidOperationException) diff --git a/Server/Forms/FrmRemoteShell.cs b/Server/Forms/FrmRemoteShell.cs index f33cc5c6..d707c2db 100644 --- a/Server/Forms/FrmRemoteShell.cs +++ b/Server/Forms/FrmRemoteShell.cs @@ -31,7 +31,7 @@ namespace xServer.Forms this.DoubleBuffered = true; if (_connectClient != null) - this.Text = Helper.GetWindowTitle("Remote Shell", _connectClient); + this.Text = WindowHelper.GetWindowTitle("Remote Shell", _connectClient); } private void FrmRemoteShell_FormClosing(object sender, FormClosingEventArgs e) diff --git a/Server/Forms/FrmReverseProxy.Designer.cs b/Server/Forms/FrmReverseProxy.Designer.cs index 9080102c..0b3aaa92 100644 --- a/Server/Forms/FrmReverseProxy.Designer.cs +++ b/Server/Forms/FrmReverseProxy.Designer.cs @@ -37,7 +37,7 @@ namespace xServer.Forms this.nudServerPort = new System.Windows.Forms.NumericUpDown(); this.tabCtrl = new System.Windows.Forms.TabControl(); this.tabPage1 = new System.Windows.Forms.TabPage(); - this.LvConnections = new xServer.Controls.ListViewEx(); + this.LvConnections = new xServer.Controls.AeroListView(); this.columnHeader6 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.columnHeader7 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); @@ -270,7 +270,7 @@ namespace xServer.Forms private System.Windows.Forms.NumericUpDown nudServerPort; private System.Windows.Forms.TabControl tabCtrl; private System.Windows.Forms.TabPage tabPage1; - private ListViewEx LvConnections; + private AeroListView LvConnections; private System.Windows.Forms.ColumnHeader columnHeader1; private System.Windows.Forms.ColumnHeader columnHeader2; private System.Windows.Forms.ColumnHeader columnHeader3; diff --git a/Server/Forms/FrmReverseProxy.cs b/Server/Forms/FrmReverseProxy.cs index 4e81f22a..d3365cba 100644 --- a/Server/Forms/FrmReverseProxy.cs +++ b/Server/Forms/FrmReverseProxy.cs @@ -31,7 +31,7 @@ namespace xServer.Forms } else if (_clients.Length == 1) { - this.Text = Helper.GetWindowTitle("Reverse Proxy", _clients[0]); + this.Text = WindowHelper.GetWindowTitle("Reverse Proxy", _clients[0]); lblLoadBalance.Text = "The Load Balancer is not active, only 1 client is used, select multiple clients to activate the load balancer"; } } @@ -134,8 +134,8 @@ namespace xServer.Forms connection.Client.Value.Country, (connection.HostName.Length > 0) ? string.Format("{0} ({1})", connection.HostName, connection.TargetServer) : connection.TargetServer, connection.TargetPort.ToString(), - Helper.GetDataSize(connection.LengthReceived), - Helper.GetDataSize(connection.LengthSent), + FileHelper.GetDataSize(connection.LengthReceived), + FileHelper.GetDataSize(connection.LengthSent), connection.Type.ToString() }) { Tag = connection }; } diff --git a/Server/Forms/FrmSettings.cs b/Server/Forms/FrmSettings.cs index b9f97bff..6f3b7fe6 100644 --- a/Server/Forms/FrmSettings.cs +++ b/Server/Forms/FrmSettings.cs @@ -1,9 +1,9 @@ using System; using System.Globalization; using System.Windows.Forms; -using xServer.Core.Misc; using xServer.Core.Networking; using xServer.Core.Networking.Utilities; +using xServer.Core.Utilities; using xServer.Settings; namespace xServer.Forms diff --git a/Server/Forms/FrmShowMessagebox.cs b/Server/Forms/FrmShowMessagebox.cs index d17f8dd7..6c0a0e62 100644 --- a/Server/Forms/FrmShowMessagebox.cs +++ b/Server/Forms/FrmShowMessagebox.cs @@ -1,6 +1,7 @@ using System; using System.Windows.Forms; using xServer.Core.Helper; +using xServer.Core.Utilities; namespace xServer.Forms { @@ -17,7 +18,7 @@ namespace xServer.Forms private void FrmShowMessagebox_Load(object sender, EventArgs e) { - this.Text = Helper.GetWindowTitle("Show Messagebox", _selectedClients); + this.Text = WindowHelper.GetWindowTitle("Show Messagebox", _selectedClients); cmbMsgButtons.Items.AddRange(new string[] {"AbortRetryIgnore", "OK", "OKCancel", "RetryCancel", "YesNo", "YesNoCancel"}); @@ -37,10 +38,10 @@ namespace xServer.Forms private void btnSend_Click(object sender, EventArgs e) { - Core.Misc.MessageBoxData.Caption = txtCaption.Text; - Core.Misc.MessageBoxData.Text = txtText.Text; - Core.Misc.MessageBoxData.Button = GetMessageBoxButton(cmbMsgButtons.SelectedIndex); - Core.Misc.MessageBoxData.Icon = GetMessageBoxIcon(cmbMsgButtons.SelectedIndex); + MessageBoxData.Caption = txtCaption.Text; + MessageBoxData.Text = txtText.Text; + MessageBoxData.Button = GetMessageBoxButton(cmbMsgButtons.SelectedIndex); + MessageBoxData.Icon = GetMessageBoxIcon(cmbMsgButtons.SelectedIndex); this.DialogResult = DialogResult.OK; this.Close(); diff --git a/Server/Forms/FrmStartupManager.Designer.cs b/Server/Forms/FrmStartupManager.Designer.cs index 5f6442e2..ecd64134 100644 --- a/Server/Forms/FrmStartupManager.Designer.cs +++ b/Server/Forms/FrmStartupManager.Designer.cs @@ -33,7 +33,7 @@ this.ctxtMenu = new System.Windows.Forms.ContextMenuStrip(this.components); this.ctxtAddEntry = new System.Windows.Forms.ToolStripMenuItem(); this.ctxtRemoveEntry = new System.Windows.Forms.ToolStripMenuItem(); - this.lstStartupItems = new xServer.Controls.ListViewEx(); + this.lstStartupItems = new xServer.Controls.AeroListView(); this.hName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.hPath = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.ctxtMenu.SuspendLayout(); @@ -118,7 +118,7 @@ private System.Windows.Forms.ContextMenuStrip ctxtMenu; private System.Windows.Forms.ToolStripMenuItem ctxtAddEntry; private System.Windows.Forms.ToolStripMenuItem ctxtRemoveEntry; - private Controls.ListViewEx lstStartupItems; + private Controls.AeroListView lstStartupItems; } } \ No newline at end of file diff --git a/Server/Forms/FrmStartupManager.cs b/Server/Forms/FrmStartupManager.cs index 6e26554f..b2d571b8 100644 --- a/Server/Forms/FrmStartupManager.cs +++ b/Server/Forms/FrmStartupManager.cs @@ -2,8 +2,8 @@ using System.Linq; using System.Windows.Forms; using xServer.Core.Helper; -using xServer.Core.Misc; using xServer.Core.Networking; +using xServer.Core.Utilities; namespace xServer.Forms { @@ -26,7 +26,7 @@ namespace xServer.Forms { if (_connectClient != null) { - this.Text = Helper.GetWindowTitle("Startup Manager", _connectClient); + this.Text = WindowHelper.GetWindowTitle("Startup Manager", _connectClient); AddGroups(); new Core.Packets.ServerPackets.GetStartupItems().Execute(_connectClient); } diff --git a/Server/Forms/FrmStatistics.cs b/Server/Forms/FrmStatistics.cs index 3eba4c4b..e654c51b 100644 --- a/Server/Forms/FrmStatistics.cs +++ b/Server/Forms/FrmStatistics.cs @@ -49,11 +49,11 @@ namespace xServer.Forms e.Graphics.DrawLine(new Pen(new SolidBrush(Color.Green), 5), new Point(220, 130), new Point(250, 130)); e.Graphics.DrawString( - string.Format("{0} received ({1}%)", Helper.GetDataSize(_bytesReceived), _receivedPercent), + string.Format("{0} received ({1}%)", FileHelper.GetDataSize(_bytesReceived), _receivedPercent), this.Font, new SolidBrush(Color.Black), new Point(260, 123)); e.Graphics.DrawLine(new Pen(new SolidBrush(Color.Blue), 5), new Point(220, 160), new Point(250, 160)); - e.Graphics.DrawString(string.Format("{0} sent ({1}%)", Helper.GetDataSize(_bytesSent), _sentPercent), + e.Graphics.DrawString(string.Format("{0} sent ({1}%)", FileHelper.GetDataSize(_bytesSent), _sentPercent), this.Font, new SolidBrush(Color.Black), new Point(260, 153)); } diff --git a/Server/Forms/FrmSystemInformation.Designer.cs b/Server/Forms/FrmSystemInformation.Designer.cs index e4a6f553..68bb90b3 100644 --- a/Server/Forms/FrmSystemInformation.Designer.cs +++ b/Server/Forms/FrmSystemInformation.Designer.cs @@ -32,7 +32,7 @@ namespace xServer.Forms { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmSystemInformation)); - this.lstSystem = new xServer.Controls.ListViewEx(); + this.lstSystem = new xServer.Controls.AeroListView(); this.hComponent = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.hValue = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.ctxtMenu = new System.Windows.Forms.ContextMenuStrip(this.components); @@ -107,6 +107,6 @@ namespace xServer.Forms private System.Windows.Forms.ColumnHeader hValue; private System.Windows.Forms.ContextMenuStrip ctxtMenu; private System.Windows.Forms.ToolStripMenuItem ctxtCopy; - private ListViewEx lstSystem; + private AeroListView lstSystem; } } \ No newline at end of file diff --git a/Server/Forms/FrmSystemInformation.cs b/Server/Forms/FrmSystemInformation.cs index a52aa2d7..efe234d1 100644 --- a/Server/Forms/FrmSystemInformation.cs +++ b/Server/Forms/FrmSystemInformation.cs @@ -23,7 +23,7 @@ namespace xServer.Forms { if (_connectClient != null) { - this.Text = Helper.GetWindowTitle("System Information", _connectClient); + this.Text = WindowHelper.GetWindowTitle("System Information", _connectClient); new Core.Packets.ServerPackets.GetSystemInfo().Execute(_connectClient); if (_connectClient.Value != null) diff --git a/Server/Forms/FrmTaskManager.Designer.cs b/Server/Forms/FrmTaskManager.Designer.cs index b1381ee3..fa34412a 100644 --- a/Server/Forms/FrmTaskManager.Designer.cs +++ b/Server/Forms/FrmTaskManager.Designer.cs @@ -37,7 +37,7 @@ namespace xServer.Forms this.ctxtStartProcess = new System.Windows.Forms.ToolStripMenuItem(); this.ctxtLine = new System.Windows.Forms.ToolStripSeparator(); this.ctxtRefresh = new System.Windows.Forms.ToolStripMenuItem(); - this.lstTasks = new xServer.Controls.ListViewEx(); + this.lstTasks = new xServer.Controls.AeroListView(); this.hProcessname = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.hPID = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.hTitle = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); @@ -145,6 +145,6 @@ namespace xServer.Forms private System.Windows.Forms.ColumnHeader hPID; private System.Windows.Forms.ColumnHeader hTitle; private System.Windows.Forms.ToolStripSeparator ctxtLine; - private ListViewEx lstTasks; + private AeroListView lstTasks; } } \ No newline at end of file diff --git a/Server/Forms/FrmTaskManager.cs b/Server/Forms/FrmTaskManager.cs index 0d0ff168..ee456461 100644 --- a/Server/Forms/FrmTaskManager.cs +++ b/Server/Forms/FrmTaskManager.cs @@ -1,8 +1,9 @@ using System; using System.Windows.Forms; +using xServer.Controls; using xServer.Core.Helper; -using xServer.Core.Misc; using xServer.Core.Networking; +using xServer.Core.Utilities; namespace xServer.Forms { @@ -26,7 +27,7 @@ namespace xServer.Forms { if (_connectClient != null) { - this.Text = Helper.GetWindowTitle("Task Manager", _connectClient); + this.Text = WindowHelper.GetWindowTitle("Task Manager", _connectClient); new Core.Packets.ServerPackets.GetProcesses().Execute(_connectClient); } } diff --git a/Server/Forms/FrmUpdate.cs b/Server/Forms/FrmUpdate.cs index 3425f169..9ef83bdb 100644 --- a/Server/Forms/FrmUpdate.cs +++ b/Server/Forms/FrmUpdate.cs @@ -17,19 +17,19 @@ namespace xServer.Forms private void FrmUpdate_Load(object sender, EventArgs e) { - this.Text = Helper.GetWindowTitle("Update Clients", _selectedClients); - if (Core.Misc.Update.UseDownload) + this.Text = WindowHelper.GetWindowTitle("Update Clients", _selectedClients); + if (Core.Utilities.Update.UseDownload) radioURL.Checked = true; - txtPath.Text = File.Exists(Core.Misc.Update.UploadPath) ? Core.Misc.Update.UploadPath : string.Empty; - txtURL.Text = Core.Misc.Update.DownloadURL; + txtPath.Text = File.Exists(Core.Utilities.Update.UploadPath) ? Core.Utilities.Update.UploadPath : string.Empty; + txtURL.Text = Core.Utilities.Update.DownloadURL; btnUpdate.Text = "Update Client" + ((_selectedClients > 1) ? "s" : string.Empty); } private void btnUpdate_Click(object sender, EventArgs e) { - Core.Misc.Update.UseDownload = radioURL.Checked; - Core.Misc.Update.UploadPath = File.Exists(txtPath.Text) ? txtPath.Text : string.Empty; - Core.Misc.Update.DownloadURL = txtURL.Text; + Core.Utilities.Update.UseDownload = radioURL.Checked; + Core.Utilities.Update.UploadPath = File.Exists(txtPath.Text) ? txtPath.Text : string.Empty; + Core.Utilities.Update.DownloadURL = txtURL.Text; this.DialogResult = DialogResult.OK; this.Close(); diff --git a/Server/Forms/FrmUploadAndExecute.cs b/Server/Forms/FrmUploadAndExecute.cs index e5a120a4..9d60dda1 100644 --- a/Server/Forms/FrmUploadAndExecute.cs +++ b/Server/Forms/FrmUploadAndExecute.cs @@ -2,6 +2,7 @@ using System.IO; using System.Windows.Forms; using xServer.Core.Helper; +using xServer.Core.Utilities; namespace xServer.Forms { @@ -17,8 +18,8 @@ namespace xServer.Forms private void FrmUploadAndExecute_Load(object sender, EventArgs e) { - this.Text = Helper.GetWindowTitle("Upload & Execute", _selectedClients); - chkRunHidden.Checked = Core.Misc.UploadAndExecute.RunHidden; + this.Text = WindowHelper.GetWindowTitle("Upload & Execute", _selectedClients); + chkRunHidden.Checked = UploadAndExecute.RunHidden; } private void btnBrowse_Click(object sender, EventArgs e) @@ -36,8 +37,8 @@ namespace xServer.Forms private void btnUploadAndExecute_Click(object sender, EventArgs e) { - Core.Misc.UploadAndExecute.FilePath = File.Exists(txtPath.Text) ? txtPath.Text : string.Empty; - Core.Misc.UploadAndExecute.RunHidden = chkRunHidden.Checked; + UploadAndExecute.FilePath = File.Exists(txtPath.Text) ? txtPath.Text : string.Empty; + UploadAndExecute.RunHidden = chkRunHidden.Checked; this.DialogResult = DialogResult.OK; this.Close(); diff --git a/Server/Forms/FrmVisitWebsite.cs b/Server/Forms/FrmVisitWebsite.cs index b81032c2..2f2d2a70 100644 --- a/Server/Forms/FrmVisitWebsite.cs +++ b/Server/Forms/FrmVisitWebsite.cs @@ -1,6 +1,7 @@ using System; using System.Windows.Forms; using xServer.Core.Helper; +using xServer.Core.Utilities; namespace xServer.Forms { @@ -16,15 +17,15 @@ namespace xServer.Forms private void FrmVisitWebsite_Load(object sender, EventArgs e) { - this.Text = Helper.GetWindowTitle("Visit Website", _selectedClients); - txtURL.Text = Core.Misc.VisitWebsite.URL; - chkVisitHidden.Checked = Core.Misc.VisitWebsite.Hidden; + this.Text = WindowHelper.GetWindowTitle("Visit Website", _selectedClients); + txtURL.Text = VisitWebsite.URL; + chkVisitHidden.Checked = VisitWebsite.Hidden; } private void btnVisitWebsite_Click(object sender, EventArgs e) { - Core.Misc.VisitWebsite.URL = txtURL.Text; - Core.Misc.VisitWebsite.Hidden = chkVisitHidden.Checked; + VisitWebsite.URL = txtURL.Text; + VisitWebsite.Hidden = chkVisitHidden.Checked; this.DialogResult = DialogResult.OK; this.Close(); diff --git a/Server/Server.csproj b/Server/Server.csproj index 7db7135d..60cf38ff 100644 --- a/Server/Server.csproj +++ b/Server/Server.csproj @@ -72,8 +72,15 @@ Component - - + + + + + + + + + @@ -83,15 +90,15 @@ - - + + - + - + - - + + @@ -232,8 +239,11 @@ - + + + + Form