Plugin system - GoldRenard/DMOAdvancedLauncher GitHub Wiki
Plugin system
SDK Library
The common shared SDK library is AdvancedLauncherSDK. It includes all service interfaces, some common abstract implementations of these interfaces and common model classes/entities. Plugins are just simple .NET Framework class libraries that references to this library and contains classes that implements IPlugin interface.
Online documentation of SDK is available here (generated by doxygen).
Main namespaces
- AdvancedLauncher.SDK.Management - contains common interfaces of public services
- AdvancedLauncher.SDK.Model - contains common model classes/entities used for communication with the application
- AdvancedLauncher.SDK.UI - contains UI controls for windows and pages
Initialization pipeline
Every application start runs PluginManager internal service that goes through the following steps:
- Scans
%APPLICATION_ROOT%/Pluginsfolder for dlls - Scans each loaded dll for types with implemented IPlugin interface.
- Initializes each type that was found:
- Validates Strong-Name of plugin assembly
- Grants CAS permissions to plugin based on result of Strong-Name validation:
- Full Trust permission set in case that it have valid Strong-Name with exactly the same PublicKey token of launcher's Strong-Name.
- Partial Trust in other cases. The full set of permissions is listed on the following section
- Creates new AppDomain for this plugin with granted permissions
- Instantiates the plugin in this AppDomain
- Calls the
void OnActivate(IPluginHost PluginHost)plugin method that should do its work (menu item registration, event listeners, etc).- Do not forget to implement
void OnStop(IPluginHost PluginHost)method that clears resources associated with plugin (removes menu items, unregisters event listeners, etc). - Manual plugin stop/start actions are implemented as
pluginconsole command. UI will be implemented in future releases.
- Do not forget to implement
Partial trust permissions list
| Permission name | Flags | Note |
|---|---|---|
| UIPermission | AllWindows, NoClipboard | Full UI access without user clipboard |
| WebPermission | Unrestricted | Full web access |
| WebBrowserPermission | Unrestricted | Full internal web browser access |
| ReflectionPermission | NoFlags | Plugins are able to access only visible members |
| SecurityPermission | Execution, SerializationFormatter, Assertion | Execution and serialization support. Service implementations may assert some plugin calls |
| FileIOPermission | PathDiscovery, Read | FileSystem access only for application's BaseDirectory and resource folder (read-only) |
| FileIOPermission | PathDiscovery, Read, Write | FileSystem full access only for 3rd-party launcher's resources (EnvironmentManager.Resources3rdPath or %APPDATA%\GoldRenard\AdvancedLauncher\Resources) |
How to get Full Trust permission access
We won't give Full Trust access by default to plugins in order to prevent any malicious actions by not-authorized plugins. Nobody wants to allow the unknown plugins to do anything they want on the host computer. Really.
Full Trust access is given to plugins that was signed with my own release private key. If your plugin implements a very nice and useful feature that requires Full Trust access, contact the author.
Simple plugin example
Please take a look at this project.