| | 1 | | using Microsoft.Win32; |
| | 2 | |
|
| | 3 | | namespace SharpHoundCommonLib |
| | 4 | | { |
| | 5 | | public interface IRegistryKey |
| | 6 | | { |
| | 7 | | public object GetValue(string subkey, string name); |
| | 8 | | } |
| | 9 | |
|
| | 10 | | public class SHRegistryKey : IRegistryKey |
| | 11 | | { |
| | 12 | | private RegistryKey _currentKey; |
| | 13 | |
|
| | 14 | | public SHRegistryKey(RegistryHive hive, string machineName) |
| | 15 | | { |
| | 16 | | var remoteKey = RegistryKey.OpenRemoteBaseKey(hive, machineName); |
| | 17 | | _currentKey = remoteKey; |
| | 18 | | } |
| | 19 | |
|
| | 20 | | public object GetValue(string subkey, string name) |
| | 21 | | { |
| | 22 | | var key = _currentKey.OpenSubKey(subkey); |
| | 23 | | return key?.GetValue(name); |
| | 24 | | } |
| | 25 | | } |
| | 26 | |
|
| | 27 | | public class MockRegistryKey : IRegistryKey |
| | 28 | | { |
| | 29 | | public virtual object GetValue(string subkey, string name) |
| 0 | 30 | | { |
| 0 | 31 | | throw new System.NotImplementedException(); |
| | 32 | | } |
| | 33 | | } |
| | 34 | | } |