public EventWaitHandleAccessRule
				(String identity,
				 EventWaitHandleRights eventRights,
				 AccessControlType type)
			: base(IdentityReference.IdentityFromName(identity),
				   (int)eventRights, false, InheritanceFlags.None,
				   PropagationFlags.None, type) {}
        public static EventWaitHandle OpenExisting(string name, EventWaitHandleRights rights)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name", Environment.GetResourceString("ArgumentNull_WithParamName"));
            }
            if (name.Length == 0)
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "name");
            }
            if ((name != null) && (260 < name.Length))
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_WaitHandleNameTooLong", new object[] { name }));
            }
            SafeWaitHandle handle = Win32Native.OpenEvent((int)rights, false, name);

            if (handle.IsInvalid)
            {
                int errorCode = Marshal.GetLastWin32Error();
                if ((2 == errorCode) || (0x7b == errorCode))
                {
                    throw new WaitHandleCannotBeOpenedException();
                }
                if (((name != null) && (name.Length != 0)) && (6 == errorCode))
                {
                    throw new WaitHandleCannotBeOpenedException(Environment.GetResourceString("Threading.WaitHandleCannotBeOpenedException_InvalidHandle", new object[] { name }));
                }
                __Error.WinIOError(errorCode, "");
            }
            return(new EventWaitHandle(handle));
        }
示例#3
0
        static public EventWaitHandle CreateWaitHandle(string id, bool initState, EventResetMode resetMode, bool allowEveryone)
        {
            //EventResetMode.AutoReset: Set()後,不管有無進入WaitOne(),馬上被自動reset
            EventWaitHandle eventWaitHandle;
            bool            createNew;

            if (allowEveryone)
            {   //避免跨Process因權限不足產生WinIOError (Access to the path 'id' is denied.)
                // create a rule that allows anybody in the "Users" group to synchronise with us
                //var users = new SecurityIdentifier(WellKnownSidType.BuiltinUsersSid, null);

                EventWaitHandleSecurity   evhSec        = new EventWaitHandleSecurity();
                EventWaitHandleRights     rights        = EventWaitHandleRights.FullControl;// EventWaitHandleRights.Synchronize | EventWaitHandleRights.Modify;
                EventWaitHandleAccessRule evhAccessRule = new EventWaitHandleAccessRule("Everyone", rights, AccessControlType.Allow);
                evhSec.AddAccessRule(evhAccessRule);
                eventWaitHandle = new EventWaitHandle(initState, resetMode, id, out createNew);
                //eventWaitHandle.SetAccessControl(evhSec);
            }
            else
            {
                eventWaitHandle = new EventWaitHandle(initState, resetMode, id, out createNew);
            }

            return(eventWaitHandle);
        }
        public EventWaitHandleAuditRule(IdentityReference identity,
                                        EventWaitHandleRights eventRights,
                                        AuditFlags flags)
            : base(identity, 0, false, InheritanceFlags.None, PropagationFlags.None, flags)
        {
            if (eventRights < EventWaitHandleRights.Modify ||
                eventRights > EventWaitHandleRights.FullControl)
            {
                throw new ArgumentOutOfRangeException("eventRights");
            }
            if (flags < AuditFlags.None ||
                flags > AuditFlags.Failure)
            {
                throw new ArgumentOutOfRangeException("flags");
            }
            if (identity == null)
            {
                throw new ArgumentNullException("identity");
            }
            if (eventRights == 0)
            {
                throw new ArgumentNullException("eventRights");
            }
            if (flags == AuditFlags.None)
            {
                throw new ArgumentException("flags");
            }
            if (!(identity is SecurityIdentifier))
            {
                throw new ArgumentException("identity");
            }

            this.rights = eventRights;
        }
		public EventWaitHandleAccessRule (IdentityReference identity,
						  EventWaitHandleRights eventRights,
						  AccessControlType type)
			: base (identity, (int)eventRights, false,
				InheritanceFlags.None, PropagationFlags.None, AccessControlType.Allow)
		{
		}
