private bool ReloadPaths() { PathManager pathManager = new PathManager(); var list = pathManager.GetAllPaths(); bool result = DevIoCore.IoRemoveAllPathsFromProtection(); this.paths.Clear(); this.sessions.Clear(); if (result) { foreach (var path in list) { uint uniqueKey; result = this.SafeAddPathForProtection(path.Key, path.Value, out uniqueKey); if (result) { this.paths.Add(uniqueKey, path.Key); } else { break; } } } return(result); }
private bool SafeAddPathForProtection(string path, bool weakProtection, out uint uniqueKey) { string physicalPath; bool result = DevIoCore.LogicalPathToPhysical(path, out physicalPath); if (!result) { uniqueKey = 0; return(false); } return(DevIoCore.IoAddPathForProtection(physicalPath, weakProtection, out uniqueKey)); }
protected override void OnStart(string[] args) { try { DevIoCore.IoStartService(); AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler; this.channel.Open(); this.ReloadPaths(); } catch (Exception e) { HandleException(e); } /* todo protect driver file */ }
private object OnRemovePathFromProtection(object message) { var packet = ( RemovePathFromProtectionMessage )message; var ret = new OperationResult(); if (!this.CheckSession(packet.SessionKey)) { ret.Value = false; return(ret); } bool removeResult; bool result = DevIoCore.IoRemovePathFromProtection(packet.UniqueKey, out removeResult); if (result && removeResult) { string path = this.GetPathByUniqueKey(packet.UniqueKey); if (path != null) { PathManager pathManager = new PathManager(); result = pathManager.DeletePath(path); } else { ret.Value = false; return(ret); } } if (result && removeResult) { result = this.paths.Remove(packet.UniqueKey); } ret.Value = result && removeResult; return(ret); }