Limit execution of a dynamically loaded assembly

I am building a board game with the ability to add a custom user bot. Behavior and decisions The bot is defined in accordance with the interface:

public interface IBotPlayer 
{
    .....

    void Init(); 

    PlayResult Play(TableState tableState) ; 

    ..... 
}

Other users can implement this interface in an external assembly, which I dynamically load in my main application.

Assembly assembly = Assembly.LoadFile("externalLib.dll");

foreach (var botPlayerType in assembly.GetTypes().Where(t => t.IsClass && t.IsAssignableFrom(typeof(IBotPlayer)))
{
    ..........

    // Execution on a new thread th
    // Now I wanna run it in some kind of sandbox with very limited right, no disk access, no network, ...

     IBotPlayer botPlayer = Activator.CreateInstance<IBotPlayer>(botPlayerType); 
     botPlayer.Init() ;     

     ........
}
  • As if the implementation IBotPlayershould be only algorithmic, is it possible to limit the executable stream only to the use of collections, for example? ** If so, how ?
+4
source share
1 answer

This answer is exactly what you need! fooobar.com/questions/638124 / ...

, . Sandboxer DLL .

+1

Source: https://habr.com/ru/post/1546998/


All Articles