示例#6
0
		public EventWaitHandleAuditRule (IdentityReference identity,
						 EventWaitHandleRights eventRights,
						 AuditFlags flags)
			: base (identity, 0, false, InheritanceFlags.None, PropagationFlags.None, flags)
		{
			if (eventRights < EventWaitHandleRights.Modify ||
			    eventRights > EventWaitHandleRights.FullControl) {
				throw new ArgumentOutOfRangeException ("eventRights");
			}
			if (flags < AuditFlags.None ||
			    flags > AuditFlags.Failure) {
				throw new ArgumentOutOfRangeException ("flags");
			}
			if (identity == null) {
				throw new ArgumentNullException ("identity");
			}
			if (eventRights == 0) {
				throw new ArgumentNullException ("eventRights");
			}
			if (flags == AuditFlags.None) {
				throw new ArgumentException ("flags");
			}
			if (!(identity is SecurityIdentifier)) {
				throw new ArgumentException ("identity");
			}
			
			this.rights = eventRights;
		}
        private static OpenExistingResult OpenExistingWorker(string name, EventWaitHandleRights rights, out EventWaitHandle?result)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (name.Length == 0)
            {
                throw new ArgumentException(SR.Argument_EmptyName, nameof(name));
            }

            result = null;
            SafeWaitHandle existingHandle = Interop.Kernel32.OpenEvent((uint)rights, false, name);

            int errorCode = Marshal.GetLastWin32Error();

            if (existingHandle.IsInvalid)
            {
                return(errorCode switch
                {
                    Interop.Errors.ERROR_FILE_NOT_FOUND or Interop.Errors.ERROR_INVALID_NAME => OpenExistingResult.NameNotFound,
                    Interop.Errors.ERROR_PATH_NOT_FOUND => OpenExistingResult.PathNotFound,
                    Interop.Errors.ERROR_INVALID_HANDLE => OpenExistingResult.NameInvalid,
                    _ => throw Win32Marshal.GetExceptionForWin32Error(errorCode, name)
                });
示例#8
0
        private static OpenExistingResult OpenExistingWorker(string name, EventWaitHandleRights rights, out EventWaitHandle result)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name", Environment.GetResourceString("ArgumentNull_WithParamName"));
            }

            if (name.Length == 0)
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "name");
            }

            if (null != name && System.IO.Path.MAX_PATH < name.Length)
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_WaitHandleNameTooLong", name));
            }

            Contract.EndContractBlock();

            result = null;

#if MOBILE
            throw new NotSupportedException();
#else
#if MONO
            int errorCode;
            var myHandle = new SafeWaitHandle(NativeEventCalls.OpenEvent_internal(name, rights, out errorCode), true);
#else
#if FEATURE_MACL
            SafeWaitHandle myHandle = Win32Native.OpenEvent((int)rights, false, name);
#else
            SafeWaitHandle myHandle = Win32Native.OpenEvent(Win32Native.EVENT_MODIFY_STATE | Win32Native.SYNCHRONIZE, false, name);
#endif
#endif

            if (myHandle.IsInvalid)
            {
#if !MONO
                int errorCode = Marshal.GetLastWin32Error();
#endif

                if (Win32Native.ERROR_FILE_NOT_FOUND == errorCode || Win32Native.ERROR_INVALID_NAME == errorCode)
                {
                    return(OpenExistingResult.NameNotFound);
                }
                if (Win32Native.ERROR_PATH_NOT_FOUND == errorCode)
                {
                    return(OpenExistingResult.PathNotFound);
                }
                if (null != name && 0 != name.Length && Win32Native.ERROR_INVALID_HANDLE == errorCode)
                {
                    return(OpenExistingResult.NameInvalid);
                }
                //this is for passed through Win32Native Errors
                __Error.WinIOError(errorCode, "");
            }
            result = new EventWaitHandle(myHandle);
            return(OpenExistingResult.Success);
#endif
        }
示例#9
0
        public static EventWaitHandle OpenExisting(string name, EventWaitHandleRights rights)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if ((name.Length == 0) ||
                (name.Length > 260))
            {
                throw new ArgumentException("name", Locale.GetText("Invalid length [1-260]."));
            }

            MonoIOError error;
            IntPtr      handle = NativeEventCalls.OpenEvent_internal(name, rights, out error);

            if (handle == (IntPtr)null)
            {
                if (error == MonoIOError.ERROR_FILE_NOT_FOUND)
                {
                    throw new WaitHandleCannotBeOpenedException(Locale.GetText("Named Event handle does not exist: ") + name);
                }
                else if (error == MonoIOError.ERROR_ACCESS_DENIED)
                {
                    throw new UnauthorizedAccessException();
                }
                else
                {
                    throw new IOException(Locale.GetText("Win32 IO error: ") + error.ToString());
                }
            }

            return(new EventWaitHandle(handle));
        }
