Exemplo n.º 1
0
        /// <summary>
        /// Initialize a Silo to a Server Silo.
        /// </summary>
        /// <param name="delete_event">Event to signal when silo deleted.</param>
        /// <param name="downlevel_container">True if a downlevel container.</param>
        /// <param name="throw_on_error">True to throw on error.</param>
        /// <returns>The NT status code.</returns>
        /// <remarks>You must have set a system root and added a \Device directory (which shadows the real directory) to the silo object directory.</remarks>
        public NtStatus InitializeServerSilo(NtEvent delete_event, bool downlevel_container, bool throw_on_error)
        {
            ServerSiloInitInformation init = new ServerSiloInitInformation()
            {
                DeleteEvent          = delete_event?.Handle.DangerousGetHandle() ?? IntPtr.Zero,
                IsDownlevelContainer = downlevel_container
            };

            return(Set(JobObjectInformationClass.JobObjectServerSiloInitialize, init, throw_on_error));
        }
        /// <summary>
        /// Initialize a Silo to a Server Silo.
        /// </summary>
        /// <param name="delete_event">Event to signal when silo deleted.</param>
        /// <param name="downlevel_container">True if a downlevel container.</param>
        /// <param name="throw_on_error">True to throw on error.</param>
        /// <returns>The NT status code.</returns>
        /// <remarks>You must have set a system root and added a \Device directory (which shadows the real directory) to the silo object directory.</remarks>
        public NtStatus InitializeServerSilo(NtEvent delete_event, bool downlevel_container, bool throw_on_error)
        {
            IntPtr event_handle            = delete_event?.Handle.DangerousGetHandle() ?? IntPtr.Zero;
            ServerSiloInitInformation init = new ServerSiloInitInformation()
            {
                DeleteEvent          = event_handle,
                IsDownlevelContainer = downlevel_container
            };

            var status = Set(JobObjectInformationClass.JobObjectServerSiloInitialize, init, false);

            if (!status.IsSuccess())
            {
                if (status != NtStatus.STATUS_INFO_LENGTH_MISMATCH)
                {
                    return(status.ToNtException(throw_on_error));
                }
                return(Set(JobObjectInformationClass.JobObjectServerSiloInitialize, event_handle, throw_on_error));
            }
            return(status);
        }