示例#1
0
        /// <summary>
        /// Sets UI restrictions.
        /// </summary>
        /// <param name="uiRestrictionsClass">The restriction class for the UI.</param>
        public void SetUiRestrictions(JOB_OBJECT_UILIMIT_FLAGS uiRestrictionsClass = JOB_OBJECT_UILIMIT_FLAGS.ALL)
        {
            this.tracer.Trace(nameof(JobObject), "Setting UI restrictions");

            var uiRestrictions = new JOBOBJECT_BASIC_UI_RESTRICTIONS
            {
                UIRestrictionsClass = uiRestrictionsClass,
            };

            using (var nativeUiRestrictions = new SafeHGlobalBuffer(Marshal.SizeOf(typeof(JOBOBJECT_BASIC_UI_RESTRICTIONS))))
            {
                Marshal.StructureToPtr(
                    uiRestrictions,
                    nativeUiRestrictions.DangerousGetHandle(),
                    false /* fDeleteOld */);

                if (!Methods.SetInformationJobObject(
                    this.handle,
                    JOB_OBJECT_INFO_CLASS.JobObjectBasicUIRestrictions,
                    nativeUiRestrictions.DangerousGetHandle(),
                    nativeUiRestrictions.Size))
                {
                    throw
                        new SandboxException(
                            "Unable to set job object basic ui restrictions",
                            new Win32Exception());
                }
            }
        }
示例#2
0
        public void SetUIRestrictions(JobObjectUILimit limits)
        {
            var restriction = new JOBOBJECT_BASIC_UI_RESTRICTIONS
            {
                UIRestrictionsClass = limits
            };

            if (!NativeMethods.SetInformationJobObject(this, JobObjectInfoClass.BasicUIRestrictions, ref restriction, Marshal.SizeOf <JOBOBJECT_BASIC_UI_RESTRICTIONS>()))
            {
                var err = Marshal.GetLastWin32Error();
                throw new Win32Exception(err);
            }
        }
示例#3
0
 internal static extern bool QueryInformationJobObject(SafeJobObjectHandle hJob, JobObjectInformationClass JobObjectInfoClass, [Out] out JOBOBJECT_BASIC_UI_RESTRICTIONS lpJobObjectInfo, int cbJobObjectInfoLength, IntPtr lpReturnLength);
示例#4
0
 internal static extern bool SetInformationJobObject(SafeJobObjectHandle hJob, JobObjectInformationClass JobObjectInfoClass, [In] ref JOBOBJECT_BASIC_UI_RESTRICTIONS lpJobObjectInfo, int cbJobObjectInfoLength);