示例#10
0
 public EventWaitHandleAccessRule(IdentityReference identity,
                                  EventWaitHandleRights eventRights,
                                  AccessControlType type)
     : base(identity, (int)eventRights, false,
            InheritanceFlags.None, PropagationFlags.None, AccessControlType.Allow)
 {
 }
示例#11
0
        private EventWaitHandleSecurity CreateSecurity(EventWaitHandleRights eventRights)
        {
            EventWaitHandleSecurity security = null;

            // When "running as user", we have to grant the target user permissions to the objects (events and file mapping) explicitly
            if (!string.IsNullOrEmpty(_session.ExecutableProcessUserName))
            {
                security = new EventWaitHandleSecurity();
                IdentityReference si;
                try
                {
                    si = new NTAccount(_session.ExecutableProcessUserName);
                }
                catch (Exception e)
                {
                    throw _logger.WriteException(new SessionLocalException(_session, string.Format(CultureInfo.CurrentCulture, "Error resolving account {0}", _session.ExecutableProcessUserName), e));
                }

                EventWaitHandleAccessRule rule =
                    new EventWaitHandleAccessRule(
                        si, eventRights, AccessControlType.Allow);
                security.AddAccessRule(rule);
            }

            return(security);
        }
示例#12
0
 // Constructor.
 public EventWaitHandleAuditRule
     (IdentityReference identity,
     EventWaitHandleRights eventRights,
     AuditFlags auditFlags)
     : base(identity, (int)eventRights, false,
            InheritanceFlags.None, PropagationFlags.None, auditFlags)
 {
 }
示例#13
0
		public EventWaitHandleAccessRule (IdentityReference identity,
						  EventWaitHandleRights eventRights,
						  AccessControlType type)
			// FIXME: accessMask=0 likely causes an error
			: base (identity, 0, false, InheritanceFlags.None, PropagationFlags.None, AccessControlType.Allow)
		{
			this.rights = eventRights;
		}
示例#14
0
 public EventWaitHandleAccessRule(IdentityReference identity,
                                  EventWaitHandleRights eventRights,
                                  AccessControlType type)
 // FIXME: accessMask=0 likely causes an error
     : base(identity, 0, false, InheritanceFlags.None, PropagationFlags.None, AccessControlType.Allow)
 {
     this.rights = eventRights;
 }
示例#15
0
 public EventWaitHandleAccessRule
     (String identity,
     EventWaitHandleRights eventRights,
     AccessControlType type)
     : base(IdentityReference.IdentityFromName(identity),
            (int)eventRights, false, InheritanceFlags.None,
            PropagationFlags.None, type)
 {
 }
		public EventWaitHandleAuditRule (IdentityReference identity,
						 EventWaitHandleRights eventRights,
						 AuditFlags flags)
			: base (identity, (int)eventRights, false, InheritanceFlags.None, PropagationFlags.None, flags)
		{
			if (eventRights < EventWaitHandleRights.Modify ||
			    eventRights > EventWaitHandleRights.FullControl) {
				throw new ArgumentOutOfRangeException ("eventRights");
			}
		}
示例#17
0
 public EventWaitHandleAuditRule(IdentityReference identity,
                                 EventWaitHandleRights eventRights,
                                 AuditFlags flags)
     : base(identity, (int)eventRights, false, InheritanceFlags.None, PropagationFlags.None, flags)
 {
     if (eventRights < EventWaitHandleRights.Modify ||
         eventRights > EventWaitHandleRights.FullControl)
     {
         throw new ArgumentOutOfRangeException("eventRights");
     }
 }
