![]() |
|
[.NET] Safe Plugin Architecture [Imports ,Jailed, IO Limited, Plugin Communications] - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [.NET] Safe Plugin Architecture [Imports ,Jailed, IO Limited, Plugin Communications] (/showthread.php?tid=5750678) |
Safe Plugin Architecture [Imports ,Jailed, IO Limited, Plugin Communications] - Barret - Nov 10, 2017 So i started with some side projects with plugin architecture and decided to write an entire new proper plugin model basis. This base does all of the former projects (except remote assemblies for the time being) and makes use of jailing (sandboxed), controlled read/write/ACL (https://msdn.microsoft.com/en-us/library/ms229742(v=vs.90).aspx), and being able to import plugin(s) inside the domain from another plugin so they can interact with each other. ![]() In this demo one assembly containing the exported types (can be separate assemblies ofc), the first one tests the read/write on local folder and then on C:\ the second one attempts to import the first plugin that has a specific interface on it, and once its imported, invokes a method that is defined from this specific interface, this is useful for plugin communications. These interfaces don't need to be defined inside the assembly but can also be separate, the loader will load all assemblies found into the domain. Keep in mind that interfaces work both ways of course. Importing plugins from and to a plugin Inside a plugin, one could import plugins with specific interfaces: Code Dim plugin As CommunicationTest = Me.Parent.Import(Of CommunicationTest)()The interface used in this example Code Public Interface CommunicationTestor if more then one is using that particular interface, Code For Each plug In Me.Parent.ImportAll(Of CommunicationTest)()Setup the base To setup and load plugins from a folder you would approach it like this Code Dim plugins As String = Path.GetFullPath(".\Plugins\")Plugin Base Structure The IContainer is the basis for all plugins that want to be able to use the internal functions of the Loader , the base methods include: Test to see if a plugin can read a specified filename or directory Code Public Function CanRead(path As String) As Boolean Implements IContainer.CanReadTest to see if a plugin can write a specified filename or directory Code Public Function CanWrite(path As String) As Boolean Implements IContainer.CanWriteTest to see if a plugin can do a specified action for that filename or directory Code Public Function Access(path As String, rights As FileSystemRights) As Boolean Implements IContainer.AccessAccess the parent (loader) that contains the Import/ImportAll methods and Assembly collection Code Public ReadOnly Property Parent As ILoader Implements IContainer.ParentGet the current base directory where the plugin resides in Code Public ReadOnly Property BaseDirectory As String Implements IContainer.BaseDirectoryChanges will be made along the way, for suggestions or questions post them in here. RE: Safe Plugin Architecture [Imports ,Jailed, IO Limited, Plugin Communications] - StaPol - Nov 11, 2017 Not bad! Here is the converted source for CSharp... Link: anonfile(.)com/dbG0Ufcdb3/CSharp-PluginLoader(.)rar Password: TheBarret RE: Safe Plugin Architecture [Imports ,Jailed, IO Limited, Plugin Communications] - Barret - Nov 11, 2017 (Nov 11, 2017 08:21 AM)StaPol Wrote: Not bad! Here is the converted source for CSharp... The conversion is nice but it seems the IDE you are using left some personal info in some of the files. RE: Safe Plugin Architecture [Imports ,Jailed, IO Limited, Plugin Communications] - StaPol - Nov 11, 2017 (Nov 11, 2017 08:47 AM)Barret Wrote: The conversion is nice but it seems the IDE you are using left some personal info in some of the files. I upload a new archive :) |