| | 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 | |
|
| 0 | 14 | | public SHRegistryKey(RegistryHive hive, string machineName) |
| 0 | 15 | | { |
| 0 | 16 | | var remoteKey = RegistryKey.OpenRemoteBaseKey(hive, machineName); |
| 0 | 17 | | _currentKey = remoteKey; |
| 0 | 18 | | } |
| | 19 | |
|
| | 20 | | public object GetValue(string subkey, string name) |
| 0 | 21 | | { |
| 0 | 22 | | var key = _currentKey.OpenSubKey(subkey); |
| 0 | 23 | | return key?.GetValue(name); |
| 0 | 24 | | } |
| | 25 | | } |
| | 26 | |
|
| | 27 | | public class MockRegistryKey : IRegistryKey |
| | 28 | | { |
| | 29 | | public virtual object GetValue(string subkey, string name) |
| | 30 | | { |
| | 31 | | throw new System.NotImplementedException(); |
| | 32 | | } |
| | 33 | | } |
| | 34 | | } |