示例#18
0
        private static OpenExistingResult OpenExistingWorker(string name, EventWaitHandleRights rights, out EventWaitHandle result)
        {
#if PLATFORM_UNIX
            throw new PlatformNotSupportedException(SR.PlatformNotSupported_NamedSynchronizationPrimitives);
#else
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name), SR.ArgumentNull_WithParamName);
            }

            if (name.Length == 0)
            {
                throw new ArgumentException(SR.Argument_EmptyName, nameof(name));
            }

            if (null != name && System.IO.Path.MaxPath < name.Length)
            {
                throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, Path.MaxPath), nameof(name));
            }

            Contract.EndContractBlock();

            result = null;

            SafeWaitHandle myHandle = Win32Native.OpenEvent(AccessRights, false, name);

            if (myHandle.IsInvalid)
            {
                int errorCode = Marshal.GetLastWin32Error();

                if (Win32Native.ERROR_FILE_NOT_FOUND == errorCode || Win32Native.ERROR_INVALID_NAME == errorCode)
                {
                    return(OpenExistingResult.NameNotFound);
                }
                if (Win32Native.ERROR_PATH_NOT_FOUND == errorCode)
                {
                    return(OpenExistingResult.PathNotFound);
                }
                if (null != name && 0 != name.Length && Win32Native.ERROR_INVALID_HANDLE == errorCode)
                {
                    return(OpenExistingResult.NameInvalid);
                }
                //this is for passed through Win32Native Errors
                __Error.WinIOError(errorCode, "");
            }
            result = new EventWaitHandle(myHandle);
            return(OpenExistingResult.Success);
#endif
        }
示例#19
0
        /// <summary>
        /// Opens a specified named event wait handle, if it already exists, applying the desired access rights.
        /// </summary>
        /// <param name="name">The name of the event wait handle to be opened. If it's prefixed by "Global", it refers to a machine-wide event wait handle. If it's prefixed by "Local", or doesn't have a prefix, it refers to a session-wide event wait handle. Both prefix and name are case-sensitive.</param>
        /// <param name="rights">The desired access rights to apply to the returned event wait handle.</param>
        /// <returns>An existing named event wait handle.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="name"/> is <see langword="null" />.</exception>
        /// <exception cref="ArgumentException"><paramref name="name"/> is an empty string.</exception>
        /// <exception cref="WaitHandleCannotBeOpenedException">The named event wait handle does not exist or is invalid.</exception>
        /// <exception cref="DirectoryNotFoundException">The path was not found.</exception>
        /// <exception cref="IOException">A Win32 error occurred.</exception>
        /// <exception cref="UnauthorizedAccessException">The named event wait handle exists, but the user does not have the security access required to use it.</exception>
        public static EventWaitHandle OpenExisting(string name, EventWaitHandleRights rights)
        {
            switch (OpenExistingWorker(name, rights, out EventWaitHandle? result))
            {
            case OpenExistingResult.NameNotFound:
                throw new WaitHandleCannotBeOpenedException();

            case OpenExistingResult.NameInvalid:
                throw new WaitHandleCannotBeOpenedException(SR.Format(SR.Threading_WaitHandleCannotBeOpenedException_InvalidHandle, name));

            case OpenExistingResult.PathNotFound:
                throw new DirectoryNotFoundException(SR.Format(SR.IO_PathNotFound_Path, name));

            case OpenExistingResult.Success:
            default:
                Debug.Assert(result != null, "result should be non-null on success");
                return(result);
            }
        }
示例#20
0
        internal static EventWaitHandle OpenExisting(string name, EventWaitHandleRights rights)
        {
            EventWaitHandle result;

            switch (OpenExistingWorker(name, rights, out result))
            {
            case OpenExistingResult.NameNotFound:
                throw new WaitHandleCannotBeOpenedException();

            case OpenExistingResult.NameInvalid:
                throw new WaitHandleCannotBeOpenedException(SR.Format(SR.Threading_WaitHandleCannotBeOpenedException_InvalidHandle, name));

            case OpenExistingResult.PathNotFound:
                throw Win32Marshal.GetExceptionForWin32Error(Interop.Errors.ERROR_PATH_NOT_FOUND, "");

            default:
                return(result);
            }
        }
示例#21
0
        public static EventWaitHandle OpenExisting(string name, EventWaitHandleRights rights)
        {
            EventWaitHandle result;

            switch (OpenExistingWorker(name, rights, out result))
            {
            case OpenExistingResult.NameNotFound:
                throw new WaitHandleCannotBeOpenedException();

            case OpenExistingResult.NameInvalid:
                throw new WaitHandleCannotBeOpenedException(Environment.GetResourceString("Threading.WaitHandleCannotBeOpenedException_InvalidHandle", name));

            case OpenExistingResult.PathNotFound:
                __Error.WinIOError(Win32Native.ERROR_PATH_NOT_FOUND, "");
                return(result);    //never executes

            default:
                return(result);
            }
        }
