├── .gitignore ├── Dominator.Net ├── DSL.cs ├── Dominator.Net.csproj ├── Model.cs ├── Properties │ └── AssemblyInfo.cs ├── Specification.cs └── State.cs ├── Dominator.Tests ├── Dominator.Tests.csproj ├── HostsTests.cs ├── Properties │ └── AssemblyInfo.cs ├── ServiceTests.cs ├── hosts.txt ├── packages.config ├── skype-ads.txt └── watson.txt ├── Dominator.Windows10 ├── App.config ├── Dominator.Windows10.csproj ├── Localization │ ├── Application.Designer.cs │ ├── Application.de.resx │ └── Application.resx ├── MultilingualResources │ └── Dominator.Windows10.de.xlf ├── Program.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Settings.Designer.cs │ └── Settings.settings ├── Settings │ ├── All.cs │ ├── Annoyances.cs │ ├── Localization │ │ ├── Settings.Designer.cs │ │ ├── Settings.de.resx │ │ └── Settings.resx │ ├── Optional.cs │ ├── Privacy.cs │ ├── ToolsIntegration.cs │ ├── skype-ads.txt │ └── telemetry.txt ├── Tools │ ├── DPI.cs │ ├── DedicatedThreadDispatcher.cs │ ├── DisposeAction.cs │ ├── HostEntry.cs │ ├── HostLine.cs │ ├── HostsTools.cs │ ├── Localization │ │ ├── Tools.Designer.cs │ │ ├── Tools.de.resx │ │ └── Tools.resx │ ├── ServiceConfiguration.cs │ ├── ServiceTools.cs │ └── SoftSynchronization.cs ├── UI.cs ├── UIController.cs ├── app.manifest ├── hammer.ico └── packages.config ├── Dominator.sln ├── Makefile └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | bin/ 2 | obj/ 3 | /.vs/ 4 | /_NCrunch_*/ 5 | *.ncrunchsolution 6 | *.ncrunchproject 7 | *.user 8 | /packages/ 9 | -------------------------------------------------------------------------------- /Dominator.Net/DSL.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | 5 | namespace Dominator.Net 6 | { 7 | public static class DSL 8 | { 9 | public static GroupBuilder BeginGroup(string title) 10 | { 11 | return new GroupBuilder(null, title); 12 | } 13 | } 14 | 15 | public class GroupBuilder 16 | { 17 | public GroupBuilder(GroupBuilder parent_, string title) 18 | { 19 | _parent_ = parent_; 20 | _title = title; 21 | } 22 | 23 | readonly GroupBuilder _parent_; 24 | readonly string _title; 25 | string _explanation_; 26 | readonly List _nested = new List(); 27 | 28 | public ItemBuilder BeginItem(string title) 29 | { 30 | return new ItemBuilder(this, title); 31 | } 32 | 33 | public GroupBuilder BeginGroup(string title) 34 | { 35 | return new GroupBuilder(this, title); 36 | } 37 | 38 | public GroupBuilder Explanation(string explanation) 39 | { 40 | _explanation_ = explanation; 41 | return this; 42 | } 43 | 44 | public GroupBuilder End() 45 | { 46 | if (_parent_ == null) 47 | throw new InvalidOperationException($"{_title}: can't end root"); 48 | _parent_.AddNested(Specification()); 49 | return _parent_; 50 | } 51 | 52 | public IDominator Specification() 53 | { 54 | // it comes in handy to allow zero nested items when building new dominators. 55 | // if (_nested.Count == 0) 56 | // throw new InvalidOperationException($"{_title}: no nested dominators"); 57 | 58 | var description = new DominatorDescription(_title, _explanation_ ?? ""); 59 | 60 | var dominator = new Group(description, _nested.ToArray()); 61 | return dominator; 62 | } 63 | 64 | internal void AddNested(IDominator dominator) 65 | { 66 | _nested.Add(dominator); 67 | } 68 | } 69 | 70 | public class ItemBuilder 71 | { 72 | internal ItemBuilder(GroupBuilder parent, string title) 73 | { 74 | _parent = parent; 75 | _title = title; 76 | } 77 | 78 | readonly GroupBuilder _parent; 79 | readonly string _title; 80 | string _explanation_; 81 | More? _more_; 82 | 83 | Action _setter_; 84 | Func _getter_; 85 | 86 | public ItemBuilder Explanation(string explanation) 87 | { 88 | _explanation_ = explanation; 89 | return this; 90 | } 91 | 92 | public ItemBuilder More(Action action, string info = "") 93 | { 94 | _more_ = new More(action, info); 95 | return this; 96 | } 97 | 98 | public ItemBuilder Setter(Action setter) 99 | { 100 | _setter_ = setter; 101 | return this; 102 | } 103 | 104 | public ItemBuilder Getter(Func getter) 105 | { 106 | Debug.Assert(_getter_ == null, "Getter can not set twice, use ChainGetter instead"); 107 | _getter_ = getter; 108 | return this; 109 | } 110 | 111 | public ItemBuilder ChainGetter(Func getter) 112 | { 113 | Debug.Assert(_getter_ != null, "There must be a Getter() registered, before a call to ChainGetter()"); 114 | 115 | var previous = _getter_; 116 | _getter_ = () => 117 | { 118 | var state = previous(); 119 | return getter(state); 120 | }; 121 | return this; 122 | } 123 | 124 | public GroupBuilder End() 125 | { 126 | var dominator = Specification(); 127 | _parent.AddNested(dominator); 128 | return _parent; 129 | } 130 | 131 | IDominator Specification() 132 | { 133 | if (_getter_ == null) 134 | throw new InvalidOperationException($"{_title}: missing getter"); 135 | if (_setter_ == null) 136 | throw new InvalidOperationException($"{_title}: missing setter"); 137 | 138 | var description = new DominatorDescription(_title, _explanation_ ?? "", _more_); 139 | var dominator = new Item(description, _getter_, _setter_); 140 | return dominator; 141 | } 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /Dominator.Net/Dominator.Net.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {5510519F-6352-4690-86E5-0FBB1F5B6088} 8 | Library 9 | Properties 10 | Dominator.Net 11 | Dominator.Net 12 | v4.5.2 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 57 | -------------------------------------------------------------------------------- /Dominator.Net/Model.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Dominator.Net 4 | { 5 | sealed class Item : IDominatorItem 6 | { 7 | internal Item( 8 | DominatorDescription description, 9 | Func getter, 10 | Action setter) 11 | { 12 | Description = description; 13 | _getter = getter; 14 | _setter = setter; 15 | } 16 | 17 | readonly Func _getter; 18 | readonly Action _setter; 19 | 20 | public DominatorDescription Description { get; } 21 | 22 | public DominatorState GetState() 23 | { 24 | return _getter(); 25 | } 26 | 27 | public void SetState(DominationAction action) 28 | { 29 | _setter(action); 30 | } 31 | } 32 | 33 | sealed class Group : IDominatorGroup 34 | { 35 | public Group(DominatorDescription description, IDominator[] nested) 36 | { 37 | Description = description; 38 | Nested = nested; 39 | } 40 | 41 | public DominatorDescription Description { get; } 42 | 43 | public IDominator[] Nested { get; } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Dominator.Net/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: AssemblyTitle("Dominator.Net")] 5 | [assembly: AssemblyDescription("")] 6 | [assembly: AssemblyConfiguration("")] 7 | [assembly: AssemblyCompany("")] 8 | [assembly: AssemblyProduct("Dominator.Net")] 9 | [assembly: AssemblyCopyright("Copyright © 2015 Armin Sander")] 10 | [assembly: AssemblyTrademark("")] 11 | [assembly: AssemblyCulture("")] 12 | 13 | [assembly: ComVisible(false)] 14 | 15 | [assembly: Guid("5510519f-6352-4690-86e5-0fbb1f5b6088")] 16 | 17 | [assembly: AssemblyVersion("1.0.0.0")] 18 | [assembly: AssemblyFileVersion("1.0.0.0")] 19 | -------------------------------------------------------------------------------- /Dominator.Net/Specification.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Dominator.Net 4 | { 5 | public enum DominatorStateKind 6 | { 7 | Submissive, 8 | Dominated, 9 | Indetermined 10 | } 11 | 12 | public struct DominatorState 13 | { 14 | DominatorState(DominatorStateKind kind, string message = "") 15 | { 16 | Kind = kind; 17 | Message = message; 18 | } 19 | 20 | public readonly DominatorStateKind Kind; 21 | public readonly string Message; 22 | 23 | public static DominatorState Submissive(string message = "") => new DominatorState(DominatorStateKind.Submissive, message); 24 | public static DominatorState Dominated(string message = "") => new DominatorState(DominatorStateKind.Dominated, message); 25 | public static DominatorState Indetermined(string message) => new DominatorState(DominatorStateKind.Indetermined , message ); 26 | 27 | public DominatorState WithMessage(string message) 28 | { 29 | return new DominatorState(Kind, message); 30 | } 31 | } 32 | 33 | public enum DominationAction 34 | { 35 | Dominate, 36 | MakeSubmissive 37 | } 38 | 39 | public struct More 40 | { 41 | public More(Action action, string info = "") 42 | { 43 | Action = action; 44 | Info = info; 45 | } 46 | 47 | public readonly Action Action; 48 | public readonly string Info; 49 | } 50 | 51 | public struct DominatorDescription 52 | { 53 | public DominatorDescription(string title, string explanation, More? more_ = null) 54 | { 55 | Title = title; 56 | Explanation = explanation; 57 | More_ = more_; 58 | } 59 | 60 | public readonly string Title; 61 | public readonly string Explanation; 62 | public readonly More? More_; 63 | } 64 | 65 | public interface IDominator 66 | { 67 | DominatorDescription Description { get; } 68 | } 69 | 70 | public interface IDominatorItem : IDominator 71 | { 72 | DominatorState GetState(); 73 | void SetState(DominationAction action); 74 | } 75 | 76 | public interface IDominatorGroup : IDominator 77 | { 78 | IDominator[] Nested { get; } 79 | } 80 | 81 | public enum DominatorClass 82 | { 83 | Group, 84 | Item 85 | } 86 | 87 | public static class DominatorExtensions 88 | { 89 | public static void DispatchTo(this IDominator dominator, Action groupHandler, Action itemHandler) 90 | { 91 | var group_ = dominator as IDominatorGroup; 92 | if (group_ != null) 93 | { 94 | groupHandler(group_); 95 | return; 96 | } 97 | 98 | var item_ = dominator as IDominatorItem; 99 | if (item_ != null) 100 | { 101 | itemHandler(item_); 102 | return; 103 | } 104 | 105 | throw new InvalidOperationException(dominator.ToString()); 106 | } 107 | 108 | public static ReturnT DispatchTo(this IDominator dominator, Func groupFunction, Func itemFunction) 109 | { 110 | var group_ = dominator as IDominatorGroup; 111 | if (group_ != null) 112 | return groupFunction(group_); 113 | 114 | var item_ = dominator as IDominatorItem; 115 | if (item_ != null) 116 | return itemFunction(item_); 117 | 118 | throw new InvalidOperationException(dominator.ToString()); 119 | } 120 | 121 | public static DominatorClass classify(this IDominator dominator) 122 | { 123 | return dominator.DispatchTo(_ => DominatorClass.Group, _ => DominatorClass.Item); 124 | } 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /Dominator.Net/State.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace Dominator.Net 6 | { 7 | public struct DominationState 8 | { 9 | public DominationState(DominatorState itemState) 10 | : this(itemState, null, Enumerable.Empty()) 11 | { 12 | } 13 | 14 | public DominationState(Exception error) 15 | : this(DominatorState.Indetermined(""), error, Enumerable.Empty()) 16 | {} 17 | 18 | public DominationState(DominatorState groupState, IEnumerable nested) 19 | : this(groupState, null, nested) 20 | {} 21 | 22 | DominationState(DominatorState? state, Exception error_, IEnumerable nested) 23 | { 24 | State_ = state; 25 | Error_ = error_; 26 | Nested = nested; 27 | } 28 | 29 | public readonly DominatorState? State_; 30 | public readonly Exception Error_; 31 | public readonly IEnumerable Nested; 32 | } 33 | 34 | public static class DominatorStateExtensions 35 | { 36 | public static DominationState QueryState(this IDominator dominator) 37 | { 38 | var item_ = dominator as IDominatorItem; 39 | if (item_ != null) 40 | return QueryItemState(item_); 41 | 42 | var group_ = dominator as IDominatorGroup; 43 | if (group_ != null) 44 | return QueryGroupState(group_); 45 | 46 | throw new InvalidOperationException(dominator.ToString()); 47 | } 48 | 49 | static DominationState QueryItemState(IDominatorItem item) 50 | { 51 | try 52 | { 53 | var state = item.GetState(); 54 | return new DominationState(state); 55 | } 56 | catch (Exception e) 57 | { 58 | return new DominationState(e); 59 | } 60 | } 61 | 62 | static DominationState QueryGroupState(IDominatorGroup group) 63 | { 64 | var nested = group.Nested.Select(QueryState).ToArray(); 65 | var state = CumulativeState(nested.Select(ns => ns.State_)); 66 | return new DominationState(state, nested); 67 | } 68 | 69 | public static DominatorState CumulativeState(this IEnumerable states) 70 | { 71 | var allDominated = states.All(state_ => state_ != null && state_.Value.Kind == DominatorStateKind.Dominated); 72 | if (allDominated) 73 | return DominatorState.Dominated(); 74 | 75 | var allSubmissive = states.All(state_ => state_ != null && state_.Value.Kind == DominatorStateKind.Submissive); 76 | if (allSubmissive) 77 | return DominatorState.Submissive(); 78 | 79 | return DominatorState.Indetermined(""); 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Dominator.Tests/Dominator.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {4437A05C-6AA0-498E-9E74-B73EE66052E6} 8 | Library 9 | Properties 10 | Dominator.Tests 11 | Dominator.Tests 12 | v4.5.2 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | ..\packages\NUnit.2.6.4\lib\nunit.framework.dll 35 | True 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | {682bd86c-1911-46ce-87fe-53381679c08b} 58 | Dominator.Windows10 59 | 60 | 61 | 62 | 63 | PreserveNewest 64 | 65 | 66 | PreserveNewest 67 | 68 | 69 | PreserveNewest 70 | 71 | 72 | 73 | 80 | -------------------------------------------------------------------------------- /Dominator.Tests/HostsTests.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Linq; 3 | using System.Text; 4 | using Dominator.Windows10.Tools; 5 | using NUnit.Framework; 6 | 7 | namespace Dominator.Tests 8 | { 9 | [TestFixture] 10 | public class HostsTests 11 | { 12 | [Test] 13 | public void readHostsFile() 14 | { 15 | var hosts = HostsTools.ReadHostsFile("hosts.txt"); 16 | Assert.That(hosts.Length, Is.EqualTo(90)); 17 | } 18 | 19 | // note NCrunch seems to add BOMs to the text files :(, so we 20 | // ignore this test for now and run it manually with R#. 21 | [Test, Ignore] 22 | public void readingAndWritingHostsFileDoesNotChangeIt() 23 | { 24 | var binaryBefore = File.ReadAllBytes("hosts.txt"); 25 | 26 | var lines = HostsTools.ReadHostsFile("hosts.txt"); 27 | HostsTools.WriteHostsFile("hosts.txt.bak", lines); 28 | 29 | var binaryAfter = File.ReadAllBytes("hosts.txt.bak"); 30 | 31 | CollectionAssert.AreEqual(binaryBefore, binaryAfter); 32 | } 33 | 34 | [Test, Ignore] 35 | public void parsingAndSerializingTheHostsFileDoesNotChangeIt() 36 | { 37 | var binaryBefore = File.ReadAllBytes("hosts.txt"); 38 | 39 | var lines = HostsTools.ReadHostsFile("hosts.txt").SafeParseHostLines(); 40 | HostsTools.WriteHostsFile("hosts.txt.bak", lines.ToLines()); 41 | 42 | var binaryAfter = File.ReadAllBytes("hosts.txt.bak"); 43 | 44 | CollectionAssert.AreEqual(binaryBefore, binaryAfter); 45 | } 46 | 47 | [Test] 48 | public void emptyStringIsEmptyLine() 49 | { 50 | var l = HostLine.Parse(""); 51 | Assert.That(l.Kind, Is.EqualTo(HostLineKind.EmptyLine)); 52 | } 53 | 54 | [Test] 55 | public void spaceIsEmptyLineToo() 56 | { 57 | var l = HostLine.Parse(" "); 58 | Assert.That(l.Kind, Is.EqualTo(HostLineKind.EmptyLine)); 59 | } 60 | 61 | [Test] 62 | public void emptyCommentLine() 63 | { 64 | var l = HostLine.Parse("#"); 65 | Assert.That(l.Kind, Is.EqualTo(HostLineKind.CommentLine)); 66 | Assert.That(l.Comment_, Is.EqualTo("#")); 67 | } 68 | 69 | [Test] 70 | public void commentLine() 71 | { 72 | var l = HostLine.Parse("#hello"); 73 | Assert.That(l.Kind, Is.EqualTo(HostLineKind.CommentLine)); 74 | Assert.That(l.Comment_, Is.EqualTo("#hello")); 75 | } 76 | 77 | [Test] 78 | public void commentLinePreservesWhitespaceBeforeComment() 79 | { 80 | var l = HostLine.Parse("\t #hello"); 81 | Assert.That(l.Kind, Is.EqualTo(HostLineKind.CommentLine)); 82 | Assert.That(l.Comment_, Is.EqualTo("\t #hello")); 83 | } 84 | 85 | [Test] 86 | public void commentAfterIP() 87 | { 88 | var l = HostLine.Parse("0#hello"); 89 | Assert.That(l.Kind, Is.EqualTo(HostLineKind.ParseError)); 90 | // that could be a better error like found no URL, or early comment or what. 91 | Assert.That(l.Error_, Is.EqualTo(HostLineError.NoSpaceOrTabDelimiterFound)); 92 | } 93 | 94 | [Test] 95 | public void ipAndHost() 96 | { 97 | var l = HostLine.Parse("0 1"); 98 | Assert.That(l.Kind, Is.EqualTo(HostLineKind.HostEntry)); 99 | Assert.That(l.Entry_.Value.IP, Is.EqualTo("0")); 100 | Assert.That(l.Entry_.Value.Host, Is.EqualTo("1")); 101 | } 102 | 103 | [Test] 104 | public void ipAndHostWithComment() 105 | { 106 | var l = HostLine.Parse("0 1#hello"); 107 | Assert.That(l.Kind, Is.EqualTo(HostLineKind.HostEntry)); 108 | Assert.That(l.Entry_.Value.IP, Is.EqualTo("0")); 109 | Assert.That(l.Entry_.Value.Host, Is.EqualTo("1")); 110 | Assert.That(l.Comment_, Is.EqualTo("#hello")); 111 | Assert.That(l.Line, Is.EqualTo("0 1#hello")); 112 | } 113 | 114 | [Test] 115 | public void ipAndHostWithMoreWhitespaceInBetween() 116 | { 117 | var l = HostLine.Parse("\t 0\t 1\t"); 118 | Assert.That(l.Kind, Is.EqualTo(HostLineKind.HostEntry)); 119 | Assert.That(l.Entry_.Value.IP, Is.EqualTo("0")); 120 | Assert.That(l.Entry_.Value.Host, Is.EqualTo("1")); 121 | Assert.That(l.Line, Is.EqualTo("\t 0\t 1\t")); 122 | } 123 | 124 | [Test] 125 | public void ipAndHostAndWhitespaceBeforeComment() 126 | { 127 | var l = HostLine.Parse("0 1 #hello"); 128 | Assert.That(l.Kind, Is.EqualTo(HostLineKind.HostEntry)); 129 | Assert.That(l.Entry_.Value.IP, Is.EqualTo("0")); 130 | Assert.That(l.Entry_.Value.Host, Is.EqualTo("1")); 131 | Assert.That(l.Comment_, Is.EqualTo(" #hello")); 132 | } 133 | 134 | [Test] 135 | public void excessCharacters() 136 | { 137 | var line = "0 1 f"; 138 | var l = HostLine.Parse(line); 139 | Assert.That(l.Kind, Is.EqualTo(HostLineKind.ParseError)); 140 | Assert.That(l.Error_.Value, Is.EqualTo(HostLineError.FoundExcessCharactersAfterIPAndHost)); 141 | Assert.That(l.Line, Is.EqualTo(line)); 142 | } 143 | 144 | [Test] 145 | public void parseTestingHostFile() 146 | { 147 | var lines = File.ReadAllLines("hosts.txt", Encoding.ASCII); 148 | Assert.That(lines.Length, Is.EqualTo(90)); 149 | var allComments = lines.Take(17) 150 | .Select(HostLine.Parse) 151 | .Select(hl => hl.Kind) 152 | .All(x => x == HostLineKind.CommentLine); 153 | Assert.True(allComments); 154 | 155 | var emptyLine = 156 | lines.Skip(17).Take(1).Select(HostLine.Parse).Select(hl => hl.Kind).All(x => x == HostLineKind.EmptyLine); 157 | Assert.True(emptyLine); 158 | 159 | // 3 comment lines skippt 160 | 161 | var successfullyParsed = 162 | lines.Skip(18+3).Take(57).Select(HostLine.Parse).Select(hl => hl.Kind).All(x => x == HostLineKind.HostEntry); 163 | Assert.True(successfullyParsed); 164 | 165 | // further empty and some more other lines skipped 166 | } 167 | 168 | [Test] 169 | public void hostsContainsAllWatsonEntries() 170 | { 171 | var lines = HostsTools.ReadHostsFile("hosts.txt").SafeParseHostLines(); 172 | var watson = HostsTools.ReadHostsFile("watson.txt").SafeParseHostLines().ExtractEntries(); 173 | Assert.That(watson.Length, Is.EqualTo(2)); 174 | 175 | var containsWatson = lines.ContainsAllHostEntries(watson); 176 | Assert.True(containsWatson); 177 | } 178 | 179 | [Test] 180 | public void merge() 181 | { 182 | var lines = HostsTools.ReadHostsFile("hosts.txt").SafeParseHostLines(); 183 | var skypeAds = HostsTools.ReadHostsFile("skype-ads.txt").SafeParseHostLines().ExtractEntries(); 184 | Assert.That(skypeAds.Length, Is.EqualTo(9)); 185 | 186 | var containsSkypeAds = lines.ContainsAllHostEntries(skypeAds); 187 | Assert.False(containsSkypeAds); 188 | 189 | // then we merge them (in this case, all entries are replaced, because they have just another IP, none is added). 190 | var merged = lines.Merge(skypeAds); 191 | Assert.That(merged.Length, Is.EqualTo(lines.Length)); 192 | 193 | var containsSkypeAds2 = merged.ContainsAllHostEntries(skypeAds); 194 | Assert.True(containsSkypeAds2); 195 | 196 | // no merge and add one 197 | var newAds = skypeAds.Concat(new[] {new HostEntry("ip", "host")}); 198 | var merged2 = lines.Merge(newAds); 199 | Assert.True(merged2.ContainsAllHostEntries(newAds)); 200 | Assert.That(merged2.Length, Is.EqualTo(merged.Length+1)); 201 | } 202 | 203 | [Test] 204 | public void filter() 205 | { 206 | var lines = HostsTools.ReadHostsFile("hosts.txt").SafeParseHostLines(); 207 | var filtered = lines.FilterHosts(new[] {"watson.live.com", "watson.microsoft.com"}); 208 | Assert.That(filtered.Length, Is.EqualTo(lines.Length-2)); 209 | } 210 | 211 | [Test] 212 | public void emptyFilterFiltersNothing() 213 | { 214 | var lines = HostsTools.ReadHostsFile("hosts.txt").SafeParseHostLines(); 215 | var filtered = lines.FilterHosts(new string[0]); 216 | Assert.That(filtered.Length, Is.EqualTo(lines.Length)); 217 | } 218 | 219 | [Test] 220 | public void duplicatesAreFiltered() 221 | { 222 | var lines = HostsTools.ReadHostsFile("hosts.txt").SafeParseHostLines() 223 | .Concat(HostsTools.ReadHostsFile("hosts.txt").SafeParseHostLines()) 224 | .ToArray(); 225 | var lines2 = lines.FilterHosts(new[] { "watson.live.com", "watson.microsoft.com" }); 226 | Assert.That(lines2.Length, Is.EqualTo(lines.Length-4)); 227 | } 228 | 229 | [Test] 230 | public void hostLineSerializesProperly() 231 | { 232 | var hostLine = new HostLine(HostLineKind.HostEntry, new HostEntry("0.1.2.3", "hostname"), comment_: " # comment"); 233 | Assert.That(hostLine.Line, Is.EqualTo("0.1.2.3 hostname # comment")); 234 | } 235 | } 236 | } 237 | -------------------------------------------------------------------------------- /Dominator.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: AssemblyTitle("Dominator.Tests")] 5 | [assembly: AssemblyDescription("")] 6 | [assembly: AssemblyConfiguration("")] 7 | [assembly: AssemblyCompany("")] 8 | [assembly: AssemblyProduct("Dominator.Tests")] 9 | [assembly: AssemblyCopyright("Copyright © 2015 Armin Sander")] 10 | [assembly: AssemblyTrademark("")] 11 | [assembly: AssemblyCulture("")] 12 | 13 | [assembly: ComVisible(false)] 14 | 15 | [assembly: Guid("4437a05c-6aa0-498e-9e74-b73ee66052e6")] 16 | 17 | [assembly: AssemblyVersion("1.0.0.0")] 18 | [assembly: AssemblyFileVersion("1.0.0.0")] 19 | -------------------------------------------------------------------------------- /Dominator.Tests/ServiceTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.ServiceProcess; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Dominator.Windows10.Settings; 8 | using Dominator.Windows10.Tools; 9 | using NUnit.Framework; 10 | 11 | namespace Dominator.Tests 12 | { 13 | [TestFixture] 14 | public class ServiceTests 15 | { 16 | [Test] 17 | public void Existing() 18 | { 19 | bool shouldExist = ServiceTools.IsInstalled("cdfs"); 20 | Assert.True(shouldExist); 21 | } 22 | 23 | [Test] 24 | public void NotExisting() 25 | { 26 | bool shouldNotExist = ServiceTools.IsInstalled("no_known_service_has_this_name"); 27 | Assert.False(shouldNotExist); 28 | } 29 | 30 | [Test] 31 | public void Startup() 32 | { 33 | var startup = ServiceTools.TryGetServiceStartup("DnsCache"); 34 | Assert.That(startup, Is.EqualTo(ServiceStartup.Automatic)); 35 | } 36 | 37 | [Test, Ignore] 38 | public void StopAndStart() 39 | { 40 | // Diagnostic Policy Service 41 | Assert.That(ServiceTools.IsInstalled("DPS")); 42 | Assert.That(ServiceTools.Status("DPS"), Is.EqualTo(ServiceControllerStatus.Running)); 43 | ServiceTools.Stop("DPS", TimeSpan.FromMilliseconds(5000)); 44 | ServiceTools.Start("DPS", TimeSpan.FromMilliseconds(5000)); 45 | } 46 | 47 | [Test, Ignore] 48 | public void StartDPS() 49 | { 50 | ServiceTools.Start("DPS", TimeSpan.FromMilliseconds(5000)); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Dominator.Tests/hosts.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 1993-2009 Microsoft Corp. 2 | # 3 | # This is a sample HOSTS file used by Microsoft TCP/IP for Windows. 4 | # 5 | # This file contains the mappings of IP addresses to host names. Each 6 | # entry should be kept on an individual line. The IP address should 7 | # be placed in the first column followed by the corresponding host name. 8 | # The IP address and the host name should be separated by at least one 9 | # space. 10 | # 11 | # Additionally, comments (such as these) may be inserted on individual 12 | # lines or following the machine name denoted by a '#' symbol. 13 | # 14 | # For example: 15 | # 16 | # 102.54.94.97 rhino.acme.com # source server 17 | # 38.25.63.10 x.acme.com # x client host 18 | 19 | # localhost name resolution is handled within DNS itself. 20 | # 127.0.0.1 localhost 21 | # ::1 localhost 22 | 127.0.0.1 localhost 23 | 127.0.0.1 localhost.localdomain 24 | 255.255.255.255 broadcasthost 25 | ::1 localhost 26 | 127.0.0.1 local 27 | 0.0.0.0 vortex.data.microsoft.com 28 | 0.0.0.0 vortex-win.data.microsoft.com 29 | 0.0.0.0 telecommand.telemetry.microsoft.com 30 | 0.0.0.0 telecommand.telemetry.microsoft.com.nsatc.net 31 | 0.0.0.0 oca.telemetry.microsoft.com 32 | 0.0.0.0 oca.telemetry.microsoft.com.nsatc.net 33 | 0.0.0.0 sqm.telemetry.microsoft.com 34 | 0.0.0.0 sqm.telemetry.microsoft.com.nsatc.net 35 | 0.0.0.0 watson.telemetry.microsoft.com 36 | 0.0.0.0 watson.telemetry.microsoft.com.nsatc.net 37 | 0.0.0.0 redir.metaservices.microsoft.com 38 | 0.0.0.0 choice.microsoft.com 39 | 0.0.0.0 choice.microsoft.com.nsatc.net 40 | 0.0.0.0 df.telemetry.microsoft.com 41 | 0.0.0.0 reports.wes.df.telemetry.microsoft.com 42 | 0.0.0.0 wes.df.telemetry.microsoft.com 43 | 0.0.0.0 services.wes.df.telemetry.microsoft.com 44 | 0.0.0.0 sqm.df.telemetry.microsoft.com 45 | 0.0.0.0 telemetry.microsoft.com 46 | 0.0.0.0 watson.ppe.telemetry.microsoft.com 47 | 0.0.0.0 telemetry.appex.bing.net 48 | 0.0.0.0 telemetry.urs.microsoft.com 49 | 0.0.0.0 telemetry.appex.bing.net:443 50 | 0.0.0.0 settings-sandbox.data.microsoft.com 51 | 0.0.0.0 vortex-sandbox.data.microsoft.com 52 | 0.0.0.0 survey.watson.microsoft.com 53 | 0.0.0.0 watson.live.com 54 | 0.0.0.0 watson.microsoft.com 55 | 0.0.0.0 statsfe2.ws.microsoft.com 56 | 0.0.0.0 corpext.msitadfs.glbdns2.microsoft.com 57 | 0.0.0.0 compatexchange.cloudapp.net 58 | 0.0.0.0 cs1.wpc.v0cdn.net 59 | 0.0.0.0 a-0001.a-msedge.net 60 | 0.0.0.0 statsfe2.update.microsoft.com.akadns.net 61 | 0.0.0.0 sls.update.microsoft.com.akadns.net 62 | 0.0.0.0 fe2.update.microsoft.com.akadns.net 63 | 0.0.0.0 65.55.108.23 64 | 0.0.0.0 65.39.117.230 65 | 0.0.0.0 23.218.212.69 66 | 0.0.0.0 134.170.30.202 67 | 0.0.0.0 137.116.81.24 68 | 0.0.0.0 diagnostics.support.microsoft.com 69 | 0.0.0.0 corp.sts.microsoft.com 70 | 0.0.0.0 statsfe1.ws.microsoft.com 71 | 0.0.0.0 pre.footprintpredict.com 72 | 0.0.0.0 204.79.197.200 73 | 0.0.0.0 23.218.212.69 74 | 0.0.0.0 i1.services.social.microsoft.com 75 | 0.0.0.0 i1.services.social.microsoft.com.nsatc.net 76 | 0.0.0.0 feedback.windows.com 77 | 0.0.0.0 feedback.microsoft-hohm.com 78 | 0.0.0.0 feedback.search.microsoft.com 79 | 80 | 81 | 127.0.0.1 rad.msn.com 82 | 127.0.0.1 live.rads.msn.com 83 | 127.0.0.1 ads1.msn.com 84 | 127.0.0.1 g.msn.com 85 | 127.0.0.1 a.ads2.msads.net 86 | 127.0.0.1 b.ads2.msads.net 87 | 127.0.0.1 ac3.msn.com 88 | 127.0.0.1 apps.skype.com 89 | 127.0.0.1 static.2mdn.net 90 | 91 | -------------------------------------------------------------------------------- /Dominator.Tests/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Dominator.Tests/skype-ads.txt: -------------------------------------------------------------------------------- 1 | 0.0.0.0 rad.msn.com 2 | 0.0.0.0 live.rads.msn.com 3 | 0.0.0.0 ads1.msn.com 4 | 0.0.0.0 g.msn.com 5 | 0.0.0.0 a.ads2.msads.net 6 | 0.0.0.0 b.ads2.msads.net 7 | 0.0.0.0 ac3.msn.com 8 | 0.0.0.0 apps.skype.com 9 | 0.0.0.0 static.2mdn.net -------------------------------------------------------------------------------- /Dominator.Tests/watson.txt: -------------------------------------------------------------------------------- 1 | 0.0.0.0 watson.live.com 2 | 0.0.0.0 watson.microsoft.com -------------------------------------------------------------------------------- /Dominator.Windows10/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Dominator.Windows10/Dominator.Windows10.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {682BD86C-1911-46CE-87FE-53381679C08B} 8 | WinExe 9 | Properties 10 | Dominator.Windows10 11 | Windows 10 Dominator 12 | v4.5.2 13 | 512 14 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 15 | 4 16 | true 17 | false 18 | publish\ 19 | true 20 | Disk 21 | true 22 | Background 23 | 7 24 | Days 25 | false 26 | false 27 | true 28 | 0 29 | 1.0.0.%2a 30 | false 31 | true 32 | true 33 | true 34 | de 35 | 36 | 37 | AnyCPU 38 | true 39 | full 40 | false 41 | bin\Debug\ 42 | DEBUG;TRACE 43 | prompt 44 | 4 45 | false 46 | false 47 | 48 | 49 | AnyCPU 50 | pdbonly 51 | true 52 | bin\Release\ 53 | TRACE 54 | prompt 55 | 4 56 | false 57 | 58 | 59 | app.manifest 60 | 61 | 62 | hammer.ico 63 | 64 | 65 | 338EA8A8EE8DF1F9C9B285F109E28E758C33BB6D 66 | 67 | 68 | Dominator.Windows10_TemporaryKey.pfx 69 | 70 | 71 | false 72 | 73 | 74 | false 75 | 76 | 77 | 4.0 78 | en-US 79 | true 80 | true 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 4.0 94 | 95 | 96 | ..\packages\ToggleSwitch.1.1.1\lib\net40-client\ToggleSwitch.dll 97 | True 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | True 106 | True 107 | Application.resx 108 | 109 | 110 | 111 | Code 112 | 113 | 114 | True 115 | Settings.settings 116 | True 117 | 118 | 119 | 120 | 121 | True 122 | True 123 | Settings.resx 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | True 133 | True 134 | Tools.resx 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | Designer 146 | 147 | 148 | 149 | SettingsSingleFileGenerator 150 | Settings.Designer.cs 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | {5510519F-6352-4690-86E5-0FBB1F5B6088} 160 | Dominator.Net 161 | 162 | 163 | 164 | 165 | False 166 | Microsoft .NET Framework 4.5.2 %28x86 and x64%29 167 | true 168 | 169 | 170 | False 171 | .NET Framework 3.5 SP1 172 | false 173 | 174 | 175 | 176 | 177 | 178 | PreserveNewest 179 | 180 | 181 | 182 | 183 | PreserveNewest 184 | 185 | 186 | 187 | 188 | Designer 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 211 | -------------------------------------------------------------------------------- /Dominator.Windows10/Localization/Application.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Dominator.Windows10.Localization { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Application { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Application() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Dominator.Windows10.Localization.Application", typeof(Application).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized string similar to N/A. 65 | /// 66 | internal static string L_N_A { 67 | get { 68 | return ResourceManager.GetString("L_N_A", resourceCulture); 69 | } 70 | } 71 | 72 | /// 73 | /// Looks up a localized string similar to NO!. 74 | /// 75 | internal static string L_NO_ { 76 | get { 77 | return ResourceManager.GetString("L_NO_", resourceCulture); 78 | } 79 | } 80 | 81 | /// 82 | /// Looks up a localized string similar to YES. 83 | /// 84 | internal static string L_YES { 85 | get { 86 | return ResourceManager.GetString("L_YES", resourceCulture); 87 | } 88 | } 89 | 90 | /// 91 | /// Looks up a localized string similar to more.... 92 | /// 93 | internal static string M_more___ { 94 | get { 95 | return ResourceManager.GetString("M_more___", resourceCulture); 96 | } 97 | } 98 | 99 | /// 100 | /// Looks up a localized string similar to No support for command lines arguments yet!. 101 | /// 102 | internal static string M_No_support_for_command_lines_arguments_yet_ { 103 | get { 104 | return ResourceManager.GetString("M_No_support_for_command_lines_arguments_yet_", resourceCulture); 105 | } 106 | } 107 | 108 | /// 109 | /// Looks up a localized string similar to Sorry, {0} must be run as Administrator.. 110 | /// 111 | internal static string M_Sorry___0__must_be_run_as_Administrator_ { 112 | get { 113 | return ResourceManager.GetString("M_Sorry___0__must_be_run_as_Administrator_", resourceCulture); 114 | } 115 | } 116 | 117 | /// 118 | /// Looks up a localized string similar to Sorry, {0} crashed, please open an issue at 119 | /// 120 | ///{1} 121 | /// 122 | ///Error Information: 123 | /// 124 | ///{2}. 125 | /// 126 | internal static string M_Sorry___0_crashed { 127 | get { 128 | return ResourceManager.GetString("M_Sorry___0_crashed", resourceCulture); 129 | } 130 | } 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /Dominator.Windows10/Localization/Application.de.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | text/microsoft-resx 5 | 6 | 7 | 2.0 8 | 9 | 10 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 11 | 12 | 13 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 14 | 15 | 16 | Sorry, {0} muss als Administrator ausgeführt werden. 17 | 18 | 19 | Sorry, {0} wurde fehlerhaft beendet. Bitte melden Sie den Fehler unter 20 | 21 | {1} 22 | 23 | Fehlermeldung: 24 | 25 | {2} 26 | 27 | 28 | Derzeit keine Unterstützung von Kommandozeilenoptionen! 29 | 30 | 31 | JA 32 | 33 | 34 | NEIN! 35 | 36 | 37 | mehr... 38 | 39 | -------------------------------------------------------------------------------- /Dominator.Windows10/Localization/Application.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | text/microsoft-resx 91 | 92 | 93 | 1.3 94 | 95 | 96 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 97 | 98 | 99 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 100 | 101 | 102 | Sorry, {0} must be run as Administrator. 103 | 104 | 105 | Sorry, {0} crashed, please open an issue at 106 | 107 | {1} 108 | 109 | Error Information: 110 | 111 | {2} 112 | 113 | 114 | No support for command lines arguments yet! 115 | 116 | 117 | YES 118 | 119 | 120 | N/A 121 | 122 | 123 | NO! 124 | 125 | 126 | more... 127 | 128 | -------------------------------------------------------------------------------- /Dominator.Windows10/MultilingualResources/Dominator.Windows10.de.xlf: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 |
5 | 6 |
7 | 8 | 9 | 10 | Service {0} is not installed. 11 | Dienst {0} ist nicht installiert. 12 | 13 | 14 | Service {0} is installed, but its startup option is not configured. 15 | Dienst {0} ist installiert, aber die Starteinstellung ist nicht konfiguriert. 16 | 17 | 18 | Failed to stop service {0} 19 | Fehler beim Anhalten von Dienst {0} 20 | 21 | 22 | Failed to start service {0} 23 | Fehler beim Starten von Dienst {0} 24 | 25 | 26 | 27 |
28 | 29 |
30 | 31 |
32 | 33 | 34 | 35 | Sorry, {0} must be run as Administrator. 36 | Sorry, {0} muss als Administrator ausgeführt werden. 37 | 38 | 39 | Sorry, {0} crashed, please open an issue at 40 | 41 | {1} 42 | 43 | Error Information: 44 | 45 | {2} 46 | Sorry, {0} wurde fehlerhaft beendet. Bitte melden Sie den Fehler unter 47 | 48 | {1} 49 | 50 | Fehlermeldung: 51 | 52 | {2} 53 | 54 | 55 | No support for command lines arguments yet! 56 | Derzeit keine Unterstützung von Kommandozeilenoptionen! 57 | 58 | 59 | YES 60 | JA 61 | 62 | 63 | N/A 64 | N/A 65 | 66 | 67 | NO! 68 | NEIN! 69 | 70 | 71 | more... 72 | mehr... 73 | 74 | 75 | 76 |
77 | 78 |
79 | 80 |
81 | 82 | 83 | 84 | Privacy 85 | Datenschutz 86 | 87 | 88 | Settings that protect your privacy 89 | Einstellungen, die Ihre Privatsphäre schützen 90 | 91 | 92 | Let apps use my advertising ID? 93 | Dürfen Apps meine Werbungs-ID verwenden? 94 | 95 | 96 | Send Microsoft info about how I write? 97 | Informationen zu meinem Schreibverhalten an Microsoft senden? 98 | 99 | 100 | Let websites provide locally relevant content by accessing my language list? 101 | Websites den Zugriff auf die eigene Sprachliste gestatten, um die Anzeige lokal relevanter Inhalte zu ermöglichen? 102 | 103 | 104 | Send data about functional issues to Microsoft (Diagnostics Tracking Service)? 105 | Daten über Probleme an Microsoft senden (Tracking Diagnosedienst)? 106 | 107 | 108 | Ask for feedback? 109 | Nach Feedback fragen? 110 | 111 | 112 | Log keystrokes (WAP Push Message Routing Service)? 113 | Protokollieren der Tastatureingaben (WAP Push Message Routing Service)? 114 | 115 | 116 | Microsoft telemetry data collection 117 | Microsoft Telemetrie-Datenerfassung 118 | 119 | 120 | Collect telemetry data? 121 | Telemetriedaten erfassen? 122 | 123 | 124 | Allow this PC to connect to Microsoft telemetry servers? 125 | PC erlauben, sich mit Microsoft Telemetrie-Servern zu verbinden? 126 | 127 | 128 | Location 129 | Standort 130 | 131 | 132 | Allow apps and services to request your location? 133 | Apps und Diensten erlauben, auf meine Standortdaten zuzugreifen? 134 | 135 | 136 | Provide web results when I use the Windows search bar? 137 | Bei Verwendung der Windowssuche auch Webergebnisse einbeziehen? 138 | 139 | 140 | Optional Protections 141 | Optionale Schutzmaßnahmen 142 | 143 | 144 | Some of them are actually useful 145 | Einige davon sind tatsächlich nützlich 146 | 147 | 148 | Turn on SmartScreen Filter to check web content (URLs) that Windows Store apps use? 149 | SmartScreen-Filter einschalten, um von Windows Store-Apps verwendete Webinhalte (URLs) zu überprüfen? 150 | 151 | 152 | Annoyances 153 | Ärgernisse 154 | 155 | 156 | Settings that may cause annoying consequences 157 | Einstellungen, die ärgerliche Folgen haben können 158 | 159 | 160 | Show Skype home and advertisements? 161 | Skype-Startseite und Werbung anzeigen? 162 | 163 | 164 | Get updates from or send updates to other PCs? 165 | Abrufen von Updates von oder Senden von Updates an andere PCs? 166 | 167 | 168 | Manage all privacy related settings in one place 169 | Verwalte alle Datenschutz-Einstellungen an einem Ort 170 | 171 | 172 | Option not found. Evil defaults may apply. 173 | Option unbekannt, nachteilige Standardwerte können vorliegen. 174 | 175 | 176 | Option value is {0} and probably safe to change. 177 | Optionswert ist {0} und wahrscheinlich sicher zu ändern. 178 | 179 | 180 | Telemetry 181 | Telemetrie 182 | 183 | 184 | Service is not installed. 185 | Dienst ist nicht installiert. 186 | 187 | 188 | Service status is not recognized, but safe to change. 189 | Dienststatus wird nicht erkannt, aber kann problemlos geändert werden. 190 | 191 | 192 | On Windows 10 Home or Professional, telemetry can not be completely disabled, so you should block the telemetry hosts with the option below. 193 | Bei Windows 10 Home or Professional kann die Telemetrie nicht komplett ausgeschaltet werden, deswegen sollten die Telemetrie-Server mit der nächsten Option blockiert werden. 194 | 195 | 196 | Show the system's hosts file. 197 | Hosts Datei des Systems anzeigen. 198 | 199 | 200 | 201 |
202 |
-------------------------------------------------------------------------------- /Dominator.Windows10/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Security.Principal; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Media; 9 | using Dominator.Windows10.Tools; 10 | using static Dominator.Windows10.Localization.Application; 11 | 12 | namespace Dominator.Windows10 13 | { 14 | static class Program 15 | { 16 | static readonly string ApplicationName = makeApplicationName(); 17 | const string ProjectIssuesURL = "https://github.com/pragmatrix/Dominator/issues"; 18 | 19 | [STAThread] 20 | public static int Main(string[] args) 21 | { 22 | // Thread.CurrentThread.CurrentUICulture = new CultureInfo("de"); 23 | try 24 | { 25 | if (!TryRunAsAdministrator()) 26 | return 0; 27 | 28 | ProtectedMain(args); 29 | return 0; 30 | } 31 | catch (Exception e) 32 | { 33 | var text = string.Format(M_Sorry___0_crashed, ApplicationName, ProjectIssuesURL, e); 34 | MessageBox.Show(text, ApplicationName); 35 | return 5; 36 | } 37 | } 38 | 39 | static void ProtectedMain(string[] args) 40 | { 41 | if (args.Length != 0) 42 | throw new InvalidOperationException(M_No_support_for_command_lines_arguments_yet_); 43 | 44 | var app = new Application(); 45 | 46 | var window = new Window 47 | { 48 | WindowStartupLocation = WindowStartupLocation.CenterScreen, 49 | Width = 640, 50 | Height = 480, 51 | Title = ApplicationName, 52 | }; 53 | 54 | // optimize text quality on low resolution screens. 55 | if (DPI.Display < 125) 56 | TextOptions.SetTextFormattingMode(window, TextFormattingMode.Display); 57 | 58 | var allSettings = Settings.Settings.All; 59 | 60 | using (var controller = new UIController()) 61 | { 62 | var ui = UI.ForDominator(allSettings, controller); 63 | 64 | var container = new ScrollViewer 65 | { 66 | Padding = new Thickness(16), 67 | VerticalScrollBarVisibility = ScrollBarVisibility.Auto, 68 | Content = ui 69 | }; 70 | 71 | window.Deactivated += (sender, eventArgs) => ui.IsEnabled = false; 72 | window.Activated += (sender, eventArgs) => 73 | { 74 | ui.IsEnabled = true; 75 | controller.scheduleUpdateAllStates(); 76 | }; 77 | 78 | window.Content = container; 79 | controller.scheduleUpdateAllStates(); 80 | app.Run(window); 81 | } 82 | } 83 | 84 | static bool TryRunAsAdministrator() 85 | { 86 | if (IsRunAsAdministrator()) 87 | return true; 88 | 89 | var processInfo = new ProcessStartInfo(Assembly.GetExecutingAssembly().CodeBase) 90 | { 91 | UseShellExecute = true, 92 | Verb = "runas" 93 | }; 94 | 95 | try 96 | { 97 | Process.Start(processInfo); 98 | return false; 99 | } 100 | catch (Exception) 101 | { 102 | // The user did not allow the application to run as administrator 103 | MessageBox.Show(string.Format(M_Sorry___0__must_be_run_as_Administrator_, ApplicationName)); 104 | return false; 105 | } 106 | } 107 | 108 | private static bool IsRunAsAdministrator() 109 | { 110 | var wi = WindowsIdentity.GetCurrent(); 111 | var wp = new WindowsPrincipal(wi); 112 | 113 | return wp.IsInRole(WindowsBuiltInRole.Administrator); 114 | } 115 | 116 | static string makeApplicationName() 117 | { 118 | var assembly = typeof(Program).Assembly; 119 | var product = (AssemblyProductAttribute)(assembly.GetCustomAttributes(typeof(AssemblyProductAttribute)).First()); 120 | return product.Product; 121 | } 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /Dominator.Windows10/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Resources; 2 | using System.Reflection; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | 7 | [assembly: AssemblyTitle("Dominator.Windows10")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("Windows 10 Dominator")] 12 | [assembly: AssemblyCopyright("Copyright © 2015 Armin Sander")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | [assembly: ComVisible(false)] 17 | 18 | [assembly: ThemeInfo( 19 | ResourceDictionaryLocation.None, 20 | ResourceDictionaryLocation.SourceAssembly 21 | )] 22 | 23 | [assembly: AssemblyVersion("1.4.0.0")] 24 | [assembly: AssemblyFileVersion("1.4.0.0")] 25 | 26 | [assembly: InternalsVisibleTo("Dominator.Tests")] 27 | [assembly: NeutralResourcesLanguage("en-US")] 28 | 29 | -------------------------------------------------------------------------------- /Dominator.Windows10/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Dominator.Windows10.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Dominator.Windows10/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Dominator.Windows10/Settings/All.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using Dominator.Net; 3 | 4 | namespace Dominator.Windows10.Settings 5 | { 6 | using static Localization.Settings; 7 | 8 | static partial class Settings 9 | { 10 | public static IDominator All => DSL 11 | .BeginGroup("Windows 10 Dominator") 12 | .Explanation(E_Manage_all_privacy_related_settings_in_one_place) 13 | .PrivacySettings() 14 | .Annoyances() 15 | .OptionalProtections() 16 | .Specification(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Dominator.Windows10/Settings/Annoyances.cs: -------------------------------------------------------------------------------- 1 | using Dominator.Net; 2 | using static Dominator.Windows10.Settings.Localization.Settings; 3 | 4 | namespace Dominator.Windows10.Settings 5 | { 6 | static partial class Settings 7 | { 8 | public static GroupBuilder Annoyances(this GroupBuilder dsl) => dsl 9 | .BeginGroup(T_Annoyances) 10 | .Explanation(E_Settings_that_may_cause_annoying_consequences) 11 | 12 | .BeginItem(E_Show_Skype_home_and_advertisements) 13 | .Hosts("Settings/skype-ads.txt") 14 | .End() 15 | 16 | // https://techjourney.net/enable-or-disable-peer-to-peer-p2p-apps-updates-download-from-more-than-one-place-in-windows-10/ 17 | 18 | .BeginItem(E_Get_updates_from_or_send_updates_to_other_PCs) 19 | .RegistryValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config", "DODownloadMode", 0, 3, optionNotFound: DominatorState.Submissive()) 20 | .MoreInSettings("windowsupdate") 21 | .End() 22 | 23 | .End(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Dominator.Windows10/Settings/Localization/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Dominator.Windows10.Settings.Localization { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Settings { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Settings() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Dominator.Windows10.Settings.Localization.Settings", typeof(Settings).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized string similar to Allow apps and services to request your location. 65 | /// 66 | internal static string E_Allow_apps_and_services_to_request_your_location { 67 | get { 68 | return ResourceManager.GetString("E_Allow_apps_and_services_to_request_your_location", resourceCulture); 69 | } 70 | } 71 | 72 | /// 73 | /// Looks up a localized string similar to Allow this PC to connect to Microsoft telemetry servers. 74 | /// 75 | internal static string E_Allow_this_PC_to_connect_to_Microsoft_telemetry_servers { 76 | get { 77 | return ResourceManager.GetString("E_Allow_this_PC_to_connect_to_Microsoft_telemetry_servers", resourceCulture); 78 | } 79 | } 80 | 81 | /// 82 | /// Looks up a localized string similar to Ask for feedback. 83 | /// 84 | internal static string E_Ask_for_feedback { 85 | get { 86 | return ResourceManager.GetString("E_Ask_for_feedback", resourceCulture); 87 | } 88 | } 89 | 90 | /// 91 | /// Looks up a localized string similar to Collect telemetry data. 92 | /// 93 | internal static string E_Collect_telemetry_data { 94 | get { 95 | return ResourceManager.GetString("E_Collect_telemetry_data", resourceCulture); 96 | } 97 | } 98 | 99 | /// 100 | /// Looks up a localized string similar to Get updates from or send updates to other PCs. 101 | /// 102 | internal static string E_Get_updates_from_or_send_updates_to_other_PCs { 103 | get { 104 | return ResourceManager.GetString("E_Get_updates_from_or_send_updates_to_other_PCs", resourceCulture); 105 | } 106 | } 107 | 108 | /// 109 | /// Looks up a localized string similar to Let apps use my advertising ID. 110 | /// 111 | internal static string E_Let_apps_use_my_advertising_ID { 112 | get { 113 | return ResourceManager.GetString("E_Let_apps_use_my_advertising_ID", resourceCulture); 114 | } 115 | } 116 | 117 | /// 118 | /// Looks up a localized string similar to Let websites provide locally relevant content by accessing my language list. 119 | /// 120 | internal static string E_Let_websites_provide_locally_relevant_content_by_accessing_my_language_list { 121 | get { 122 | return ResourceManager.GetString("E_Let_websites_provide_locally_relevant_content_by_accessing_my_language_list", resourceCulture); 123 | } 124 | } 125 | 126 | /// 127 | /// Looks up a localized string similar to Log keystrokes (WAP Push Message Routing Service). 128 | /// 129 | internal static string E_Log_keystrokes { 130 | get { 131 | return ResourceManager.GetString("E_Log_keystrokes", resourceCulture); 132 | } 133 | } 134 | 135 | /// 136 | /// Looks up a localized string similar to Manage all privacy related settings in one place. 137 | /// 138 | internal static string E_Manage_all_privacy_related_settings_in_one_place { 139 | get { 140 | return ResourceManager.GetString("E_Manage_all_privacy_related_settings_in_one_place", resourceCulture); 141 | } 142 | } 143 | 144 | /// 145 | /// Looks up a localized string similar to Microsoft telemetry data collection. 146 | /// 147 | internal static string E_Microsoft_telemetry_data_collection { 148 | get { 149 | return ResourceManager.GetString("E_Microsoft_telemetry_data_collection", resourceCulture); 150 | } 151 | } 152 | 153 | /// 154 | /// Looks up a localized string similar to Provide web results when I use the Windows search bar. 155 | /// 156 | internal static string E_Provide_web_results_when_I_use_the_Windows_search_bar { 157 | get { 158 | return ResourceManager.GetString("E_Provide_web_results_when_I_use_the_Windows_search_bar", resourceCulture); 159 | } 160 | } 161 | 162 | /// 163 | /// Looks up a localized string similar to Send data about functional issues to Microsoft (Diagnostics Tracking Service). 164 | /// 165 | internal static string E_Send_data_about_functional_issues_to_Microsoft { 166 | get { 167 | return ResourceManager.GetString("E_Send_data_about_functional_issues_to_Microsoft", resourceCulture); 168 | } 169 | } 170 | 171 | /// 172 | /// Looks up a localized string similar to Send Microsoft info about how I write. 173 | /// 174 | internal static string E_Send_Microsoft_info_about_how_I_write { 175 | get { 176 | return ResourceManager.GetString("E_Send_Microsoft_info_about_how_I_write", resourceCulture); 177 | } 178 | } 179 | 180 | /// 181 | /// Looks up a localized string similar to Settings that may cause annoying consequences. 182 | /// 183 | internal static string E_Settings_that_may_cause_annoying_consequences { 184 | get { 185 | return ResourceManager.GetString("E_Settings_that_may_cause_annoying_consequences", resourceCulture); 186 | } 187 | } 188 | 189 | /// 190 | /// Looks up a localized string similar to Settings that protect your privacy. 191 | /// 192 | internal static string E_Settings_that_protect_your_privacy { 193 | get { 194 | return ResourceManager.GetString("E_Settings_that_protect_your_privacy", resourceCulture); 195 | } 196 | } 197 | 198 | /// 199 | /// Looks up a localized string similar to Show Skype home and advertisements. 200 | /// 201 | internal static string E_Show_Skype_home_and_advertisements { 202 | get { 203 | return ResourceManager.GetString("E_Show_Skype_home_and_advertisements", resourceCulture); 204 | } 205 | } 206 | 207 | /// 208 | /// Looks up a localized string similar to Some of them are actually useful. 209 | /// 210 | internal static string E_Some_of_them_are_actually_useful { 211 | get { 212 | return ResourceManager.GetString("E_Some_of_them_are_actually_useful", resourceCulture); 213 | } 214 | } 215 | 216 | /// 217 | /// Looks up a localized string similar to Turn on SmartScreen Filter to check web content (URLs) that Windows Store apps use. 218 | /// 219 | internal static string E_Turn_on_SmartScreen_Filter_to_check_web_content__URLs__that_Windows_Store_apps_use { 220 | get { 221 | return ResourceManager.GetString("E_Turn_on_SmartScreen_Filter_to_check_web_content__URLs__that_Windows_Store_apps_" + 222 | "use", resourceCulture); 223 | } 224 | } 225 | 226 | /// 227 | /// Looks up a localized string similar to On Windows 10 Home or Professional, telemetry can not be completely disabled, so you should block the telemetry hosts with the option below.. 228 | /// 229 | internal static string M_On_Windows_10_Home_or_Professional__telemetry_can_not_be_completely_disabled { 230 | get { 231 | return ResourceManager.GetString("M_On_Windows_10_Home_or_Professional__telemetry_can_not_be_completely_disabled", resourceCulture); 232 | } 233 | } 234 | 235 | /// 236 | /// Looks up a localized string similar to Option not found. Evil defaults may apply.. 237 | /// 238 | internal static string M_Option_not_found__Evil_defaults_may_apply { 239 | get { 240 | return ResourceManager.GetString("M_Option_not_found__Evil_defaults_may_apply", resourceCulture); 241 | } 242 | } 243 | 244 | /// 245 | /// Looks up a localized string similar to Option value is {0} and probably safe to change.. 246 | /// 247 | internal static string M_Option_value_is__0__and_probably_safe_to_change { 248 | get { 249 | return ResourceManager.GetString("M_Option_value_is__0__and_probably_safe_to_change", resourceCulture); 250 | } 251 | } 252 | 253 | /// 254 | /// Looks up a localized string similar to Service is not installed.. 255 | /// 256 | internal static string M_Service_is_not_installed { 257 | get { 258 | return ResourceManager.GetString("M_Service_is_not_installed", resourceCulture); 259 | } 260 | } 261 | 262 | /// 263 | /// Looks up a localized string similar to Service status is not recognized, but safe to change.. 264 | /// 265 | internal static string M_Service_status_is_not_recognized__but_safe_to_change { 266 | get { 267 | return ResourceManager.GetString("M_Service_status_is_not_recognized__but_safe_to_change", resourceCulture); 268 | } 269 | } 270 | 271 | /// 272 | /// Looks up a localized string similar to Show the system's hosts file.. 273 | /// 274 | internal static string M_Show_the_system_s_hosts_file_ { 275 | get { 276 | return ResourceManager.GetString("M_Show_the_system_s_hosts_file_", resourceCulture); 277 | } 278 | } 279 | 280 | /// 281 | /// Looks up a localized string similar to Annoyances. 282 | /// 283 | internal static string T_Annoyances { 284 | get { 285 | return ResourceManager.GetString("T_Annoyances", resourceCulture); 286 | } 287 | } 288 | 289 | /// 290 | /// Looks up a localized string similar to Location. 291 | /// 292 | internal static string T_Location { 293 | get { 294 | return ResourceManager.GetString("T_Location", resourceCulture); 295 | } 296 | } 297 | 298 | /// 299 | /// Looks up a localized string similar to Optional Protections. 300 | /// 301 | internal static string T_Optional_Protections { 302 | get { 303 | return ResourceManager.GetString("T_Optional_Protections", resourceCulture); 304 | } 305 | } 306 | 307 | /// 308 | /// Looks up a localized string similar to Privacy. 309 | /// 310 | internal static string T_Privacy { 311 | get { 312 | return ResourceManager.GetString("T_Privacy", resourceCulture); 313 | } 314 | } 315 | 316 | /// 317 | /// Looks up a localized string similar to Telemetry. 318 | /// 319 | internal static string T_Telemetry { 320 | get { 321 | return ResourceManager.GetString("T_Telemetry", resourceCulture); 322 | } 323 | } 324 | } 325 | } 326 | -------------------------------------------------------------------------------- /Dominator.Windows10/Settings/Localization/Settings.de.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | text/microsoft-resx 5 | 6 | 7 | 2.0 8 | 9 | 10 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 11 | 12 | 13 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 14 | 15 | 16 | Datenschutz 17 | 18 | 19 | Einstellungen, die Ihre Privatsphäre schützen 20 | 21 | 22 | Dürfen Apps meine Werbungs-ID verwenden? 23 | 24 | 25 | Informationen zu meinem Schreibverhalten an Microsoft senden? 26 | 27 | 28 | Websites den Zugriff auf die eigene Sprachliste gestatten, um die Anzeige lokal relevanter Inhalte zu ermöglichen? 29 | 30 | 31 | Daten über Probleme an Microsoft senden (Tracking Diagnosedienst)? 32 | 33 | 34 | Nach Feedback fragen? 35 | 36 | 37 | Protokollieren der Tastatureingaben (WAP Push Message Routing Service)? 38 | 39 | 40 | Microsoft Telemetrie-Datenerfassung 41 | 42 | 43 | Telemetriedaten erfassen? 44 | 45 | 46 | PC erlauben, sich mit Microsoft Telemetrie-Servern zu verbinden? 47 | 48 | 49 | Standort 50 | 51 | 52 | Apps und Diensten erlauben, auf meine Standortdaten zuzugreifen? 53 | 54 | 55 | Bei Verwendung der Windowssuche auch Webergebnisse einbeziehen? 56 | 57 | 58 | Optionale Schutzmaßnahmen 59 | 60 | 61 | Einige davon sind tatsächlich nützlich 62 | 63 | 64 | SmartScreen-Filter einschalten, um von Windows Store-Apps verwendete Webinhalte (URLs) zu überprüfen? 65 | 66 | 67 | Ärgernisse 68 | 69 | 70 | Einstellungen, die ärgerliche Folgen haben können 71 | 72 | 73 | Skype-Startseite und Werbung anzeigen? 74 | 75 | 76 | Abrufen von Updates von oder Senden von Updates an andere PCs? 77 | 78 | 79 | Verwalte alle Datenschutz-Einstellungen an einem Ort 80 | 81 | 82 | Option unbekannt, nachteilige Standardwerte können vorliegen. 83 | 84 | 85 | Optionswert ist {0} und wahrscheinlich sicher zu ändern. 86 | 87 | 88 | Telemetrie 89 | 90 | 91 | Dienst ist nicht installiert. 92 | 93 | 94 | Dienststatus wird nicht erkannt, aber kann problemlos geändert werden. 95 | 96 | 97 | Bei Windows 10 Home or Professional kann die Telemetrie nicht komplett ausgeschaltet werden, deswegen sollten die Telemetrie-Server mit der nächsten Option blockiert werden. 98 | 99 | 100 | Hosts Datei des Systems anzeigen. 101 | 102 | -------------------------------------------------------------------------------- /Dominator.Windows10/Settings/Localization/Settings.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | Privacy 122 | 123 | 124 | Settings that protect your privacy 125 | 126 | 127 | Let apps use my advertising ID? 128 | 129 | 130 | Send Microsoft info about how I write? 131 | 132 | 133 | Let websites provide locally relevant content by accessing my language list? 134 | 135 | 136 | Send data about functional issues to Microsoft (Diagnostics Tracking Service)? 137 | 138 | 139 | Ask for feedback? 140 | 141 | 142 | Log keystrokes (WAP Push Message Routing Service)? 143 | 144 | 145 | Microsoft telemetry data collection 146 | 147 | 148 | Collect telemetry data? 149 | 150 | 151 | Allow this PC to connect to Microsoft telemetry servers? 152 | 153 | 154 | Location 155 | 156 | 157 | Allow apps and services to request your location? 158 | 159 | 160 | Provide web results when I use the Windows search bar? 161 | 162 | 163 | Optional Protections 164 | 165 | 166 | Some of them are actually useful 167 | 168 | 169 | Turn on SmartScreen Filter to check web content (URLs) that Windows Store apps use? 170 | 171 | 172 | Annoyances 173 | 174 | 175 | Settings that may cause annoying consequences 176 | 177 | 178 | Show Skype home and advertisements? 179 | 180 | 181 | Get updates from or send updates to other PCs? 182 | 183 | 184 | Manage all privacy related settings in one place 185 | 186 | 187 | Option not found. Evil defaults may apply. 188 | 189 | 190 | Option value is {0} and probably safe to change. 191 | 192 | 193 | Telemetry 194 | 195 | 196 | Service is not installed. 197 | 198 | 199 | Service status is not recognized, but safe to change. 200 | 201 | 202 | On Windows 10 Home or Professional, telemetry can not be completely disabled, so you should block the telemetry hosts with the option below. 203 | 204 | 205 | Show the system's hosts file. 206 | 207 | -------------------------------------------------------------------------------- /Dominator.Windows10/Settings/Optional.cs: -------------------------------------------------------------------------------- 1 | using Dominator.Net; 2 | using static Dominator.Windows10.Settings.Localization.Settings; 3 | 4 | namespace Dominator.Windows10.Settings 5 | { 6 | static partial class Settings 7 | { 8 | 9 | public static GroupBuilder OptionalProtections(this GroupBuilder dsl) => dsl 10 | .BeginGroup(T_Optional_Protections) 11 | .Explanation(E_Some_of_them_are_actually_useful) 12 | 13 | .BeginItem(E_Turn_on_SmartScreen_Filter_to_check_web_content__URLs__that_Windows_Store_apps_use) 14 | .RegistryUserValueWithHKLMDefault(@"SOFTWARE\Microsoft\Windows\CurrentVersion\AppHost", "EnableWebContentEvaluation", 0, 1) 15 | .MoreInSettings("privacy") 16 | .End() 17 | 18 | .End(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Dominator.Windows10/Settings/Privacy.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Dominator.Net; 3 | using Dominator.Windows10.Tools; 4 | using static Dominator.Windows10.Settings.Localization.Settings; 5 | 6 | namespace Dominator.Windows10.Settings 7 | { 8 | static partial class Settings 9 | { 10 | public static GroupBuilder PrivacySettings(this GroupBuilder dsl) => dsl 11 | .BeginGroup(T_Privacy) 12 | .Explanation(E_Settings_that_protect_your_privacy) 13 | 14 | // Express Settings: the Search key exists in HKLM, but nothing is in there, and changing BingSearchEnabled does not have an 15 | // effect when the user key is not set. 16 | .BeginItem(E_Provide_web_results_when_I_use_the_Windows_search_bar) 17 | .RegistryValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Search", "BingSearchEnabled", 0, 1, optionNotFound: DominatorState.Submissive()) 18 | .End() 19 | 20 | .BeginItem(E_Let_apps_use_my_advertising_ID) 21 | .RegistryUserValueWithHKLMDefault(@"SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo", "Enabled", 0, 1) 22 | .MoreInSettings("privacy") 23 | .End() 24 | 25 | .BeginItem(E_Send_Microsoft_info_about_how_I_write) 26 | .RegistryUserValueWithHKLMDefault(@"SOFTWARE\Microsoft\Input\TIPC", "Enabled", 0, 1) 27 | .MoreInSettings("privacy") 28 | .End() 29 | 30 | // no HKLM backing field, is on by default on Express Settings and Custom. 31 | .BeginItem(E_Let_websites_provide_locally_relevant_content_by_accessing_my_language_list) 32 | .RegistryValue(@"HKEY_CURRENT_USER\Control Panel\International\User Profile", "HttpAcceptLanguageOptOut", 1, 0, optionNotFound: DominatorState.Submissive()) 33 | .MoreInSettings("privacy") 34 | .End() 35 | 36 | .BeginItem(E_Send_data_about_functional_issues_to_Microsoft) 37 | .Service("DiagTrack", ServiceStartup.Disabled, ServiceStartup.Automatic) 38 | .End() 39 | 40 | .BeginItem(E_Ask_for_feedback) 41 | .RegistryValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Siuf\Rules", "NumberOfSIUFInPeriod", 0, 1, optionNotFound: DominatorState.Submissive()) 42 | .MoreInSettings("privacy-feedback") 43 | .End() 44 | 45 | /* 46 | .BeginItem("Diagnostics Tracking Log") 47 | .Explanation("Keep the log file about functional issues") 48 | .File(Environment.SpecialFolder.CommonApplicationData, @"Microsoft\Diagnosis\ETLLogs\AutoLogger\AutoLogger-Diagtrack-Listener.etl", FileConfiguration.MissingOrEmpty, FileConfiguration.ExistingAndNotEmpty) 49 | .End() 50 | */ 51 | 52 | .BeginItem(E_Log_keystrokes) 53 | .Service("dmwappushservice", ServiceStartup.Disabled, ServiceStartup.Automatic) 54 | .End() 55 | 56 | .BeginGroup(T_Telemetry) 57 | .Explanation(E_Microsoft_telemetry_data_collection) 58 | 59 | // Value is set to 3 in Express Settings and 2 in Custom Settings. Key always exists. 60 | .BeginItem(E_Collect_telemetry_data) 61 | .RegistryValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection", "AllowTelemetry", 0, 1, alsoTreatAsSubmissive: v => v >= 1 && v <=3) 62 | .WarnWhenDominated(M_On_Windows_10_Home_or_Professional__telemetry_can_not_be_completely_disabled) 63 | .MoreInSettings("privacy-feedback") 64 | .End() 65 | 66 | .BeginItem(E_Allow_this_PC_to_connect_to_Microsoft_telemetry_servers) 67 | .Hosts("Settings/telemetry.txt") 68 | .End() 69 | .End() 70 | 71 | .BeginGroup(T_Location) 72 | 73 | .BeginItem(E_Allow_apps_and_services_to_request_your_location) 74 | .RegistryValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\{BFA794E4-F964-4FDB-90F6-51056BFE4B44}", "Value", "Deny", "Allow") 75 | .MoreInSettings("privacy-location") 76 | .End() 77 | .End() 78 | 79 | .End(); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /Dominator.Windows10/Settings/ToolsIntegration.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.IO; 4 | using System.Linq; 5 | using Dominator.Net; 6 | using Dominator.Windows10.Tools; 7 | using Microsoft.Win32; 8 | using static Dominator.Windows10.Settings.Localization.Settings; 9 | 10 | namespace Dominator.Windows10.Settings 11 | { 12 | static partial class Settings 13 | { 14 | static readonly string OptionNotFoundMessage = M_Option_not_found__Evil_defaults_may_apply; 15 | static readonly string ValueNotRecognizedMessage = M_Option_value_is__0__and_probably_safe_to_change; 16 | 17 | static ItemBuilder MoreInSettings(this ItemBuilder dsl, string setting) 18 | { 19 | return dsl.MoreAt(new Uri($"ms-settings:{setting}", UriKind.Absolute)); 20 | } 21 | 22 | static ItemBuilder MoreAt(this ItemBuilder dsl, Uri uri) 23 | { 24 | return dsl.More(() => 25 | { 26 | Process.Start(uri.ToString()); 27 | }, uri.ToString()); 28 | } 29 | 30 | static ItemBuilder WarnWhenDominated(this ItemBuilder dsl, string warning) 31 | { 32 | return dsl.ChainGetter(state => state.Kind != DominatorStateKind.Dominated ? state : state.WithMessage(warning)); 33 | } 34 | 35 | static ItemBuilder RegistryValue(this ItemBuilder dsl, string key, string valueName, int dominatedValue, int submissiveValue, DominatorState? optionNotFound = null, Func alsoTreatAsSubmissive = null) 36 | { 37 | Func isTreatedAsSubmissive = v => v == submissiveValue || (alsoTreatAsSubmissive != null && alsoTreatAsSubmissive(v)); 38 | 39 | return dsl 40 | .Setter( 41 | action => Registry.SetValue(key, valueName, action == DominationAction.Dominate ? dominatedValue : submissiveValue, RegistryValueKind.DWord)) 42 | .Getter(() => 43 | { 44 | var value = Registry.GetValue(key, valueName, null); 45 | if (!(value is int)) 46 | return optionNotFound ?? DominatorState.Indetermined(OptionNotFoundMessage); 47 | 48 | var v = (int)value; 49 | if (v == dominatedValue) 50 | return DominatorState.Dominated(); 51 | if (isTreatedAsSubmissive(v)) 52 | return DominatorState.Submissive(); 53 | return DominatorState.Indetermined(string.Format(ValueNotRecognizedMessage, v)); 54 | }); 55 | } 56 | 57 | const string HKLM = "HKEY_LOCAL_MACHINE"; 58 | const string HKCU = "HKEY_CURRENT_USER"; 59 | 60 | static ItemBuilder RegistryUserValueWithHKLMDefault(this ItemBuilder dsl, string key, string valueName, int dominatedValue, int submissiveValue) 61 | { 62 | return dsl 63 | .Setter( 64 | action => Registry.SetValue(userKey(key), valueName, action == DominationAction.Dominate ? dominatedValue : submissiveValue, RegistryValueKind.DWord)) 65 | .Getter(() => 66 | { 67 | var value = tryGetUserOrMachineValue(key, valueName); 68 | if (!(value is int)) 69 | return DominatorState.Indetermined(OptionNotFoundMessage); 70 | 71 | var v = (int)value; 72 | if (v == dominatedValue) 73 | return DominatorState.Dominated(); 74 | if (v == submissiveValue) 75 | return DominatorState.Submissive(); 76 | return DominatorState.Indetermined(string.Format(ValueNotRecognizedMessage, v)); 77 | }); 78 | } 79 | 80 | static object tryGetUserOrMachineValue(string key, string valueName) 81 | { 82 | var userValue = Registry.GetValue(userKey(key), valueName, null); 83 | return userValue ?? Registry.GetValue(machineKey(key), valueName, null); 84 | } 85 | 86 | static string machineKey(string key) => HKLM + @"\" + key; 87 | static string userKey(string key) => HKCU + @"\" + key; 88 | 89 | static ItemBuilder RegistryValue(this ItemBuilder dsl, string key, string valueName, string dominatedValue, string submissiveValue) 90 | { 91 | return dsl 92 | .Setter( 93 | action => Registry.SetValue(key, valueName, action == DominationAction.Dominate ? dominatedValue : submissiveValue, RegistryValueKind.String)) 94 | .Getter(() => 95 | { 96 | var value = Registry.GetValue(key, valueName, null); 97 | 98 | if (!(value is string)) 99 | return DominatorState.Indetermined(OptionNotFoundMessage); 100 | 101 | var v = (string)value; 102 | if (v == dominatedValue) 103 | return DominatorState.Dominated(); 104 | if (v == submissiveValue) 105 | return DominatorState.Submissive(); 106 | return DominatorState.Indetermined(string.Format(ValueNotRecognizedMessage, v)); 107 | }); 108 | } 109 | 110 | static readonly string ServiceDoesNotExistMessage = M_Service_is_not_installed; 111 | static readonly string ServiceStateNotRecognizedMessage = M_Service_status_is_not_recognized__but_safe_to_change; 112 | 113 | public static ItemBuilder Service(this ItemBuilder dsl, string name, ServiceStartup dominate, ServiceStartup makeSubmissive) 114 | { 115 | return dsl 116 | .Setter( 117 | action => 118 | { 119 | ServiceTools.Configure(name, action == DominationAction.Dominate ? dominate : makeSubmissive); 120 | }) 121 | .Getter( 122 | () => 123 | { 124 | var configuration = ServiceTools.TryGetConfiguration(name); 125 | if (configuration == null) 126 | return (dominate == ServiceStartup.Disabled) 127 | ? DominatorState.Dominated(ServiceDoesNotExistMessage) 128 | : DominatorState.Indetermined(ServiceStateNotRecognizedMessage); 129 | 130 | if (configuration.Value.Startup == dominate) 131 | return DominatorState.Dominated(); 132 | if (configuration.Value.Startup == makeSubmissive) 133 | return DominatorState.Submissive(); 134 | 135 | return DominatorState.Indetermined(ServiceStateNotRecognizedMessage); 136 | }); 137 | } 138 | 139 | public static ItemBuilder Hosts(this ItemBuilder dsl, string blockingFile) 140 | { 141 | return dsl 142 | .Getter(() => 143 | { 144 | var hosts = HostsTools.ReadSystemHostsFile().SafeParseHostLines(); 145 | var blocked = HostsTools.ReadHostsFile(blockingFile).SafeParseHostLines().ExtractEntries(); 146 | return hosts.ContainsAllHostEntries(blocked) 147 | ? DominatorState.Dominated() 148 | : DominatorState.Submissive(); 149 | }) 150 | .Setter(action => 151 | { 152 | var hosts = HostsTools.ReadSystemHostsFile().SafeParseHostLines(); 153 | var blocked = HostsTools.ReadHostsFile(blockingFile).SafeParseHostLines().ExtractEntries(); 154 | switch (action) 155 | { 156 | case DominationAction.Dominate: 157 | { 158 | var result = hosts.Merge(blocked).ToLines(); 159 | HostsTools.WriteSystemHostsFile(result); 160 | } 161 | break; 162 | 163 | case DominationAction.MakeSubmissive: 164 | { 165 | var result = hosts.FilterHosts(blocked.Select(e => e.Host)).ToLines(); 166 | HostsTools.WriteSystemHostsFile(result); 167 | } 168 | break; 169 | } 170 | }) 171 | .More(showHostsFile, M_Show_the_system_s_hosts_file_); 172 | } 173 | 174 | static void showHostsFile() 175 | { 176 | var fn = Path.GetTempFileName(); 177 | var fntxt = Path.ChangeExtension(fn, "txt"); 178 | File.Move(fn, fntxt); 179 | File.Copy(HostsTools.SystemHostsFilePath, fntxt, overwrite: true); 180 | Process.Start(fntxt); 181 | } 182 | } 183 | } 184 | -------------------------------------------------------------------------------- /Dominator.Windows10/Settings/skype-ads.txt: -------------------------------------------------------------------------------- 1 | 0.0.0.0 rad.msn.com 2 | 0.0.0.0 live.rads.msn.com 3 | 0.0.0.0 ads1.msn.com 4 | 0.0.0.0 g.msn.com 5 | 0.0.0.0 a.ads2.msads.net 6 | 0.0.0.0 b.ads2.msads.net 7 | 0.0.0.0 ac3.msn.com 8 | 0.0.0.0 apps.skype.com 9 | 0.0.0.0 static.2mdn.net -------------------------------------------------------------------------------- /Dominator.Windows10/Settings/telemetry.txt: -------------------------------------------------------------------------------- 1 | 0.0.0.0 vortex.data.microsoft.com 2 | 0.0.0.0 vortex-win.data.microsoft.com 3 | 0.0.0.0 telecommand.telemetry.microsoft.com 4 | 0.0.0.0 telecommand.telemetry.microsoft.com.nsatc.net 5 | 0.0.0.0 oca.telemetry.microsoft.com 6 | 0.0.0.0 oca.telemetry.microsoft.com.nsatc.net 7 | 0.0.0.0 sqm.telemetry.microsoft.com 8 | 0.0.0.0 sqm.telemetry.microsoft.com.nsatc.net 9 | 0.0.0.0 watson.telemetry.microsoft.com 10 | 0.0.0.0 watson.telemetry.microsoft.com.nsatc.net 11 | 0.0.0.0 redir.metaservices.microsoft.com 12 | 0.0.0.0 choice.microsoft.com 13 | 0.0.0.0 choice.microsoft.com.nsatc.net 14 | 0.0.0.0 df.telemetry.microsoft.com 15 | 0.0.0.0 reports.wes.df.telemetry.microsoft.com 16 | 0.0.0.0 wes.df.telemetry.microsoft.com 17 | 0.0.0.0 services.wes.df.telemetry.microsoft.com 18 | 0.0.0.0 sqm.df.telemetry.microsoft.com 19 | 0.0.0.0 telemetry.microsoft.com 20 | 0.0.0.0 watson.ppe.telemetry.microsoft.com 21 | 0.0.0.0 telemetry.appex.bing.net 22 | 0.0.0.0 telemetry.urs.microsoft.com 23 | 0.0.0.0 telemetry.appex.bing.net:443 24 | 0.0.0.0 settings-sandbox.data.microsoft.com 25 | 0.0.0.0 vortex-sandbox.data.microsoft.com 26 | 0.0.0.0 survey.watson.microsoft.com 27 | 0.0.0.0 watson.live.com 28 | 0.0.0.0 watson.microsoft.com 29 | 0.0.0.0 statsfe2.ws.microsoft.com 30 | 0.0.0.0 corpext.msitadfs.glbdns2.microsoft.com 31 | 0.0.0.0 compatexchange.cloudapp.net 32 | 0.0.0.0 cs1.wpc.v0cdn.net 33 | 0.0.0.0 a-0001.a-msedge.net 34 | 0.0.0.0 statsfe2.update.microsoft.com.akadns.net 35 | 0.0.0.0 sls.update.microsoft.com.akadns.net 36 | 0.0.0.0 fe2.update.microsoft.com.akadns.net 37 | 0.0.0.0 65.55.108.23 38 | 0.0.0.0 65.39.117.230 39 | 0.0.0.0 23.218.212.69 40 | 0.0.0.0 134.170.30.202 41 | 0.0.0.0 137.116.81.24 42 | 0.0.0.0 diagnostics.support.microsoft.com 43 | 0.0.0.0 corp.sts.microsoft.com 44 | 0.0.0.0 statsfe1.ws.microsoft.com 45 | 0.0.0.0 pre.footprintpredict.com 46 | 0.0.0.0 204.79.197.200 47 | 0.0.0.0 i1.services.social.microsoft.com.nsatc.net 48 | 0.0.0.0 feedback.windows.com 49 | 0.0.0.0 feedback.microsoft-hohm.com 50 | 0.0.0.0 feedback.search.microsoft.com -------------------------------------------------------------------------------- /Dominator.Windows10/Tools/DPI.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace Dominator.Windows10.Tools 5 | { 6 | static class DPI 7 | { 8 | public static readonly int Display = getDPI(); 9 | 10 | static int getDPI() 11 | { 12 | IntPtr hDc = GetDC(IntPtr.Zero); 13 | if (hDc == null) 14 | throw new Exception("Failed to get DPIs for the display"); 15 | try 16 | { 17 | // int dpiX = GetDeviceCaps(hDc, LOGPIXELSX); 18 | int dpiY = GetDeviceCaps(hDc, LOGPIXELSY); 19 | return dpiY; 20 | } 21 | finally 22 | { 23 | ReleaseDC(IntPtr.Zero, hDc); 24 | } 25 | } 26 | 27 | const int LOGPIXELSX = 88; 28 | const int LOGPIXELSY = 90; 29 | 30 | [DllImport("user32.dll")] 31 | public static extern IntPtr GetDC(IntPtr hWnd); 32 | 33 | [DllImport("user32.dll")] 34 | static extern int ReleaseDC(IntPtr hWnd, IntPtr hDc); 35 | 36 | [DllImport("gdi32.dll")] 37 | static extern int GetDeviceCaps(IntPtr hDc, int nIndex); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Dominator.Windows10/Tools/DedicatedThreadDispatcher.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Concurrent; 3 | using System.Threading; 4 | 5 | namespace Dominator.Windows10.Tools 6 | { 7 | sealed class DedicatedThreadDispatcher 8 | { 9 | readonly BlockingCollection _eventQueue = new BlockingCollection(); 10 | readonly CancellationTokenSource _threadCancellation = new CancellationTokenSource(); 11 | 12 | public DedicatedThreadDispatcher() 13 | { 14 | // copy the variables the thread needs on the stack, so we don't capture 'this' 15 | // into the thread and so would prevent the finalizer from running. 16 | var cancellationToken = _threadCancellation.Token; 17 | var queue = _eventQueue; 18 | 19 | var thread = new Thread(() => EventDispatcherThread(cancellationToken, queue)); 20 | thread.Start(); 21 | } 22 | 23 | ~DedicatedThreadDispatcher() 24 | { 25 | _threadCancellation.Cancel(); 26 | } 27 | 28 | public void QueueAction(Action action) 29 | { 30 | _eventQueue.Add(action); 31 | } 32 | 33 | public void Dispose() 34 | { 35 | _threadCancellation.Cancel(); 36 | // We can not join the thread here, because we might be called back from it 37 | // and don't want to cause a deadlock. The GC will clean everything up 38 | // including the CancellationTokenSource and the BlockingCollection. 39 | } 40 | 41 | static void EventDispatcherThread(CancellationToken cancellationToken, BlockingCollection queue) 42 | { 43 | try 44 | { 45 | while (true) 46 | { 47 | var action = queue.Take(cancellationToken); 48 | action(); 49 | } 50 | } 51 | catch (OperationCanceledException) 52 | { } 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Dominator.Windows10/Tools/DisposeAction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Dominator.Windows10.Tools 4 | { 5 | struct DisposeAction : IDisposable 6 | { 7 | readonly Action _action; 8 | 9 | public DisposeAction(Action action) 10 | { 11 | _action = action; 12 | } 13 | 14 | public void Dispose() 15 | { 16 | _action(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Dominator.Windows10/Tools/HostEntry.cs: -------------------------------------------------------------------------------- 1 | namespace Dominator.Windows10.Tools 2 | { 3 | struct HostEntry 4 | { 5 | public HostEntry(string ip, string host) 6 | { 7 | IP = ip; 8 | Host = host; 9 | } 10 | 11 | public readonly string IP; 12 | public readonly string Host; 13 | 14 | #region R# 15 | 16 | public bool Equals(HostEntry other) 17 | { 18 | return string.Equals(IP, other.IP) && string.Equals(Host, other.Host); 19 | } 20 | 21 | public override bool Equals(object obj) 22 | { 23 | if (ReferenceEquals(null, obj)) 24 | return false; 25 | return obj is HostEntry && Equals((HostEntry)obj); 26 | } 27 | 28 | public override int GetHashCode() 29 | { 30 | unchecked 31 | { 32 | return ((IP != null ? IP.GetHashCode() : 0) * 397) ^ (Host != null ? Host.GetHashCode() : 0); 33 | } 34 | } 35 | 36 | public static bool operator ==(HostEntry left, HostEntry right) 37 | { 38 | return left.Equals(right); 39 | } 40 | 41 | public static bool operator !=(HostEntry left, HostEntry right) 42 | { 43 | return !left.Equals(right); 44 | } 45 | 46 | #endregion 47 | } 48 | } -------------------------------------------------------------------------------- /Dominator.Windows10/Tools/HostLine.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | 4 | namespace Dominator.Windows10.Tools 5 | { 6 | enum HostLineKind 7 | { 8 | CommentLine, 9 | EmptyLine, 10 | HostEntry, 11 | ParseError 12 | } 13 | 14 | enum HostLineError 15 | { 16 | NoSpaceOrTabDelimiterFound, 17 | ZeroLengthURL, 18 | FoundExcessCharactersAfterIPAndHost, 19 | InternalError 20 | } 21 | 22 | struct HostLine 23 | { 24 | public readonly HostLineKind Kind; 25 | public readonly HostEntry? Entry_; 26 | // note that comments do include all the prefixing whitespace and '#' 27 | public readonly string Comment_; 28 | public readonly HostLineError? Error_; 29 | public readonly string Line; 30 | 31 | public HostLine(HostLineKind kind, HostEntry? entry_ = null, string comment_ = null, HostLineError? error_ = null, string line_ = null) 32 | { 33 | Kind = kind; 34 | Entry_ = entry_; 35 | Comment_ = comment_; 36 | Error_ = error_; 37 | Line = line_ ?? mkLine(Entry_, Comment_); 38 | } 39 | 40 | static string mkLine(HostEntry? entry_, string comment_) 41 | { 42 | var sb = new StringBuilder(); 43 | if (entry_ != null) 44 | { 45 | sb.Append(entry_.Value.IP); 46 | sb.Append(' '); 47 | sb.Append(entry_.Value.Host); 48 | } 49 | 50 | if (comment_ != null) 51 | sb.Append(comment_); 52 | 53 | return sb.ToString(); 54 | } 55 | 56 | public override string ToString() 57 | { 58 | return Line; 59 | } 60 | 61 | public static HostLine FromEntry(HostEntry entry, string comment_ = null) 62 | { 63 | return new HostLine(HostLineKind.HostEntry, entry_: entry, comment_: comment_); 64 | } 65 | 66 | public static HostLine SafeParse(string line) 67 | { 68 | // The line parser should be pretty robust, but we'll never know for sure. 69 | try 70 | { 71 | return Parse(line); 72 | } 73 | catch (Exception) 74 | { 75 | return new HostLine(HostLineKind.ParseError, error_: HostLineError.InternalError); 76 | } 77 | } 78 | 79 | public static HostLine Parse(string line) 80 | { 81 | var todo = line.Trim(); 82 | if (todo == "") 83 | return new HostLine(HostLineKind.EmptyLine); 84 | 85 | if (todo.StartsWith("#")) 86 | return new HostLine(HostLineKind.CommentLine, comment_: line, line_: line); 87 | 88 | var firstSpaceOrTab = todo.IndexOfAny(new[] {' ', '\t'}); 89 | if (firstSpaceOrTab == -1) 90 | return Error(HostLineError.NoSpaceOrTabDelimiterFound, line); 91 | 92 | var ip = todo.Substring(0, firstSpaceOrTab); 93 | todo = todo.Substring(firstSpaceOrTab).TrimStart(); 94 | var urlEnd = todo.IndexOfAny(new[] {' ', '\t', '#'}); 95 | if (urlEnd == -1) 96 | { 97 | if (todo.Length == 0) 98 | return Error(HostLineError.ZeroLengthURL, line); 99 | return new HostLine(HostLineKind.HostEntry, new HostEntry(ip, todo), line_: line); 100 | } 101 | var host = todo.Substring(0, urlEnd); 102 | var rest = todo.Substring(urlEnd); 103 | todo = rest.TrimStart(); 104 | if (todo.StartsWith("#")) 105 | return new HostLine(HostLineKind.HostEntry, new HostEntry(ip, host), rest, line_: line); 106 | return Error(HostLineError.FoundExcessCharactersAfterIPAndHost, line); 107 | } 108 | 109 | static HostLine Error(HostLineError error, string line) 110 | { 111 | return new HostLine(HostLineKind.ParseError, error_: error, line_: line); 112 | } 113 | } 114 | } -------------------------------------------------------------------------------- /Dominator.Windows10/Tools/HostsTools.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | 7 | namespace Dominator.Windows10.Tools 8 | { 9 | static class HostsTools 10 | { 11 | public static readonly string SystemHostsFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), @"drivers\etc\hosts"); 12 | 13 | public static string[] ReadSystemHostsFile() 14 | { 15 | return ReadHostsFile(SystemHostsFilePath); 16 | } 17 | 18 | public static void WriteSystemHostsFile(IEnumerable lines) 19 | { 20 | WriteHostsFile(SystemHostsFilePath, lines); 21 | } 22 | 23 | public static string[] ReadHostsFile(string path) 24 | { 25 | return File.ReadAllLines(path, Encoding.ASCII); 26 | } 27 | 28 | public static void WriteHostsFile(string path, IEnumerable lines) 29 | { 30 | File.WriteAllLines(path, lines, Encoding.ASCII); 31 | } 32 | 33 | public static HostLine[] SafeParseHostLines(this IEnumerable lines) 34 | { 35 | return lines.Select(HostLine.SafeParse).ToArray(); 36 | } 37 | 38 | public static HostLine[] Merge(this IEnumerable left, IEnumerable right) 39 | { 40 | var todo = right.ToDictionary(he => he.Host, he => he); 41 | 42 | // first replace the ones that are already existing and delete them from the dictionary. 43 | 44 | var replaced = left.Select(line => 45 | { 46 | if (line.Kind != HostLineKind.HostEntry || !todo.ContainsKey(line.Entry_.Value.Host)) 47 | return line; 48 | 49 | var host = line.Entry_.Value.Host; 50 | var entry = todo[host]; 51 | todo.Remove(host); 52 | return new HostLine(HostLineKind.HostEntry, entry, comment_: line.Comment_); 53 | }).ToArray(); 54 | 55 | // then add the remaining ones. 56 | 57 | var remaining = todo.Values.Select(e => HostLine.FromEntry(e)); 58 | return replaced.Concat(remaining).ToArray(); 59 | } 60 | 61 | public static HostLine[] FilterHosts(this IEnumerable left, IEnumerable hosts) 62 | { 63 | var table = new HashSet(hosts); 64 | 65 | return left.Where(l => l.Kind != HostLineKind.HostEntry || !table.Contains(l.Entry_.Value.Host)).ToArray(); 66 | } 67 | 68 | public static bool ContainsAllHostEntries(this IEnumerable lines, IEnumerable entries) 69 | { 70 | var tocheck = entries.ToDictionary(l => l.Host, l => l); 71 | foreach (var line in lines) 72 | { 73 | if (line.Kind != HostLineKind.HostEntry) 74 | continue; 75 | 76 | var entry = line.Entry_.Value; 77 | var host = entry.Host; 78 | if (!tocheck.ContainsKey(host)) 79 | continue; 80 | 81 | var entryToCheck = tocheck[line.Entry_.Value.Host]; 82 | 83 | if (line.Entry_.Value.IP != entryToCheck.IP) 84 | continue; 85 | 86 | tocheck.Remove(host); 87 | } 88 | 89 | return tocheck.Count == 0; 90 | } 91 | 92 | public static HostEntry[] ExtractEntries(this IEnumerable lines) 93 | { 94 | return lines 95 | .Where(l => l.Kind == HostLineKind.HostEntry) 96 | .Select(l => l.Entry_.Value) 97 | .ToArray(); 98 | } 99 | 100 | public static string[] ToLines(this IEnumerable lines) 101 | { 102 | return lines.Select(l => l.Line).ToArray(); 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /Dominator.Windows10/Tools/Localization/Tools.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Dominator.Windows10.Tools.Localization { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Tools { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Tools() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Dominator.Windows10.Tools.Localization.Tools", typeof(Tools).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized string similar to Failed to start service {0}. 65 | /// 66 | internal static string M_Failed_to_start_service__0_ { 67 | get { 68 | return ResourceManager.GetString("M_Failed_to_start_service__0_", resourceCulture); 69 | } 70 | } 71 | 72 | /// 73 | /// Looks up a localized string similar to Failed to stop service {0}. 74 | /// 75 | internal static string M_Failed_to_stop_service__0_ { 76 | get { 77 | return ResourceManager.GetString("M_Failed_to_stop_service__0_", resourceCulture); 78 | } 79 | } 80 | 81 | /// 82 | /// Looks up a localized string similar to Service {0} is installed, but its startup option is not configured.. 83 | /// 84 | internal static string M_Service__0__is_installed__but_its_startup_option_is_not_configured_ { 85 | get { 86 | return ResourceManager.GetString("M_Service__0__is_installed__but_its_startup_option_is_not_configured_", resourceCulture); 87 | } 88 | } 89 | 90 | /// 91 | /// Looks up a localized string similar to Service {0} is not installed.. 92 | /// 93 | internal static string M_Service__0__is_not_installed_ { 94 | get { 95 | return ResourceManager.GetString("M_Service__0__is_not_installed_", resourceCulture); 96 | } 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /Dominator.Windows10/Tools/Localization/Tools.de.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | text/microsoft-resx 5 | 6 | 7 | 2.0 8 | 9 | 10 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 11 | 12 | 13 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 14 | 15 | 16 | Dienst {0} ist nicht installiert. 17 | 18 | 19 | Dienst {0} ist installiert, aber die Starteinstellung ist nicht konfiguriert. 20 | 21 | 22 | Fehler beim Anhalten von Dienst {0} 23 | 24 | 25 | Fehler beim Starten von Dienst {0} 26 | 27 | -------------------------------------------------------------------------------- /Dominator.Windows10/Tools/Localization/Tools.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | text/microsoft-resx 91 | 92 | 93 | 1.3 94 | 95 | 96 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 97 | 98 | 99 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 100 | 101 | 102 | Service {0} is not installed. 103 | 104 | 105 | Service {0} is installed, but its startup option is not configured. 106 | 107 | 108 | Failed to stop service {0} 109 | 110 | 111 | Failed to start service {0} 112 | 113 | -------------------------------------------------------------------------------- /Dominator.Windows10/Tools/ServiceConfiguration.cs: -------------------------------------------------------------------------------- 1 | namespace Dominator.Windows10.Tools 2 | { 3 | public enum ServiceStatus 4 | { 5 | Started, 6 | Stopped 7 | } 8 | 9 | public enum ServiceStartup 10 | { 11 | Automatic = 2, 12 | Manual = 3, 13 | Disabled = 4 14 | } 15 | 16 | public struct ServiceConfiguration 17 | { 18 | public readonly ServiceStartup Startup; 19 | public readonly ServiceStatus Status; 20 | 21 | public static readonly ServiceConfiguration Disabled = new ServiceConfiguration(ServiceStartup.Disabled, ServiceStatus.Stopped); 22 | 23 | public ServiceConfiguration(ServiceStartup startup, ServiceStatus status) 24 | { 25 | Startup = startup; 26 | Status = status; 27 | } 28 | 29 | #region R# 30 | 31 | public bool Equals(ServiceConfiguration other) 32 | { 33 | return Startup == other.Startup && Status == other.Status; 34 | } 35 | 36 | public override bool Equals(object obj) 37 | { 38 | if (ReferenceEquals(null, obj)) 39 | return false; 40 | return obj is ServiceConfiguration && Equals((ServiceConfiguration) obj); 41 | } 42 | 43 | public override int GetHashCode() 44 | { 45 | unchecked 46 | { 47 | return ((int) Startup*397) ^ (int) Status; 48 | } 49 | } 50 | 51 | public static bool operator ==(ServiceConfiguration left, ServiceConfiguration right) 52 | { 53 | return left.Equals(right); 54 | } 55 | 56 | public static bool operator !=(ServiceConfiguration left, ServiceConfiguration right) 57 | { 58 | return !left.Equals(right); 59 | } 60 | 61 | #endregion 62 | } 63 | } -------------------------------------------------------------------------------- /Dominator.Windows10/Tools/ServiceTools.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.ServiceProcess; 4 | using Microsoft.Win32; 5 | using static Dominator.Windows10.Tools.Localization.Tools; 6 | 7 | namespace Dominator.Windows10.Tools 8 | { 9 | static class ServiceTools 10 | { 11 | public static void Configure(string name, ServiceStartup startup) 12 | { 13 | if (!IsInstalled(name)) 14 | throw new Exception(string.Format(M_Service__0__is_not_installed_, name)); 15 | 16 | if (startup == ServiceStartup.Disabled) 17 | SetServiceStatus(name, ServiceStatus.Stopped); 18 | 19 | SetServiceStartup(name, startup); 20 | 21 | if (startup == ServiceStartup.Automatic) 22 | SetServiceStatus(name, ServiceStatus.Started); 23 | } 24 | 25 | public static ServiceConfiguration? TryGetConfiguration(string name) 26 | { 27 | if (!IsInstalled(name)) 28 | return null; 29 | var startup = TryGetServiceStartup(name); 30 | if (startup == null) 31 | throw new Exception(string.Format(M_Service__0__is_installed__but_its_startup_option_is_not_configured_, name)); 32 | var status = Status(name); 33 | return new ServiceConfiguration(startup.Value, ToServiceStatus(status)); 34 | } 35 | 36 | static ServiceStatus ToServiceStatus(ServiceControllerStatus status) 37 | { 38 | switch (status) 39 | { 40 | case ServiceControllerStatus.StopPending: 41 | return ServiceStatus.Stopped; 42 | case ServiceControllerStatus.Stopped: 43 | return ServiceStatus.Stopped; 44 | default: 45 | return ServiceStatus.Started; 46 | } 47 | } 48 | 49 | public static bool IsInstalled(string name) 50 | { 51 | return Registry.GetValue(mkServiceKey(name), "ImagePath", null) != null; 52 | } 53 | 54 | public static ServiceStartup? TryGetServiceStartup(string name) 55 | { 56 | var value = Registry.GetValue(mkServiceKey(name), "Start", null); 57 | if (!(value is int)) 58 | return null; 59 | 60 | switch ((int)value) 61 | { 62 | case (int)ServiceStartup.Automatic: 63 | return ServiceStartup.Automatic; 64 | case (int)ServiceStartup.Manual: 65 | return ServiceStartup.Manual; 66 | case (int)ServiceStartup.Disabled: 67 | return ServiceStartup.Disabled; 68 | } 69 | 70 | return null; 71 | } 72 | 73 | public static void SetServiceStartup(string name, ServiceStartup startup) 74 | { 75 | Registry.SetValue(mkServiceKey(name), "Start", (int)startup, RegistryValueKind.DWord); 76 | } 77 | 78 | public static void SetServiceStatus(string name, ServiceStatus status) 79 | { 80 | switch (status) 81 | { 82 | case ServiceStatus.Started: 83 | Start(name, StatusChangeTimeout); 84 | return; 85 | case ServiceStatus.Stopped: 86 | Stop(name, StatusChangeTimeout); 87 | return; 88 | } 89 | 90 | Debug.Assert(false, status.ToString()); 91 | } 92 | 93 | static readonly TimeSpan StatusChangeTimeout = TimeSpan.FromMilliseconds(5000); 94 | 95 | public static ServiceControllerStatus Status(string service) 96 | { 97 | using (var sc = new ServiceController(service)) 98 | { 99 | return sc.Status; 100 | } 101 | } 102 | 103 | public static void Stop(string service, TimeSpan timeToWait) 104 | { 105 | using (var sc = new ServiceController(service)) 106 | { 107 | if (sc.Status == ServiceControllerStatus.Stopped) 108 | return; 109 | sc.Stop(); 110 | sc.WaitForStatus(ServiceControllerStatus.Stopped, timeToWait); 111 | Console.WriteLine(sc.Status); 112 | if (sc.Status != ServiceControllerStatus.Stopped) 113 | throw new Exception(string.Format(M_Failed_to_stop_service__0_, service)); 114 | } 115 | } 116 | 117 | public static void Start(string service, TimeSpan timeToWait) 118 | { 119 | using (var sc = new ServiceController(service)) 120 | { 121 | if (sc.Status == ServiceControllerStatus.Running) 122 | return; 123 | sc.Start(); 124 | sc.WaitForStatus(ServiceControllerStatus.Running, timeToWait); 125 | if (sc.Status != ServiceControllerStatus.Running) 126 | throw new Exception(string.Format(M_Failed_to_start_service__0_, service)); 127 | } 128 | } 129 | 130 | 131 | static string mkServiceKey(string service) 132 | { 133 | return BaseKey + "\\" + service; 134 | } 135 | 136 | const string BaseKey = @"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services"; 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /Dominator.Windows10/Tools/SoftSynchronization.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | 4 | namespace Dominator.Windows10.Tools 5 | { 6 | static class Soft 7 | { 8 | public class Section 9 | { 10 | public bool IsLocked { get; private set; } 11 | 12 | public IDisposable Lock() 13 | { 14 | Debug.Assert(!IsLocked); 15 | IsLocked = true; 16 | return new DisposeAction(() => 17 | { 18 | Debug.Assert(IsLocked); 19 | IsLocked = false; 20 | }); 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Dominator.Windows10/UI.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Windows; 4 | using System.Windows.Controls; 5 | using System.Windows.Documents; 6 | using System.Windows.Media; 7 | using System.Windows.Media.Animation; 8 | using Dominator.Net; 9 | using Dominator.Windows10.Tools; 10 | using ToggleSwitch; 11 | using static Dominator.Windows10.Localization.Application; 12 | 13 | namespace Dominator.Windows10 14 | { 15 | static class UI 16 | { 17 | public static UIElement ForDominator(IDominator dominator, IUIRegistrationContext registrationContext) 18 | { 19 | return dominator.DispatchTo(group => ForGroup(group, registrationContext), item => ForItem(item, registrationContext)); 20 | } 21 | 22 | public static UIElement ForGroup(IDominatorGroup group, IUIRegistrationContext context) 23 | { 24 | var panel = new StackPanel(); 25 | var description = CreateDescription(group.Description, forGroup: true); 26 | panel.Children.Add(description); 27 | 28 | var nestedStackPanel = new StackPanel 29 | { 30 | Margin = new Thickness(16, 8, 0, 8) 31 | }; 32 | 33 | foreach (var nested in group.Nested) 34 | { 35 | var nestedUI = ForDominator(nested, context); 36 | nestedStackPanel.Children.Add(nestedUI); 37 | } 38 | 39 | panel.Children.Add(nestedStackPanel); 40 | return panel; 41 | } 42 | 43 | static readonly Brush RedBrush = new SolidColorBrush(Colors.Red); 44 | const int DefaultMargin = 6; 45 | 46 | public static UIElement ForItem(IDominatorItem item, IUIRegistrationContext context) 47 | { 48 | var panel = new StackPanel 49 | { 50 | Margin = new Thickness(0, 0, 0, DefaultMargin * 2) 51 | }; 52 | var description = CreateDescription(item.Description, forGroup: false); 53 | panel.Children.Add(description); 54 | 55 | var switchPanel = new DockPanel 56 | { 57 | Margin = new Thickness(0, DefaultMargin, 0, 0) 58 | }; 59 | 60 | var sw = createSwitch(); 61 | sw.VerticalAlignment = VerticalAlignment.Top; 62 | 63 | switchPanel.Children.Add(sw); 64 | // we don't want to use actual Label controls, because they parse '_' underscores as 65 | // Alt Key shortcuts. 66 | var errorLabel = CreateTextBlock(""); 67 | errorLabel.VerticalAlignment = VerticalAlignment.Center; 68 | errorLabel.Foreground = RedBrush; 69 | errorLabel.Margin = new Thickness(DefaultMargin*2, 0, DefaultMargin, 0); 70 | 71 | var messageLabel = CreateTextBlock(""); 72 | messageLabel.VerticalAlignment = VerticalAlignment.Center; 73 | messageLabel.Margin = new Thickness(DefaultMargin * 2, 0, DefaultMargin, 0); 74 | 75 | switchPanel.Children.Add(errorLabel); 76 | switchPanel.Children.Add(messageLabel); 77 | 78 | // argh, that **** calls us back when we change the state manually. 79 | var section = new Soft.Section(); 80 | 81 | sw.Checked += (sender, args) => 82 | { 83 | if (!section.IsLocked) 84 | context.requestAction(item, DominationAction.Dominate); 85 | }; 86 | 87 | sw.Unchecked += (sender, args) => 88 | { 89 | if (!section.IsLocked) 90 | context.requestAction(item, DominationAction.MakeSubmissive); 91 | }; 92 | 93 | context.registerFeedback(item, 94 | state => 95 | { 96 | bool error = state.Error_ != null; 97 | if (error) 98 | { 99 | errorLabel.Text = state.Error_.Message; 100 | } 101 | else 102 | { 103 | Debug.Assert(state.State_ != null); 104 | switch (state.State_.Value.Kind) 105 | { 106 | case DominatorStateKind.Dominated: 107 | using (section.Lock()) 108 | sw.IsChecked = true; 109 | break; 110 | case DominatorStateKind.Submissive: 111 | using (section.Lock()) 112 | sw.IsChecked = false; 113 | sw.UncheckedContent = L_YES; 114 | sw.UncheckedBackground = UncheckedBackgroundRed; 115 | break; 116 | case DominatorStateKind.Indetermined: 117 | using (section.Lock()) 118 | sw.IsChecked = false; 119 | sw.UncheckedContent = L_N_A; 120 | sw.UncheckedBackground = UncheckedBackgroundOrange; 121 | break; 122 | } 123 | 124 | messageLabel.Text = state.State_.Value.Message; 125 | } 126 | 127 | errorLabel.Visibility = error ? Visibility.Visible : Visibility.Collapsed; 128 | messageLabel.Visibility = error ? Visibility.Collapsed : Visibility.Visible; 129 | }); 130 | 131 | panel.Children.Add(switchPanel); 132 | return panel; 133 | } 134 | 135 | static HorizontalToggleSwitch createSwitch() 136 | { 137 | var sw = new HorizontalToggleSwitch 138 | { 139 | UncheckedContent = L_YES, 140 | CheckedContent = L_NO_, 141 | Margin = new Thickness(DefaultMargin, 0, 0, 0), 142 | Padding = new Thickness(0) 143 | }; 144 | 145 | return sw; 146 | } 147 | 148 | static readonly Brush UncheckedBackgroundOrange = new SolidColorBrush(Colors.Orange); 149 | static readonly Brush UncheckedBackgroundRed = getOriginalUncheckedBrush(); 150 | 151 | static Brush getOriginalUncheckedBrush() 152 | { 153 | var sw = new HorizontalToggleSwitch(); 154 | return sw.UncheckedBackground; 155 | } 156 | 157 | public static UIElement CreateDescription(DominatorDescription description, bool forGroup) 158 | { 159 | var panel = new StackPanel(); 160 | var hasExplanation = description.Explanation != ""; 161 | var showTitle = hasExplanation; 162 | 163 | if (showTitle) 164 | { 165 | var title = CreateTextBlock(description.Title); 166 | title.FontSize = forGroup ? 22 : 16; 167 | panel.Children.Add(title); 168 | } 169 | 170 | var explanation = hasExplanation ? description.Explanation : description.Title; 171 | 172 | var explanationLabel = CreateTextBlock(explanation); 173 | if (!showTitle) 174 | explanationLabel.FontSize = forGroup ? 22 : 16; 175 | 176 | if (description.More_ != null) 177 | { 178 | var hPanel = new Grid 179 | { 180 | ColumnDefinitions = 181 | { 182 | new ColumnDefinition 183 | { 184 | Width=new GridLength(1, GridUnitType.Star) 185 | }, 186 | new ColumnDefinition 187 | { 188 | Width = GridLength.Auto 189 | } 190 | } 191 | }; 192 | hPanel.Children.Add(explanationLabel); 193 | var moreLink = createHyperlink(M_more___, description.More_.Value.Action, description.More_.Value.Info); 194 | moreLink.Margin = new Thickness(0, 0, 0, DefaultMargin); 195 | moreLink.VerticalAlignment = VerticalAlignment.Bottom; 196 | Grid.SetColumn(moreLink, 1); 197 | hPanel.Children.Add(moreLink); 198 | panel.Children.Add(hPanel); 199 | } 200 | else 201 | { 202 | panel.Children.Add(explanationLabel); 203 | } 204 | 205 | return panel; 206 | } 207 | 208 | static TextBlock createHyperlink(string text, Action action, string info) 209 | { 210 | var hl = new Hyperlink 211 | { 212 | Inlines = 213 | { 214 | new Run 215 | { 216 | Text = text 217 | } 218 | } 219 | }; 220 | 221 | hl.Click += (sender, args) => 222 | { 223 | try 224 | { 225 | action(); 226 | } 227 | catch (Exception) 228 | { 229 | // ignored 230 | } 231 | }; 232 | 233 | var tb = new TextBlock 234 | { 235 | Inlines = { hl }, 236 | }; 237 | 238 | if (info != "") 239 | { 240 | tb.ToolTip = info; 241 | } 242 | 243 | return tb; 244 | } 245 | 246 | public static TextBlock CreateTextBlock(string text) 247 | { 248 | return new TextBlock 249 | { 250 | Margin = new Thickness(DefaultMargin), 251 | Text = text, 252 | TextWrapping = TextWrapping.WrapWithOverflow 253 | }; 254 | } 255 | } 256 | 257 | interface IUIRegistrationContext 258 | { 259 | void requestAction(IDominatorItem dominator, DominationAction action); 260 | void registerFeedback(IDominatorItem dominator, Action feedbackFunction); 261 | } 262 | } 263 | -------------------------------------------------------------------------------- /Dominator.Windows10/UIController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Windows.Threading; 6 | using Dominator.Net; 7 | using Dominator.Windows10.Tools; 8 | 9 | namespace Dominator.Windows10 10 | { 11 | sealed class UIController : IUIRegistrationContext, IDisposable 12 | { 13 | readonly Dispatcher _uiThreadDispatcher; 14 | readonly Dictionary> _feedback = new Dictionary>(); 15 | readonly DedicatedThreadDispatcher _dispatcher = new DedicatedThreadDispatcher(); 16 | 17 | public UIController() 18 | { 19 | _uiThreadDispatcher = Dispatcher.CurrentDispatcher; 20 | } 21 | 22 | public void Dispose() 23 | { 24 | requireOnUIThread(); 25 | 26 | _dispatcher.Dispose(); 27 | } 28 | 29 | public void requestAction(IDominatorItem dominator, DominationAction action) 30 | { 31 | requireOnUIThread(); 32 | scheduleDominationAndFeedback(dominator, action); 33 | } 34 | 35 | public void registerFeedback(IDominatorItem dominator, Action feedbackFunction) 36 | { 37 | requireOnUIThread(); 38 | _feedback[dominator] = feedbackFunction; 39 | } 40 | 41 | public void scheduleUpdateAllStates() 42 | { 43 | var allItems = AllItems.ToArray(); 44 | schedule(() => 45 | { 46 | var allStates = allItems 47 | .Select(item => new { Item = item, State = item.QueryState() }) 48 | .ToArray(); 49 | 50 | scheduleToUI(() => 51 | { 52 | foreach (var state in allStates) 53 | feedBackState(state.Item, state.State); 54 | }); 55 | }); 56 | } 57 | 58 | void scheduleDominationAndFeedback(IDominatorItem dominator, DominationAction action) 59 | { 60 | schedule(() => 61 | { 62 | try 63 | { 64 | dominator.SetState(action); 65 | var state = dominator.QueryState(); 66 | scheduleToUI(() => feedBackState(dominator, state)); 67 | } 68 | catch (Exception e) 69 | { 70 | var state = new DominationState(e); 71 | scheduleToUI(() => feedBackState(dominator, state)); 72 | } 73 | }); 74 | } 75 | 76 | void scheduleFeedbackFor(IDominatorItem dominator) 77 | { 78 | schedule(() => 79 | { 80 | var state = dominator.QueryState(); 81 | scheduleToUI(() => feedBackState(dominator, state)); 82 | }); 83 | } 84 | 85 | void schedule(Action action) 86 | { 87 | _dispatcher.QueueAction(action); 88 | } 89 | 90 | void feedBackState(IDominatorItem dominator, DominationState state) 91 | { 92 | requireOnUIThread(); 93 | _feedback[dominator](state); 94 | } 95 | 96 | void scheduleToUI(Action action) 97 | { 98 | _uiThreadDispatcher.InvokeAsync(action); 99 | } 100 | 101 | IEnumerable AllItems 102 | { 103 | get 104 | { 105 | requireOnUIThread(); 106 | return _feedback.Keys; 107 | } 108 | } 109 | 110 | [Conditional("DEBUG")] 111 | void requireOnUIThread() 112 | { 113 | Debug.Assert(Dispatcher.CurrentDispatcher == _uiThreadDispatcher); 114 | } 115 | } 116 | } -------------------------------------------------------------------------------- /Dominator.Windows10/app.manifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Dominator.Windows10/hammer.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pragmatrix/Dominator/06fba9d33ac529c551710bd42709b44820b1f49d/Dominator.Windows10/hammer.ico -------------------------------------------------------------------------------- /Dominator.Windows10/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Dominator.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.23107.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dominator.Windows10", "Dominator.Windows10\Dominator.Windows10.csproj", "{682BD86C-1911-46CE-87FE-53381679C08B}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dominator.Net", "Dominator.Net\Dominator.Net.csproj", "{5510519F-6352-4690-86E5-0FBB1F5B6088}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dominator.Tests", "Dominator.Tests\Dominator.Tests.csproj", "{4437A05C-6AA0-498E-9E74-B73EE66052E6}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Release|Any CPU = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {682BD86C-1911-46CE-87FE-53381679C08B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {682BD86C-1911-46CE-87FE-53381679C08B}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {682BD86C-1911-46CE-87FE-53381679C08B}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {682BD86C-1911-46CE-87FE-53381679C08B}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {5510519F-6352-4690-86E5-0FBB1F5B6088}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {5510519F-6352-4690-86E5-0FBB1F5B6088}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {5510519F-6352-4690-86E5-0FBB1F5B6088}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {5510519F-6352-4690-86E5-0FBB1F5B6088}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {4437A05C-6AA0-498E-9E74-B73EE66052E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {4437A05C-6AA0-498E-9E74-B73EE66052E6}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {4437A05C-6AA0-498E-9E74-B73EE66052E6}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {4437A05C-6AA0-498E-9E74-B73EE66052E6}.Release|Any CPU.Build.0 = Release|Any CPU 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | EndGlobal 35 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | DATE:=$(shell date +'%Y%m%d%H%M') 2 | package=Dominator10_${DATE} 3 | 4 | .PHONY: all 5 | all: 6 | echo "no target" 7 | 8 | .PHONY: own 9 | own: 10 | chown -R ${USERNAME} * 11 | 12 | conf=Release 13 | msbuild=msbuild.exe /verbosity:m /nologo /p:Configuration=${conf} 14 | 15 | # don't want to expose our actual build path, so we build in the tmp directory 16 | 17 | package_files=Dominator.Net.dll ToggleSwitch.dll "Windows 10 Dominator.exe" "Windows 10 Dominator.exe.config" "Settings/skype-ads.txt" "Settings/telemetry.txt" "de/Windows 10 Dominator.resources.dll" 18 | 19 | builddir=${package}_build 20 | 21 | appdir=Dominator.Windows10 22 | toolsdir=${appdir}/Tools 23 | settingsdir=${appdir}/Settings 24 | 25 | .PHONY: import-de 26 | import-de: 27 | cp /tmp/${appdir}_Application.de.xlf ${appdir}/Localization/Application.de.xlf 28 | cp /tmp/${appdir}_Tools.de.xlf ${toolsdir}/Localization/Tools.de.xlf 29 | cp /tmp/${appdir}_Settings.de.xlf ${settingsdir}/Localization/Settings.de.xlf 30 | 31 | .PHONY: package 32 | package: 33 | rm -rf /tmp/${builddir} 34 | mkdir -p /tmp/${builddir} 35 | cp -R * /tmp/${builddir} 36 | make -C /tmp/${builddir} build 37 | 38 | rm -rf /tmp/${package} 39 | mkdir -p /tmp/${package} 40 | cd /tmp/${builddir}/Dominator.Windows10/bin/${conf} && cp --parents ${package_files} /tmp/${package}/ 41 | rm -f /tmp/${package}.zip 42 | cd /tmp && zip -r ${package}.zip ${package} 43 | 44 | .PHONY: build 45 | build: 46 | ${msbuild} Dominator.sln /t:"Clean" 47 | ${msbuild} Dominator.sln /t:"Build" 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Windows 10 Dominator 2 | 3 | [![Build status](https://ci.appveyor.com/api/projects/status/8uicoi1ompqqp29w?svg=true)](https://ci.appveyor.com/project/pragmatrix/dominator) 4 | 5 | A Windows desktop application that protects your privacy. 6 | 7 | ![Windows 10 Dominator Screenshot](https://cloud.githubusercontent.com/assets/1003751/9167242/808caa6e-3f54-11e5-83f3-2a732b2ed4a9.jpg) 8 | 9 | License: [MIT] 10 | 11 | (c) 2018 Armin Sander 12 | 13 | Application icon thankfully provided by [Icons8](https://icons8.com) 14 | 15 | [MIT]: https://opensource.org/licenses/MIT 16 | --------------------------------------------------------------------------------