Changeset 2288
- Timestamp:
- 1/4/2011 5:23:07 AM (2 years ago)
- Location:
- branches/eraser6/pluginsRewrite
- Files:
-
- 2 added
- 5 edited
-
Eraser.Manager/ManagerLibrary.cs (modified) (4 diffs)
-
Eraser.Manager/Settings.cs (modified) (2 diffs)
-
Eraser.Plugins/Eraser.Plugins.csproj (modified) (2 diffs)
-
Eraser.Plugins/PluginLoadEventArgs.cs (added)
-
Eraser.Plugins/PluginLoadedEventArgs.cs (added)
-
Eraser.Plugins/Plugins.cs (modified) (6 diffs)
-
Eraser.Plugins/Properties/AssemblyInfo.cs (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eraser6/pluginsRewrite/Eraser.Manager/ManagerLibrary.cs
r2286 r2288 24 24 using System.Text; 25 25 using System.Runtime.Serialization; 26 27 using Eraser.Plugins; 28 using Eraser.Util; 26 29 27 30 namespace Eraser.Manager … … 62 65 { 63 66 EntropySourceRegistrar.Poller.Abort(); 64 Host. Dispose();67 Host.Instance.Dispose(); 65 68 SettingsManager.Save(); 66 69 } … … 74 77 Dispose(true); 75 78 GC.SuppressFinalize(this); 79 } 80 81 private void OnPluginLoad(object sender, PluginLoadEventArgs e) 82 { 83 //If the plugin does not have an approval or denial, check for the presence of 84 //a valid signature. 85 IDictionary<Guid, bool> approvals = ManagerLibrary.Settings.PluginApprovals; 86 if (!approvals.ContainsKey(e.Plugin.AssemblyInfo.Guid) && 87 (e.Plugin.Assembly.GetName().GetPublicKey().Length == 0 || 88 !Security.VerifyStrongName(e.Plugin.Assembly.Location) || 89 e.Plugin.AssemblyAuthenticode == null)) 90 { 91 e.Load = false; 92 } 93 94 //Is there an approval or denial? 95 else if (approvals.ContainsKey(e.Plugin.AssemblyInfo.Guid)) 96 e.Load = approvals[e.Plugin.AssemblyInfo.Guid]; 97 98 //There's no approval or denial, what is the specified loading policy? 99 else 100 e.Load = e.Plugin.LoadingPolicy != LoadingPolicy.DefaultOff; 76 101 } 77 102 … … 129 154 /// </summary> 130 155 private static ManagerSettings settingsInstance; 131 132 /// <summary>133 /// The global instance of the Plugin host.134 /// </summary>135 internal Plugin.DefaultHost Host;136 156 } 137 157 } -
branches/eraser6/pluginsRewrite/Eraser.Manager/Settings.cs
r2013 r2288 25 25 using System.Reflection; 26 26 using System.Runtime.InteropServices; 27 using System.Globalization; 28 27 29 using Eraser.Util; 28 using System.Globalization;30 using Eraser.Plugins; 29 31 30 32 namespace Eraser.Manager … … 374 376 375 377 //We have not computed the value. Compute the default. 376 Plugin.Host pluginHost = ManagerLibrary.Instance.Host;377 IList<Plugin .PluginInstance> plugins = pluginHost.Plugins;378 Host pluginHost = Host.Instance; 379 IList<PluginInstance> plugins = pluginHost.Plugins; 378 380 SortedList<int, Guid> priorities = new SortedList<int, Guid>(); 379 381 380 foreach (Plugin .PluginInstance plugin in plugins)382 foreach (PluginInstance plugin in plugins) 381 383 { 382 384 //Check whether the plugin is signed by us. -
branches/eraser6/pluginsRewrite/Eraser.Plugins/Eraser.Plugins.csproj
r2286 r2288 13 13 <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> 14 14 <FileAlignment>512</FileAlignment> 15 <SignAssembly>true</SignAssembly> 16 <AssemblyOriginatorKeyFile>..\Strong Name.snk</AssemblyOriginatorKeyFile> 15 17 </PropertyGroup> 16 18 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> … … 49 51 <Compile Include="IConfigurer.cs" /> 50 52 <Compile Include="IRegistrar.cs" /> 53 <Compile Include="PluginLoadedEventArgs.cs" /> 54 <Compile Include="PluginLoadEventArgs.cs" /> 51 55 <Compile Include="Plugins.cs" /> 52 56 <Compile Include="Properties\AssemblyInfo.cs" /> -
branches/eraser6/pluginsRewrite/Eraser.Plugins/Plugins.cs
r2286 r2288 32 32 33 33 using Eraser.Util; 34 35 namespace Eraser.Manager.Plugin 34 using Eraser.Util.ExtensionMethods; 35 using Path = System.IO.Path; 36 37 namespace Eraser.Plugins 36 38 { 37 39 /// <summary> … … 94 96 95 97 /// <summary> 98 /// The plugin load event, allowing clients to decide whether to load 99 /// the given plugin. 100 /// </summary> 101 public EventHandler<PluginLoadEventArgs> PluginLoad { get; set; } 102 103 /// <summary> 96 104 /// The plugin loaded event. 97 105 /// </summary> … … 116 124 /// and return True.</remarks> 117 125 public abstract bool LoadPlugin(string filePath); 118 }119 120 /// <summary>121 /// Event argument for the plugin loaded event.122 /// </summary>123 public class PluginLoadedEventArgs : EventArgs124 {125 /// <summary>126 /// Constructor.127 /// </summary>128 /// <param name="instance">The plugin instance of the recently loaded plugin.</param>129 public PluginLoadedEventArgs(PluginInstance instance)130 {131 Instance = instance;132 }133 134 /// <summary>135 /// The <see cref="PluginInstance"/> object representing the newly loaded plugin.136 /// </summary>137 public PluginInstance Instance { get; private set; }138 126 } 139 127 … … 308 296 plugins.Add(instance); 309 297 310 //If the plugin does not have an approval or denial, check for the presence of 311 //a valid signature. 312 IDictionary<Guid, bool> approvals = ManagerLibrary.Settings.PluginApprovals; 313 if (!approvals.ContainsKey(instance.AssemblyInfo.Guid) && 314 (reflectAssembly.GetName().GetPublicKey().Length == 0 || 315 !Security.VerifyStrongName(filePath) || 316 instance.AssemblyAuthenticode == null)) 317 { 318 return false; 319 } 320 321 //Preliminary checks to verify whether the plugin can be loaded (safely) passes, 322 //Load the assembly fully, and then initialise it. 323 instance.Assembly = Assembly.Load(reflectAssembly.GetName()); 324 325 //The plugin either is explicitly allowed or disallowed to load, or 326 //it has an Authenticode Signature as well as a Strong Name. Get the 327 //loading policy of the plugin. 328 { 329 330 } 331 332 bool initialisePlugin = false; 333 334 //Is there an approval or denial? 335 if (approvals.ContainsKey(instance.AssemblyInfo.Guid)) 336 initialisePlugin = approvals[instance.AssemblyInfo.Guid]; 337 338 //There's no approval or denial, what is the specified loading policy? 339 else 340 initialisePlugin = instance.LoadingPolicy != LoadingPolicy.DefaultOff; 341 342 if (initialisePlugin) 298 PluginLoadEventArgs e = new PluginLoadEventArgs(instance); 299 PluginLoad(this, e); 300 if (PluginLoad == null || e.Load) 343 301 { 344 302 InitialisePlugin(instance); … … 353 311 /// </summary> 354 312 /// <param name="instance">The <see cref="PluginInstance"/> structure to fill.</param> 313 /// <exception cref="System.IO.FileLoadException" /> 355 314 private void InitialisePlugin(PluginInstance instance) 356 315 { … … 373 332 catch (System.Security.SecurityException e) 374 333 { 375 MessageBox.Show(S._("Could not load the plugin {0}.\n\nThe error returned was: {1}", 376 instance.Assembly.Location, e.Message), S._("Eraser"), MessageBoxButtons.OK, 377 MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, 378 Localisation.IsRightToLeft(null) ? 379 MessageBoxOptions.RtlReading | MessageBoxOptions.RightAlign : 0); 334 throw new FileLoadException(S._("Could not load the plugin."), 335 instance.Assembly.Location, e); 380 336 } 381 337 } -
branches/eraser6/pluginsRewrite/Eraser.Plugins/Properties/AssemblyInfo.cs
r2286 r2288 22 22 // The following GUID is for the ID of the typelib if this project is exposed to COM 23 23 [assembly: Guid("1c4e0bd3-4272-4cc8-9fb6-d0e0703b2013")] 24 25 // Version information for an assembly consists of the following four values:26 //27 // Major Version28 // Minor Version29 // Build Number30 // Revision31 //32 // You can specify all the values or you can default the Build and Revision Numbers33 // 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")]
Note: See TracChangeset
for help on using the changeset viewer.