示例#22
0
        public static EventWaitHandle OpenExisting(string name, EventWaitHandleRights rights)
        {
            EventWaitHandle result;

            switch (EventWaitHandle.OpenExistingWorker(name, rights, out result))
            {
            case WaitHandle.OpenExistingResult.NameNotFound:
                throw new WaitHandleCannotBeOpenedException();

            case WaitHandle.OpenExistingResult.PathNotFound:
                __Error.WinIOError(3, "");
                return(result);

            case WaitHandle.OpenExistingResult.NameInvalid:
                throw new WaitHandleCannotBeOpenedException(Environment.GetResourceString("Threading.WaitHandleCannotBeOpenedException_InvalidHandle", (object)name));

            default:
                return(result);
            }
        }
示例#23
0
        private static OpenExistingResult OpenExistingWorker(string name, EventWaitHandleRights rights, out EventWaitHandle result)
        {
#if PLATFORM_WINDOWS
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            if (name.Length == 0)
            {
                throw new ArgumentException(SR.Argument_EmptyName, nameof(name));
            }

            result = null;
            SafeWaitHandle myHandle = Win32Native.OpenEvent(AccessRights, false, name);

            if (myHandle.IsInvalid)
            {
                int errorCode = Marshal.GetLastWin32Error();

                if (Interop.Errors.ERROR_FILE_NOT_FOUND == errorCode || Interop.Errors.ERROR_INVALID_NAME == errorCode)
                {
                    return(OpenExistingResult.NameNotFound);
                }
                if (Interop.Errors.ERROR_PATH_NOT_FOUND == errorCode)
                {
                    return(OpenExistingResult.PathNotFound);
                }
                if (null != name && 0 != name.Length && Interop.Errors.ERROR_INVALID_HANDLE == errorCode)
                {
                    return(OpenExistingResult.NameInvalid);
                }
                //this is for passed through Win32Native Errors
                throw Win32Marshal.GetExceptionForWin32Error(errorCode, "");
            }
            result = new EventWaitHandle(myHandle);
            return(OpenExistingResult.Success);
#else
            throw new PlatformNotSupportedException(SR.PlatformNotSupported_NamedSynchronizationPrimitives);
#endif
        }
        private static WaitHandle.OpenExistingResult OpenExistingWorker(string name, EventWaitHandleRights rights, out EventWaitHandle result)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name", Environment.GetResourceString("ArgumentNull_WithParamName"));
            }
            if (name.Length == 0)
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "name");
            }
            if (name != null && 260 < name.Length)
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_WaitHandleNameTooLong", new object[]
                {
                    name
                }));
            }
            result = null;
            SafeWaitHandle safeWaitHandle = Win32Native.OpenEvent((int)rights, false, name);

            if (safeWaitHandle.IsInvalid)
            {
                int lastWin32Error = Marshal.GetLastWin32Error();
                if (2 == lastWin32Error || 123 == lastWin32Error)
                {
                    return(WaitHandle.OpenExistingResult.NameNotFound);
                }
                if (3 == lastWin32Error)
                {
                    return(WaitHandle.OpenExistingResult.PathNotFound);
                }
                if (name != null && name.Length != 0 && 6 == lastWin32Error)
                {
                    return(WaitHandle.OpenExistingResult.NameInvalid);
                }
                __Error.WinIOError(lastWin32Error, "");
            }
            result = new EventWaitHandle(safeWaitHandle);
            return(WaitHandle.OpenExistingResult.Success);
        }
示例#25
0
        public static bool TryOpenExisting(string name, EventWaitHandleRights rights,
                                           out EventWaitHandle result)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if ((name.Length == 0) || (name.Length > 260))
            {
                throw new ArgumentException("name", Locale.GetText("Invalid length [1-260]."));
            }

            MonoIOError error;
            IntPtr      handle = NativeEventCalls.OpenEvent_internal(name, rights, out error);

            if (handle == (IntPtr)null)
            {
                result = null;
                return(false);
            }

            result = new EventWaitHandle(handle);
            return(true);
        }
 public EventWaitHandleAccessRule(IdentityReference identity, EventWaitHandleRights eventRights, AccessControlType type);
 public EventWaitHandleAuditRule(IdentityReference identity, EventWaitHandleRights eventRights, AuditFlags flags);
