private void FillKeys(RegistryKeySnapshot snapshot, RegistryKey key) { if (key.SubKeyCount != 0) { RegistryKeySnapshotCollection children; children = new RegistryKeySnapshotCollection(snapshot); // ReSharper disable once LoopCanBePartlyConvertedToQuery foreach (string name in key.GetSubKeyNames()) { // HACK: Although I thought key names were unique, clearly I was wrong as the scan used to crash on // HKEY_LOCAL_MACHINE\SOFTWARE\Yamaha APO which appears at least twice on my system, although RegEdit // only shows a single copy if (!children.Contains(this.GetShortName(name))) { RegistryKey subKey; subKey = this.GetSubKey(key, name); if (subKey != null) { RegistryKeySnapshot childSnapshot; childSnapshot = this.TakeSnapshot(subKey); children.Add(childSnapshot); } } } snapshot.SubKeys = children; } }
private void SetParents(RegistryKeySnapshot key) { RegistryKeySnapshotCollection subKeys; RegistryValueSnapshotCollection values; values = key.Values; subKeys = key.SubKeys; if (values != null) { values.Parent = key; } if (subKeys != null) { subKeys.Parent = key; foreach (RegistryKeySnapshot child in subKeys) { child.Parent = key; this.SetParents(child); } } }
private RegistryKeySnapshot TakeSnapshot(RegistryKey key) { RegistryKeySnapshot snapshot; string name; Trace.WriteLine($"Scanning: {key.Name}"); name = this.GetShortName(key.Name); snapshot = new RegistryKeySnapshot(name); this.FillSnapshot(snapshot, key); return(snapshot); }
private void FillValues(RegistryKeySnapshot snapshot, RegistryKey key) { if (key.ValueCount != 0) { RegistryValueSnapshotCollection children; string[] names; children = new RegistryValueSnapshotCollection(snapshot); try { names = key.GetValueNames(); } catch (IOException) { // system error, saw this in latest Windows 10 // when trying to scan HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager\CreativeEventCache\SubscribedContent-314559 names = _emptyArray; } for (int i = 0; i < names.Length; i++) { string name; string value; RegistryValueKind type; object rawValue; name = names[i]; type = key.GetValueKind(name); rawValue = this.GetValue(key, type, name); value = this.TransformRawValue(type, rawValue); children.Add(new RegistryValueSnapshot(name, value, type)); } snapshot.Values = children; } }
private void FillValues(RegistryKeySnapshot snapshot, RegistryKey key) { if (key.ValueCount != 0) { RegistryValueSnapshotCollection children; children = new RegistryValueSnapshotCollection(snapshot); foreach (string name in key.GetValueNames()) { string value; RegistryValueKind type; object rawValue; type = key.GetValueKind(name); rawValue = this.GetValue(key, type, name); value = this.TransformRawValue(type, rawValue); children.Add(new RegistryValueSnapshot(name, value, type)); } snapshot.Values = children; } }
private void FillSnapshot(RegistryKeySnapshot snapshot, RegistryKey key) { this.FillKeys(snapshot, key); this.FillValues(snapshot, key); }
public RegistryValueSnapshotCollection(RegistryKeySnapshot parent) : this() { this.Parent = parent; }
private void CompareKeys(RegistryKeySnapshot lhs, RegistryKeySnapshot rhs, ICollection <ChangeResult> results) { this.CompareValues(lhs.Values, rhs.Values, results); this.CompareKeys(lhs.SubKeys, rhs.SubKeys, results); }
private void CompareKeys(RegistryKeySnapshot lhs, RegistryKeySnapshot rhs, ICollection<ChangeResult> results) { this.CompareValues(lhs.Values, rhs.Values, results); this.CompareKeys(lhs.SubKeys, rhs.SubKeys, results); }
private RegistryKeySnapshot TakeSnapshot(RegistryKey key) { RegistryKeySnapshot snapshot; string name; Trace.WriteLine($"Scanning: {key.Name}"); name = this.GetShortName(key.Name); snapshot = new RegistryKeySnapshot(name); this.FillSnapshot(snapshot, key); return snapshot; }