├── .gitattributes ├── .gitignore ├── DesktopSharing.suo ├── DesktopSharingStarter ├── App.config ├── DesktopSharingServiceMonitor.csproj ├── DesktopSharingServiceMonitor.csproj.user ├── Installer1.Designer.cs ├── Installer1.cs ├── Installer1.resx ├── Interactive.cs ├── Program.cs ├── Properties │ └── AssemblyInfo.cs ├── Service1.cs ├── Service1.designer.cs └── Toolkit.cs ├── DesktopSharing_Server.sln ├── DesktopSharing_Server.suo ├── DesktopSharing_Server.v12.suo ├── DesktopSharing_Server ├── App.config ├── AppIcon.ico ├── DesktopService_API.cs ├── DesktopSharing_Server.csproj ├── Desktop_Service.cs ├── Program.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ └── Resources.resx ├── ScreenCaptureService.cs └── privatekey.xml ├── DesktopSharing_Viewer.sln ├── DesktopSharing_Viewer.v12.suo ├── DesktopSharing_Viewer ├── App.config ├── Code │ ├── InputListener.cs │ ├── PictureBoxEx.cs │ ├── ViewPort.cs │ └── Viewer_Loop.cs ├── Connect.Designer.cs ├── Connect.cs ├── Connect.resx ├── DesktopSharing_Viewer.csproj ├── Form1.Designer.cs ├── Form1.cs ├── Form1.resx ├── Program.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings └── publickey.xml ├── Desktop_Sharing_Shared ├── Bitmap_Helper.cs ├── Compression │ └── Zip.cs ├── Desktop │ ├── DesktopHandle.cs │ ├── DesktopInfo.cs │ ├── PInvoke.cs │ └── StationHandle.cs ├── Desktop_Sharing_Shared.csproj ├── Keyboard │ └── PInvoke.cs ├── Message_Types.cs ├── Mouse │ ├── DeviceHandle.cs │ ├── IconHandle.cs │ ├── IconHandleInfo.cs │ ├── MouseCapture.cs │ └── PInvoke.cs ├── Properties │ └── AssemblyInfo.cs ├── Screen │ ├── BitmapHandle.cs │ ├── PInvoke.cs │ ├── Raw_Image.cs │ └── ScreenCapture.cs └── Utilities │ ├── Copy.cs │ └── Format_Bytes.cs ├── Key_Generator ├── App.config ├── Form1.Designer.cs ├── Form1.cs ├── Form1.resx ├── Key_Generator.csproj ├── Program.cs └── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── Pipes ├── Class2.cs ├── IDesktopService_API.cs ├── Pipes.csproj ├── Properties │ └── AssemblyInfo.cs └── Receiver.cs ├── README.md ├── SSLTcp ├── Message.cs ├── Properties │ └── AssemblyInfo.cs ├── SecureTcp.csproj ├── Secure_Stream.cs ├── Secure_Tcp_Client.cs ├── Secure_Tcp_Listener.cs ├── TCP_Server.cs └── Utilities.cs └── Server_System_Tray ├── App.config ├── Form1.Designer.cs ├── Form1.cs ├── Program.cs ├── Properties ├── AssemblyInfo.cs ├── Resources.Designer.cs ├── Resources.resx ├── Settings.Designer.cs └── Settings.settings └── Server_System_Tray.csproj /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | *obj/ 11 | *bin/ 12 | 13 | # Windows Installer files 14 | *.cab 15 | *.msi 16 | *.msm 17 | *.msp 18 | 19 | # ========================= 20 | # Operating System Files 21 | # ========================= 22 | 23 | # OSX 24 | # ========================= 25 | 26 | .DS_Store 27 | .AppleDouble 28 | .LSOverride 29 | 30 | # Icon must ends with two \r. 31 | Icon 32 | 33 | # Thumbnails 34 | ._* 35 | 36 | # Files that might appear on external disk 37 | .Spotlight-V100 38 | .Trashes 39 | -------------------------------------------------------------------------------- /DesktopSharing.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smasherprog/Desktop_Sharing/90c779732cfae271d3db3bd40c48df69d9fc42b6/DesktopSharing.suo -------------------------------------------------------------------------------- /DesktopSharingStarter/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /DesktopSharingStarter/DesktopSharingServiceMonitor.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {6E417B2C-F606-4193-9361-FCD1E11DF410} 8 | Exe 9 | Properties 10 | DesktopSharingServiceMonitor 11 | DesktopSharingServiceMonitor 12 | v3.5 13 | 512 14 | 15 | publish\ 16 | true 17 | Disk 18 | false 19 | Foreground 20 | 7 21 | Days 22 | false 23 | false 24 | true 25 | 0 26 | 1.0.0.%2a 27 | false 28 | false 29 | true 30 | 31 | 32 | AnyCPU 33 | true 34 | full 35 | false 36 | bin\Debug\ 37 | DEBUG;TRACE 38 | prompt 39 | 4 40 | 41 | 42 | AnyCPU 43 | pdbonly 44 | true 45 | bin\Release\ 46 | TRACE 47 | prompt 48 | 4 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | Component 64 | 65 | 66 | Installer1.cs 67 | 68 | 69 | 70 | 71 | 72 | Component 73 | 74 | 75 | Service1.cs 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | {f1b0f688-0745-4f46-b06d-30392c625444} 85 | DesktopSharing_Server 86 | 87 | 88 | 89 | 90 | False 91 | .NET Framework 3.5 SP1 Client Profile 92 | false 93 | 94 | 95 | False 96 | .NET Framework 3.5 SP1 97 | true 98 | 99 | 100 | 101 | 102 | Installer1.cs 103 | 104 | 105 | 106 | 113 | -------------------------------------------------------------------------------- /DesktopSharingStarter/DesktopSharingServiceMonitor.csproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | publish\ 5 | 6 | 7 | 8 | 9 | 10 | en-US 11 | false 12 | 13 | -------------------------------------------------------------------------------- /DesktopSharingStarter/Installer1.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace DesktopSharing_Server 2 | { 3 | partial class Installer1 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if(disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Component Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.serviceProcessInstaller1 = new System.ServiceProcess.ServiceProcessInstaller(); 32 | this.serviceInstaller1 = new System.ServiceProcess.ServiceInstaller(); 33 | // 34 | // serviceProcessInstaller1 35 | // 36 | this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem; 37 | this.serviceProcessInstaller1.Password = null; 38 | this.serviceProcessInstaller1.Username = null; 39 | // 40 | // serviceInstaller1 41 | // 42 | this.serviceInstaller1.Description = "Nothing to note here.. really"; 43 | this.serviceInstaller1.DisplayName = "DesktopSharing"; 44 | this.serviceInstaller1.ServiceName = "ScottsService"; 45 | this.serviceInstaller1.ServicesDependedOn = new string[] { 46 | "SENS", 47 | "COMSysApp"}; 48 | this.serviceInstaller1.AfterInstall += new System.Configuration.Install.InstallEventHandler(this.serviceInstaller1_AfterInstall); 49 | // 50 | // Installer1 51 | // 52 | this.Installers.AddRange(new System.Configuration.Install.Installer[] { 53 | this.serviceProcessInstaller1, 54 | this.serviceInstaller1}); 55 | 56 | } 57 | 58 | #endregion 59 | 60 | private System.ServiceProcess.ServiceProcessInstaller serviceProcessInstaller1; 61 | private System.ServiceProcess.ServiceInstaller serviceInstaller1; 62 | } 63 | } -------------------------------------------------------------------------------- /DesktopSharingStarter/Installer1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.ComponentModel; 5 | using System.Configuration.Install; 6 | using System.Diagnostics; 7 | using System.Linq; 8 | using System.ServiceProcess; 9 | 10 | namespace DesktopSharing_Server 11 | { 12 | [RunInstaller(true)] 13 | public partial class Installer1 : System.Configuration.Install.Installer 14 | { 15 | public Installer1() 16 | { 17 | InitializeComponent(); 18 | } 19 | 20 | private void serviceInstaller1_AfterInstall(object sender, InstallEventArgs e) 21 | { 22 | ProcessStartInfo startInfo = new ProcessStartInfo(); 23 | startInfo.WindowStyle = ProcessWindowStyle.Hidden; 24 | startInfo.FileName = "cmd.exe"; 25 | startInfo.Arguments = "/C sc start " + this.serviceInstaller1.ServiceName; 26 | 27 | Process process = new Process(); 28 | process.StartInfo = startInfo; 29 | process.Start(); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /DesktopSharingStarter/Interactive.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | using System.Reflection; 5 | using System.ServiceProcess; 6 | using System.Text; 7 | using System.Threading; 8 | 9 | namespace WindowsService 10 | { 11 | public static class Interactive 12 | { 13 | static public void Run(ServiceBase[] servicesToRun) 14 | { 15 | Console.WriteLine("Services running in interactive mode."); 16 | Console.WriteLine(); 17 | 18 | MethodInfo onStartMethod = typeof(ServiceBase).GetMethod("OnStart", 19 | BindingFlags.Instance | BindingFlags.NonPublic); 20 | foreach(ServiceBase service in servicesToRun) 21 | { 22 | Console.WriteLine("Starting {0}...", service.ServiceName); 23 | onStartMethod.Invoke(service, new object[] { new string[] { } }); 24 | Console.WriteLine("Started"); 25 | } 26 | 27 | Console.WriteLine("Press any Key To stop the services . . "); 28 | Console.ReadKey(); 29 | 30 | MethodInfo onStopMethod = typeof(ServiceBase).GetMethod("OnStop", BindingFlags.Instance | BindingFlags.NonPublic); 31 | foreach(ServiceBase service in servicesToRun) 32 | { 33 | Console.WriteLine("Stopping {0}...", service.ServiceName); 34 | onStopMethod.Invoke(service, null); 35 | Console.WriteLine("Stopped"); 36 | } 37 | 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /DesktopSharingStarter/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration.Install; 4 | using System.Linq; 5 | using System.Reflection; 6 | using System.ServiceProcess; 7 | using System.Text; 8 | 9 | 10 | namespace DesktopSharingStarter 11 | { 12 | class Program 13 | { 14 | static void Main(string[] args) 15 | { 16 | var ServicesToRun = new List(); 17 | ServicesToRun.Add(new Client_Service.Service1()); 18 | 19 | var par = string.Concat(args); 20 | 21 | //if started by a user 22 | if(Environment.UserInteractive) 23 | { 24 | #if DEBUG 25 | //if in debug mode, run the services as a non service application 26 | WindowsService.Interactive.Run(ServicesToRun.ToArray()); 27 | #else 28 | //otherwise, install the application 29 | 30 | switch(par) 31 | { 32 | case "--install": 33 | ManagedInstallerClass.InstallHelper(new string[] { Assembly.GetExecutingAssembly().Location }); 34 | break; 35 | case "--uninstall": 36 | ManagedInstallerClass.InstallHelper(new string[] { "/u", Assembly.GetExecutingAssembly().Location }); 37 | break; 38 | default: 39 | Console.Error.WriteLine("Insvalid Paramters!"); 40 | break; 41 | } 42 | #endif 43 | 44 | } else 45 | { 46 | 47 | ServiceBase.Run(ServicesToRun.ToArray()); 48 | } 49 | 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /DesktopSharingStarter/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("DesktopSharingServiceMonitor")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("DesktopSharingServiceMonitor")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("c7fe92cb-3600-4014-bef8-89f50b4efd96")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /DesktopSharingStarter/Service1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Diagnostics; 6 | using System.IO; 7 | using System.Reflection; 8 | using System.Security.Principal; 9 | using System.ServiceProcess; 10 | using System.Text; 11 | 12 | namespace Client_Service 13 | { 14 | public partial class Service1 : ServiceBase 15 | { 16 | public Service1() 17 | { 18 | InitializeComponent(); 19 | } 20 | protected override void OnStart(string[] args) 21 | { 22 | DesktopSharingServiceMonitor.Toolkit.ApplicationLoader.PROCESS_INFORMATION proc; 23 | DesktopSharingServiceMonitor.Toolkit.ApplicationLoader.StartProcessAndBypassUAC(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location)+"\\DesktopSharing_Server.exe", out proc); 24 | } 25 | 26 | protected override void OnStop() 27 | { 28 | using(var f = System.IO.File.CreateText(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "\\log2.txt")) 29 | { 30 | var processes = Process.GetProcesses(); 31 | // set break point here 32 | foreach(Process process in processes) 33 | { 34 | f.WriteLine(process.ProcessName); 35 | } 36 | processes = Process.GetProcessesByName("DesktopSharing_Server"); 37 | // set break point here 38 | foreach(Process process in processes) 39 | { 40 | process.Kill(); 41 | } 42 | } 43 | } 44 | protected override void OnSessionChange(SessionChangeDescription changeDescription) 45 | { 46 | 47 | switch(changeDescription.Reason) 48 | { 49 | case SessionChangeReason.SessionLogon: 50 | Debug.WriteLine(changeDescription.SessionId + " logon"); 51 | break; 52 | case SessionChangeReason.SessionLogoff: 53 | Debug.WriteLine(changeDescription.SessionId + " logoff"); 54 | break; 55 | case SessionChangeReason.SessionLock: 56 | Debug.WriteLine(changeDescription.SessionId + " lock"); 57 | break; 58 | case SessionChangeReason.SessionUnlock: 59 | Debug.WriteLine(changeDescription.SessionId + " unlock"); 60 | break; 61 | } 62 | Debug.WriteLine(GetUserName(changeDescription.SessionId)); 63 | base.OnSessionChange(changeDescription); 64 | } 65 | public static WindowsIdentity GetUserName(int sessionId) 66 | { 67 | foreach(Process p in Process.GetProcesses()) 68 | { 69 | if(p.SessionId == sessionId) 70 | { 71 | return new WindowsIdentity(p.Handle); 72 | } 73 | } 74 | return null; 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /DesktopSharingStarter/Service1.designer.cs: -------------------------------------------------------------------------------- 1 | namespace Client_Service 2 | { 3 | partial class Service1 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if(disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | 21 | base.Dispose(disposing); 22 | } 23 | 24 | #region Component Designer generated code 25 | 26 | /// 27 | /// Required method for Designer support - do not modify 28 | /// the contents of this method with the code editor. 29 | /// 30 | private void InitializeComponent() 31 | { 32 | components = new System.ComponentModel.Container(); 33 | this.ServiceName = "Service1"; 34 | } 35 | 36 | #endregion 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /DesktopSharing_Server.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 12.00 2 | # Visual Studio 2013 3 | VisualStudioVersion = 12.0.30723.0 4 | MinimumVisualStudioVersion = 10.0.40219.1 5 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DesktopSharing_Server", "DesktopSharing_Server\DesktopSharing_Server.csproj", "{F1B0F688-0745-4F46-B06D-30392C625444}" 6 | EndProject 7 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DesktopSharingServiceMonitor", "DesktopSharingStarter\DesktopSharingServiceMonitor.csproj", "{6E417B2C-F606-4193-9361-FCD1E11DF410}" 8 | EndProject 9 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecureTcp", "SSLTcp\SecureTcp.csproj", "{A16D46D3-C103-4C9B-84DA-17DCFD29F9E6}" 10 | EndProject 11 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Key_Generator", "Key_Generator\Key_Generator.csproj", "{CD1B3B4A-F4F8-4728-A0E9-EADD1BC7A977}" 12 | EndProject 13 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pipes", "Pipes\Pipes.csproj", "{982892A9-3967-44D3-8EED-88C30ABE2EF1}" 14 | EndProject 15 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Server_System_Tray", "Server_System_Tray\Server_System_Tray.csproj", "{8BC9CFA1-EB3B-4C77-B4BB-C097A37B5C21}" 16 | EndProject 17 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Desktop_Sharing_Shared", "Desktop_Sharing_Shared\Desktop_Sharing_Shared.csproj", "{1B902504-63F4-4F38-9EC6-EAD8C94A228E}" 18 | EndProject 19 | Global 20 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 21 | Debug|Any CPU = Debug|Any CPU 22 | Release|Any CPU = Release|Any CPU 23 | EndGlobalSection 24 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 25 | {F1B0F688-0745-4F46-B06D-30392C625444}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 26 | {F1B0F688-0745-4F46-B06D-30392C625444}.Debug|Any CPU.Build.0 = Debug|Any CPU 27 | {F1B0F688-0745-4F46-B06D-30392C625444}.Release|Any CPU.ActiveCfg = Release|Any CPU 28 | {F1B0F688-0745-4F46-B06D-30392C625444}.Release|Any CPU.Build.0 = Release|Any CPU 29 | {6E417B2C-F606-4193-9361-FCD1E11DF410}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 30 | {6E417B2C-F606-4193-9361-FCD1E11DF410}.Debug|Any CPU.Build.0 = Debug|Any CPU 31 | {6E417B2C-F606-4193-9361-FCD1E11DF410}.Release|Any CPU.ActiveCfg = Release|Any CPU 32 | {6E417B2C-F606-4193-9361-FCD1E11DF410}.Release|Any CPU.Build.0 = Release|Any CPU 33 | {A16D46D3-C103-4C9B-84DA-17DCFD29F9E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 34 | {A16D46D3-C103-4C9B-84DA-17DCFD29F9E6}.Debug|Any CPU.Build.0 = Debug|Any CPU 35 | {A16D46D3-C103-4C9B-84DA-17DCFD29F9E6}.Release|Any CPU.ActiveCfg = Release|Any CPU 36 | {A16D46D3-C103-4C9B-84DA-17DCFD29F9E6}.Release|Any CPU.Build.0 = Release|Any CPU 37 | {CD1B3B4A-F4F8-4728-A0E9-EADD1BC7A977}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 38 | {CD1B3B4A-F4F8-4728-A0E9-EADD1BC7A977}.Debug|Any CPU.Build.0 = Debug|Any CPU 39 | {CD1B3B4A-F4F8-4728-A0E9-EADD1BC7A977}.Release|Any CPU.ActiveCfg = Release|Any CPU 40 | {CD1B3B4A-F4F8-4728-A0E9-EADD1BC7A977}.Release|Any CPU.Build.0 = Release|Any CPU 41 | {982892A9-3967-44D3-8EED-88C30ABE2EF1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 42 | {982892A9-3967-44D3-8EED-88C30ABE2EF1}.Debug|Any CPU.Build.0 = Debug|Any CPU 43 | {982892A9-3967-44D3-8EED-88C30ABE2EF1}.Release|Any CPU.ActiveCfg = Release|Any CPU 44 | {982892A9-3967-44D3-8EED-88C30ABE2EF1}.Release|Any CPU.Build.0 = Release|Any CPU 45 | {8BC9CFA1-EB3B-4C77-B4BB-C097A37B5C21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 46 | {8BC9CFA1-EB3B-4C77-B4BB-C097A37B5C21}.Debug|Any CPU.Build.0 = Debug|Any CPU 47 | {8BC9CFA1-EB3B-4C77-B4BB-C097A37B5C21}.Release|Any CPU.ActiveCfg = Release|Any CPU 48 | {8BC9CFA1-EB3B-4C77-B4BB-C097A37B5C21}.Release|Any CPU.Build.0 = Release|Any CPU 49 | {1B902504-63F4-4F38-9EC6-EAD8C94A228E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 50 | {1B902504-63F4-4F38-9EC6-EAD8C94A228E}.Debug|Any CPU.Build.0 = Debug|Any CPU 51 | {1B902504-63F4-4F38-9EC6-EAD8C94A228E}.Release|Any CPU.ActiveCfg = Release|Any CPU 52 | {1B902504-63F4-4F38-9EC6-EAD8C94A228E}.Release|Any CPU.Build.0 = Release|Any CPU 53 | EndGlobalSection 54 | GlobalSection(SolutionProperties) = preSolution 55 | HideSolutionNode = FALSE 56 | EndGlobalSection 57 | EndGlobal 58 | -------------------------------------------------------------------------------- /DesktopSharing_Server.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smasherprog/Desktop_Sharing/90c779732cfae271d3db3bd40c48df69d9fc42b6/DesktopSharing_Server.suo -------------------------------------------------------------------------------- /DesktopSharing_Server.v12.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smasherprog/Desktop_Sharing/90c779732cfae271d3db3bd40c48df69d9fc42b6/DesktopSharing_Server.v12.suo -------------------------------------------------------------------------------- /DesktopSharing_Server/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /DesktopSharing_Server/AppIcon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smasherprog/Desktop_Sharing/90c779732cfae271d3db3bd40c48df69d9fc42b6/DesktopSharing_Server/AppIcon.ico -------------------------------------------------------------------------------- /DesktopSharing_Server/DesktopService_API.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.ServiceModel; 5 | using System.Text; 6 | 7 | namespace Pipes 8 | { 9 | [ServiceBehavior 10 | (InstanceContextMode = InstanceContextMode.Single)] 11 | public class DesktopService_API : IDesktopService_API 12 | { 13 | public static string URI = "net.pipe://localhost/IDesktopService_API"; 14 | public string PipeIn(string data) 15 | { 16 | if(DataReady != null) 17 | return DataReady(data); 18 | return ""; 19 | } 20 | 21 | public delegate string DataIsReady(string hotData); 22 | public DataIsReady DataReady = null; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /DesktopSharing_Server/DesktopSharing_Server.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {F1B0F688-0745-4F46-B06D-30392C625444} 8 | WinExe 9 | Properties 10 | DesktopSharing_Server 11 | DesktopSharing_Server 12 | v3.5 13 | 512 14 | 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | true 26 | 27 | 28 | AnyCPU 29 | pdbonly 30 | true 31 | bin\Release\ 32 | TRACE 33 | prompt 34 | 4 35 | 36 | 37 | 38 | 39 | 40 | AppIcon.ico 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | True 60 | True 61 | Resources.resx 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | PreserveNewest 72 | 73 | 74 | 75 | 76 | ResXFileCodeGenerator 77 | Resources.Designer.cs 78 | 79 | 80 | 81 | 82 | {1b902504-63f4-4f38-9ec6-ead8c94a228e} 83 | Desktop_Sharing_Shared 84 | 85 | 86 | {982892a9-3967-44d3-8eed-88c30abe2ef1} 87 | Pipes 88 | 89 | 90 | {a16d46d3-c103-4c9b-84da-17dcfd29f9e6} 91 | SecureTcp 92 | 93 | 94 | 95 | 102 | -------------------------------------------------------------------------------- /DesktopSharing_Server/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace DesktopSharing_Server 7 | { 8 | class Program 9 | { 10 | static void Main(string[] args) 11 | { 12 | var p = new ScreenCaptureService(); 13 | p.OnStart(); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /DesktopSharing_Server/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("DesktopSharing_Server")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("DesktopSharing_Server")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("11998c86-03d6-46bd-9a7f-ae4920ea89b5")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /DesktopSharing_Server/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.18444 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace DesktopSharing_Server.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DesktopSharing_Server.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). 65 | /// 66 | internal static System.Drawing.Icon AppIcon { 67 | get { 68 | object obj = ResourceManager.GetObject("AppIcon", resourceCulture); 69 | return ((System.Drawing.Icon)(obj)); 70 | } 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /DesktopSharing_Server/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 122 | ..\AppIcon.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 123 | 124 | -------------------------------------------------------------------------------- /DesktopSharing_Server/privatekey.xml: -------------------------------------------------------------------------------- 1 | 3EtBB9hmISw7JgcZ0pPAlNLNUFX4cYORznKcVtvmjNOo6R/Y8oRP0gYIKFZq4OZXVTK9T6xJikKHWGogpGq1IDXasz+szMONbyhrzfZiHIliGTk7RM3CPaalWD1yKR+x72lCwVIXwxG8IY04R2wJr86rpVAoEoOTywaVSx+N1AWqiCOnfn0uFcY1qrH9ArfGZZKhOmd4jHTMeGLn38lh9oAunj30QYJmsMXBbxNNB+f9sDxD/6+epRfL/L/Q+QoJZ9s6HlK1Ndrr/penV+3pogn256sHXpV7g09wn1Qoe8HNowmvw6/wzP0fKDfe8NAozU7whbdckPORlx1pJKRPgCAgXSayPg/kK96GXFJSoD5Kdvnw+2BgxWAWzRn7yhuvN1F1BIEf6E9SgkkhATePYHTW8WSD79pa5gXD7+Byw868Ph0QpMU8awHQjPavxr4P+NqKKwVzWEC/wujA4X2omPGrtXUpJakCUiEGUPkLorGgWQy7p8bNTdELBdD3yrlXAQAB