示例#28
0
		public EventWaitHandleAccessRule (string identity,
						  EventWaitHandleRights eventRights,
						  AccessControlType type)
			: this (new SecurityIdentifier (identity), eventRights, type)
		{
		}
示例#29
0
 public static bool TryOpenExisting(string name, EventWaitHandleRights rights, out EventWaitHandle result)
 {
     return(OpenExistingWorker(name, rights, out result) == OpenExistingResult.Success);
 }
示例#30
0
 public static EventWaitHandle OpenExisting(string name, EventWaitHandleRights rights)
 {
     if (name == null)
     {
         throw new ArgumentNullException("name", Environment.GetResourceString("ArgumentNull_WithParamName"));
     }
     if (name.Length == 0)
     {
         throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "name");
     }
     if ((name != null) && (260 < name.Length))
     {
         throw new ArgumentException(Environment.GetResourceString("Argument_WaitHandleNameTooLong", new object[] { name }));
     }
     SafeWaitHandle handle = Win32Native.OpenEvent((int) rights, false, name);
     if (handle.IsInvalid)
     {
         int errorCode = Marshal.GetLastWin32Error();
         if ((2 == errorCode) || (0x7b == errorCode))
         {
             throw new WaitHandleCannotBeOpenedException();
         }
         if (((name != null) && (name.Length != 0)) && (6 == errorCode))
         {
             throw new WaitHandleCannotBeOpenedException(Environment.GetResourceString("Threading.WaitHandleCannotBeOpenedException_InvalidHandle", new object[] { name }));
         }
         __Error.WinIOError(errorCode, "");
     }
     return new EventWaitHandle(handle);
 }
 public static EventWaitHandle OpenExisting(string name, EventWaitHandleRights rights);
        private static OpenExistingResult OpenExistingWorker(string name, EventWaitHandleRights rights, out EventWaitHandle result)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name", Environment.GetResourceString("ArgumentNull_WithParamName"));
            }

            if(name.Length  == 0)
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "name");
            }

            if(null != name && System.IO.Path.MAX_PATH < name.Length)
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_WaitHandleNameTooLong",name));
            }
            
            Contract.EndContractBlock();

            result = null;

#if FEATURE_MACL
            SafeWaitHandle myHandle = Win32Native.OpenEvent((int) rights, false, name);
#else
            SafeWaitHandle myHandle = Win32Native.OpenEvent(Win32Native.EVENT_MODIFY_STATE | Win32Native.SYNCHRONIZE, false, name);
#endif
            
            if (myHandle.IsInvalid)
            {
                int errorCode = Marshal.GetLastWin32Error();

                if(Win32Native.ERROR_FILE_NOT_FOUND == errorCode || Win32Native.ERROR_INVALID_NAME == errorCode)
                    return OpenExistingResult.NameNotFound;
                if (Win32Native.ERROR_PATH_NOT_FOUND == errorCode)
                    return OpenExistingResult.PathNotFound;
                if(null != name && 0 != name.Length && Win32Native.ERROR_INVALID_HANDLE == errorCode)
                    return OpenExistingResult.NameInvalid;
                //this is for passed through Win32Native Errors
                __Error.WinIOError(errorCode,"");
            }
            result = new EventWaitHandle(myHandle);
            return OpenExistingResult.Success;
        }
示例#33
0
		public static EventWaitHandle OpenExisting (string name, EventWaitHandleRights rights)
		{
			throw new NotSupportedException (); 
		}
 public EventWaitHandleAccessRule(System.Security.Principal.IdentityReference identity, EventWaitHandleRights eventRights, AccessControlType type) : base (default(System.Security.Principal.IdentityReference), default(int), default(bool), default(InheritanceFlags), default(PropagationFlags), default(AccessControlType))
 {
 }
 public static bool TryOpenExisting(string name, EventWaitHandleRights rights, out EventWaitHandle result)
 {
     return OpenExistingWorker(name, rights, out result) == OpenExistingResult.Success;
 }
示例#36
0
 public static EventWaitHandle OpenExisting(string name, EventWaitHandleRights rights)
 {
     throw new NotSupportedException();
 }
示例#37
0
 public EventWaitHandleAuditRule(IdentityReference identity, EventWaitHandleRights eventRights, AuditFlags flags)
     : this(identity, (int)eventRights, false, InheritanceFlags.None, PropagationFlags.None, flags)
 {
 }
