/// <summary>Starts FileWall driver service and connects to minifilter port.</summary> public virtual void Start() { if (driverSC.Status != ServiceControllerStatus.Running && driverSC.Status != ServiceControllerStatus.Stopped) { throw new NotSupportedException("FileWall driver have unsupported state - " + driverSC.Status + ". Try again later."); } if (IsRunning) { throw new InvalidOperationException("Driver already started. Stop it first."); } if (driverSC.Status == ServiceControllerStatus.Stopped) { driverSC.Start(); driverSC.WaitForStatus(ServiceControllerStatus.Running); } var hr = fltLib.FilterConnectCommunicationPort("\\FileWallPort", 0, IntPtr.Zero, 0, IntPtr.Zero, out portHandle); Marshal.ThrowExceptionForHR(hr); //if (PortHandle.ToInt32() == -1) // throw new ApplicationException("Invalid handle."); }
public void Start() { if (IsStarted) { throw new InvalidOperationException("Service is already started."); } _SC.Start(); _SC.WaitForStatus(ServiceControllerStatus.Running); // Get fresh service interface. ServiceInterface = _ServiceInterfaceManager.GetMarshalledInteface(); OnStarted(); }