81zFX1zQczYIriC4F2Xj75TtyPjYfK/H+moNw9uNQiLbL+CjPNjeUAw8r3Pe+pOEWIUwC/nX1yQhG79q3rvQdy20FCIgp0eMakLCvu65h10ofsC5grUvE7LgdMAdravDFAzm+lOtKh88C96DYZiNdr3hQ00yOZxZ74rkxKRjav0cSwyEnZqegB8X8BnooykYzOyytbcMlBy3JIec494DJ0/HdFjjQhmfnEzJmphAAcjnB/jlEaYLNC6jMQBRX3pV

57vQdQV/Ai5QnXZiFIc2w0tzSdZMMpLBHosQT3M7fp3Kliw9mbgHjnqE+3gOVz5H8muyIxVj3hvi7eVrr+x+5ATMKRQbIQYqf11qIgG5n/IA12FLVpMxi4TQuJxdypBFXO2+USb9R8UoonnzIZTAL0nS/I7kqWZxtjD3c5PxgWYc6MoGTkXTxKn1ssEXCApv1l6pcU0wjpnTiNfA8gHvop9DtUdveLqmBERM8fphOzRy54Pc6Otf/XJi2Wk9Tqj7FdSxo+9Yh61GNBCdUwQB4YETn56rFOxT3SPcXkB4uIEV9oKJQjEWKEogu4CCdSn8ilBQUhK0iQklqy6NsLNabQZ9i/zPvxHNB887VxNlMz5pHo29VntYYMUAG5kMUIMC+e56XeRZuViZ81qfoIal0gwQhBANvFtJOhLUmMtCW9ueySCzWMwBAe9IH3LDirdqER/+nAxypWq6Bx3fNhW5ZLJkawx6Pni797Jvt12HCGH0T6PFMMMbaC/y1bd4lT8NRKDxxoZfK/UteMTDnVLCHCpvNVHa9StTOEl1BiKZXxE6Gyl1AN5oloCge5z9mkbepePROOSv0+qsVUoZj1tZ5Quqrwu+URRzZ47xzKp4H+9a4m51Emm7RZeK/PGKMWByumfKclw6rJOuShgVsj9Mf3S8oIFtJOIrEQsFbdxFrM3iB+s03N9/LQIsusjGmmIE5xbX1a9HjyPtatyCzulV3/KM6dYDJF0ap67Wnt9JBnCtCvWZaf2zSusibULmnjIbpBihPoPMNaTbRtbilJlu3NaHKhzz82qhLjDMu0bkcg8ToYNYpjLUoXrLYMW+3BrbAqBCxokl444tQrtx6EgxeYin49KMy5e+2kmh9UvV5TqY9IOvxyWfq7fBXMxJuaVUFViAQIfZoJ7M6gDhe31Njyd/WqZ+K+v1ODDcp7tBpKza1drEtSdVryqxNHr9toKRaLlsPu+iFNwxOErypt+ZkM7xgL4wZct44w9Mc3fiqYv2BG0udPIjE+kR3xf/3xRryX2PaoSUzUyugRbHmKKJ59Vz80He7ryflUuhEZUqp65E9Y2qmg9JDtlzhqmcMj6crJGvM/tqfCpjrwvK9XegWWjIs2DPRa6rY3t+NzFfBajm8Bk3y7PDMS6GV1JEY7bYwhjt9PKIR2SmRa3sRu9bYNFQj/Dj5iMw/+bykHa4+69/DexGm9wVVdcoaQtJVr4OmgLmswvG5/lAt/AHE9oXXyZY/WW/TlfeY1tNlLH7p/qaQCKvM2NHYMuGSZSMp+xzgVzadcKK3uHVRiJ//Tp0C65mm/3OtfvRPFOG4wlbSSlCc89L2Pimv/vFgQAAbSNMK/Wpebtn6mutUjNxJ/wJib1K00vWndjQGqH6qG6ZvvxBuc+k7H41TLFwWg4zGy/MU+c9MYfl0jz1cP/UgVoSSljd/bHBxJg5L10pswLy4IE2pyRf1QB2oUUTiptulZI8PJasSP9uvMO/0AYMcKh8jW5it+Mhhy8zs9jqPiJKuOGN8am9fZ6xMQT+2Y/5RSs5
-------------------------------------------------------------------------------- /DesktopSharing_Viewer.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 12.00 2 | # Visual Studio 2013 3 | VisualStudioVersion = 12.0.30501.0 4 | MinimumVisualStudioVersion = 10.0.40219.1 5 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecureTcp", "SSLTcp\SecureTcp.csproj", "{A16D46D3-C103-4C9B-84DA-17DCFD29F9E6}" 6 | EndProject 7 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Key_Generator", "Key_Generator\Key_Generator.csproj", "{CD1B3B4A-F4F8-4728-A0E9-EADD1BC7A977}" 8 | EndProject 9 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pipes", "Pipes\Pipes.csproj", "{982892A9-3967-44D3-8EED-88C30ABE2EF1}" 10 | EndProject 11 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Server_System_Tray", "Server_System_Tray\Server_System_Tray.csproj", "{8BC9CFA1-EB3B-4C77-B4BB-C097A37B5C21}" 12 | EndProject 13 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DesktopSharing_Viewer", "DesktopSharing_Viewer\DesktopSharing_Viewer.csproj", "{C3C16211-85E0-4BF7-9DB0-5EA6CC1BA79C}" 14 | EndProject 15 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Desktop_Sharing_Shared", "Desktop_Sharing_Shared\Desktop_Sharing_Shared.csproj", "{1B902504-63F4-4F38-9EC6-EAD8C94A228E}" 16 | EndProject 17 | Global 18 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 19 | Debug|Any CPU = Debug|Any CPU 20 | Release|Any CPU = Release|Any CPU 21 | EndGlobalSection 22 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 23 | {A16D46D3-C103-4C9B-84DA-17DCFD29F9E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 24 | {A16D46D3-C103-4C9B-84DA-17DCFD29F9E6}.Debug|Any CPU.Build.0 = Debug|Any CPU 25 | {A16D46D3-C103-4C9B-84DA-17DCFD29F9E6}.Release|Any CPU.ActiveCfg = Release|Any CPU 26 | {A16D46D3-C103-4C9B-84DA-17DCFD29F9E6}.Release|Any CPU.Build.0 = Release|Any CPU 27 | {CD1B3B4A-F4F8-4728-A0E9-EADD1BC7A977}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 28 | {CD1B3B4A-F4F8-4728-A0E9-EADD1BC7A977}.Debug|Any CPU.Build.0 = Debug|Any CPU 29 | {CD1B3B4A-F4F8-4728-A0E9-EADD1BC7A977}.Release|Any CPU.ActiveCfg = Release|Any CPU 30 | {CD1B3B4A-F4F8-4728-A0E9-EADD1BC7A977}.Release|Any CPU.Build.0 = Release|Any CPU 31 | {982892A9-3967-44D3-8EED-88C30ABE2EF1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 32 | {982892A9-3967-44D3-8EED-88C30ABE2EF1}.Debug|Any CPU.Build.0 = Debug|Any CPU 33 | {982892A9-3967-44D3-8EED-88C30ABE2EF1}.Release|Any CPU.ActiveCfg = Release|Any CPU 34 | {982892A9-3967-44D3-8EED-88C30ABE2EF1}.Release|Any CPU.Build.0 = Release|Any CPU 35 | {8BC9CFA1-EB3B-4C77-B4BB-C097A37B5C21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 36 | {8BC9CFA1-EB3B-4C77-B4BB-C097A37B5C21}.Debug|Any CPU.Build.0 = Debug|Any CPU 37 | {8BC9CFA1-EB3B-4C77-B4BB-C097A37B5C21}.Release|Any CPU.ActiveCfg = Release|Any CPU 38 | {8BC9CFA1-EB3B-4C77-B4BB-C097A37B5C21}.Release|Any CPU.Build.0 = Release|Any CPU 39 | {C3C16211-85E0-4BF7-9DB0-5EA6CC1BA79C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 40 | {C3C16211-85E0-4BF7-9DB0-5EA6CC1BA79C}.Debug|Any CPU.Build.0 = Debug|Any CPU 41 | {C3C16211-85E0-4BF7-9DB0-5EA6CC1BA79C}.Release|Any CPU.ActiveCfg = Release|Any CPU 42 | {C3C16211-85E0-4BF7-9DB0-5EA6CC1BA79C}.Release|Any CPU.Build.0 = Release|Any CPU 43 | {1B902504-63F4-4F38-9EC6-EAD8C94A228E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 44 | {1B902504-63F4-4F38-9EC6-EAD8C94A228E}.Debug|Any CPU.Build.0 = Debug|Any CPU 45 | {1B902504-63F4-4F38-9EC6-EAD8C94A228E}.Release|Any CPU.ActiveCfg = Release|Any CPU 46 | {1B902504-63F4-4F38-9EC6-EAD8C94A228E}.Release|Any CPU.Build.0 = Release|Any CPU 47 | EndGlobalSection 48 | GlobalSection(SolutionProperties) = preSolution 49 | HideSolutionNode = FALSE 50 | EndGlobalSection 51 | EndGlobal 52 | -------------------------------------------------------------------------------- /DesktopSharing_Viewer.v12.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smasherprog/Desktop_Sharing/90c779732cfae271d3db3bd40c48df69d9fc42b6/DesktopSharing_Viewer.v12.suo -------------------------------------------------------------------------------- /DesktopSharing_Viewer/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /DesktopSharing_Viewer/Code/InputListener.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Drawing; 5 | using System.Linq; 6 | using System.Text; 7 | 8 | namespace DesktopSharing_Viewer.Code 9 | { 10 | public class InputListener : System.Windows.Forms.IMessageFilter 11 | { 12 | public event Desktop_Sharing_Shared.Mouse.PInvoke.MouseEventHandler InputMouseEvent; 13 | public event Desktop_Sharing_Shared.Keyboard.PInvoke.KeyEventHandler InputKeyEvent; 14 | private DateTime KeyboardSecondCounter = DateTime.Now; 15 | private DateTime MouseSecondCounter = DateTime.Now; 16 | 17 | private const int InputPerSec = 30; 18 | private List Keys_Down; 19 | private int _LastMsg, _LastX, _LastY, _Lastwheel; 20 | 21 | private IntPtr Handle; 22 | public InputListener(IntPtr handle) 23 | { 24 | Handle = handle; 25 | Keys_Down = new List(); 26 | _LastMsg = _LastX = _LastY = _Lastwheel = 0; 27 | } 28 | 29 | public bool PreFilterMessage(ref System.Windows.Forms.Message m) 30 | { 31 | if(Handle == m.HWnd) 32 | { 33 | if(m.Msg == Desktop_Sharing_Shared.Keyboard.PInvoke.WM_KEYDOWN || m.Msg == Desktop_Sharing_Shared.Keyboard.PInvoke.WM_KEYUP) 34 | { 35 | if(InputKeyEvent != null) 36 | { 37 | 38 | var temp = unchecked(IntPtr.Size == 8 ? (int)m.WParam.ToInt64() : (int)m.WParam.ToInt32()); 39 | 40 | if(m.Msg == Desktop_Sharing_Shared.Keyboard.PInvoke.WM_KEYDOWN) 41 | { 42 | //Debug.WriteLine("KeyDown"); 43 | if(Keys_Down.Contains(temp)) 44 | { 45 | if((DateTime.Now - KeyboardSecondCounter).TotalMilliseconds < InputPerSec) 46 | return false; 47 | else 48 | KeyboardSecondCounter = DateTime.Now; 49 | } else 50 | { 51 | Keys_Down.Add(temp); 52 | } 53 | } else 54 | { 55 | //Debug.WriteLine("KeyUP"); 56 | Keys_Down.Remove(temp);//else its an up, so remove it 57 | } 58 | InputKeyEvent(new Desktop_Sharing_Shared.Keyboard.KeyboardEventStruct 59 | { 60 | bVk = temp, 61 | s = m.Msg == Desktop_Sharing_Shared.Keyboard.PInvoke.WM_KEYDOWN ? Desktop_Sharing_Shared.Keyboard.PInvoke.PInvoke_KeyState.DOWN : Desktop_Sharing_Shared.Keyboard.PInvoke.PInvoke_KeyState.UP 62 | }); 63 | 64 | return true; 65 | } 66 | 67 | } 68 | if(InputMouseEvent != null && ((int[])Enum.GetValues(typeof(Desktop_Sharing_Shared.Mouse.PInvoke.WinFormMouseEventFlags))).Contains(m.Msg)) 69 | { 70 | if(m.Msg == Desktop_Sharing_Shared.Mouse.PInvoke.WM_MOUSEMOVE) 71 | { 72 | if((DateTime.Now - MouseSecondCounter).TotalMilliseconds < InputPerSec) 73 | return false; 74 | else 75 | MouseSecondCounter = DateTime.Now; 76 | } 77 | var p = GetPoint(m.LParam); 78 | var wheel = 0; 79 | if(m.Msg == Desktop_Sharing_Shared.Mouse.PInvoke.WM_MOUSEWHEEL) 80 | { 81 | uint xy = unchecked(IntPtr.Size == 8 ? (uint)m.WParam.ToInt64() : (uint)m.WParam.ToInt32()); 82 | wheel = unchecked((short)(xy >> 16)); 83 | } 84 | if(_LastMsg != m.Msg || p.X != _LastX || p.Y != _LastY || _Lastwheel != wheel) 85 | { 86 | InputMouseEvent(new Desktop_Sharing_Shared.Mouse.MouseEventStruct 87 | { 88 | msg = (Desktop_Sharing_Shared.Mouse.PInvoke.WinFormMouseEventFlags)m.Msg, 89 | x = p.X, 90 | y = p.Y, 91 | wheel_delta = wheel 92 | 93 | }); 94 | 95 | _LastMsg = m.Msg; 96 | p.X = _LastX; 97 | p.Y = _LastY; 98 | _Lastwheel = wheel; 99 | } 100 | 101 | } 102 | // Debug.WriteLine("Mouse Event"); 103 | } 104 | return false; 105 | } 106 | private int GetInt(IntPtr ptr) 107 | { 108 | return IntPtr.Size == 8 ? unchecked((int)ptr.ToInt64()) : ptr.ToInt32(); 109 | } 110 | private Point GetPoint(IntPtr _xy) 111 | { 112 | uint xy = unchecked(IntPtr.Size == 8 ? (uint)_xy.ToInt64() : (uint)_xy.ToInt32()); 113 | int x = unchecked((short)xy); 114 | int y = unchecked((short)(xy >> 16)); 115 | return new Point(x, y); 116 | } 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /DesktopSharing_Viewer/Code/PictureBoxEx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Drawing; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Windows.Forms; 8 | 9 | namespace DesktopSharing_Viewer.Code 10 | { 11 | public class PictureBoxEx : PictureBox 12 | { 13 | public Bitmap MouseImage = null; 14 | public Point MousePos; 15 | public PictureBoxEx() 16 | { 17 | this.SetStyle(ControlStyles.Selectable, true); 18 | MouseEnter += PictureBoxEx_MouseEnter; 19 | MouseLeave += PictureBoxEx_MouseLeave; 20 | Paint += PictureBoxEx_Paint; 21 | } 22 | 23 | void PictureBoxEx_Paint(object sender, PaintEventArgs e) 24 | { 25 | DrawMouse(e.Graphics); 26 | } 27 | 28 | void PictureBoxEx_MouseLeave(object sender, EventArgs e) 29 | { 30 | // Cursor.Show(); 31 | } 32 | 33 | void PictureBoxEx_MouseEnter(object sender, EventArgs e) 34 | { 35 | 36 | // Cursor.Hide(); 37 | } 38 | 39 | protected override void OnClick(EventArgs e) 40 | { 41 | this.Focus(); 42 | base.OnClick(e); 43 | } 44 | private void DrawMouse(Graphics g) 45 | { 46 | if(MouseImage != null && Image != null) 47 | { 48 | var dt = DateTime.Now; 49 | var mouserect = new Rectangle(MousePos.X, MousePos.Y, 32, 32); 50 | var imgrect = new Rectangle(0, 0, Image.Width, Image.Height); 51 | 52 | if(imgrect.Contains(new Point(MousePos.X, MousePos.Y))) 53 | { 54 | g.DrawImage(MouseImage, MousePos); 55 | } 56 | Debug.WriteLine("DrawMouse : " + (DateTime.Now - dt).TotalMilliseconds + "ms"); 57 | } 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /DesktopSharing_Viewer/Connect.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace DesktopSharing_Viewer 2 | { 3 | partial class Connect 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if(disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.textBox1 = new System.Windows.Forms.TextBox(); 32 | this.label1 = new System.Windows.Forms.Label(); 33 | this.button1 = new System.Windows.Forms.Button(); 34 | this.SuspendLayout(); 35 | // 36 | // textBox1 37 | // 38 | this.textBox1.Location = new System.Drawing.Point(85, 6); 39 | this.textBox1.Name = "textBox1"; 40 | this.textBox1.Size = new System.Drawing.Size(131, 20); 41 | this.textBox1.TabIndex = 0; 42 | this.textBox1.Text = "192.168.207.130"; 43 | // 44 | // label1 45 | // 46 | this.label1.AutoSize = true; 47 | this.label1.Location = new System.Drawing.Point(13, 12); 48 | this.label1.Name = "label1"; 49 | this.label1.Size = new System.Drawing.Size(66, 13); 50 | this.label1.TabIndex = 1; 51 | this.label1.Text = "Connect To:"; 52 | // 53 | // button1 54 | // 55 | this.button1.Location = new System.Drawing.Point(222, 6); 56 | this.button1.Name = "button1"; 57 | this.button1.Size = new System.Drawing.Size(75, 23); 58 | this.button1.TabIndex = 2; 59 | this.button1.Text = "Connect"; 60 | this.button1.UseVisualStyleBackColor = true; 61 | this.button1.Click += new System.EventHandler(this.button1_Click); 62 | // 63 | // Connect 64 | // 65 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 66 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 67 | this.ClientSize = new System.Drawing.Size(309, 41); 68 | this.Controls.Add(this.button1); 69 | this.Controls.Add(this.label1); 70 | this.Controls.Add(this.textBox1); 71 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; 72 | this.Name = "Connect"; 73 | this.Text = "Connect"; 74 | this.ResumeLayout(false); 75 | this.PerformLayout(); 76 | 77 | } 78 | 79 | #endregion 80 | 81 | private System.Windows.Forms.TextBox textBox1; 82 | private System.Windows.Forms.Label label1; 83 | private System.Windows.Forms.Button button1; 84 | } 85 | } -------------------------------------------------------------------------------- /DesktopSharing_Viewer/Connect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Net; 8 | using System.Text; 9 | using System.Windows.Forms; 10 | 11 | namespace DesktopSharing_Viewer 12 | { 13 | public partial class Connect : Form 14 | { 15 | public Connect() 16 | { 17 | InitializeComponent(); 18 | } 19 | 20 | private void button1_Click(object sender, EventArgs e) 21 | { 22 | string addrString = "192.168.0.1"; 23 | IPAddress address; 24 | if(IPAddress.TryParse(textBox1.Text, out address)) 25 | { 26 | addrString = address.ToString(); 27 | } else 28 | { 29 | IPAddress[] addresslist = Dns.GetHostAddresses(textBox1.Text); 30 | if(addresslist.Length > 0) 31 | addrString=addresslist[0].ToString(); 32 | else 33 | { 34 | MessageBox.Show("Address entered is invalid, please try again. You can enter a valid FQDN or an IPV4 Address."); 35 | return; 36 | } 37 | } 38 | var f = new DesktopSharing.Form1(addrString); 39 | f.Show(); 40 | this.Hide(); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /DesktopSharing_Viewer/Connect.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /DesktopSharing_Viewer/DesktopSharing_Viewer.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {C3C16211-85E0-4BF7-9DB0-5EA6CC1BA79C} 8 | WinExe 9 | Properties 10 | DesktopSharing_Viewer 11 | DesktopSharing_Viewer 12 | v3.5 13 | 512 14 | 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | true 26 | 27 | 28 | AnyCPU 29 | pdbonly 30 | true 31 | bin\Release\ 32 | TRACE 33 | prompt 34 | 4 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | Component 50 | 51 | 52 | 53 | 54 | Component 55 | 56 | 57 | Form 58 | 59 | 60 | Connect.cs 61 | 62 | 63 | Form 64 | 65 | 66 | Form1.cs 67 | 68 | 69 | 70 | 71 | Connect.cs 72 | 73 | 74 | Form1.cs 75 | 76 | 77 | ResXFileCodeGenerator 78 | Resources.Designer.cs 79 | Designer 80 | 81 | 82 | True 83 | Resources.resx 84 | True 85 | 86 | 87 | SettingsSingleFileGenerator 88 | Settings.Designer.cs 89 | 90 | 91 | True 92 | Settings.settings 93 | True 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | {1b902504-63f4-4f38-9ec6-ead8c94a228e} 102 | Desktop_Sharing_Shared 103 | 104 | 105 | {a16d46d3-c103-4c9b-84da-17dcfd29f9e6} 106 | SecureTcp 107 | 108 | 109 | 110 | 111 | PreserveNewest 112 | 113 | 114 | 115 | 122 | -------------------------------------------------------------------------------- /DesktopSharing_Viewer/Form1.Designer.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing; 2 | namespace DesktopSharing 3 | { 4 | partial class Form1 5 | { 6 | /// 7 | /// Required designer variable. 8 | /// 9 | private System.ComponentModel.IContainer components = null; 10 | 11 | /// 12 | /// Clean up any resources being used. 13 | /// 14 | /// true if managed resources should be disposed; otherwise, false. 15 | protected override void Dispose(bool disposing) 16 | { 17 | if(disposing && (components != null)) 18 | { 19 | components.Dispose(); 20 | } 21 | base.Dispose(disposing); 22 | } 23 | 24 | #region Windows Form Designer generated code 25 | 26 | /// 27 | /// Required method for Designer support - do not modify 28 | /// the contents of this method with the code editor. 29 | /// 30 | private void InitializeComponent() 31 | { 32 | this.statusStrip1 = new System.Windows.Forms.StatusStrip(); 33 | this.pictureBox1 = new DesktopSharing_Viewer.Code.ViewPort(); 34 | 35 | this.SuspendLayout(); 36 | // 37 | // statusStrip1 38 | // 39 | this.statusStrip1.Location = new System.Drawing.Point(0, 680); 40 | this.statusStrip1.Name = "statusStrip1"; 41 | this.statusStrip1.Size = new System.Drawing.Size(985, 22); 42 | this.statusStrip1.TabIndex = 1; 43 | this.statusStrip1.Text = "statusStrip1"; 44 | // 45 | // pictureBox1 46 | // 47 | this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 48 | | System.Windows.Forms.AnchorStyles.Left) 49 | | System.Windows.Forms.AnchorStyles.Right))); 50 | 51 | this.pictureBox1.Location = new System.Drawing.Point(0, 0); 52 | this.pictureBox1.Name = "pictureBox1"; 53 | this.pictureBox1.Size = new System.Drawing.Size(985, 677); 54 | this.pictureBox1.TabIndex = 0; 55 | this.pictureBox1.TabStop = false; 56 | // 57 | // Form1 58 | // 59 | this.AllowDrop = true; 60 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 61 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 62 | this.ClientSize = new System.Drawing.Size(985, 702); 63 | this.Controls.Add(this.statusStrip1); 64 | this.Controls.Add(this.pictureBox1); 65 | this.Name = "Form1"; 66 | this.Text = "Desktop Viewer"; 67 | 68 | this.ResumeLayout(false); 69 | this.PerformLayout(); 70 | 71 | } 72 | 73 | #endregion 74 | 75 | private DesktopSharing_Viewer.Code.ViewPort pictureBox1; 76 | private System.Windows.Forms.StatusStrip statusStrip1; 77 | 78 | } 79 | } 80 | 81 | -------------------------------------------------------------------------------- /DesktopSharing_Viewer/Form1.cs: -------------------------------------------------------------------------------- 1 | using DesktopSharing_Viewer.Code; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel; 5 | using System.Data; 6 | using System.Diagnostics; 7 | using System.Drawing; 8 | using System.IO; 9 | using System.Linq; 10 | using System.Net; 11 | using System.Net.Sockets; 12 | using System.Text; 13 | using System.Windows.Forms; 14 | 15 | namespace DesktopSharing 16 | { 17 | public partial class Form1 : Form 18 | { 19 | DesktopSharing_Viewer.Code.Viewer_Loop _Viewer_Loop; 20 | 21 | public Form1(string ipaddress) 22 | { 23 | InitializeComponent(); 24 | FormClosing += Form1_FormClosing; 25 | _Viewer_Loop = new DesktopSharing_Viewer.Code.Viewer_Loop(); 26 | _Viewer_Loop.UpdateImageEvent += Update_Image; 27 | _Viewer_Loop.NewImageEvent += New_Image; 28 | _Viewer_Loop.MouseImageChangedEvent += _Viewer_Loop_MouseUpdateEvent; 29 | _Viewer_Loop.MousePositionChangedEvent += _Viewer_Loop_MousePositionChangedEvent; 30 | var t = new InputListener(pictureBox1.Handle); 31 | t.InputMouseEvent += _Viewer_Loop.OnMouseEvent; 32 | t.InputKeyEvent += _Viewer_Loop.OnKeyEvent; 33 | 34 | Application.AddMessageFilter(t); 35 | this.DragDrop += new DragEventHandler(this.Form1_DragDrop); 36 | this.DragEnter += new DragEventHandler(this.Form1_DragEnter); 37 | 38 | _Viewer_Loop.IPtoConnect = ipaddress; 39 | _Viewer_Loop.Start(); 40 | } 41 | 42 | void _Viewer_Loop_MousePositionChangedEvent(Point tl) 43 | { 44 | 45 | pictureBox1.Mouse_Position = tl; 46 | 47 | 48 | pictureBox1.Invoke((MethodInvoker)delegate 49 | { 50 | try 51 | { 52 | pictureBox1.Invalidate(); 53 | } catch(Exception e) 54 | { 55 | Debug.WriteLine(e.Message); 56 | } 57 | }); 58 | 59 | } 60 | 61 | void _Viewer_Loop_MouseUpdateEvent(Point tl, byte[] data) 62 | { 63 | 64 | 65 | pictureBox1.Invoke((MethodInvoker)delegate 66 | { 67 | try 68 | { 69 | var dt = DateTime.Now; 70 | using(var ms = new MemoryStream(data)) 71 | { 72 | var b = (Bitmap)Bitmap.FromStream(ms); 73 | pictureBox1.Mouse_Image = b; 74 | pictureBox1.Mouse_Position = tl; 75 | } 76 | Debug.WriteLine("_Viewer_Loop_MouseUpdateEvent (1): " + (DateTime.Now - dt).TotalMilliseconds + "ms"); 77 | pictureBox1.Invalidate(); 78 | } catch(Exception e) 79 | { 80 | Debug.WriteLine(e.Message); 81 | } 82 | }); 83 | 84 | } 85 | 86 | 87 | 88 | private void Update_Image(Rectangle p, byte[] m) 89 | { 90 | 91 | pictureBox1.Invoke((MethodInvoker)delegate 92 | { 93 | try 94 | { 95 | var dt = new Stopwatch(); 96 | dt.Start(); 97 | pictureBox1.UpdateRegion(p, m); 98 | dt.Stop(); 99 | Debug.WriteLine("Update_Image (1): " + dt.ElapsedMilliseconds); 100 | pictureBox1.Invalidate(); 101 | } catch(Exception e) 102 | { 103 | Debug.WriteLine(e.Message); 104 | } 105 | }); 106 | 107 | } 108 | 109 | private void New_Image(Point sz, byte[] m) 110 | { 111 | pictureBox1.Invoke((MethodInvoker)delegate 112 | { 113 | try 114 | { 115 | var dt = DateTime.Now; 116 | pictureBox1.New_Image(sz, m); 117 | pictureBox1.Invalidate(); 118 | } catch(Exception e) 119 | { 120 | Debug.WriteLine(e.Message); 121 | } 122 | }); 123 | } 124 | 125 | 126 | private void Form1_DragEnter(object sender, DragEventArgs e) 127 | { 128 | // If the data is a file or a bitmap, display the copy cursor. 129 | if(e.Data.GetDataPresent(DataFormats.Bitmap) || 130 | e.Data.GetDataPresent(DataFormats.FileDrop)) 131 | { 132 | e.Effect = DragDropEffects.Copy; 133 | } else 134 | { 135 | e.Effect = DragDropEffects.None; 136 | } 137 | } 138 | 139 | void Form1_DragDrop(object sender, DragEventArgs e) 140 | { 141 | _Viewer_Loop.SendFiles((string[])e.Data.GetData(DataFormats.FileDrop)); 142 | } 143 | void Form1_FormClosing(object sender, FormClosingEventArgs e) 144 | { 145 | _Viewer_Loop.Stop(); 146 | Application.Exit(); 147 | } 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /DesktopSharing_Viewer/Form1.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 17 122 | 123 | -------------------------------------------------------------------------------- /DesktopSharing_Viewer/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Windows.Forms; 6 | 7 | namespace DesktopSharing 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// The main entry point for the application. 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | try 18 | { 19 | Application.EnableVisualStyles(); 20 | Application.SetCompatibleTextRenderingDefault(false); 21 | Application.Run(new DesktopSharing_Viewer.Connect()); 22 | } catch(Exception e) 23 | { 24 | Debug.WriteLine(e.Message); 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /DesktopSharing_Viewer/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("DesktopSharing_Viewer")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("DesktopSharing_Viewer")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("99192d3e-0ff2-483b-84d7-8bddd888b9d3")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /DesktopSharing_Viewer/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.18444 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace DesktopSharing_Viewer.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DesktopSharing_Viewer.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /DesktopSharing_Viewer/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /DesktopSharing_Viewer/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.18444 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace DesktopSharing_Viewer.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /DesktopSharing_Viewer/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /DesktopSharing_Viewer/publickey.xml: -------------------------------------------------------------------------------- 1 | 3EtBB9hmISw7JgcZ0pPAlNLNUFX4cYORznKcVtvmjNOo6R/Y8oRP0gYIKFZq4OZXVTK9T6xJikKHWGogpGq1IDXasz+szMONbyhrzfZiHIliGTk7RM3CPaalWD1yKR+x72lCwVIXwxG8IY04R2wJr86rpVAoEoOTywaVSx+N1AWqiCOnfn0uFcY1qrH9ArfGZZKhOmd4jHTMeGLn38lh9oAunj30QYJmsMXBbxNNB+f9sDxD/6+epRfL/L/Q+QoJZ9s6HlK1Ndrr/penV+3pogn256sHXpV7g09wn1Qoe8HNowmvw6/wzP0fKDfe8NAozU7whbdckPORlx1pJKRPgCAgXSayPg/kK96GXFJSoD5Kdvnw+2BgxWAWzRn7yhuvN1F1BIEf6E9SgkkhATePYHTW8WSD79pa5gXD7+Byw868Ph0QpMU8awHQjPavxr4P+NqKKwVzWEC/wujA4X2omPGrtXUpJakCUiEGUPkLorGgWQy7p8bNTdELBdD3yrlXAQAB -------------------------------------------------------------------------------- /Desktop_Sharing_Shared/Compression/Zip.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.IO; 6 | using System.IO.Packaging; 7 | using System.IO.Compression; 8 | using System.Diagnostics; 9 | 10 | namespace Desktop_Sharing_Shared.Compression 11 | { 12 | public static class GZip 13 | { 14 | public static byte[] Compress(byte[] raw) 15 | { 16 | using(MemoryStream memory = new MemoryStream()) 17 | { 18 | using(GZipStream gzip = new GZipStream(memory, CompressionMode.Compress, true)) 19 | { 20 | gzip.Write(raw, 0, raw.Length); 21 | } 22 | Debug.WriteLine("Compressed Before: " + raw.Length + " to: " + memory.Length); 23 | return memory.ToArray(); 24 | } 25 | } 26 | public static byte[] Decompress(byte[] gzip) 27 | { 28 | // Create a GZIP stream with decompression mode. 29 | // ... Then create a buffer and write into while reading from the GZIP stream. 30 | using(GZipStream stream = new GZipStream(new MemoryStream(gzip), CompressionMode.Decompress)) 31 | { 32 | const int size = 4096; 33 | byte[] buffer = new byte[size]; 34 | using(MemoryStream memory = new MemoryStream()) 35 | { 36 | int count = 0; 37 | do 38 | { 39 | count = stream.Read(buffer, 0, size); 40 | if(count > 0) 41 | { 42 | memory.Write(buffer, 0, count); 43 | } 44 | } 45 | while(count > 0); 46 | return memory.ToArray(); 47 | } 48 | } 49 | } 50 | 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Desktop_Sharing_Shared/Desktop/DesktopHandle.cs: -------------------------------------------------------------------------------- 1 | using Desktop_Sharing_Shared.Mouse; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | 8 | namespace Desktop_Sharing_Shared.Desktop 9 | { 10 | 11 | public class DesktopHandle : IDisposable 12 | { 13 | public IntPtr Handle { get; private set; } 14 | public DesktopHandle(IntPtr handle) 15 | { 16 | Handle = handle; 17 | } 18 | public bool IsInvalid 19 | { 20 | get { return Handle == IntPtr.Zero; } 21 | } 22 | 23 | public void Dispose() 24 | { 25 | Dispose(true); 26 | GC.SuppressFinalize(this); 27 | } 28 | 29 | protected virtual void Dispose(bool disposing) 30 | { 31 | if(disposing) 32 | { 33 | PInvoke.CloseDesktop(Handle); 34 | } 35 | } 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Desktop_Sharing_Shared/Desktop/PInvoke.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Diagnostics; 5 | using System.Linq; 6 | using System.Runtime.InteropServices; 7 | using System.Text; 8 | 9 | namespace Desktop_Sharing_Shared.Desktop 10 | { 11 | public enum Desktops 12 | { 13 | ScreenSaver, 14 | Winlogon, 15 | Default 16 | } 17 | [Flags] 18 | public enum ACCESS_MASK : uint 19 | { 20 | DELETE = 0x00010000, 21 | READ_CONTROL = 0x00020000, 22 | WRITE_DAC = 0x00040000, 23 | WRITE_OWNER = 0x00080000, 24 | SYNCHRONIZE = 0x00100000, 25 | 26 | STANDARD_RIGHTS_REQUIRED = 0x000F0000, 27 | 28 | STANDARD_RIGHTS_READ = 0x00020000, 29 | STANDARD_RIGHTS_WRITE = 0x00020000, 30 | STANDARD_RIGHTS_EXECUTE = 0x00020000, 31 | 32 | STANDARD_RIGHTS_ALL = 0x001F0000, 33 | 34 | SPECIFIC_RIGHTS_ALL = 0x0000FFFF, 35 | 36 | ACCESS_SYSTEM_SECURITY = 0x01000000, 37 | 38 | MAXIMUM_ALLOWED = 0x02000000, 39 | 40 | GENERIC_READ = 0x80000000, 41 | GENERIC_WRITE = 0x40000000, 42 | GENERIC_EXECUTE = 0x20000000, 43 | GENERIC_ALL = 0x10000000, 44 | 45 | DESKTOP_READOBJECTS = 0x00000001, 46 | DESKTOP_CREATEWINDOW = 0x00000002, 47 | DESKTOP_CREATEMENU = 0x00000004, 48 | DESKTOP_HOOKCONTROL = 0x00000008, 49 | DESKTOP_JOURNALRECORD = 0x00000010, 50 | DESKTOP_JOURNALPLAYBACK = 0x00000020, 51 | DESKTOP_ENUMERATE = 0x00000040, 52 | DESKTOP_WRITEOBJECTS = 0x00000080, 53 | DESKTOP_SWITCHDESKTOP = 0x00000100, 54 | 55 | WINSTA_ENUMDESKTOPS = 0x00000001, 56 | WINSTA_READATTRIBUTES = 0x00000002, 57 | WINSTA_ACCESSCLIPBOARD = 0x00000004, 58 | WINSTA_CREATEDESKTOP = 0x00000008, 59 | WINSTA_WRITEATTRIBUTES = 0x00000010, 60 | WINSTA_ACCESSGLOBALATOMS = 0x00000020, 61 | WINSTA_EXITWINDOWS = 0x00000040, 62 | WINSTA_ENUMERATE = 0x00000100, 63 | WINSTA_READSCREEN = 0x00000200, 64 | 65 | WINSTA_ALL_ACCESS = 0x0000037F 66 | } 67 | public static class PInvoke{ 68 | 69 | 70 | [DllImport("User32.dll", CharSet = CharSet.Unicode, SetLastError = true)] 71 | public static extern IntPtr GetProcessWindowStation(); 72 | 73 | [DllImport("User32.dll", CharSet = CharSet.Unicode, SetLastError = true)] 74 | public static extern IntPtr OpenWindowStation(string lpszWinSta, bool fInherit, ACCESS_MASK dwDesiredAccess); 75 | [DllImport("user32.dll", SetLastError = true)] 76 | public static extern bool SetProcessWindowStation(IntPtr hWinSta); 77 | [DllImport("user32.dll", SetLastError = true)] 78 | public static extern IntPtr OpenDesktop(string lpszDesktop, uint dwFlags, bool fInherit, ACCESS_MASK dwDesiredAccess); 79 | [DllImport("user32.dll", SetLastError = true)] 80 | public static extern bool SetThreadDesktop(IntPtr hDesktop); 81 | [DllImport("user32.dll", SetLastError = true)] 82 | public static extern bool CloseDesktop(IntPtr hDesktop); 83 | [DllImport("user32", CharSet = CharSet.Unicode, SetLastError = true)] 84 | public static extern bool CloseWindowStation(IntPtr hWinsta); 85 | [DllImport("user32", SetLastError = true)] 86 | [return: MarshalAs(UnmanagedType.Bool)] 87 | public static extern bool SwitchDesktop(IntPtr hDesktop); 88 | 89 | public const int UOI_FLAGS = 1; 90 | public const int UOI_NAME = 2; 91 | public const int UOI_TYPE = 3; 92 | public const int UOI_USER_SID = 4; 93 | public const int UOI_HEAPSIZE = 5; //Windows Server 2003 and Windows XP/2000: This value is not supported. 94 | public const int UOI_IO = 6; //Windows Server 2003 and Windows XP/2000: This value is not supported. 95 | 96 | 97 | 98 | [DllImport("user32.dll")] 99 | public static extern bool GetUserObjectInformation(IntPtr hObj, int nIndex, IntPtr pvInfo, int nLength, ref int lpnLengthNeeded); 100 | 101 | [DllImport("user32.dll", SetLastError = true)] 102 | public static extern IntPtr OpenInputDesktop(uint dwFlags, bool fInherit, ACCESS_MASK dwDesiredAccess); 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /Desktop_Sharing_Shared/Desktop/StationHandle.cs: -------------------------------------------------------------------------------- 1 | using Desktop_Sharing_Shared.Mouse; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | 8 | namespace Desktop_Sharing_Shared.Desktop 9 | { 10 | 11 | public class StationHandle : IDisposable 12 | { 13 | public IntPtr Handle { get; private set; } 14 | public StationHandle(IntPtr handle) 15 | { 16 | Handle = handle; 17 | } 18 | public bool IsInvalid 19 | { 20 | get { return Handle == IntPtr.Zero; } 21 | } 22 | public void Dispose() 23 | { 24 | Dispose(true); 25 | GC.SuppressFinalize(this); 26 | } 27 | 28 | protected virtual void Dispose(bool disposing) 29 | { 30 | if(disposing) 31 | { 32 | PInvoke.CloseWindowStation(Handle); 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Desktop_Sharing_Shared/Desktop_Sharing_Shared.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {1B902504-63F4-4F38-9EC6-EAD8C94A228E} 8 | Library 9 | Properties 10 | Desktop_Sharing_Shared 11 | Desktop_Sharing_Shared 12 | v3.5 13 | 512 14 | 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | true 25 | 26 | 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | true 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 76 | -------------------------------------------------------------------------------- /Desktop_Sharing_Shared/Keyboard/PInvoke.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.InteropServices; 5 | using System.Text; 6 | 7 | namespace Desktop_Sharing_Shared.Keyboard 8 | { 9 | public struct KeyboardEventStruct 10 | { 11 | public int bVk; 12 | public Desktop_Sharing_Shared.Keyboard.PInvoke.PInvoke_KeyState s; 13 | } 14 | public static class PInvoke 15 | { 16 | public const int WM_KEYDOWN = 0x100; 17 | public const int WM_KEYUP = 0x101; 18 | 19 | [DllImport("user32.dll", CharSet = CharSet.Auto)] 20 | private static extern int MapVirtualKey(int uCode, int uMapType); 21 | 22 | [DllImport("user32.dll")] 23 | private static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo); 24 | public enum PInvoke_KeyState : int 25 | { 26 | UP = 0x0002, 27 | DOWN = 0 28 | } 29 | 30 | public delegate void KeyEventHandler(KeyboardEventStruct k); 31 | public static void KeyEvent(KeyboardEventStruct k) 32 | { 33 | var scan = MapVirtualKey(k.bVk, 0); 34 | //Console.WriteLine("Received " + bVk + " in state " + s + " scan code is " + scan); 35 | keybd_event((byte)k.bVk, (byte)scan, (int)k.s, 0); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Desktop_Sharing_Shared/Message_Types.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Desktop_Sharing_Shared 7 | { 8 | public enum Message_Types 9 | { 10 | RESOLUTION_CHANGE, 11 | UPDATE_REGION, 12 | MOUSE_EVENT, 13 | PING, 14 | PING_ACK, 15 | KEY_EVENT, 16 | FOLDER, 17 | FILE, 18 | MOUSE_IMAGE_EVENT, 19 | MOUSE_POSITION_EVENT 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Desktop_Sharing_Shared/Mouse/DeviceHandle.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Drawing; 4 | using System.Linq; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | 8 | namespace Desktop_Sharing_Shared.Mouse 9 | { 10 | 11 | public class DeviceHandle : IDisposable 12 | { 13 | public IntPtr Handle { get; private set; } 14 | public DeviceHandle(IntPtr handle) 15 | { 16 | Handle = handle; 17 | } 18 | public static DeviceHandle CreateCompatibleDC(Graphics graphics) 19 | { 20 | if(graphics == null) 21 | throw new ArgumentNullException("graphics"); 22 | 23 | IntPtr source = graphics.GetHdc(); 24 | 25 | IntPtr handle = PInvoke.CreateCompatibleDC(source); 26 | DeviceHandle dc = new DeviceHandle(handle); 27 | 28 | graphics.ReleaseHdc(source); 29 | 30 | return dc; 31 | } 32 | public bool IsInvalid 33 | { 34 | get { return Handle == IntPtr.Zero; } 35 | } 36 | public void Dispose() 37 | { 38 | Dispose(true); 39 | GC.SuppressFinalize(this); 40 | } 41 | 42 | protected virtual void Dispose(bool disposing) 43 | { 44 | if(disposing) 45 | { 46 | PInvoke.DeleteDC(Handle); 47 | } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Desktop_Sharing_Shared/Mouse/IconHandle.cs: -------------------------------------------------------------------------------- 1 | using Desktop_Sharing_Shared.Mouse; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | 8 | namespace Desktop_Sharing_Shared 9 | { 10 | 11 | public class IconHandle : IDisposable 12 | { 13 | public IntPtr Handle { get; private set; } 14 | public IconHandle(IntPtr handle) 15 | { 16 | Handle = handle; 17 | } 18 | public static IconHandle GetCursorIcon(CURSORINFO cursor) 19 | { 20 | IntPtr hIcon = PInvoke.CopyIcon(cursor.hCursor); 21 | 22 | if(hIcon == IntPtr.Zero) 23 | return null; 24 | 25 | return new IconHandle(hIcon); 26 | } 27 | public bool IsInvalid 28 | { 29 | get { return Handle == IntPtr.Zero; } 30 | } 31 | public void Dispose() 32 | { 33 | Dispose(true); 34 | GC.SuppressFinalize(this); 35 | } 36 | 37 | protected virtual void Dispose(bool disposing) 38 | { 39 | if(disposing) 40 | { 41 | PInvoke.DestroyIcon(Handle); 42 | } 43 | } 44 | 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Desktop_Sharing_Shared/Mouse/IconHandleInfo.cs: -------------------------------------------------------------------------------- 1 | using Desktop_Sharing_Shared.Screen; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Drawing; 5 | using System.Linq; 6 | using System.Text; 7 | 8 | namespace Desktop_Sharing_Shared.Mouse 9 | { 10 | 11 | public class IconHandleInfo : IDisposable 12 | { 13 | public bool IsIcon { get; private set; } 14 | public Point Hotspot { get; private set; } 15 | public BitmapHandle MaskBitmap { get; private set; } 16 | public BitmapHandle ColorBitmap { get; private set; } 17 | 18 | internal IconHandleInfo(ICONINFO info) 19 | { 20 | this.IsIcon = info.fIcon; 21 | this.Hotspot = new Point(info.xHotspot, info.yHotspot); 22 | this.MaskBitmap = new BitmapHandle(info.hbmMask); 23 | this.ColorBitmap = new BitmapHandle(info.hbmColor); 24 | } 25 | 26 | public static IconHandleInfo GetIconInfo(IconHandle iconHandle) 27 | { 28 | if(iconHandle == null) 29 | return null; 30 | 31 | ICONINFO iconInfo; 32 | if(!PInvoke.GetIconInfo(iconHandle.Handle, out iconInfo)) 33 | return null; 34 | return new IconHandleInfo(iconInfo); 35 | } 36 | public void Dispose() 37 | { 38 | Dispose(true); 39 | GC.SuppressFinalize(this); 40 | } 41 | 42 | protected virtual void Dispose(bool disposing) 43 | { 44 | if(disposing) 45 | { 46 | // free managed resources 47 | MaskBitmap.Dispose(); 48 | ColorBitmap.Dispose(); 49 | } 50 | } 51 | 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Desktop_Sharing_Shared/Mouse/MouseCapture.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Drawing; 5 | using System.Drawing.Imaging; 6 | using System.IO; 7 | using System.Linq; 8 | using System.Runtime.InteropServices; 9 | using System.Text; 10 | 11 | namespace Desktop_Sharing_Shared.Mouse 12 | { 13 | 14 | public class MouseCapture : IDisposable 15 | { 16 | private DeviceHandle mask; 17 | private int cursorInfoSize; 18 | private IntPtr LastCursor = IntPtr.Zero;//dont need to dispose, just a copy of a pointer 19 | 20 | public delegate void MousePositionChangedHandler(Point tl); 21 | public event MousePositionChangedHandler MousePositionChangedEvent; 22 | 23 | public delegate void MouseImageChangedHandler(Point tl, byte[] data); 24 | public event MouseImageChangedHandler MouseImageChangedEvent; 25 | 26 | public MouseCapture() 27 | { 28 | IntPtr desk = PInvoke.GetDesktopWindow(); 29 | using(Graphics desktop = Graphics.FromHwnd(desk)) 30 | mask = DeviceHandle.CreateCompatibleDC(desktop); 31 | 32 | cursorInfoSize = Marshal.SizeOf(typeof(CURSORINFO)); 33 | 34 | } 35 | 36 | public void Update() 37 | { 38 | 39 | CURSORINFO cursorInfo; 40 | cursorInfo.cbSize = cursorInfoSize; 41 | 42 | if(!PInvoke.GetCursorInfo(out cursorInfo)) 43 | return; 44 | 45 | if(cursorInfo.flags != PInvoke.CURSOR_SHOWING)// same cursor as previous 46 | return; 47 | 48 | using(IconHandle hicon = IconHandle.GetCursorIcon(cursorInfo)) 49 | using(IconHandleInfo iconInfo = IconHandleInfo.GetIconInfo(hicon)) 50 | { 51 | if(iconInfo == null) 52 | return; 53 | var tmpx = _Position.X; 54 | var tmpy = _Position.Y; 55 | _Position.X = cursorInfo.ptScreenPos.x - iconInfo.Hotspot.X; 56 | _Position.Y = cursorInfo.ptScreenPos.y - iconInfo.Hotspot.Y; 57 | if(LastCursor == cursorInfo.hCursor) 58 | { 59 | if(MousePositionChangedEvent != null && tmpx != _Position.X && tmpy != _Position.Y) 60 | { 61 | MousePositionChangedEvent(_Position); 62 | } 63 | return;//no more work here, the cursor is the same 64 | } 65 | LastCursor = cursorInfo.hCursor;//just a copy 66 | Bitmap resultBitmap = null; 67 | 68 | using(Bitmap bitmapMask = Bitmap.FromHbitmap(iconInfo.MaskBitmap.Handle)) 69 | { 70 | // Here we have to determine if the current cursor is monochrome in order 71 | // to do a proper processing. If we just extracted the cursor icon from 72 | // the icon handle, monochrome cursors would appear garbled. 73 | 74 | if(bitmapMask.Height == bitmapMask.Width * 2) 75 | { 76 | // Yes, this is a monochrome cursor. We will have to manually copy 77 | // the bitmap and the bitmak layers of the cursor into the bitmap. 78 | 79 | resultBitmap = new Bitmap(bitmapMask.Width, bitmapMask.Width); 80 | PInvoke.SelectObject(mask.Handle, iconInfo.MaskBitmap.Handle); 81 | 82 | using(Graphics resultGraphics = Graphics.FromImage(resultBitmap)) 83 | { 84 | IntPtr resultHandle = resultGraphics.GetHdc(); 85 | 86 | // These two operation will result in a black cursor over a white background. Later 87 | // in the code, a call to MakeTransparent() will get rid of the white background. 88 | PInvoke.BitBlt(resultHandle, 0, 0, 32, 32, mask.Handle, 0, 32, CopyPixelOperation.SourceCopy); 89 | PInvoke.BitBlt(resultHandle, 0, 0, 32, 32, mask.Handle, 0, 0, CopyPixelOperation.SourceInvert); 90 | 91 | resultGraphics.ReleaseHdc(resultHandle); 92 | } 93 | 94 | // Remove the white background from the BitBlt calls, 95 | // resulting in a black cursor over a transparent background. 96 | resultBitmap.MakeTransparent(Color.White); 97 | } else 98 | { 99 | // This isn't a monochrome cursor. 100 | using(Icon icon = Icon.FromHandle(hicon.Handle)) 101 | resultBitmap = icon.ToBitmap(); 102 | } 103 | } 104 | _Cursor = resultBitmap; 105 | if(MouseImageChangedEvent != null) 106 | { 107 | using(var ms = new MemoryStream()) 108 | { 109 | _Cursor.Save(ms, ImageFormat.Png);//png to preserve the transparency 110 | MouseImageChangedEvent(_Position, ms.ToArray()); 111 | } 112 | } 113 | } 114 | } 115 | 116 | private Bitmap _Cursor = null; 117 | private Point _Position = new Point(); 118 | 119 | public void Draw(Graphics graphics) 120 | { 121 | if(graphics == null) 122 | throw new ArgumentNullException("graphics"); 123 | 124 | Bitmap cursor = _Cursor; 125 | 126 | if(cursor != null) 127 | graphics.DrawImage(cursor, _Position); 128 | } 129 | 130 | public void Dispose() 131 | { 132 | Dispose(true); 133 | GC.SuppressFinalize(this); 134 | } 135 | 136 | protected virtual void Dispose(bool disposing) 137 | { 138 | if(disposing) 139 | { 140 | // free managed resources 141 | mask.Dispose(); 142 | mask = null; 143 | } 144 | } 145 | private ImageCodecInfo GetEncoder(ImageFormat format) 146 | { 147 | 148 | ImageCodecInfo[] codecs = ImageCodecInfo.GetImageDecoders(); 149 | 150 | foreach(ImageCodecInfo codec in codecs) 151 | { 152 | if(codec.FormatID == format.Guid) 153 | { 154 | return codec; 155 | } 156 | } 157 | return null; 158 | } 159 | 160 | } 161 | } 162 | 163 | -------------------------------------------------------------------------------- /Desktop_Sharing_Shared/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Desktop_Sharing_Shared")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Desktop_Sharing_Shared")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("99d16d79-58fc-4a99-b889-e33f25479258")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Desktop_Sharing_Shared/Screen/BitmapHandle.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.InteropServices; 5 | using System.Text; 6 | 7 | namespace Desktop_Sharing_Shared.Screen 8 | { 9 | 10 | public class BitmapHandle : IDisposable 11 | { 12 | public IntPtr Handle { get; private set; } 13 | public BitmapHandle(IntPtr handle) 14 | { 15 | Handle = handle; 16 | } 17 | public bool IsInvalid 18 | { 19 | get { return Handle == IntPtr.Zero; } 20 | } 21 | public void Dispose() 22 | { 23 | Dispose(true); 24 | GC.SuppressFinalize(this); 25 | } 26 | 27 | protected virtual void Dispose(bool disposing) 28 | { 29 | if(disposing) 30 | { 31 | PInvoke.DeleteObject(Handle); 32 | } 33 | } 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Desktop_Sharing_Shared/Screen/PInvoke.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Drawing; 4 | using System.Linq; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | 8 | namespace Desktop_Sharing_Shared.Screen 9 | { 10 | public static class PInvoke 11 | { 12 | public enum DIB_Color_Mode : uint 13 | { 14 | DIB_RGB_COLORS = 0, 15 | DIB_PAL_COLORS = 1 16 | } 17 | public enum BitmapCompressionMode : uint 18 | { 19 | BI_RGB = 0, 20 | BI_RLE8 = 1, 21 | BI_RLE4 = 2, 22 | BI_BITFIELDS = 3, 23 | BI_JPEG = 4, 24 | BI_PNG = 5 25 | } 26 | [StructLayout(LayoutKind.Sequential)] 27 | public struct RGBQUAD 28 | { 29 | public byte rgbBlue; 30 | public byte rgbGreen; 31 | public byte rgbRed; 32 | public byte rgbReserved; 33 | } 34 | [StructLayout(LayoutKind.Sequential)] 35 | public struct BITMAPINFOHEADER 36 | { 37 | public uint biSize; 38 | public int biWidth; 39 | public int biHeight; 40 | public ushort biPlanes; 41 | public ushort biBitCount; 42 | public BitmapCompressionMode biCompression; 43 | public uint biSizeImage; 44 | public int biXPelsPerMeter; 45 | public int biYPelsPerMeter; 46 | public uint biClrUsed; 47 | public uint biClrImportant; 48 | } 49 | [StructLayoutAttribute(LayoutKind.Sequential)] 50 | public struct BITMAPINFO 51 | { 52 | /// 53 | /// A BITMAPINFOHEADER structure that contains information about the dimensions of color format. 54 | /// 55 | public BITMAPINFOHEADER bmiHeader; 56 | 57 | /// 58 | /// An array of RGBQUAD. The elements of the array that make up the color table. 59 | /// 60 | [MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 1, ArraySubType = UnmanagedType.Struct)] 61 | public RGBQUAD[] bmiColors; 62 | } 63 | // P/Invoke declarations 64 | [DllImport("gdi32.dll")] 65 | public static extern bool BitBlt(IntPtr hdcDest, int xDest, int yDest, int wDest, int hDest, IntPtr hdcSource, int xSrc, int ySrc, CopyPixelOperation rop); 66 | [DllImport("user32.dll")] 67 | public static extern bool ReleaseDC(IntPtr hWnd, IntPtr hDc); 68 | [DllImport("gdi32.dll")] 69 | public static extern IntPtr DeleteDC(IntPtr hDc); 70 | [DllImport("gdi32.dll")] 71 | public static extern IntPtr DeleteObject(IntPtr hDc); 72 | [DllImport("gdi32.dll")] 73 | public static extern IntPtr CreateCompatibleBitmap(IntPtr hdc, int nWidth, int nHeight); 74 | [DllImport("gdi32.dll")] 75 | public static extern IntPtr CreateCompatibleDC(IntPtr hdc); 76 | [DllImport("gdi32.dll")] 77 | public static extern IntPtr SelectObject(IntPtr hdc, IntPtr bmp); 78 | [DllImport("user32.dll")] 79 | public static extern IntPtr GetDesktopWindow(); 80 | [DllImport("user32.dll")] 81 | public static extern IntPtr GetWindowDC(IntPtr ptr); 82 | [DllImport("gdi32.dll", EntryPoint = "GetDIBits")] 83 | public static extern int GetDIBits([In] IntPtr hdc, [In] IntPtr hbmp, uint uStartScan, uint cScanLines, [Out] byte[] lpvBits, ref BITMAPINFO lpbi, DIB_Color_Mode uUsage); 84 | 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /Desktop_Sharing_Shared/Screen/Raw_Image.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Drawing; 4 | using System.Linq; 5 | using System.Text; 6 | 7 | namespace Desktop_Sharing_Shared.Screen 8 | { 9 | public class Raw_Image 10 | { 11 | public Rectangle Dimensions; 12 | public byte[] Data; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Desktop_Sharing_Shared/Screen/ScreenCapture.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Drawing; 4 | using System.Drawing.Imaging; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Runtime.InteropServices; 8 | using System.Text; 9 | 10 | namespace Desktop_Sharing_Shared.Screen 11 | { 12 | public class ScreenCapture : IDisposable 13 | { 14 | public ImageCodecInfo _jgpEncoder; 15 | public EncoderParameters _myEncoderParameters; 16 | IntPtr nDesk = IntPtr.Zero; 17 | IntPtr nSrce = IntPtr.Zero; 18 | IntPtr nDest = IntPtr.Zero; 19 | IntPtr nBmp = IntPtr.Zero; 20 | private Size PreviousSize = new Size(0, 0); 21 | 22 | public ScreenCapture(long jpgquality = 60L) 23 | { 24 | _jgpEncoder = GetEncoder(ImageFormat.Jpeg); 25 | var myEncoder = System.Drawing.Imaging.Encoder.Quality; 26 | var myEncoderParameter = new EncoderParameter(myEncoder, jpgquality); 27 | _myEncoderParameters = new EncoderParameters(1); 28 | _myEncoderParameters.Param[0] = myEncoderParameter; 29 | 30 | } 31 | public void Dispose() 32 | { 33 | if(nBmp != IntPtr.Zero) 34 | PInvoke.DeleteObject(nBmp); 35 | if(nDest != IntPtr.Zero) 36 | PInvoke.DeleteDC(nDest); 37 | PInvoke.ReleaseDC(nDesk, nSrce); 38 | nDesk = IntPtr.Zero; 39 | nSrce = IntPtr.Zero; 40 | nDest = IntPtr.Zero; 41 | nBmp = IntPtr.Zero; 42 | } 43 | public void ReleaseHandles() 44 | { 45 | Dispose(); 46 | } 47 | public Raw_Image GetScreen(Size sz) 48 | { 49 | IntPtr hOldBmp = IntPtr.Zero; 50 | Raw_Image raw = new Raw_Image(); 51 | try 52 | { 53 | var dt = DateTime.Now; 54 | 55 | if(nDesk == IntPtr.Zero) 56 | nDesk = PInvoke.GetDesktopWindow(); 57 | if(nSrce == IntPtr.Zero) 58 | nSrce = PInvoke.GetWindowDC(nDesk); 59 | if(nDest == IntPtr.Zero) 60 | nDest = PInvoke.CreateCompatibleDC(nSrce); 61 | if(nBmp == IntPtr.Zero) 62 | nBmp = PInvoke.CreateCompatibleBitmap(nSrce, sz.Width, sz.Height); 63 | else if(sz.Height != PreviousSize.Height || sz.Width != PreviousSize.Width) 64 | {// user changed resolution.. get new bitmap 65 | PInvoke.DeleteObject(nBmp); 66 | nBmp = PInvoke.CreateCompatibleBitmap(nSrce, sz.Width, sz.Height); 67 | } 68 | PreviousSize = sz; 69 | hOldBmp = PInvoke.SelectObject(nDest, nBmp); 70 | 71 | bool b = PInvoke.BitBlt(nDest, 0, 0, sz.Width, sz.Height, nSrce, 0, 0, CopyPixelOperation.SourceCopy | CopyPixelOperation.CaptureBlt); 72 | 73 | Desktop_Sharing_Shared.Screen.PInvoke.BITMAPINFO bi = new PInvoke.BITMAPINFO(); 74 | 75 | bi.bmiHeader.biSize = 40; 76 | bi.bmiHeader.biWidth = sz.Width; 77 | bi.bmiHeader.biHeight = -sz.Height; 78 | bi.bmiHeader.biPlanes = 1; 79 | bi.bmiHeader.biBitCount = 32; 80 | bi.bmiHeader.biCompression = Desktop_Sharing_Shared.Screen.PInvoke.BitmapCompressionMode.BI_RGB; 81 | bi.bmiHeader.biSizeImage = 0; 82 | bi.bmiHeader.biXPelsPerMeter = 0; 83 | bi.bmiHeader.biYPelsPerMeter = 0; 84 | bi.bmiHeader.biClrUsed = 0; 85 | bi.bmiHeader.biClrImportant = 0; 86 | var dwBmpSize = ((sz.Width * bi.bmiHeader.biBitCount + 31) / 32) * 4 * sz.Height; 87 | raw.Data = new byte[dwBmpSize]; 88 | raw.Dimensions = new Rectangle(0, 0, sz.Width, sz.Height); 89 | 90 | Desktop_Sharing_Shared.Screen.PInvoke.GetDIBits(nSrce, nBmp, 0, Convert.ToUInt32(sz.Height), raw.Data, ref bi, PInvoke.DIB_Color_Mode.DIB_RGB_COLORS); 91 | //unsafe 92 | //{ 93 | // fixed(byte* datb = raw.Data) 94 | // { 95 | // using(Bitmap image = new Bitmap(sz.Width, sz.Height, sz.Width * 4, 96 | // PixelFormat.Format32bppRgb, new IntPtr(datb))) 97 | // { 98 | 99 | // image.Save(@"C:\Users\scott\Desktop\text.png", ImageFormat.Png); 100 | // } 101 | // } 102 | //} 103 | //Bitmap bmp = Bitmap.FromHbitmap(nBmp); 104 | PInvoke.SelectObject(nDest, hOldBmp); 105 | 106 | // return bmp; 107 | } catch(Exception e) 108 | { 109 | System.Diagnostics.Debug.WriteLine(e.Message); 110 | } 111 | // return new Bitmap(sz.Width, sz.Height); 112 | return raw; 113 | } 114 | //Raw_Image WriteBitmapFile(string filename, int width, int height, byte[] imageData) 115 | //{ 116 | // var stride = width * 4; 117 | // unsafe 118 | // { 119 | // fixed(byte* ptr = imageData) 120 | // { 121 | // var p = ptr + stride * (height - 1); 122 | // using(Bitmap image = new Bitmap(width, height, -stride, PixelFormat.Format32bppRgb, new IntPtr(p))) 123 | // { 124 | // image.Save(filename); 125 | // } 126 | // } 127 | // } 128 | 129 | // return 1; 130 | //} 131 | 132 | private ImageCodecInfo GetEncoder(ImageFormat format) 133 | { 134 | 135 | ImageCodecInfo[] codecs = ImageCodecInfo.GetImageDecoders(); 136 | 137 | foreach(ImageCodecInfo codec in codecs) 138 | { 139 | if(codec.FormatID == format.Guid) 140 | { 141 | return codec; 142 | } 143 | } 144 | return null; 145 | } 146 | 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /Desktop_Sharing_Shared/Utilities/Copy.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.InteropServices; 5 | using System.Security; 6 | using System.Text; 7 | 8 | namespace Desktop_Sharing_Shared.Utilities 9 | { 10 | public static class PInvoke 11 | { 12 | [DllImport("msvcrt.dll", EntryPoint = "memcpy", CallingConvention = CallingConvention.Cdecl, SetLastError = false), SuppressUnmanagedCodeSecurity] 13 | public static unsafe extern void* CopyMemory(void* dest, void* src, ulong byte_count); 14 | public static unsafe void CustomCopy(void* dest, void* src, int count) 15 | { 16 | int block; 17 | 18 | block = count >> 3; 19 | 20 | long* pDest = (long*)dest; 21 | long* pSrc = (long*)src; 22 | 23 | for(int i = 0; i < block; i++) 24 | { 25 | var s = *pSrc; 26 | 27 | *pDest = s; 28 | pDest++; 29 | pSrc++; 30 | } 31 | dest = pDest; 32 | src = pSrc; 33 | count = count - (block << 3); 34 | 35 | if(count > 0) 36 | { 37 | byte* pDestB = (byte*)dest; 38 | byte* pSrcB = (byte*)src; 39 | for(int i = 0; i < count; i++) 40 | { 41 | *pDestB = *pSrcB; 42 | pDestB++; 43 | pSrcB++; 44 | } 45 | } 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Desktop_Sharing_Shared/Utilities/Format_Bytes.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Desktop_Sharing_Shared.Utilities 7 | { 8 | public class Format 9 | { 10 | public static string FormatBytes(long bytes) 11 | { 12 | const long scale = 1024; 13 | string[] orders = new string[] { "YB", "ZB", "EB", "PB", "TB", "GB", "MB", "KB", "Bytes" }; 14 | var max = (long)Math.Pow(scale, (orders.Length - 1)); 15 | foreach(string order in orders) 16 | { 17 | if(bytes > max) 18 | return string.Format("{0:##.##} {1}", Decimal.Divide(bytes, max), order); 19 | max /= scale; 20 | } 21 | return "0 Bytes"; 22 | } 23 | public static byte[] GetBytes(string str) 24 | { 25 | byte[] bytes = new byte[str.Length * sizeof(char)]; 26 | System.Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length); 27 | return bytes; 28 | } 29 | 30 | public static string GetString(byte[] bytes) 31 | { 32 | char[] chars = new char[bytes.Length / sizeof(char)]; 33 | System.Buffer.BlockCopy(bytes, 0, chars, 0, bytes.Length); 34 | return new string(chars); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Key_Generator/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Key_Generator/Form1.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace Key_Generator 2 | { 3 | partial class Form1 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if(disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.components = new System.ComponentModel.Container(); 32 | this.textBox1 = new System.Windows.Forms.TextBox(); 33 | this.button1 = new System.Windows.Forms.Button(); 34 | this.label1 = new System.Windows.Forms.Label(); 35 | this.comboBox1 = new System.Windows.Forms.ComboBox(); 36 | this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); 37 | this.button2 = new System.Windows.Forms.Button(); 38 | this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog(); 39 | this.SuspendLayout(); 40 | // 41 | // textBox1 42 | // 43 | this.textBox1.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.FileSystemDirectories; 44 | this.textBox1.Location = new System.Drawing.Point(75, 5); 45 | this.textBox1.Name = "textBox1"; 46 | this.textBox1.Size = new System.Drawing.Size(264, 20); 47 | this.textBox1.TabIndex = 0; 48 | // 49 | // button1 50 | // 51 | this.button1.Location = new System.Drawing.Point(510, 2); 52 | this.button1.Name = "button1"; 53 | this.button1.Size = new System.Drawing.Size(75, 23); 54 | this.button1.TabIndex = 2; 55 | this.button1.Text = "Generate"; 56 | this.button1.UseVisualStyleBackColor = true; 57 | this.button1.Click += new System.EventHandler(this.button1_Click); 58 | // 59 | // label1 60 | // 61 | this.label1.AutoSize = true; 62 | this.label1.Location = new System.Drawing.Point(12, 8); 63 | this.label1.Name = "label1"; 64 | this.label1.Size = new System.Drawing.Size(57, 13); 65 | this.label1.TabIndex = 3; 66 | this.label1.Text = "Save Path"; 67 | // 68 | // comboBox1 69 | // 70 | this.comboBox1.DisplayMember = "3072"; 71 | this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 72 | this.comboBox1.FormattingEnabled = true; 73 | this.comboBox1.Items.AddRange(new object[] { 74 | "3072", 75 | "7680", 76 | "15360"}); 77 | this.comboBox1.Location = new System.Drawing.Point(427, 3); 78 | this.comboBox1.Name = "comboBox1"; 79 | this.comboBox1.Size = new System.Drawing.Size(77, 21); 80 | this.comboBox1.TabIndex = 4; 81 | this.toolTip1.SetToolTip(this.comboBox1, "3072 is equal to 128 bit strength\r\n7680 is equal to 192 bit strength\r\n15360 is eq" + 82 | "ual to 256 bit strength"); 83 | this.comboBox1.ValueMember = "3072"; 84 | // 85 | // button2 86 | // 87 | this.button2.Location = new System.Drawing.Point(346, 1); 88 | this.button2.Name = "button2"; 89 | this.button2.Size = new System.Drawing.Size(75, 23); 90 | this.button2.TabIndex = 5; 91 | this.button2.Text = "Browse"; 92 | this.button2.UseVisualStyleBackColor = true; 93 | this.button2.Click += new System.EventHandler(this.button2_Click); 94 | // 95 | // Form1 96 | // 97 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 98 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 99 | this.ClientSize = new System.Drawing.Size(622, 36); 100 | this.Controls.Add(this.button2); 101 | this.Controls.Add(this.comboBox1); 102 | this.Controls.Add(this.label1); 103 | this.Controls.Add(this.button1); 104 | this.Controls.Add(this.textBox1); 105 | this.Name = "Form1"; 106 | this.Text = "RSA Key Generator"; 107 | this.ResumeLayout(false); 108 | this.PerformLayout(); 109 | 110 | } 111 | 112 | #endregion 113 | 114 | private System.Windows.Forms.TextBox textBox1; 115 | private System.Windows.Forms.Button button1; 116 | private System.Windows.Forms.Label label1; 117 | private System.Windows.Forms.ComboBox comboBox1; 118 | private System.Windows.Forms.ToolTip toolTip1; 119 | private System.Windows.Forms.Button button2; 120 | private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1; 121 | } 122 | } 123 | 124 | -------------------------------------------------------------------------------- /Key_Generator/Form1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.IO; 7 | using System.Linq; 8 | using System.Security.Cryptography; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | using System.Windows.Forms; 12 | 13 | namespace Key_Generator 14 | { 15 | public partial class Form1 : Form 16 | { 17 | public Form1() 18 | { 19 | InitializeComponent(); 20 | comboBox1.SelectedIndex = 0; 21 | } 22 | 23 | private void button1_Click(object sender, EventArgs e) 24 | { 25 | var RSA = new RSACryptoServiceProvider(Convert.ToInt32(comboBox1.SelectedItem.ToString())); 26 | 27 | var rootpath = textBox1.Text; 28 | if(!rootpath.EndsWith("\\"))rootpath+="\\"; 29 | File.WriteAllText(rootpath + "publickey.xml", RSA.ToXmlString(false)); 30 | File.WriteAllText(rootpath + "privatekey.xml", RSA.ToXmlString(true)); 31 | } 32 | 33 | private void button2_Click(object sender, EventArgs e) 34 | { 35 | folderBrowserDialog1.ShowDialog(); 36 | textBox1.Text = folderBrowserDialog1.SelectedPath; 37 | } 38 | 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Key_Generator/Form1.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 153, 17 122 | 123 | 124 | 250, 17 125 | 126 | -------------------------------------------------------------------------------- /Key_Generator/Key_Generator.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {CD1B3B4A-F4F8-4728-A0E9-EADD1BC7A977} 8 | WinExe 9 | Properties 10 | Key_Generator 11 | Key_Generator 12 | v4.5 13 | 512 14 | 15 | 16 | AnyCPU 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | AnyCPU 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | Form 49 | 50 | 51 | Form1.cs 52 | 53 | 54 | 55 | 56 | Form1.cs 57 | 58 | 59 | ResXFileCodeGenerator 60 | Resources.Designer.cs 61 | Designer 62 | 63 | 64 | True 65 | Resources.resx 66 | 67 | 68 | SettingsSingleFileGenerator 69 | Settings.Designer.cs 70 | 71 | 72 | True 73 | Settings.settings 74 | True 75 | 76 | 77 | 78 | 79 | 80 | 81 | 88 | -------------------------------------------------------------------------------- /Key_Generator/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace Key_Generator 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// The main entry point for the application. 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | Application.Run(new Form1()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Key_Generator/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Key_Generator")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Key_Generator")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("3d8d8237-6f3f-400b-a7d5-4c415378cee2")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Key_Generator/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.18444 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Key_Generator.Properties 12 | { 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources 26 | { 27 | 28 | private static global::System.Resources.ResourceManager resourceMan; 29 | 30 | private static global::System.Globalization.CultureInfo resourceCulture; 31 | 32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 33 | internal Resources() 34 | { 35 | } 36 | 37 | /// 38 | /// Returns the cached ResourceManager instance used by this class. 39 | /// 40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 41 | internal static global::System.Resources.ResourceManager ResourceManager 42 | { 43 | get 44 | { 45 | if((resourceMan == null)) 46 | { 47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Key_Generator.Properties.Resources", typeof(Resources).Assembly); 48 | resourceMan = temp; 49 | } 50 | return resourceMan; 51 | } 52 | } 53 | 54 | /// 55 | /// Overrides the current thread's CurrentUICulture property for all 56 | /// resource lookups using this strongly typed resource class. 57 | /// 58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 59 | internal static global::System.Globalization.CultureInfo Culture 60 | { 61 | get 62 | { 63 | return resourceCulture; 64 | } 65 | set 66 | { 67 | resourceCulture = value; 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Key_Generator/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /Key_Generator/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.18444 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Key_Generator.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Key_Generator/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Pipes/Class2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.ServiceModel; 6 | using System.Text; 7 | 8 | namespace Pipes 9 | { 10 | public class Sender 11 | { 12 | private string _PipeURI = string.Empty; 13 | private string _PipeName = string.Empty; 14 | private EndpointAddress _EndpointAddr = null; 15 | public Sender(string pipename, string pipeuri) 16 | { 17 | _PipeName = pipename; 18 | _PipeURI = pipeuri; 19 | _EndpointAddr = new EndpointAddress(string.Format("{0}/{1}", _PipeURI,_PipeName)); 20 | } 21 | //public static void SendMessage(string messages) 22 | //{ 23 | 24 | // IPipeService proxy = ChannelFactory.CreateChannel(new NetNamedPipeBinding(), ep); 25 | // var s =proxy.PipeIn(messages); 26 | 27 | //} 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Pipes/IDesktopService_API.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.ServiceModel; 5 | using System.Text; 6 | 7 | namespace Pipes 8 | { 9 | [ServiceContract(Namespace = "http://www.mydohc.com/DesktopsharingNamespace")] 10 | public interface IDesktopService_API 11 | { 12 | [OperationContract] 13 | string PipeIn(string data); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Pipes/Pipes.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {982892A9-3967-44D3-8EED-88C30ABE2EF1} 8 | Library 9 | Properties 10 | Pipes 11 | Pipes 12 | v3.5 13 | 512 14 | 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | pdbonly 27 | true 28 | bin\Release\ 29 | TRACE 30 | prompt 31 | 4 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 56 | -------------------------------------------------------------------------------- /Pipes/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Pipes")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Pipes")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("a65bd2e2-0240-4d8f-9857-f3c6483255a5")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Pipes/Receiver.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.ServiceModel; 6 | using System.Text; 7 | 8 | namespace Pipes 9 | { 10 | 11 | public class Receiver : IDisposable 12 | { 13 | private object _Singleton = null; 14 | private ServiceHost _Host = null; 15 | private string _PipeName = string.Empty; 16 | private string _PipeURI = string.Empty; 17 | private Type _Contract_Type = null; 18 | 19 | public Receiver(string pipename, string pipeuri, Type contract_type, object singleton) 20 | { 21 | _PipeName = pipename; 22 | _PipeURI = pipeuri; 23 | _Contract_Type = contract_type; 24 | _Singleton = singleton; 25 | } 26 | public bool Start() 27 | { 28 | try 29 | { 30 | _Host = new ServiceHost(_Singleton, new Uri(_PipeURI)); 31 | _Host.AddServiceEndpoint(_Contract_Type, new NetNamedPipeBinding(), _PipeName); 32 | _Host.Open(); 33 | return true; 34 | } catch(Exception ex) 35 | { 36 | Debug.WriteLine(ex.Message); 37 | Stop(); 38 | return false; 39 | } 40 | } 41 | 42 | public void Stop() 43 | { 44 | if(_Host != null) 45 | if(_Host.State != CommunicationState.Closed) 46 | _Host.Close(); 47 | _Host = null; 48 | } 49 | 50 | // A basic dispose. 51 | public void Dispose() 52 | { 53 | Stop(); 54 | if(_Singleton != null) 55 | _Singleton = null; 56 | } 57 | 58 | 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Desktop_Sharing 2 | =============== 3 | 4 | This was my first attempt at a VNC like program written in c#. Unfortunatly, c# was too unreliable in performance so I am rewriting this in c++. 5 | You can check out the rewrite at https://github.com/smasherprog/Remote_Access_Library 6 |