示例#38
0
 public EventWaitHandleAccessRule(String identity, EventWaitHandleRights eventRights, AccessControlType type)
     : this(new NTAccount(identity), (int)eventRights, false, InheritanceFlags.None, PropagationFlags.None, type)
 {
 }
 public IAutoResetEvent OpenExisting(string name, EventWaitHandleRights rights)
 {
     return new AutoResetEventWrap(AutoResetEvent.OpenExisting(name, rights) as AutoResetEvent);
 }
 public EventWaitHandleAccessRule(string identity, EventWaitHandleRights eventRights, AccessControlType type) : base (default(System.Security.Principal.IdentityReference), default(int), default(bool), default(InheritanceFlags), default(PropagationFlags), default(AccessControlType))
 {
   Contract.Ensures(0 <= identity.Length);
   Contract.Ensures(identity.Length <= 512);
 }
		public static IntPtr OpenEvent_internal (string name, EventWaitHandleRights rights, out MonoIOError error)
		{
			throw new System.NotImplementedException();
		}
		public EventWaitHandleAccessRule (string identity,
						  EventWaitHandleRights eventRights,
						  AccessControlType type)
			: this (new NTAccount (identity), eventRights, type)
		{
		}
示例#43
0
		public static bool TryOpenExisting (string name, EventWaitHandleRights rights,
		                                    out EventWaitHandle result)
		{
			throw new NotSupportedException (); 
		}
示例#44
0
 public static extern IntPtr OpenEvent_internal(string name, EventWaitHandleRights rights, out MonoIOError error);
 public static bool TryOpenExisting(string name, EventWaitHandleRights rights, out EventWaitHandle result);
 // Constructors
 public EventWaitHandleAccessRule(System.Security.Principal.IdentityReference identity, EventWaitHandleRights eventRights, AccessControlType type)
 {
 }
 /// <summary>Initializes a new instance of the <see cref="T:System.Security.AccessControl.EventWaitHandleAccessRule" /> class, specifying the name of the user or group the rule applies to, the access rights, and whether the specified access rights are allowed or denied.</summary><param name="identity">The name of the user or group the rule applies to.</param><param name="eventRights">A bitwise combination of <see cref="T:System.Security.AccessControl.EventWaitHandleRights" /> values specifying the rights allowed or denied.</param><param name="type">One of the <see cref="T:System.Security.AccessControl.AccessControlType" /> values specifying whether the rights are allowed or denied.</param><exception cref="T:System.ArgumentOutOfRangeException"><paramref name="eventRights" /> specifies an invalid value.-or-<paramref name="type" /> specifies an invalid value.</exception><exception cref="T:System.ArgumentNullException"><paramref name="eventRights" /> is zero.</exception><exception cref="T:System.ArgumentException"><paramref name="identity" /> is null.-or-<paramref name="identity" /> is a zero-length string.-or-<paramref name="identity" /> is longer than 512 characters.</exception>
 public EventWaitHandleAccessRule(string identity, EventWaitHandleRights eventRights, AccessControlType type)
     : base(null, 0, false, InheritanceFlags.None, PropagationFlags.None, AccessControlType.Allow)
 {
     throw new NotImplementedException();
 }
 public EventWaitHandleAccessRule(string identity, EventWaitHandleRights eventRights, AccessControlType type)
 {
 }
 public EventWaitHandleAuditRule(System.Security.Principal.IdentityReference identity, EventWaitHandleRights eventRights, AuditFlags flags) : base (default(System.Security.Principal.IdentityReference), default(int), default(bool), default(InheritanceFlags), default(PropagationFlags), default(AuditFlags))
 {
 }
	// Constructors
	public EventWaitHandleAuditRule(System.Security.Principal.IdentityReference identity, EventWaitHandleRights eventRights, AuditFlags flags) {}
	// Constructors
	public EventWaitHandleAccessRule(System.Security.Principal.IdentityReference identity, EventWaitHandleRights eventRights, AccessControlType type) {}
示例#52
0
		public static extern IntPtr OpenEvent_internal (string name, EventWaitHandleRights rights, out int errorCode);
 public EventWaitHandleAccessRule(string identity, EventWaitHandleRights eventRights, AccessControlType type);
示例#54
0
 public EventWaitHandleAccessRule(string identity, EventWaitHandleRights eventRights, AccessControlType type)
     : this(new NTAccount(identity), (int)eventRights, false, InheritanceFlags.None, PropagationFlags.None, type)
 {
 }
