コード例 #1
0
        public void Lockdown(PrisonRules prisonRules)
        {
            if (this.isLocked)
            {
                throw new InvalidOperationException("This prison is already locked.");
            }

            Logger.Debug("Locking down prison {0}", this.ID);

            Directory.CreateDirectory(prisonRules.PrisonHomePath);

            this.prisonRules = prisonRules;

            if (prisonRules.CellType != RuleType.None)
            {
                foreach (Type cellType in cellTypes)
                {
                    Rule cell = (Rule)cellType.GetConstructor(Type.EmptyTypes).Invoke(null);
                    if (CellEnabled(cell.GetFlag()))
                    {
                        prisonCells.Add(cell);
                    }
                }
            }

            // Create the Windows User
            this.user = new PrisonUser(this.Tag);
            this.user.Create();

            // InitializeSystemVirtualAddressSpaceQuotas();

            this.InitializeJobObject();

            // Lock all cells
            foreach (Rule cell in this.prisonCells)
            {
                if (cell.GetFlag() != RuleType.WindowStation)
                {
                    cell.Apply(this);
                }
            }

            this.CreateUserProfile();

            // Directory.CreateDirectory(prisonRules.PrisonHomePath);
            this.ChangeProfilePath(Path.Combine(prisonRules.PrisonHomePath, "profile"));

            // RunGuard();

            this.isLocked = true;

            this.Save();
        }
コード例 #2
0
ファイル: Prison.cs プロジェクト: solakian/windows-isolation
        public void Lockdown(PrisonRules prisonRules)
        {
            if (this.isLocked)
            {
                throw new InvalidOperationException("This prison is already locked.");
            }

            Logger.Debug("Locking down prison {0}", this.ID);

            Directory.CreateDirectory(prisonRules.PrisonHomePath);

            this.prisonRules = prisonRules;

            if (prisonRules.CellType != RuleType.None)
            {
                foreach (Type cellType in cellTypes)
                {
                    Rule cell = (Rule)cellType.GetConstructor(Type.EmptyTypes).Invoke(null);
                    if (CellEnabled(cell.GetFlag()))
                    {
                        prisonCells.Add(cell);
                    }
                }
            }

            // Create the Windows User
            this.user = new PrisonUser(this.Tag);
            this.user.Create();

            // InitializeSystemVirtualAddressSpaceQuotas();

            this.InitializeJobObject();

            // Lock all cells
            foreach (Rule cell in this.prisonCells)
            {
                if (cell.GetFlag() != RuleType.WindowStation)
                {
                    cell.Apply(this);
                }
            }

            this.CreateUserProfile();

            // Directory.CreateDirectory(prisonRules.PrisonHomePath);
            this.ChangeProfilePath(Path.Combine(prisonRules.PrisonHomePath, "profile"));

            // RunGuard();

            this.isLocked = true;

            this.Save();
        }