Skip to content

Commit ef058be

Browse files
committed
always enable ActiveX Controls
1 parent 413c6e9 commit ef058be

6 files changed

Lines changed: 392 additions & 1 deletion

File tree

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel;
4+
using System.Linq;
5+
using System.Runtime.InteropServices;
6+
using System.Runtime.InteropServices.ComTypes;
7+
using System.Text;
8+
using System.Threading.Tasks;
9+
using System.Windows.Forms;
10+
11+
using static FlashpointSecurePlayer.Shared;
12+
using static FlashpointSecurePlayer.Shared.Exceptions;
13+
using static FlashpointSecurePlayer.InternetInterfaces;
14+
15+
namespace FlashpointSecurePlayer {
16+
public class CustomSecurityManager : InternetInterfaces.IServiceProvider, InternetInterfaces.IInternetSecurityManager {
17+
public CustomSecurityManager(WebBrowser _WebBrowser) {
18+
InternetInterfaces.IServiceProvider webBrowserServiceProviderInterface = _WebBrowser.ActiveXInstance as InternetInterfaces.IServiceProvider;
19+
IntPtr profferServiceInterfacePointer = IntPtr.Zero;
20+
21+
try {
22+
int err = webBrowserServiceProviderInterface.QueryService(ref InternetInterfaces.SID_SProfferService, ref InternetInterfaces.IID_IProfferService, out profferServiceInterfacePointer);
23+
24+
if (err != S_OK) {
25+
throw new Win32Exception();
26+
}
27+
28+
InternetInterfaces.IProfferService profferServiceInterface = Marshal.GetObjectForIUnknown(profferServiceInterfacePointer) as InternetInterfaces.IProfferService;
29+
30+
if (profferServiceInterface == null) {
31+
throw new Win32Exception();
32+
}
33+
34+
err = profferServiceInterface.ProfferService(ref InternetInterfaces.IID_IInternetSecurityManager, this, out int cookie);
35+
36+
if (err != S_OK) {
37+
throw new Win32Exception();
38+
}
39+
} catch (SEHException) {
40+
throw new Win32Exception();
41+
} catch (ExternalException) {
42+
throw new Win32Exception();
43+
}
44+
}
45+
46+
int InternetInterfaces.IServiceProvider.QueryService(ref Guid guidService, ref Guid riid, out IntPtr ppvObject) {
47+
ppvObject = IntPtr.Zero;
48+
49+
if (guidService.CompareTo(InternetInterfaces.IID_IInternetSecurityManager) == 0) {
50+
return Marshal.QueryInterface(Marshal.GetIUnknownForObject(this), ref riid, out ppvObject);
51+
}
52+
return E_NOINTERFACE;
53+
}
54+
55+
int InternetInterfaces.IInternetSecurityManager.SetSecuritySite(IntPtr pSite) {
56+
return INET_E_DEFAULT_ACTION;
57+
}
58+
59+
int InternetInterfaces.IInternetSecurityManager.GetSecuritySite(out IntPtr pSite) {
60+
pSite = IntPtr.Zero;
61+
return INET_E_DEFAULT_ACTION;
62+
}
63+
64+
int InternetInterfaces.IInternetSecurityManager.MapUrlToZone([MarshalAs(UnmanagedType.LPWStr)] string pwszUrl, ref uint pdwZone, uint dwFlags) {
65+
pdwZone = 0;
66+
return INET_E_DEFAULT_ACTION;
67+
}
68+
69+
int InternetInterfaces.IInternetSecurityManager.GetSecurityId([MarshalAs(UnmanagedType.LPWStr)] string pwszUrl, [MarshalAs(UnmanagedType.LPArray)] byte[] pbSecurityId, ref uint pcbSecurityId, uint dwReserved) {
70+
return INET_E_DEFAULT_ACTION;
71+
}
72+
73+
int InternetInterfaces.IInternetSecurityManager.ProcessUrlAction([MarshalAs(UnmanagedType.LPWStr)] string pwszUrl, uint dwAction, out uint pPolicy, uint cbPolicy, byte pContext, uint cbContext, uint dwFlags, uint dwReserved) {
74+
pPolicy = URLPOLICY_DISALLOW;
75+
76+
if (dwAction == URLACTION_ACTIVEX_TREATASUNTRUSTED || // trust ActiveX Controls always
77+
dwAction == URLACTION_HTML_MIXED_CONTENT || // block HTTPS content on HTTP websites for Flashpoint Proxy
78+
dwAction == URLACTION_CLIENT_CERT_PROMPT || // don't allow invalid certificates
79+
dwAction == URLACTION_AUTOMATIC_ACTIVEX_UI || // do not display the install dialog for ActiveX Controls
80+
dwAction == URLACTION_ALLOW_RESTRICTEDPROTOCOLS || // use same settings for every protocol
81+
dwAction == URLACTION_ALLOW_APEVALUATION || // the phishing filter is not applicable to this application
82+
dwAction == URLACTION_LOWRIGHTS || // turn off Protected Mode
83+
dwAction == URLACTION_ALLOW_ACTIVEX_FILTERING) { // don't allow ActiveX filtering
84+
return S_OK;
85+
}
86+
87+
pPolicy = URLPOLICY_JAVA_LOW;
88+
89+
if (dwAction == URLACTION_JAVA_PERMISSIONS) { // allow Java applets to be as terrible as they need to be to function
90+
return S_OK;
91+
}
92+
93+
pPolicy = URLPOLICY_ALLOW;
94+
95+
if ((dwAction >= URLACTION_DOWNLOAD_MIN && dwAction <= URLACTION_DOWNLOAD_MAX) || // allow downloading ActiveX Controls, scripts, etc.
96+
(dwAction >= URLACTION_ACTIVEX_MIN && dwAction <= URLACTION_ACTIVEX_MAX) || // allow ActiveX Controls
97+
(dwAction >= URLACTION_SCRIPT_MIN && dwAction <= URLACTION_SCRIPT_MAX) || // allow scripts
98+
(dwAction >= URLACTION_HTML_MIN && dwAction <= URLACTION_HTML_MAX) || // allow forms, fonts, meta elements, etc.
99+
(dwAction >= URLACTION_JAVA_MIN && dwAction <= URLACTION_JAVA_MAX) || // allow Java applets
100+
dwAction == URLACTION_COOKIES || // allow all cookies, which are not in fact dangerous and are in fact harmless plaintext files that don't have any code in them
101+
dwAction == URLACTION_COOKIES_SESSION ||
102+
dwAction == URLACTION_COOKIES_THIRD_PARTY ||
103+
dwAction == URLACTION_COOKIES_SESSION_THIRD_PARTY ||
104+
dwAction == URLACTION_COOKIES_ENABLED ||
105+
dwAction == URLACTION_BEHAVIOR_RUN || // allow running behaviours
106+
dwAction == URLACTION_MANAGED_SIGNED || // run components regardless of if they're signed or not
107+
dwAction == URLACTION_MANAGED_UNSIGNED ||
108+
dwAction == URLACTION_DOTNET_USERCONTROLS || // allow .NET user controls
109+
dwAction == URLACTION_FEATURE_DATA_BINDING || // allow databinding
110+
dwAction == URLACTION_FEATURE_CROSSDOMAIN_FOCUS_CHANGE || // allow crossdomain
111+
dwAction == URLACTION_ALLOW_AUDIO_VIDEO || // allow audio and video always
112+
dwAction == URLACTION_ALLOW_AUDIO_VIDEO_PLUGINS ||
113+
dwAction == URLACTION_ALLOW_CROSSDOMAIN_DROP_WITHIN_WINDOW || // allow crossdomain, again
114+
dwAction == URLACTION_ALLOW_CROSSDOMAIN_DROP_ACROSS_WINDOWS ||
115+
dwAction == URLACTION_ALLOW_CROSSDOMAIN_APPCACHE_MANIFEST ||
116+
dwAction == URLACTION_ALLOW_RENDER_LEGACY_DXTFILTERS) { // allow DX transforms
117+
return S_OK;
118+
}
119+
// default zone setting for any other action
120+
return INET_E_DEFAULT_ACTION;
121+
}
122+
123+
int InternetInterfaces.IInternetSecurityManager.QueryCustomPolicy([MarshalAs(UnmanagedType.LPWStr)] string pwszUrl, ref Guid guidKey, ref byte ppPolicy, ref uint pcbPolicy, ref byte pContext, uint cbContext, uint dwReserved) {
124+
return INET_E_DEFAULT_ACTION;
125+
}
126+
127+
int InternetInterfaces.IInternetSecurityManager.SetZoneMapping(uint dwZone, [MarshalAs(UnmanagedType.LPWStr)] string lpszPattern, uint dwFlags) {
128+
return INET_E_DEFAULT_ACTION;
129+
}
130+
131+
int InternetInterfaces.IInternetSecurityManager.GetZoneMappings(uint dwZone, out IEnumString ppenumString, uint dwFlags) {
132+
ppenumString = null;
133+
return INET_E_DEFAULT_ACTION;
134+
}
135+
}
136+
}

FlashpointSecurePlayer/FlashpointSecurePlayer.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@
7777
</ItemGroup>
7878
<ItemGroup>
7979
<Compile Include="ActiveXControl.cs" />
80+
<Compile Include="CustomSecurityManager.cs" />
8081
<Compile Include="DownloadsBefore.cs" />
82+
<Compile Include="InternetInterfaces.cs" />
8183
<Compile Include="ModeTemplates.cs" />
8284
<Compile Include="EnvironmentVariables.cs" />
8385
<Compile Include="FlashpointSecurePlayer.cs">

0 commit comments

Comments
 (0)