示例#55
0
		public static EventWaitHandle OpenExisting (string name, EventWaitHandleRights rights)
		{
			if (name == null) {
				throw new ArgumentNullException ("name");
			}
			if ((name.Length == 0) ||
			    (name.Length > 260)) {
				throw new ArgumentException ("name", Locale.GetText ("Invalid length [1-260]."));
			}
			
			MonoIOError error;
			IntPtr handle = NativeEventCalls.OpenEvent_internal (name, rights, out error);
			if (handle == (IntPtr)null) {
				if (error == MonoIOError.ERROR_FILE_NOT_FOUND) {
					throw new WaitHandleCannotBeOpenedException (Locale.GetText ("Named Event handle does not exist: ") + name);
				} else if (error == MonoIOError.ERROR_ACCESS_DENIED) {
					throw new UnauthorizedAccessException ();
				} else {
					throw new IOException (Locale.GetText ("Win32 IO error: ") + error.ToString ());
				}
			}
			
			return(new EventWaitHandle (handle));
		}
示例#56
0
		public static bool TryOpenExisting (string name, EventWaitHandleRights rights,
		                                    out EventWaitHandle result)
		{
			if (name == null) {
				throw new ArgumentNullException ("name");
			}
			if ((name.Length == 0) || (name.Length > 260)) {
				throw new ArgumentException ("name", Locale.GetText ("Invalid length [1-260]."));
			}
			
			MonoIOError error;
			IntPtr handle = NativeEventCalls.OpenEvent_internal (name, rights, out error);
			if (handle == (IntPtr)null) {
				result = null;
				return false;
			}

			result = new EventWaitHandle (handle);
			return true;
		}
        public static EventWaitHandle OpenExisting(string name, EventWaitHandleRights rights)
        {
            EventWaitHandle result;
            switch (OpenExistingWorker(name, rights, out result))
            {
                case OpenExistingResult.NameNotFound:
                    throw new WaitHandleCannotBeOpenedException();

                case OpenExistingResult.NameInvalid:
                    throw new WaitHandleCannotBeOpenedException(Environment.GetResourceString("Threading.WaitHandleCannotBeOpenedException_InvalidHandle", name));

                case OpenExistingResult.PathNotFound:
                    __Error.WinIOError(Win32Native.ERROR_PATH_NOT_FOUND, "");
                    return result; //never executes

                default:
                    return result;
            }
        }
		public static extern IntPtr OpenEvent_internal (string name, EventWaitHandleRights rights, out MonoIOError error);
示例#59
0
 public static bool TryOpenExisting(string name, EventWaitHandleRights rights,
                                    out EventWaitHandle result)
 {
     throw new NotSupportedException();
 }
示例#60
0
        public static EventWaitHandle OpenExisting(string name, EventWaitHandleRights rights) 
        { 
            if (name == null)
            { 
                throw new ArgumentNullException("name", Environment.GetResourceString("ArgumentNull_WithParamName"));
            }

            if(name.Length  == 0) 
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "name"); 
            } 

            if(null != name && System.IO.Path.MAX_PATH < name.Length) 
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_WaitHandleNameTooLong",name));
            }
 
            Contract.EndContractBlock();
 
#if !FEATURE_PAL && FEATURE_MACL 
            SafeWaitHandle myHandle = Win32Native.OpenEvent((int) rights, false, name);
#else 
            SafeWaitHandle myHandle = Win32Native.OpenEvent(Win32Native.EVENT_MODIFY_STATE | Win32Native.SYNCHRONIZE, false, name);
#endif

            if (myHandle.IsInvalid) 
            {
                int errorCode = Marshal.GetLastWin32Error(); 
 
                if(Win32Native.ERROR_FILE_NOT_FOUND == errorCode || Win32Native.ERROR_INVALID_NAME == errorCode)
                    throw new WaitHandleCannotBeOpenedException(); 
                if(null != name && 0 != name.Length && Win32Native.ERROR_INVALID_HANDLE == errorCode)
                    throw new WaitHandleCannotBeOpenedException(Environment.GetResourceString("Threading.WaitHandleCannotBeOpenedException_InvalidHandle",name));
                //this is for passed through Win32Native Errors
                __Error.WinIOError(errorCode,""); 
            }
            return new EventWaitHandle(myHandle); 
        }