From 44d1bd14bd2f9c22fee6b57ac3df4018db146e1d Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Tue, 19 May 2015 14:48:57 -0700 Subject: Enable right-click menu for copy/paste/etc. in Windows UI wrapper. --- windows/WebUIWrapper/Form1.Designer.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'windows/WebUIWrapper') diff --git a/windows/WebUIWrapper/Form1.Designer.cs b/windows/WebUIWrapper/Form1.Designer.cs index 8d8eb9e9..81d69cd0 100644 --- a/windows/WebUIWrapper/Form1.Designer.cs +++ b/windows/WebUIWrapper/Form1.Designer.cs @@ -36,20 +36,21 @@ // this.webContainer.AllowNavigation = false; this.webContainer.Dock = System.Windows.Forms.DockStyle.Fill; - this.webContainer.IsWebBrowserContextMenuEnabled = false; this.webContainer.Location = new System.Drawing.Point(0, 0); - this.webContainer.MinimumSize = new System.Drawing.Size(20, 20); + this.webContainer.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.webContainer.MinimumSize = new System.Drawing.Size(18, 16); this.webContainer.Name = "webContainer"; - this.webContainer.Size = new System.Drawing.Size(1012, 556); + this.webContainer.Size = new System.Drawing.Size(900, 445); this.webContainer.TabIndex = 0; // // Form1 // - this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1012, 556); + this.ClientSize = new System.Drawing.Size(900, 445); this.Controls.Add(this.webContainer); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.Name = "Form1"; this.Text = "ZeroTier One"; this.Load += new System.EventHandler(this.Form1_Load); -- cgit v1.2.3 From 63cea7d337a55fed8333a3aaf3d1d5bb50a03018 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Tue, 19 May 2015 16:02:26 -0700 Subject: Try to automatically enable access to http://127.0.0.1 in web wrapper if IE is in enhanced security mode. --- ext/bin/win-ui-wrapper/ZeroTier One.exe | Bin 761304 -> 763352 bytes windows/WebUIWrapper/Program.cs | 70 ++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) (limited to 'windows/WebUIWrapper') diff --git a/ext/bin/win-ui-wrapper/ZeroTier One.exe b/ext/bin/win-ui-wrapper/ZeroTier One.exe index 50eec7d6..622b5b36 100644 Binary files a/ext/bin/win-ui-wrapper/ZeroTier One.exe and b/ext/bin/win-ui-wrapper/ZeroTier One.exe differ diff --git a/windows/WebUIWrapper/Program.cs b/windows/WebUIWrapper/Program.cs index 3dfdb94f..bfcdb831 100644 --- a/windows/WebUIWrapper/Program.cs +++ b/windows/WebUIWrapper/Program.cs @@ -3,17 +3,87 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Windows.Forms; +using System.Runtime.InteropServices; +using System.ComponentModel; namespace WebUIWrapper { + [ComImport, GuidAttribute("79EAC9EE-BAF9-11CE-8C82-00AA004BA90B"), + InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] + public interface IInternetSecurityManager + { + [return: MarshalAs(UnmanagedType.I4)] + [PreserveSig] + int SetSecuritySite([In] IntPtr pSite); + + [return: MarshalAs(UnmanagedType.I4)] + [PreserveSig] + int GetSecuritySite([Out] IntPtr pSite); + + [return: MarshalAs(UnmanagedType.I4)] + [PreserveSig] + int MapUrlToZone([In, MarshalAs(UnmanagedType.LPWStr)] string pwszUrl, out UInt32 pdwZone, UInt32 dwFlags); + + [return: MarshalAs(UnmanagedType.I4)] + [PreserveSig] + int GetSecurityId([MarshalAs(UnmanagedType.LPWStr)] string pwszUrl, [MarshalAs(UnmanagedType.LPArray)] byte[] pbSecurityId, ref UInt32 pcbSecurityId, uint dwReserved); + + [return: MarshalAs(UnmanagedType.I4)] + [PreserveSig] + int ProcessUrlAction([In, MarshalAs(UnmanagedType.LPWStr)] string pwszUrl, UInt32 dwAction, out byte pPolicy, UInt32 cbPolicy, byte pContext, UInt32 cbContext, UInt32 dwFlags, UInt32 dwReserved); + + [return: MarshalAs(UnmanagedType.I4)] + [PreserveSig] + int QueryCustomPolicy([In, MarshalAs(UnmanagedType.LPWStr)] string pwszUrl, ref Guid guidKey, ref byte ppPolicy, ref UInt32 pcbPolicy, ref byte pContext, UInt32 cbContext, UInt32 dwReserved); + + [return: MarshalAs(UnmanagedType.I4)] + [PreserveSig] + int SetZoneMapping(UInt32 dwZone, [In, MarshalAs(UnmanagedType.LPWStr)] string lpszPattern, UInt32 dwFlags); + + [return: MarshalAs(UnmanagedType.I4)] + [PreserveSig] + int GetZoneMappings(UInt32 dwZone, out UCOMIEnumString ppenumString, UInt32 dwFlags); + } + static class Program { + // constants from urlmon.h + public const UInt32 URLZONE_LOCAL_MACHINE = 0; + public const UInt32 URLZONE_INTRANET = URLZONE_LOCAL_MACHINE + 1; + public const UInt32 URLZONE_TRUSTED = URLZONE_INTRANET + 1; + public const UInt32 URLZONE_INTERNET = URLZONE_TRUSTED + 1; + public const UInt32 URLZONE_UNTRUSTED = URLZONE_INTERNET + 1; + public const UInt32 URLZONE_ESC_FLAG = 0x100; + public const UInt32 SZM_CREATE = 0; + public const UInt32 SZM_DELETE = 0x1; + + public static Guid CLSID_InternetSecurityManager = new Guid("7b8a2d94-0ac9-11d1-896c-00c04fb6bfc4"); + public static Guid IID_IInternetSecurityManager = new Guid("79eac9ee-baf9-11ce-8c82-00aa004ba90b"); + /// /// The main entry point for the application. /// [STAThread] static void Main() { + try + { + Type t = Type.GetTypeFromCLSID(CLSID_InternetSecurityManager); + object securityManager = Activator.CreateInstance(t); + if (securityManager != null) + { + IInternetSecurityManager ism = (IInternetSecurityManager)securityManager; + ism.SetZoneMapping(URLZONE_TRUSTED, "http://127.0.0.1", SZM_CREATE); + ism.SetZoneMapping(URLZONE_INTRANET, "http://127.0.0.1", SZM_CREATE); + ism.SetZoneMapping(URLZONE_ESC_FLAG | URLZONE_TRUSTED, "http://127.0.0.1", SZM_CREATE); + ism.SetZoneMapping(URLZONE_ESC_FLAG | URLZONE_INTRANET, "http://127.0.0.1", SZM_CREATE); + } + } + catch + { + // Okay to continue if adding URL to trusted zone doesn't work... + } + Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); -- cgit v1.2.3