protected static extern NativeService CreateService(
     NativeServiceManager hSCManager,
     string lpServiceName,
     string lpDisplayName,
     ServiceRights dwDesiredAccess,
     ServiceType dwServiceType,
     ServiceStartType dwStartType,
     ServiceErrorControl dwErrorControl,
     string lpBinaryPathName,
     string lpLoadOrderGroup,
     IntPtr lpdwTagId,
     string lpDependencies,
     string lpServiceStartName,
     string lpPassword
 );
 protected static extern NativeService OpenService(
     NativeServiceManager hSCManager,
     string lpServiceName,
     ServiceRights dwDesiredAccess
 );
        public NativeService CreateService(string name, string displayname, string cmdline, ServiceRights rights)
        {
            if (!(this.IsInvalid || this.IsClosed))
            {
                Logger.Log(LogLevel.Debug, "CreateService({0},{1},{2},{3},{4})", this.handle, name, displayname, cmdline, rights);
                NativeService service = CreateService(this, name, displayname, rights, ServiceType.OwnProcess, ServiceStartType.AutoStart, ServiceErrorControl.Normal, cmdline, null, IntPtr.Zero, null, null, null);

                if (service.IsClosed || service.IsInvalid)
                {
                    Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
                }

                return service;
            }
            else
            {
                throw new ObjectDisposedException("NativeServiceManager");
            }
        }
 public NativeService OpenService(string name, ServiceRights rights)
 {
     if (!(this.IsInvalid || this.IsClosed))
     {
         NativeService service = OpenService(this, name, rights);
         if (service.IsClosed || service.IsInvalid)
         {
             Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
         }
         return service;
     }
     else
     {
         throw new ObjectDisposedException("NativeServiceManager");
     }
 }
 private static extern IntPtr OpenService(IntPtr hSCManager, string
 lpServiceName, ServiceRights dwDesiredAccess);
        public NativeService CreateService(string name, string displayname, string cmdline, ServiceRights rights, ServiceStartType starttype = ServiceStartType.AutoStart)
        {
            if (!(this.IsInvalid || this.IsClosed))
            {
                NativeService service = CreateService(this, name, displayname, rights, ServiceType.OwnProcess, starttype, ServiceErrorControl.Normal, cmdline, null, IntPtr.Zero, null, null, null);

                if (service.IsClosed || service.IsInvalid)
                {
                    Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
                }

                return service;
            }
            else
            {
                throw new ObjectDisposedException("NativeServiceManager");
            }
        }
 public ServiceAccessRule(string identity, ServiceRights serviceRights, AccessControlType type)
     : this(new NTAccount(identity), serviceRights, type)
 {
 }
 private static extern IntPtr CreateService(IntPtr hSCManager, string
 lpServiceName, string lpDisplayName, ServiceRights dwDesiredAccess, int
 dwServiceType, ServiceBootFlag dwStartType, ServiceError dwErrorControl,
 string lpBinaryPathName, string lpLoadOrderGroup, IntPtr lpdwTagId, string
 lpDependencies, string lp, string lpPassword);
Example #9
0
 private static extern IntPtr OpenService(IntPtr hSCManager, string
                                          lpServiceName, ServiceRights dwDesiredAccess);
 public ServiceAccessRule(IdentityReference identity, ServiceRights serviceRights, AccessControlType type)
     : base(identity, (int)serviceRights, false, InheritanceFlags.None, PropagationFlags.None, type)
 {
 }
Example #11
0
 private static extern IntPtr CreateService(IntPtr hSCManager, string
                                            lpServiceName, string lpDisplayName, ServiceRights dwDesiredAccess, int
                                            dwServiceType, ServiceBootFlag dwStartType, ServiceError dwErrorControl,
                                            string lpBinaryPathName, string lpLoadOrderGroup, IntPtr lpdwTagId, string
                                            lpDependencies, string lp, string lpPassword);
Example #12
0
        public NativeService CreateService(string name, string displayname, string cmdline, ServiceRights rights)
        {
            if (!(this.IsInvalid || this.IsClosed))
            {
                Logger.Log(LogLevel.Debug, "CreateService({0},{1},{2},{3},{4})", this.handle, name, displayname, cmdline, rights);
                NativeService service = CreateService(this, name, displayname, rights, ServiceType.OwnProcess, ServiceStartType.AutoStart, ServiceErrorControl.Normal, cmdline, null, IntPtr.Zero, null, null, null);

                if (service.IsClosed || service.IsInvalid)
                {
                    Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
                }

                return(service);
            }
            else
            {
                throw new ObjectDisposedException("NativeServiceManager");
            }
        }
Example #13
0
 protected static extern NativeService OpenService(
     NativeServiceManager hSCManager,
     string lpServiceName,
     ServiceRights dwDesiredAccess
     );
 /// <summary>
 /// Initializes a new instance of the <see cref="ServiceAuditRule"/> class.
 /// </summary>
 /// <param name="identity">The identity.</param>
 /// <param name="serviceRights">The service rights.</param>
 /// <param name="type">The type.</param>
 public ServiceAuditRule(string identity, ServiceRights serviceRights, AuditFlags type)
     : this(new NTAccount(identity), serviceRights, type)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ServiceAuditRule"/> class.
 /// </summary>
 /// <param name="identity">The identity.</param>
 /// <param name="serviceRights">The service rights.</param>
 /// <param name="type">The type.</param>
 public ServiceAuditRule(IdentityReference identity, ServiceRights serviceRights, AuditFlags type)
     : base(identity, (int)serviceRights, false, InheritanceFlags.None, PropagationFlags.None, type)
 {
 }