License

7 | mit 8 | -------------------------------------------------------------------------------- /SSLTcp/Message.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | 7 | namespace SecureTcp 8 | { 9 | public class Tcp_Message 10 | { 11 | public Tcp_Message(int t) 12 | { 13 | Blocks = new List(); 14 | Add_Block(BitConverter.GetBytes(t)); 15 | } 16 | public void Add_Block(byte[] b) 17 | { 18 | Blocks.Add(b); 19 | } 20 | 21 | public void Add_Blocks(params byte[][] list) 22 | { 23 | foreach(var item in list) 24 | { 25 | Add_Block(item); 26 | } 27 | 28 | } 29 | public long length 30 | { 31 | get 32 | { 33 | var t = 4 + (Blocks.Count * 4); 34 | foreach(var item in Blocks) 35 | t += item.Length; 36 | return t; 37 | } 38 | } 39 | public static Tcp_Message FromBuffer(byte[] b) 40 | { 41 | var m = new Tcp_Message(1); 42 | m.Blocks.Clear(); 43 | 44 | var curbuff = 0; 45 | var tempbuffer = new byte[4]; 46 | Buffer.BlockCopy(b, curbuff, tempbuffer, 0, 4); 47 | curbuff += 4; 48 | var end = BitConverter.ToInt32(tempbuffer, 0); 49 | for(var i = 0; i < end; i++) 50 | { 51 | Buffer.BlockCopy(b, curbuff, tempbuffer, 0, 4); 52 | curbuff += 4; 53 | var tmpbuf = new byte[BitConverter.ToInt32(tempbuffer, 0)]; 54 | Buffer.BlockCopy(b, curbuff, tmpbuf, 0, tmpbuf.Length); 55 | curbuff += tmpbuf.Length; 56 | m.Add_Block(tmpbuf); 57 | } 58 | 59 | return m; 60 | } 61 | public static byte[] ToBuffer(Tcp_Message m) 62 | { 63 | var sizeneeded = 4 + (m.Blocks.Count * 4); 64 | foreach(var item in m.Blocks) 65 | sizeneeded += item.Length; 66 | var inbuffer = new byte[sizeneeded]; 67 | var curbuff = 0; 68 | Buffer.BlockCopy(BitConverter.GetBytes(m.Blocks.Count), 0, inbuffer, curbuff, 4); 69 | curbuff += 4; 70 | foreach(var item in m.Blocks) 71 | { 72 | Buffer.BlockCopy(BitConverter.GetBytes(item.Length), 0, inbuffer, curbuff, 4); 73 | curbuff += 4; 74 | Buffer.BlockCopy(item, 0, inbuffer, curbuff, item.Length); 75 | curbuff += item.Length; 76 | } 77 | return inbuffer; 78 | } 79 | private static int roundUp(int numToRound, int multiple) 80 | { 81 | if(multiple == 0) 82 | { 83 | return numToRound; 84 | } 85 | 86 | int remainder = numToRound % multiple; 87 | if(remainder == 0) 88 | { 89 | return numToRound; 90 | } 91 | 92 | return numToRound + multiple - remainder; 93 | } 94 | public int Type 95 | { 96 | get 97 | { return BitConverter.ToInt32(Blocks[0], 0); } 98 | set 99 | { Buffer.BlockCopy(BitConverter.GetBytes(value), 0, Blocks[0], 0, 4); } 100 | } 101 | public List Blocks; 102 | 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /SSLTcp/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("SecureTcp")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("SecureTcp")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("584d80cd-149f-47ba-9a14-de460d30f902")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /SSLTcp/SecureTcp.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {A16D46D3-C103-4C9B-84DA-17DCFD29F9E6} 8 | Library 9 | Properties 10 | SecureTcp 11 | SecureTcp 12 | v3.5 13 | 512 14 | 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | pdbonly 27 | true 28 | bin\Release\ 29 | TRACE 30 | prompt 31 | 4 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 58 | -------------------------------------------------------------------------------- /SSLTcp/Secure_Tcp_Client.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.IO; 5 | using System.Linq; 6 | using System.Net; 7 | using System.Net.Security; 8 | using System.Net.Sockets; 9 | using System.Security.Cryptography; 10 | using System.Security.Cryptography.X509Certificates; 11 | using System.Text; 12 | 13 | namespace SecureTcp 14 | { 15 | public static class Secure_Tcp_Client 16 | { 17 | public static Secure_Stream Connect(string key_location, string ipaddr, int port) 18 | { 19 | var client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); 20 | client.ReceiveTimeout = 5000; 21 | client.NoDelay = true; 22 | 23 | client.Connect(new IPEndPoint(IPAddress.Parse(ipaddr), port)); 24 | var sessionkey = ExchangeKeys(key_location, client); 25 | if(sessionkey == null) 26 | { 27 | client.Close(); 28 | client = null; 29 | throw new ArgumentException("Key Exchange Failed"); 30 | } 31 | return new Secure_Stream(client, sessionkey); 32 | } 33 | 34 | private static byte[] ExchangeKeys(string key_location, Socket socket) 35 | { 36 | try 37 | { 38 | byte[] sessionkey = null; 39 | using(Aes aes = Aes.Create()) 40 | { 41 | aes.KeySize = aes.LegalKeySizes[0].MaxSize; 42 | sessionkey = aes.Key; 43 | } 44 | byte[] sessionkeyhash = SHA256.Create().ComputeHash(sessionkey); 45 | 46 | using(RSACryptoServiceProvider rsa = new RSACryptoServiceProvider()) 47 | { 48 | var keyfile = File.ReadAllText(key_location); 49 | rsa.FromXmlString(keyfile); 50 | //encrypt the session key with the public key 51 | var data = rsa.Encrypt(sessionkey, true); 52 | //send it with the length 53 | byte[] intBytes = BitConverter.GetBytes(data.Length); 54 | socket.Send(intBytes); 55 | socket.Send(data); 56 | 57 | //read the sessionkeyhash response from the server to ensure it received it correctly 58 | var b = BitConverter.GetBytes(0); 59 | Utilities.Receive_Exact(socket,b,0, b.Length); 60 | var len = BitConverter.ToInt32(b, 0); 61 | if(len > 4000) 62 | throw new ArgumentException("Buffer Overlflow in Encryption key exchange!"); 63 | var serversessionkeyhash = new byte[len]; 64 | Utilities.Receive_Exact(socket, serversessionkeyhash, 0, serversessionkeyhash.Length); 65 | 66 | //compare the sessionhash returned by the server to our hash 67 | if(serversessionkeyhash.SequenceEqual(sessionkeyhash)) 68 | { 69 | Debug.WriteLine("Key Exchange completed!"); 70 | return sessionkey; 71 | } else 72 | { 73 | Debug.WriteLine("Key Exchange failed keys are not the same!"); 74 | return null; 75 | } 76 | } 77 | } catch(Exception e) 78 | { 79 | Debug.WriteLine(e.Message); 80 | return null; 81 | } 82 | 83 | } 84 | 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /SSLTcp/Secure_Tcp_Listener.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.IO; 5 | using System.Linq; 6 | using System.Net.Security; 7 | using System.Net.Sockets; 8 | using System.Security.Cryptography; 9 | using System.Security.Cryptography.X509Certificates; 10 | using System.Text; 11 | using System.Threading; 12 | 13 | namespace SecureTcp 14 | { 15 | 16 | public class Secure_Tcp_Listener : IDisposable 17 | { 18 | private Socket SecureServer; 19 | private string _SessionKey; 20 | 21 | public delegate void ClientEventHandler(Secure_Stream client); 22 | public event ClientEventHandler NewClientEvent; 23 | private int _Port; 24 | 25 | public Secure_Tcp_Listener(string key, int port) 26 | { 27 | _Port = port; 28 | _SessionKey = File.ReadAllText(key); 29 | } 30 | public void Dispose() 31 | { 32 | if(SecureServer != null) 33 | SecureServer.Close(); 34 | SecureServer = null; 35 | } 36 | public void Start() 37 | { 38 | SecureServer = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); 39 | SecureServer.Bind(new System.Net.IPEndPoint(System.Net.IPAddress.Any, _Port)); 40 | SecureServer.Listen(100); 41 | _BeginAccept(); 42 | } 43 | 44 | private void _BeginAccept() 45 | { 46 | SecureServer.BeginAccept(new AsyncCallback(AcceptCallback), SecureServer); 47 | } 48 | private void AcceptCallback(IAsyncResult ar) 49 | { 50 | try 51 | { 52 | Debug.WriteLine("New connection received"); 53 | 54 | var listener = (Socket)ar.AsyncState; 55 | var handler = listener.EndAccept(ar); 56 | handler.NoDelay = true; 57 | var sessionkey = ExchangeKeys(_SessionKey, handler); 58 | if(sessionkey == null) 59 | { 60 | handler.Close(); 61 | handler = null; 62 | } 63 | if(NewClientEvent != null) 64 | NewClientEvent(new Secure_Stream(handler, sessionkey)); 65 | 66 | } catch(Exception e) 67 | { 68 | Debug.WriteLine(e.Message); 69 | } 70 | _BeginAccept(); 71 | } 72 | 73 | private static byte[] ExchangeKeys(string sesskey, Socket sock) 74 | { 75 | try 76 | { 77 | using(RSACryptoServiceProvider rsa = new RSACryptoServiceProvider()) 78 | { 79 | rsa.FromXmlString(sesskey); 80 | var b = BitConverter.GetBytes(0); 81 | Utilities.Receive_Exact(sock, b, 0, b.Length); 82 | var len = BitConverter.ToInt32(b, 0); 83 | if(len > 4000) 84 | throw new ArgumentException("Buffer Overlflow in Encryption key exchange!"); 85 | byte[] sessionkey = new byte[len]; 86 | 87 | Utilities.Receive_Exact(sock, sessionkey, 0, len); 88 | sessionkey = rsa.Decrypt(sessionkey, true);//decrypt the session key 89 | //hash the key and send it back to prove that I received it correctly 90 | byte[] sessionkeyhash = SHA256.Create().ComputeHash(sessionkey); 91 | //send it back to the client 92 | byte[] intBytes = BitConverter.GetBytes(sessionkeyhash.Length); 93 | sock.Send(intBytes); 94 | sock.Send(sessionkeyhash); 95 | 96 | Debug.WriteLine("Key Exchange completed!"); 97 | return sessionkey; 98 | 99 | } 100 | } catch(Exception e) 101 | { 102 | Debug.WriteLine(e.Message); 103 | return null; 104 | } 105 | 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /SSLTcp/TCP_Server.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading; 6 | 7 | namespace SecureTcp 8 | { 9 | public class TCP_Server : IDisposable 10 | { 11 | 12 | private AutoResetEvent allDone = new AutoResetEvent(false); 13 | private object _ClientLock = new object(); 14 | private List _Clients = new List(); 15 | public int ClientCount = 0; 16 | private Secure_Tcp_Listener _Secure_Tcp_Listener; 17 | 18 | public delegate void ReceiveHandler(Tcp_Message m); 19 | public event ReceiveHandler ReceiveEvent; 20 | public event SecureTcp.Secure_Tcp_Listener.ClientEventHandler NewClientEvent; 21 | public event SecureTcp.Secure_Stream.DisconnectEventHandler DisconnectEvent; 22 | 23 | private string _Key; 24 | private int _Port; 25 | public TCP_Server(string key, int port) 26 | { 27 | _Key = key; 28 | _Port = port; 29 | 30 | } 31 | private void _Secure_Tcp_Listener_NewClient(Secure_Stream client) 32 | { 33 | lock(_ClientLock) 34 | { 35 | _Clients.Add(client); 36 | } 37 | ClientCount += 1; 38 | if(NewClientEvent != null) 39 | NewClientEvent(client); 40 | client.MessageReceivedEvent += client_MessageReceivedEvent; 41 | client.DisconnectEvent += client_DisconnectEvent; 42 | client.BeginRead(); 43 | } 44 | 45 | void client_DisconnectEvent(Secure_Stream client) 46 | { 47 | ClientCount -= 1; 48 | if(DisconnectEvent != null) 49 | DisconnectEvent(client); 50 | client.Dispose(); 51 | } 52 | 53 | void client_MessageReceivedEvent(Secure_Stream client, Tcp_Message ms) 54 | { 55 | if(ReceiveEvent != null) 56 | ReceiveEvent(ms); 57 | } 58 | public void Start() 59 | { 60 | _Secure_Tcp_Listener = new SecureTcp.Secure_Tcp_Listener(_Key, _Port); 61 | _Secure_Tcp_Listener.NewClientEvent += _Secure_Tcp_Listener_NewClient; 62 | ClientCount = 0; 63 | _Secure_Tcp_Listener.Start(); 64 | 65 | } 66 | 67 | public void Stop() 68 | { 69 | 70 | lock(_ClientLock) 71 | { 72 | foreach(var item in _Clients) 73 | item.Dispose(); 74 | _Clients.Clear(); 75 | } 76 | 77 | if(_Secure_Tcp_Listener != null) 78 | _Secure_Tcp_Listener.Dispose(); 79 | _Secure_Tcp_Listener = null; 80 | ClientCount = 0; 81 | } 82 | public void Send(Tcp_Message m) 83 | { 84 | lock(_ClientLock) 85 | { 86 | _Clients.RemoveAll(a => a.Client==null); 87 | foreach(var item in _Clients) 88 | item.Encrypt_And_Send(m); 89 | } 90 | } 91 | public void Dispose() 92 | { 93 | Stop(); 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /SSLTcp/Utilities.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Net.Sockets; 6 | using System.Security.Cryptography; 7 | using System.Text; 8 | using System.Threading; 9 | 10 | namespace SecureTcp 11 | { 12 | public static class Utilities 13 | { 14 | public static void Receive_Exact(Socket socket, byte[] buffer, int offset, int size) 15 | { 16 | int received = 0; // how many bytes is already received 17 | do 18 | { 19 | try 20 | { 21 | received += socket.Receive(buffer, offset + received, size - received, SocketFlags.None); 22 | } catch(SocketException ex) 23 | { 24 | if(ex.SocketErrorCode == SocketError.WouldBlock || 25 | ex.SocketErrorCode == SocketError.IOPending || 26 | ex.SocketErrorCode == SocketError.NoBufferSpaceAvailable) 27 | { 28 | } else 29 | throw ex; // any serious error occurr 30 | } 31 | } while(received < size); 32 | } 33 | static readonly string[] SizeSuffixes = { "bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" }; 34 | public static string SizeSuffix(Int64 value) 35 | { 36 | if(value <= 0) 37 | return "0 bytes"; 38 | int mag = (int)Math.Log(value, 1024); 39 | decimal adjustedSize = (decimal)value / (1L << (mag * 10)); 40 | 41 | return string.Format("{0:n1} {1}", adjustedSize, SizeSuffixes[mag]); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Server_System_Tray/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Server_System_Tray/Form1.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace Server_System_Tray 2 | { 3 | partial class Form1 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if(disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.components = new System.ComponentModel.Container(); 32 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 33 | this.Text = "Form1"; 34 | } 35 | 36 | #endregion 37 | } 38 | } 39 | 40 | -------------------------------------------------------------------------------- /Server_System_Tray/Form1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace Server_System_Tray 12 | { 13 | public partial class Form1 : Form 14 | { 15 | public Form1() 16 | { 17 | InitializeComponent(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Server_System_Tray/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace Server_System_Tray 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// The main entry point for the application. 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | Application.Run(new Form1()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Server_System_Tray/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Server_System_Tray")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Server_System_Tray")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("2ec696b9-5989-43f9-8f74-db80ef3bbc99")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Server_System_Tray/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.18444 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Server_System_Tray.Properties 12 | { 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources 26 | { 27 | 28 | private static global::System.Resources.ResourceManager resourceMan; 29 | 30 | private static global::System.Globalization.CultureInfo resourceCulture; 31 | 32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 33 | internal Resources() 34 | { 35 | } 36 | 37 | /// 38 | /// Returns the cached ResourceManager instance used by this class. 39 | /// 40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 41 | internal static global::System.Resources.ResourceManager ResourceManager 42 | { 43 | get 44 | { 45 | if((resourceMan == null)) 46 | { 47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Server_System_Tray.Properties.Resources", typeof(Resources).Assembly); 48 | resourceMan = temp; 49 | } 50 | return resourceMan; 51 | } 52 | } 53 | 54 | /// 55 | /// Overrides the current thread's CurrentUICulture property for all 56 | /// resource lookups using this strongly typed resource class. 57 | /// 58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 59 | internal static global::System.Globalization.CultureInfo Culture 60 | { 61 | get 62 | { 63 | return resourceCulture; 64 | } 65 | set 66 | { 67 | resourceCulture = value; 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Server_System_Tray/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /Server_System_Tray/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.18444 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Server_System_Tray.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Server_System_Tray/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Server_System_Tray/Server_System_Tray.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {8BC9CFA1-EB3B-4C77-B4BB-C097A37B5C21} 8 | WinExe 9 | Properties 10 | Server_System_Tray 11 | Server_System_Tray 12 | v4.5 13 | 512 14 | 15 | 16 | AnyCPU 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | AnyCPU 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | Form 49 | 50 | 51 | Form1.cs 52 | 53 | 54 | 55 | 56 | ResXFileCodeGenerator 57 | Resources.Designer.cs 58 | Designer 59 | 60 | 61 | True 62 | Resources.resx 63 | 64 | 65 | SettingsSingleFileGenerator 66 | Settings.Designer.cs 67 | 68 | 69 | True 70 | Settings.settings 71 | True 72 | 73 | 74 | 75 | 76 | 77 | 78 | 85 | --------------------------------------------------------------------------------