Coder Social home page Coder Social logo

hhnl.processisolation's Introduction

hhnl.ProcessIsolation

A .net library to start isolated processes.

Nuget

Eventhough this is a .net standard project, only windows is currently supported. Processes are run inside an appcontainer which restricts network, file and windows access.

Example:

IProcessIsolator isolator = new AppContainerIsolator()
isolator.StartIsolatedProcess("MyIsolatedProcess", "c:\\windows\\notepad.exe", makeApplicationDirectoryReadable: false);

This should open notepad. If you try to open a file with "File => Open" you should get an error "Access denied". See https://docs.microsoft.com/en-us/windows/win32/secauthz/appcontainer-isolation for more information.

Remarks:

By default the application will be granted read access to the folder the executable is in.

If you want to prevent this behaviour because the application does not need acces or the current user has no permission to that folder, you can suppress the behaviour by setting 'makeApplicationDirectoryReadable: false'.

It is included in this example because changing the permissions of 'c:\windows' requires admin privileges by default.

Allow network access:

using hhnl.ProcessIsolation.Windows;

// Allows internet and local network access
isolator.StartIsolatedProcess("MyIsolatedProcess", "myapp.exe", networkPermissions: NetworkPermissions.Internet | NetworkPermissions.LocalNetwork);

Allow file access:

using System;
using hhnl.ProcessIsolation.Windows;

// Allows read and write access to the desktop
var desktopPath = Environment.ExpandEnvironmentVariables("%userprofile%\\Desktop");
var desktopFileAccess = new FileAccess(desktopPath, FileAccess.Right.Read | FileAccess.Right.Write);

isolator.StartIsolatedProcess("MyIsolatedProcess", "myapp.exe", fileAccess: new[] { desktopFileAccess });

Attach child process:

By default the create process will be attached to the current process. This will cause the new process to be closed once the current process is close. To prevent this behaviour you can set attachToCurrentProcess = false

hhnl.processisolation's People

Contributors

anhaehne avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.