This commit is contained in:
niko
2026-06-04 11:42:34 +02:00
parent f39ba70a9f
commit e720b98cd1
7488 changed files with 2493818 additions and 0 deletions
+56
View File
@@ -0,0 +1,56 @@
using System;
using System.Text;
namespace Microsoft.Win32
{
// Token: 0x02000079 RID: 121
internal class ExpandString
{
// Token: 0x06000734 RID: 1844 RVA: 0x00015EBC File Offset: 0x000140BC
public ExpandString(string s)
{
this.value = s;
}
// Token: 0x06000735 RID: 1845 RVA: 0x00015ECC File Offset: 0x000140CC
public override string ToString()
{
return this.value;
}
// Token: 0x06000736 RID: 1846 RVA: 0x00015ED4 File Offset: 0x000140D4
public string Expand()
{
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < this.value.Length; i++)
{
if (this.value[i] == '%')
{
int j;
for (j = i + 1; j < this.value.Length; j++)
{
if (this.value[j] == '%')
{
string text = this.value.Substring(i + 1, j - i - 1);
stringBuilder.Append(Environment.GetEnvironmentVariable(text));
i += j;
break;
}
}
if (j == this.value.Length)
{
stringBuilder.Append('%');
}
}
else
{
stringBuilder.Append(this.value[i]);
}
}
return stringBuilder.ToString();
}
// Token: 0x04000101 RID: 257
private string value;
}
}
+53
View File
@@ -0,0 +1,53 @@
using System;
namespace Microsoft.Win32
{
// Token: 0x02000072 RID: 114
internal interface IRegistryApi
{
// Token: 0x060006F1 RID: 1777
RegistryKey CreateSubKey(RegistryKey rkey, string keyname);
// Token: 0x060006F2 RID: 1778
RegistryKey OpenRemoteBaseKey(RegistryHive hKey, string machineName);
// Token: 0x060006F3 RID: 1779
RegistryKey OpenSubKey(RegistryKey rkey, string keyname, bool writtable);
// Token: 0x060006F4 RID: 1780
void Flush(RegistryKey rkey);
// Token: 0x060006F5 RID: 1781
void Close(RegistryKey rkey);
// Token: 0x060006F6 RID: 1782
object GetValue(RegistryKey rkey, string name, object default_value, RegistryValueOptions options);
// Token: 0x060006F7 RID: 1783
void SetValue(RegistryKey rkey, string name, object value);
// Token: 0x060006F8 RID: 1784
int SubKeyCount(RegistryKey rkey);
// Token: 0x060006F9 RID: 1785
int ValueCount(RegistryKey rkey);
// Token: 0x060006FA RID: 1786
void DeleteValue(RegistryKey rkey, string value, bool throw_if_missing);
// Token: 0x060006FB RID: 1787
void DeleteKey(RegistryKey rkey, string keyName, bool throw_if_missing);
// Token: 0x060006FC RID: 1788
string[] GetSubKeyNames(RegistryKey rkey);
// Token: 0x060006FD RID: 1789
string[] GetValueNames(RegistryKey rkey);
// Token: 0x060006FE RID: 1790
string ToString(RegistryKey rkey);
// Token: 0x060006FF RID: 1791
void SetValue(RegistryKey rkey, string name, object value, RegistryValueKind valueKind);
}
}
+606
View File
@@ -0,0 +1,606 @@
using System;
using System.Collections;
using System.IO;
using System.Security;
using System.Threading;
namespace Microsoft.Win32
{
// Token: 0x0200007A RID: 122
internal class KeyHandler
{
// Token: 0x06000737 RID: 1847 RVA: 0x00015FAC File Offset: 0x000141AC
private KeyHandler(RegistryKey rkey, string basedir)
{
if (!Directory.Exists(basedir))
{
try
{
Directory.CreateDirectory(basedir);
}
catch (UnauthorizedAccessException)
{
throw new SecurityException("No access to the given key");
}
}
this.Dir = basedir;
this.file = Path.Combine(this.Dir, "values.xml");
this.Load();
}
// Token: 0x06000739 RID: 1849 RVA: 0x00016048 File Offset: 0x00014248
public void Load()
{
this.values = new Hashtable();
if (!File.Exists(this.file))
{
return;
}
try
{
using (FileStream fileStream = File.OpenRead(this.file))
{
StreamReader streamReader = new StreamReader(fileStream);
string text = streamReader.ReadToEnd();
if (text.Length != 0)
{
SecurityElement securityElement = SecurityElement.FromString(text);
if (securityElement.Tag == "values" && securityElement.Children != null)
{
foreach (object obj in securityElement.Children)
{
SecurityElement securityElement2 = (SecurityElement)obj;
if (securityElement2.Tag == "value")
{
this.LoadKey(securityElement2);
}
}
}
}
}
}
catch (UnauthorizedAccessException)
{
this.values.Clear();
throw new SecurityException("No access to the given key");
}
catch (Exception ex)
{
Console.Error.WriteLine("While loading registry key at {0}: {1}", this.file, ex);
this.values.Clear();
}
}
// Token: 0x0600073A RID: 1850 RVA: 0x000161E8 File Offset: 0x000143E8
private void LoadKey(SecurityElement se)
{
Hashtable attributes = se.Attributes;
try
{
string text = (string)attributes["name"];
if (text != null)
{
string text2 = (string)attributes["type"];
if (text2 != null)
{
string text3 = text2;
switch (text3)
{
case "int":
this.values[text] = int.Parse(se.Text);
break;
case "bytearray":
this.values[text] = Convert.FromBase64String(se.Text);
break;
case "string":
this.values[text] = se.Text;
break;
case "expand":
this.values[text] = new ExpandString(se.Text);
break;
case "qword":
this.values[text] = long.Parse(se.Text);
break;
case "string-array":
{
ArrayList arrayList = new ArrayList();
if (se.Children != null)
{
foreach (object obj in se.Children)
{
SecurityElement securityElement = (SecurityElement)obj;
arrayList.Add(securityElement.Text);
}
}
this.values[text] = arrayList.ToArray(typeof(string));
break;
}
}
}
}
}
catch
{
}
}
// Token: 0x0600073B RID: 1851 RVA: 0x00016434 File Offset: 0x00014634
public RegistryKey Ensure(RegistryKey rkey, string extra, bool writable)
{
Type typeFromHandle = typeof(KeyHandler);
RegistryKey registryKey2;
lock (typeFromHandle)
{
string text = Path.Combine(this.Dir, extra);
KeyHandler keyHandler = (KeyHandler)KeyHandler.dir_to_handler[text];
if (keyHandler == null)
{
keyHandler = new KeyHandler(rkey, text);
}
RegistryKey registryKey = new RegistryKey(keyHandler, KeyHandler.CombineName(rkey, extra), writable);
KeyHandler.key_to_handler[registryKey] = keyHandler;
KeyHandler.dir_to_handler[text] = keyHandler;
registryKey2 = registryKey;
}
return registryKey2;
}
// Token: 0x0600073C RID: 1852 RVA: 0x000164D8 File Offset: 0x000146D8
public RegistryKey Probe(RegistryKey rkey, string extra, bool writable)
{
RegistryKey registryKey = null;
Type typeFromHandle = typeof(KeyHandler);
RegistryKey registryKey2;
lock (typeFromHandle)
{
string text = Path.Combine(this.Dir, extra);
KeyHandler keyHandler = (KeyHandler)KeyHandler.dir_to_handler[text];
if (keyHandler != null)
{
registryKey = new RegistryKey(keyHandler, KeyHandler.CombineName(rkey, extra), writable);
KeyHandler.key_to_handler[registryKey] = keyHandler;
}
else if (Directory.Exists(text))
{
keyHandler = new KeyHandler(rkey, text);
registryKey = new RegistryKey(keyHandler, KeyHandler.CombineName(rkey, extra), writable);
KeyHandler.dir_to_handler[text] = keyHandler;
KeyHandler.key_to_handler[registryKey] = keyHandler;
}
registryKey2 = registryKey;
}
return registryKey2;
}
// Token: 0x0600073D RID: 1853 RVA: 0x000165A8 File Offset: 0x000147A8
private static string CombineName(RegistryKey rkey, string extra)
{
if (extra.IndexOf('/') != -1)
{
extra = extra.Replace('/', '\\');
}
return rkey.Name + "\\" + extra;
}
// Token: 0x0600073E RID: 1854 RVA: 0x000165E0 File Offset: 0x000147E0
public static KeyHandler Lookup(RegistryKey rkey, bool createNonExisting)
{
Type typeFromHandle = typeof(KeyHandler);
KeyHandler keyHandler2;
lock (typeFromHandle)
{
KeyHandler keyHandler = (KeyHandler)KeyHandler.key_to_handler[rkey];
if (keyHandler != null)
{
keyHandler2 = keyHandler;
}
else if (!rkey.IsRoot || !createNonExisting)
{
keyHandler2 = null;
}
else
{
RegistryHive hive = rkey.Hive;
RegistryHive registryHive = hive;
switch (registryHive + -2147483648)
{
case (RegistryHive)0:
case (RegistryHive)2:
case (RegistryHive)3:
case (RegistryHive)4:
case (RegistryHive)5:
case (RegistryHive)6:
{
string text = Path.Combine(KeyHandler.MachineStore, hive.ToString());
keyHandler = new KeyHandler(rkey, text);
KeyHandler.dir_to_handler[text] = keyHandler;
break;
}
case (RegistryHive)1:
{
string text2 = Path.Combine(KeyHandler.UserStore, hive.ToString());
keyHandler = new KeyHandler(rkey, text2);
KeyHandler.dir_to_handler[text2] = keyHandler;
break;
}
default:
throw new Exception("Unknown RegistryHive");
}
KeyHandler.key_to_handler[rkey] = keyHandler;
keyHandler2 = keyHandler;
}
}
return keyHandler2;
}
// Token: 0x0600073F RID: 1855 RVA: 0x00016718 File Offset: 0x00014918
public static void Drop(RegistryKey rkey)
{
Type typeFromHandle = typeof(KeyHandler);
lock (typeFromHandle)
{
KeyHandler keyHandler = (KeyHandler)KeyHandler.key_to_handler[rkey];
if (keyHandler != null)
{
KeyHandler.key_to_handler.Remove(rkey);
int num = 0;
foreach (object obj in KeyHandler.key_to_handler)
{
if (((DictionaryEntry)obj).Value == keyHandler)
{
num++;
}
}
if (num == 0)
{
KeyHandler.dir_to_handler.Remove(keyHandler.Dir);
}
}
}
}
// Token: 0x06000740 RID: 1856 RVA: 0x0001680C File Offset: 0x00014A0C
public static void Drop(string dir)
{
Type typeFromHandle = typeof(KeyHandler);
lock (typeFromHandle)
{
KeyHandler keyHandler = (KeyHandler)KeyHandler.dir_to_handler[dir];
if (keyHandler != null)
{
KeyHandler.dir_to_handler.Remove(dir);
ArrayList arrayList = new ArrayList();
foreach (object obj in KeyHandler.key_to_handler)
{
DictionaryEntry dictionaryEntry = (DictionaryEntry)obj;
if (dictionaryEntry.Value == keyHandler)
{
arrayList.Add(dictionaryEntry.Key);
}
}
foreach (object obj2 in arrayList)
{
KeyHandler.key_to_handler.Remove(obj2);
}
}
}
}
// Token: 0x06000741 RID: 1857 RVA: 0x00016958 File Offset: 0x00014B58
public object GetValue(string name, RegistryValueOptions options)
{
if (this.IsMarkedForDeletion)
{
return null;
}
if (name == null)
{
name = string.Empty;
}
object obj = this.values[name];
ExpandString expandString = obj as ExpandString;
if (expandString == null)
{
return obj;
}
if ((options & RegistryValueOptions.DoNotExpandEnvironmentNames) == RegistryValueOptions.None)
{
return expandString.Expand();
}
return expandString.ToString();
}
// Token: 0x06000742 RID: 1858 RVA: 0x000169B0 File Offset: 0x00014BB0
public void SetValue(string name, object value)
{
this.AssertNotMarkedForDeletion();
if (name == null)
{
name = string.Empty;
}
if (value is int || value is string || value is byte[] || value is string[])
{
this.values[name] = value;
}
else
{
this.values[name] = value.ToString();
}
this.SetDirty();
}
// Token: 0x06000743 RID: 1859 RVA: 0x00016A28 File Offset: 0x00014C28
public string[] GetValueNames()
{
this.AssertNotMarkedForDeletion();
ICollection keys = this.values.Keys;
string[] array = new string[keys.Count];
keys.CopyTo(array, 0);
return array;
}
// Token: 0x06000744 RID: 1860 RVA: 0x00016A5C File Offset: 0x00014C5C
public void SetValue(string name, object value, RegistryValueKind valueKind)
{
this.SetDirty();
if (name == null)
{
name = string.Empty;
}
switch (valueKind)
{
case RegistryValueKind.String:
if (value is string)
{
this.values[name] = value;
return;
}
goto IL_186;
case RegistryValueKind.ExpandString:
if (value is string)
{
this.values[name] = new ExpandString((string)value);
return;
}
goto IL_186;
case RegistryValueKind.Binary:
if (value is byte[])
{
this.values[name] = value;
return;
}
goto IL_186;
case RegistryValueKind.DWord:
if (value is long && (long)value < 2147483647L && (long)value > -2147483648L)
{
this.values[name] = (int)((long)value);
return;
}
if (value is int)
{
this.values[name] = value;
return;
}
goto IL_186;
case RegistryValueKind.MultiString:
if (value is string[])
{
this.values[name] = value;
return;
}
goto IL_186;
case RegistryValueKind.QWord:
if (value is int)
{
this.values[name] = (long)((int)value);
return;
}
if (value is long)
{
this.values[name] = value;
return;
}
goto IL_186;
}
throw new ArgumentException("unknown value", "valueKind");
IL_186:
throw new ArgumentException("Value could not be converted to specified type", "valueKind");
}
// Token: 0x06000745 RID: 1861 RVA: 0x00016C00 File Offset: 0x00014E00
private void SetDirty()
{
Type typeFromHandle = typeof(KeyHandler);
lock (typeFromHandle)
{
if (!this.dirty)
{
this.dirty = true;
new Timer(new TimerCallback(this.DirtyTimeout), null, 3000, -1);
}
}
}
// Token: 0x06000746 RID: 1862 RVA: 0x00016C78 File Offset: 0x00014E78
public void DirtyTimeout(object state)
{
this.Flush();
}
// Token: 0x06000747 RID: 1863 RVA: 0x00016C80 File Offset: 0x00014E80
public void Flush()
{
Type typeFromHandle = typeof(KeyHandler);
lock (typeFromHandle)
{
if (this.dirty)
{
this.Save();
this.dirty = false;
}
}
}
// Token: 0x06000748 RID: 1864 RVA: 0x00016CE0 File Offset: 0x00014EE0
public bool ValueExists(string name)
{
if (name == null)
{
name = string.Empty;
}
return this.values.Contains(name);
}
// Token: 0x170000D8 RID: 216
// (get) Token: 0x06000749 RID: 1865 RVA: 0x00016CFC File Offset: 0x00014EFC
public int ValueCount
{
get
{
return this.values.Keys.Count;
}
}
// Token: 0x170000D9 RID: 217
// (get) Token: 0x0600074A RID: 1866 RVA: 0x00016D10 File Offset: 0x00014F10
public bool IsMarkedForDeletion
{
get
{
return !KeyHandler.dir_to_handler.Contains(this.Dir);
}
}
// Token: 0x0600074B RID: 1867 RVA: 0x00016D28 File Offset: 0x00014F28
public void RemoveValue(string name)
{
this.AssertNotMarkedForDeletion();
this.values.Remove(name);
this.SetDirty();
}
// Token: 0x0600074C RID: 1868 RVA: 0x00016D50 File Offset: 0x00014F50
~KeyHandler()
{
this.Flush();
}
// Token: 0x0600074D RID: 1869 RVA: 0x00016D8C File Offset: 0x00014F8C
private void Save()
{
if (this.IsMarkedForDeletion)
{
return;
}
if (!File.Exists(this.file) && this.values.Count == 0)
{
return;
}
SecurityElement securityElement = new SecurityElement("values");
foreach (object obj in this.values)
{
DictionaryEntry dictionaryEntry = (DictionaryEntry)obj;
object value = dictionaryEntry.Value;
SecurityElement securityElement2 = new SecurityElement("value");
securityElement2.AddAttribute("name", SecurityElement.Escape((string)dictionaryEntry.Key));
if (value is string)
{
securityElement2.AddAttribute("type", "string");
securityElement2.Text = SecurityElement.Escape((string)value);
}
else if (value is int)
{
securityElement2.AddAttribute("type", "int");
securityElement2.Text = value.ToString();
}
else if (value is long)
{
securityElement2.AddAttribute("type", "qword");
securityElement2.Text = value.ToString();
}
else if (value is byte[])
{
securityElement2.AddAttribute("type", "bytearray");
securityElement2.Text = Convert.ToBase64String((byte[])value);
}
else if (value is ExpandString)
{
securityElement2.AddAttribute("type", "expand");
securityElement2.Text = SecurityElement.Escape(value.ToString());
}
else if (value is string[])
{
securityElement2.AddAttribute("type", "string-array");
foreach (string text in (string[])value)
{
securityElement2.AddChild(new SecurityElement("string")
{
Text = SecurityElement.Escape(text)
});
}
}
securityElement.AddChild(securityElement2);
}
using (FileStream fileStream = File.Create(this.file))
{
StreamWriter streamWriter = new StreamWriter(fileStream);
streamWriter.Write(securityElement.ToString());
streamWriter.Flush();
}
}
// Token: 0x0600074E RID: 1870 RVA: 0x0001701C File Offset: 0x0001521C
private void AssertNotMarkedForDeletion()
{
if (this.IsMarkedForDeletion)
{
throw RegistryKey.CreateMarkedForDeletionException();
}
}
// Token: 0x170000DA RID: 218
// (get) Token: 0x0600074F RID: 1871 RVA: 0x00017030 File Offset: 0x00015230
private static string UserStore
{
get
{
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), ".mono/registry");
}
}
// Token: 0x170000DB RID: 219
// (get) Token: 0x06000750 RID: 1872 RVA: 0x00017044 File Offset: 0x00015244
private static string MachineStore
{
get
{
string text = Environment.GetEnvironmentVariable("MONO_REGISTRY_PATH");
if (text != null)
{
return text;
}
text = Environment.GetMachineConfigPath();
int num = text.IndexOf("machine.config");
return Path.Combine(Path.Combine(text.Substring(0, num - 1), ".."), "registry");
}
}
// Token: 0x04000102 RID: 258
private static Hashtable key_to_handler = new Hashtable();
// Token: 0x04000103 RID: 259
private static Hashtable dir_to_handler = new Hashtable(new CaseInsensitiveHashCodeProvider(), new CaseInsensitiveComparer());
// Token: 0x04000104 RID: 260
public string Dir;
// Token: 0x04000105 RID: 261
private Hashtable values;
// Token: 0x04000106 RID: 262
private string file;
// Token: 0x04000107 RID: 263
private bool dirty;
}
}
+197
View File
@@ -0,0 +1,197 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace Microsoft.Win32
{
/// <summary>Provides <see cref="T:Microsoft.Win32.RegistryKey" /> objects that represent the root keys in the Windows registry, and static methods to access key/value pairs.</summary>
// Token: 0x02000073 RID: 115
[ComVisible(true)]
public static class Registry
{
// Token: 0x06000701 RID: 1793 RVA: 0x000155C0 File Offset: 0x000137C0
private static RegistryKey ToKey(string keyName, bool setting)
{
if (keyName == null)
{
throw new ArgumentException("Not a valid registry key name", "keyName");
}
string[] array = keyName.Split(new char[] { '\\' });
string text = array[0];
if (text != null)
{
if (Registry.<>f__switch$map0 == null)
{
Registry.<>f__switch$map0 = new Dictionary<string, int>(7)
{
{ "HKEY_CLASSES_ROOT", 0 },
{ "HKEY_CURRENT_CONFIG", 1 },
{ "HKEY_CURRENT_USER", 2 },
{ "HKEY_DYN_DATA", 3 },
{ "HKEY_LOCAL_MACHINE", 4 },
{ "HKEY_PERFORMANCE_DATA", 5 },
{ "HKEY_USERS", 6 }
};
}
int num;
if (Registry.<>f__switch$map0.TryGetValue(text, out num))
{
RegistryKey registryKey;
switch (num)
{
case 0:
registryKey = Registry.ClassesRoot;
break;
case 1:
registryKey = Registry.CurrentConfig;
break;
case 2:
registryKey = Registry.CurrentUser;
break;
case 3:
registryKey = Registry.DynData;
break;
case 4:
registryKey = Registry.LocalMachine;
break;
case 5:
registryKey = Registry.PerformanceData;
break;
case 6:
registryKey = Registry.Users;
break;
default:
goto IL_132;
}
for (int i = 1; i < array.Length; i++)
{
RegistryKey registryKey2 = registryKey.OpenSubKey(array[i], setting);
if (registryKey2 == null)
{
if (!setting)
{
return null;
}
registryKey2 = registryKey.CreateSubKey(array[i]);
}
registryKey = registryKey2;
}
return registryKey;
}
}
IL_132:
throw new ArgumentException("Keyname does not start with a valid registry root", "keyName");
}
/// <summary>Sets the specified name/value pair on the specified registry key. If the specified key does not exist, it is created.</summary>
/// <param name="keyName">The full registry path of the key, beginning with a valid registry root, such as "HKEY_CURRENT_USER".</param>
/// <param name="valueName">The name of the name/value pair.</param>
/// <param name="value">The value to be stored.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="value" /> is null. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="keyName" /> does not begin with a valid registry root.-or-<paramref name="valueName" /> is longer than the maximum length allowed (255 characters). </exception>
/// <exception cref="T:System.UnauthorizedAccessException">The <see cref="T:Microsoft.Win32.RegistryKey" /> is read-only, and thus cannot be written to; for example, it is a root-level node. </exception>
/// <exception cref="T:System.Security.SecurityException">The user does not have the permissions required to create or modify registry keys. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.RegistryPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x06000702 RID: 1794 RVA: 0x0001574C File Offset: 0x0001394C
public static void SetValue(string keyName, string valueName, object value)
{
RegistryKey registryKey = Registry.ToKey(keyName, true);
if (valueName.Length > 255)
{
throw new ArgumentException("valueName is larger than 255 characters", "valueName");
}
if (registryKey == null)
{
throw new ArgumentException("cant locate that keyName", "keyName");
}
registryKey.SetValue(valueName, value);
}
/// <summary>Sets the name/value pair on the specified registry key, using the specified registry data type. If the specified key does not exist, it is created.</summary>
/// <param name="keyName">The full registry path of the key, beginning with a valid registry root, such as "HKEY_CURRENT_USER".</param>
/// <param name="valueName">The name of the name/value pair.</param>
/// <param name="value">The value to be stored.</param>
/// <param name="valueKind">The registry data type to use when storing the data.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="value" /> is null. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="keyName" /> does not begin with a valid registry root.-or-<paramref name="keyName" /> is longer than the maximum length allowed (255 characters).-or- The type of <paramref name="value" /> did not match the registry data type specified by <paramref name="valueKind" />, therefore the data could not be converted properly. </exception>
/// <exception cref="T:System.UnauthorizedAccessException">The <see cref="T:Microsoft.Win32.RegistryKey" /> is read-only, and thus cannot be written to; for example, it is a root-level node, or the key has not been opened with write access. </exception>
/// <exception cref="T:System.Security.SecurityException">The user does not have the permissions required to create or modify registry keys. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.RegistryPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x06000703 RID: 1795 RVA: 0x000157A0 File Offset: 0x000139A0
public static void SetValue(string keyName, string valueName, object value, RegistryValueKind valueKind)
{
RegistryKey registryKey = Registry.ToKey(keyName, true);
if (valueName.Length > 255)
{
throw new ArgumentException("valueName is larger than 255 characters", "valueName");
}
if (registryKey == null)
{
throw new ArgumentException("cant locate that keyName", "keyName");
}
registryKey.SetValue(valueName, value, valueKind);
}
/// <summary>Retrieves the value associated with the specified name, in the specified registry key. If the name is not found in the specified key, returns a default value that you provide, or null if the specified key does not exist. </summary>
/// <returns>null if the subkey specified by <paramref name="keyName" /> does not exist; otherwise, the value associated with <paramref name="valueName" />, or <paramref name="defaultValue" /> if <paramref name="valueName" /> is not found.</returns>
/// <param name="keyName">The full registry path of the key, beginning with a valid registry root, such as "HKEY_CURRENT_USER".</param>
/// <param name="valueName">The name of the name/value pair.</param>
/// <param name="defaultValue">The value to return if <paramref name="valueName" /> does not exist.</param>
/// <exception cref="T:System.Security.SecurityException">The user does not have the permissions required to read from the registry key. </exception>
/// <exception cref="T:System.IO.IOException">The <see cref="T:Microsoft.Win32.RegistryKey" /> that contains the specified value has been marked for deletion. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="keyName" /> does not begin with a valid registry root. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.RegistryPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Read="\" />
/// </PermissionSet>
// Token: 0x06000704 RID: 1796 RVA: 0x000157F4 File Offset: 0x000139F4
public static object GetValue(string keyName, string valueName, object defaultValue)
{
RegistryKey registryKey = Registry.ToKey(keyName, false);
if (registryKey == null)
{
return defaultValue;
}
return registryKey.GetValue(valueName, defaultValue);
}
/// <summary>Defines the types (or classes) of documents and the properties associated with those types. This field reads the Windows registry base key HKEY_CLASSES_ROOT.</summary>
// Token: 0x040000DC RID: 220
public static readonly RegistryKey ClassesRoot = new RegistryKey(RegistryHive.ClassesRoot);
/// <summary>Contains configuration information pertaining to the hardware that is not specific to the user. This field reads the Windows registry base key HKEY_CURRENT_CONFIG.</summary>
// Token: 0x040000DD RID: 221
public static readonly RegistryKey CurrentConfig = new RegistryKey(RegistryHive.CurrentConfig);
/// <summary>Contains information about the current user preferences. This field reads the Windows registry base key HKEY_CURRENT_USER </summary>
// Token: 0x040000DE RID: 222
public static readonly RegistryKey CurrentUser = new RegistryKey(RegistryHive.CurrentUser);
/// <summary>Contains dynamic registry data. This field reads the Windows registry base key HKEY_DYN_DATA.</summary>
/// <exception cref="T:System.ObjectDisposedException">The operating system is not Windows 98, Windows 98 Second Edition, or Windows Millennium Edition.</exception>
// Token: 0x040000DF RID: 223
public static readonly RegistryKey DynData = new RegistryKey(RegistryHive.DynData);
/// <summary>Contains the configuration data for the local machine. This field reads the Windows registry base key HKEY_LOCAL_MACHINE.</summary>
// Token: 0x040000E0 RID: 224
public static readonly RegistryKey LocalMachine = new RegistryKey(RegistryHive.LocalMachine);
/// <summary>Contains performance information for software components. This field reads the Windows registry base key HKEY_PERFORMANCE_DATA.</summary>
// Token: 0x040000E1 RID: 225
public static readonly RegistryKey PerformanceData = new RegistryKey(RegistryHive.PerformanceData);
/// <summary>Contains information about the default user configuration. This field reads the Windows registry base key HKEY_USERS.</summary>
// Token: 0x040000E2 RID: 226
public static readonly RegistryKey Users = new RegistryKey(RegistryHive.Users);
}
}
+34
View File
@@ -0,0 +1,34 @@
using System;
using System.Runtime.InteropServices;
namespace Microsoft.Win32
{
/// <summary>Represents the possible values for a top-level node on a foreign machine.</summary>
// Token: 0x02000074 RID: 116
[ComVisible(true)]
[Serializable]
public enum RegistryHive
{
/// <summary>Represents the HKEY_CLASSES_ROOT base key on another computer. This value can be passed to the <see cref="M:Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(Microsoft.Win32.RegistryHive,System.String)" /> method, to open this node remotely.</summary>
// Token: 0x040000E5 RID: 229
ClassesRoot = -2147483648,
/// <summary>Represents the HKEY_CURRENT_CONFIG base key on another computer. This value can be passed to the <see cref="M:Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(Microsoft.Win32.RegistryHive,System.String)" /> method, to open this node remotely.</summary>
// Token: 0x040000E6 RID: 230
CurrentConfig = -2147483643,
/// <summary>Represents the HKEY_CURRENT_USER base key on another computer. This value can be passed to the <see cref="M:Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(Microsoft.Win32.RegistryHive,System.String)" /> method, to open this node remotely.</summary>
// Token: 0x040000E7 RID: 231
CurrentUser = -2147483647,
/// <summary>Represents the HKEY_DYN_DATA base key on another computer. This value can be passed to the <see cref="M:Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(Microsoft.Win32.RegistryHive,System.String)" /> method, to open this node remotely.</summary>
// Token: 0x040000E8 RID: 232
DynData = -2147483642,
/// <summary>Represents the HKEY_LOCAL_MACHINE base key on another computer. This value can be passed to the <see cref="M:Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(Microsoft.Win32.RegistryHive,System.String)" /> method, to open this node remotely.</summary>
// Token: 0x040000E9 RID: 233
LocalMachine = -2147483646,
/// <summary>Represents the HKEY_PERFORMANCE_DATA base key on another computer. This value can be passed to the <see cref="M:Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(Microsoft.Win32.RegistryHive,System.String)" /> method, to open this node remotely.</summary>
// Token: 0x040000EA RID: 234
PerformanceData = -2147483644,
/// <summary>Represents the HKEY_USERS base key on another computer. This value can be passed to the <see cref="M:Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(Microsoft.Win32.RegistryHive,System.String)" /> method, to open this node remotely.</summary>
// Token: 0x040000EB RID: 235
Users = -2147483645
}
}
+832
View File
@@ -0,0 +1,832 @@
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Security.AccessControl;
using System.Text;
namespace Microsoft.Win32
{
/// <summary>Represents a key-level node in the Windows registry. This class is a registry encapsulation.</summary>
// Token: 0x02000075 RID: 117
[ComVisible(true)]
public sealed class RegistryKey : MarshalByRefObject, IDisposable
{
// Token: 0x06000705 RID: 1797 RVA: 0x0001581C File Offset: 0x00013A1C
internal RegistryKey(RegistryHive hiveId)
: this(hiveId, new IntPtr((int)hiveId), false)
{
}
// Token: 0x06000706 RID: 1798 RVA: 0x0001582C File Offset: 0x00013A2C
internal RegistryKey(RegistryHive hiveId, IntPtr keyHandle, bool remoteRoot)
{
this.hive = hiveId;
this.handle = keyHandle;
this.qname = RegistryKey.GetHiveName(hiveId);
this.isRemoteRoot = remoteRoot;
this.isWritable = true;
}
// Token: 0x06000707 RID: 1799 RVA: 0x00015874 File Offset: 0x00013A74
internal RegistryKey(object data, string keyName, bool writable)
{
this.handle = data;
this.qname = keyName;
this.isWritable = writable;
}
// Token: 0x06000708 RID: 1800 RVA: 0x00015894 File Offset: 0x00013A94
static RegistryKey()
{
if (Path.DirectorySeparatorChar == '\\')
{
RegistryKey.RegistryApi = new Win32RegistryApi();
}
else
{
RegistryKey.RegistryApi = new UnixRegistryApi();
}
}
/// <summary>Performs a <see cref="M:Microsoft.Win32.RegistryKey.Close" /> on the current key.</summary>
// Token: 0x06000709 RID: 1801 RVA: 0x000158BC File Offset: 0x00013ABC
void IDisposable.Dispose()
{
GC.SuppressFinalize(this);
this.Close();
}
// Token: 0x0600070A RID: 1802 RVA: 0x000158CC File Offset: 0x00013ACC
~RegistryKey()
{
this.Close();
}
/// <summary>Retrieves the name of the key.</summary>
/// <returns>The absolute (qualified) name of the key.</returns>
/// <exception cref="T:System.ObjectDisposedException">The <see cref="T:Microsoft.Win32.RegistryKey" /> is closed (closed keys cannot be accessed). </exception>
// Token: 0x170000D1 RID: 209
// (get) Token: 0x0600070B RID: 1803 RVA: 0x00015908 File Offset: 0x00013B08
public string Name
{
get
{
return this.qname;
}
}
/// <summary>Writes all the attributes of the specified open registry key into the registry.</summary>
// Token: 0x0600070C RID: 1804 RVA: 0x00015910 File Offset: 0x00013B10
public void Flush()
{
RegistryKey.RegistryApi.Flush(this);
}
/// <summary>Closes the key and flushes it to disk if its contents have been modified.</summary>
// Token: 0x0600070D RID: 1805 RVA: 0x00015920 File Offset: 0x00013B20
public void Close()
{
this.Flush();
if (!this.isRemoteRoot && this.IsRoot)
{
return;
}
RegistryKey.RegistryApi.Close(this);
this.handle = null;
}
/// <summary>Retrieves the count of subkeys of the current key.</summary>
/// <returns>The number of subkeys of the current key.</returns>
/// <exception cref="T:System.Security.SecurityException">The user does not have read permission for the key. </exception>
/// <exception cref="T:System.ObjectDisposedException">The <see cref="T:Microsoft.Win32.RegistryKey" /> being manipulated is closed (closed keys cannot be accessed). </exception>
/// <exception cref="T:System.UnauthorizedAccessException">The user does not have the necessary registry rights.</exception>
/// <exception cref="T:System.IO.IOException">A system error occurred, for example the current key has been deleted.</exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.RegistryPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x170000D2 RID: 210
// (get) Token: 0x0600070E RID: 1806 RVA: 0x0001595C File Offset: 0x00013B5C
public int SubKeyCount
{
get
{
this.AssertKeyStillValid();
return RegistryKey.RegistryApi.SubKeyCount(this);
}
}
/// <summary>Retrieves the count of values in the key.</summary>
/// <returns>The number of name/value pairs in the key.</returns>
/// <exception cref="T:System.Security.SecurityException">The user does not have read permission for the key. </exception>
/// <exception cref="T:System.ObjectDisposedException">The <see cref="T:Microsoft.Win32.RegistryKey" /> being manipulated is closed (closed keys cannot be accessed). </exception>
/// <exception cref="T:System.UnauthorizedAccessException">The user does not have the necessary registry rights.</exception>
/// <exception cref="T:System.IO.IOException">A system error occurred, for example the current key has been deleted.</exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.RegistryPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x170000D3 RID: 211
// (get) Token: 0x0600070F RID: 1807 RVA: 0x00015970 File Offset: 0x00013B70
public int ValueCount
{
get
{
this.AssertKeyStillValid();
return RegistryKey.RegistryApi.ValueCount(this);
}
}
/// <summary>Sets the specified name/value pair.</summary>
/// <param name="name">The name of the value to store. </param>
/// <param name="value">The data to be stored. </param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="value" /> is null. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="value" /> is an unsupported data type.-or-<paramref name="name" /> is longer than the maximum length allowed (255 characters). </exception>
/// <exception cref="T:System.ObjectDisposedException">The <see cref="T:Microsoft.Win32.RegistryKey" /> that contains the specified value is closed (closed keys cannot be accessed). </exception>
/// <exception cref="T:System.UnauthorizedAccessException">The <see cref="T:Microsoft.Win32.RegistryKey" /> is read-only, and cannot be written to; for example, the key has not been opened with write access. -or-The <see cref="T:Microsoft.Win32.RegistryKey" /> object represents a root-level node, and the operating system is Windows Millennium Edition or Windows 98.</exception>
/// <exception cref="T:System.Security.SecurityException">The user does not have the permissions required to create or modify registry keys. </exception>
/// <exception cref="T:System.IO.IOException">The <see cref="T:Microsoft.Win32.RegistryKey" /> object represents a root-level node, and the operating system is Windows 2000, Windows XP, or Windows Server 2003.</exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.RegistryPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x06000710 RID: 1808 RVA: 0x00015984 File Offset: 0x00013B84
public void SetValue(string name, object value)
{
this.AssertKeyStillValid();
if (value == null)
{
throw new ArgumentNullException("value");
}
if (name != null)
{
this.AssertKeyNameLength(name);
}
if (!this.IsWritable)
{
throw new UnauthorizedAccessException("Cannot write to the registry key.");
}
RegistryKey.RegistryApi.SetValue(this, name, value);
}
/// <summary>Sets the value of a name/value pair in the registry key, using the specified registry data type.</summary>
/// <param name="name">The name of the value to be stored. </param>
/// <param name="value">The data to be stored. </param>
/// <param name="valueKind">The registry data type to use when storing the data. </param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="value" /> is null. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="name" /> is longer than the maximum length allowed (255 characters).-or- The type of <paramref name="value" /> did not match the registry data type specified by <paramref name="valueKind" />, therefore the data could not be converted properly. </exception>
/// <exception cref="T:System.ObjectDisposedException">The <see cref="T:Microsoft.Win32.RegistryKey" /> that contains the specified value is closed (closed keys cannot be accessed). </exception>
/// <exception cref="T:System.UnauthorizedAccessException">The <see cref="T:Microsoft.Win32.RegistryKey" /> is read-only, and cannot be written to; for example, the key has not been opened with write access.-or-The <see cref="T:Microsoft.Win32.RegistryKey" /> object represents a root-level node, and the operating system is Windows Millennium Edition or Windows 98. </exception>
/// <exception cref="T:System.Security.SecurityException">The user does not have the permissions required to create or modify registry keys. </exception>
/// <exception cref="T:System.IO.IOException">The <see cref="T:Microsoft.Win32.RegistryKey" /> object represents a root-level node, and the operating system is Windows 2000, Windows XP, or Windows Server 2003.</exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.RegistryPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x06000711 RID: 1809 RVA: 0x000159D8 File Offset: 0x00013BD8
[ComVisible(false)]
public void SetValue(string name, object value, RegistryValueKind valueKind)
{
this.AssertKeyStillValid();
if (value == null)
{
throw new ArgumentNullException("value");
}
if (name != null)
{
this.AssertKeyNameLength(name);
}
if (!this.IsWritable)
{
throw new UnauthorizedAccessException("Cannot write to the registry key.");
}
RegistryKey.RegistryApi.SetValue(this, name, value, valueKind);
}
/// <summary>Retrieves a subkey as read-only.</summary>
/// <returns>The subkey requested, or null if the operation failed.</returns>
/// <param name="name">The name or path of the subkey to open read-only. </param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="name" /> is null</exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="name" /> is longer than the maximum length allowed (255 characters). </exception>
/// <exception cref="T:System.ObjectDisposedException">The <see cref="T:Microsoft.Win32.RegistryKey" /> is closed (closed keys cannot be accessed). </exception>
/// <exception cref="T:System.Security.SecurityException">The user does not have the permissions required to read the registry key. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.RegistryPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Read="\" />
/// </PermissionSet>
// Token: 0x06000712 RID: 1810 RVA: 0x00015A30 File Offset: 0x00013C30
public RegistryKey OpenSubKey(string name)
{
return this.OpenSubKey(name, false);
}
/// <summary>Retrieves a specified subkey.</summary>
/// <returns>The subkey requested, or null if the operation failed.</returns>
/// <param name="name">Name or path of the subkey to open. </param>
/// <param name="writable">Set to true if you need write access to the key. </param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="name" /> is null. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="name" /> is longer than the maximum length allowed (255 characters). </exception>
/// <exception cref="T:System.ObjectDisposedException">The <see cref="T:Microsoft.Win32.RegistryKey" /> is closed (closed keys cannot be accessed). </exception>
/// <exception cref="T:System.Security.SecurityException">The user does not have the permissions required to access the registry key in the specified mode. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.RegistryPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x06000713 RID: 1811 RVA: 0x00015A3C File Offset: 0x00013C3C
public RegistryKey OpenSubKey(string name, bool writable)
{
this.AssertKeyStillValid();
if (name == null)
{
throw new ArgumentNullException("name");
}
this.AssertKeyNameLength(name);
return RegistryKey.RegistryApi.OpenSubKey(this, name, writable);
}
/// <summary>Retrieves the value associated with the specified name. Returns null if the name/value pair does not exist in the registry.</summary>
/// <returns>The value associated with <paramref name="name" />, or null if <paramref name="name" /> is not found.</returns>
/// <param name="name">The name of the value to retrieve. </param>
/// <exception cref="T:System.Security.SecurityException">The user does not have the permissions required to read from the registry key. </exception>
/// <exception cref="T:System.ObjectDisposedException">The <see cref="T:Microsoft.Win32.RegistryKey" /> that contains the specified value is closed (closed keys cannot be accessed). </exception>
/// <exception cref="T:System.IO.IOException">The <see cref="T:Microsoft.Win32.RegistryKey" /> that contains the specified value has been marked for deletion. </exception>
/// <exception cref="T:System.UnauthorizedAccessException">The user does not have the necessary registry rights.</exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.RegistryPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Read="\" />
/// </PermissionSet>
// Token: 0x06000714 RID: 1812 RVA: 0x00015A74 File Offset: 0x00013C74
public object GetValue(string name)
{
return this.GetValue(name, null);
}
/// <summary>Retrieves the value associated with the specified name. If the name is not found, returns the default value that you provide.</summary>
/// <returns>The value associated with <paramref name="name" />, with any embedded environment variables left unexpanded, or <paramref name="defaultValue" /> if <paramref name="name" /> is not found.</returns>
/// <param name="name">The name of the value to retrieve. </param>
/// <param name="defaultValue">The value to return if <paramref name="name" /> does not exist. </param>
/// <exception cref="T:System.Security.SecurityException">The user does not have the permissions required to read from the registry key. </exception>
/// <exception cref="T:System.ObjectDisposedException">The <see cref="T:Microsoft.Win32.RegistryKey" /> that contains the specified value is closed (closed keys cannot be accessed). </exception>
/// <exception cref="T:System.IO.IOException">The <see cref="T:Microsoft.Win32.RegistryKey" /> that contains the specified value has been marked for deletion. </exception>
/// <exception cref="T:System.UnauthorizedAccessException">The user does not have the necessary registry rights.</exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.RegistryPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Read="\" />
/// </PermissionSet>
// Token: 0x06000715 RID: 1813 RVA: 0x00015A80 File Offset: 0x00013C80
public object GetValue(string name, object defaultValue)
{
this.AssertKeyStillValid();
return RegistryKey.RegistryApi.GetValue(this, name, defaultValue, RegistryValueOptions.None);
}
/// <summary>Retrieves the value associated with the specified name and retrieval options. If the name is not found, returns the default value that you provide.</summary>
/// <returns>The value associated with <paramref name="name" />, processed according to the specified <paramref name="options" />, or <paramref name="defaultValue" /> if <paramref name="name" /> is not found.</returns>
/// <param name="name">The name of the value to retrieve. </param>
/// <param name="defaultValue">The value to return if <paramref name="name" /> does not exist. </param>
/// <param name="options">One of the <see cref="T:Microsoft.Win32.RegistryValueOptions" /> values that specifies optional processing of the retrieved value.</param>
/// <exception cref="T:System.Security.SecurityException">The user does not have the permissions required to read from the registry key. </exception>
/// <exception cref="T:System.ObjectDisposedException">The <see cref="T:Microsoft.Win32.RegistryKey" /> that contains the specified value is closed (closed keys cannot be accessed). </exception>
/// <exception cref="T:System.IO.IOException">The <see cref="T:Microsoft.Win32.RegistryKey" /> that contains the specified value has been marked for deletion. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="options" /> is not a valid <see cref="T:Microsoft.Win32.RegistryValueOptions" /> value; for example, an invalid value is cast to <see cref="T:Microsoft.Win32.RegistryValueOptions" />.</exception>
/// <exception cref="T:System.UnauthorizedAccessException">The user does not have the necessary registry rights.</exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.RegistryPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Read="\" />
/// </PermissionSet>
// Token: 0x06000716 RID: 1814 RVA: 0x00015AA4 File Offset: 0x00013CA4
[ComVisible(false)]
public object GetValue(string name, object defaultValue, RegistryValueOptions options)
{
this.AssertKeyStillValid();
return RegistryKey.RegistryApi.GetValue(this, name, defaultValue, options);
}
/// <summary>Retrieves the registry data type of the value associated with the specified name.</summary>
/// <returns>A <see cref="T:Microsoft.Win32.RegistryValueKind" /> value representing the registry data type of the value associated with <paramref name="name" />.</returns>
/// <param name="name">The name of the value whose registry data type is to be retrieved. </param>
/// <exception cref="T:System.Security.SecurityException">The user does not have the permissions required to read from the registry key. </exception>
/// <exception cref="T:System.ObjectDisposedException">The <see cref="T:Microsoft.Win32.RegistryKey" /> that contains the specified value is closed (closed keys cannot be accessed). </exception>
/// <exception cref="T:System.IO.IOException">The subkey that contains the specified value does not exist.-or-The name/value pair specified by <paramref name="name" /> does not exist.This exception is not thrown on Windows 95, Windows 98, or Windows Millennium Edition.</exception>
/// <exception cref="T:System.UnauthorizedAccessException">The user does not have the necessary registry rights.</exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.RegistryPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Read="\" />
/// </PermissionSet>
// Token: 0x06000717 RID: 1815 RVA: 0x00015AC8 File Offset: 0x00013CC8
[ComVisible(false)]
public RegistryValueKind GetValueKind(string name)
{
throw new NotImplementedException();
}
/// <summary>Creates a new subkey or opens an existing subkey for write access. The string <paramref name="subkey" /> is not case-sensitive.</summary>
/// <returns>A <see cref="T:Microsoft.Win32.RegistryKey" /> object that represents the existing or newly created subkey, or null if the operation failed. If a zero-length string is specified for <paramref name="subkey" />, the current <see cref="T:Microsoft.Win32.RegistryKey" /> object is returned.</returns>
/// <param name="subkey">The name or path of the subkey to create or open. </param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="subkey" /> is null. </exception>
/// <exception cref="T:System.Security.SecurityException">The user does not have the permissions required to create or open the registry key. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="subkey" /> is longer than the maximum length allowed (255 characters). </exception>
/// <exception cref="T:System.ObjectDisposedException">The <see cref="T:Microsoft.Win32.RegistryKey" /> on which this method is being invoked is closed (closed keys cannot be accessed). </exception>
/// <exception cref="T:System.UnauthorizedAccessException">The <see cref="T:Microsoft.Win32.RegistryKey" /> cannot be written to; for example, it was not opened as a writable key , or the user does not have the necessary access rights. </exception>
/// <exception cref="T:System.IO.IOException">The nesting level exceeds 510.-or-A system error occurred, such as deletion of the key, or an attempt to create a key in the <see cref="F:Microsoft.Win32.Registry.LocalMachine" /> root.</exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.RegistryPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x06000718 RID: 1816 RVA: 0x00015AD0 File Offset: 0x00013CD0
public RegistryKey CreateSubKey(string subkey)
{
this.AssertKeyStillValid();
this.AssertKeyNameNotNull(subkey);
this.AssertKeyNameLength(subkey);
if (!this.IsWritable)
{
throw new UnauthorizedAccessException("Cannot write to the registry key.");
}
return RegistryKey.RegistryApi.CreateSubKey(this, subkey);
}
/// <summary>Creates a new subkey or opens an existing subkey for write access, using the specified permission check option. The string <paramref name="subkey" /> is not case-sensitive.</summary>
/// <returns>A <see cref="T:Microsoft.Win32.RegistryKey" /> object that represents the existing or newly created subkey, or null if the operation failed. If a zero-length string is specified for <paramref name="subkey" />, the current <see cref="T:Microsoft.Win32.RegistryKey" /> object is returned.</returns>
/// <param name="subkey">The name or path of the subkey to create or open.</param>
/// <param name="permissionCheck">One of the <see cref="T:Microsoft.Win32.RegistryKeyPermissionCheck" /> values that specifies whether the key is opened for read or read/write access.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="subkey" /> is null. </exception>
/// <exception cref="T:System.Security.SecurityException">The user does not have the permissions required to create or open the registry key. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="subkey" /> is longer than the maximum length allowed (255 characters). -or-<paramref name="permissionCheck" /> contains an invalid value.</exception>
/// <exception cref="T:System.ObjectDisposedException">The <see cref="T:Microsoft.Win32.RegistryKey" /> on which this method is being invoked is closed (closed keys cannot be accessed). </exception>
/// <exception cref="T:System.UnauthorizedAccessException">The <see cref="T:Microsoft.Win32.RegistryKey" /> cannot be written to; for example, it was not opened as a writable key, or the user does not have the necessary access rights. </exception>
/// <exception cref="T:System.IO.IOException">The nesting level exceeds 510.-or-A system error occurred, such as deletion of the key, or an attempt to create a key in the <see cref="F:Microsoft.Win32.Registry.LocalMachine" /> root.</exception>
// Token: 0x06000719 RID: 1817 RVA: 0x00015B14 File Offset: 0x00013D14
[ComVisible(false)]
public RegistryKey CreateSubKey(string subkey, RegistryKeyPermissionCheck permissionCheck)
{
throw new NotImplementedException();
}
/// <summary>Creates a new subkey or opens an existing subkey for write access, using the specified permission check option and registry security. The string <paramref name="subkey" /> is not case-sensitive.</summary>
/// <returns>A <see cref="T:Microsoft.Win32.RegistryKey" /> object that represents existing or the newly created subkey, or null if the operation failed. If a zero-length string is specified for <paramref name="subkey" />, the current <see cref="T:Microsoft.Win32.RegistryKey" /> object is returned.</returns>
/// <param name="subkey">The name or path of the subkey to create or open.</param>
/// <param name="permissionCheck">One of the <see cref="T:Microsoft.Win32.RegistryKeyPermissionCheck" /> values that specifies whether the key is opened for read or read/write access.</param>
/// <param name="registrySecurity">A <see cref="T:System.Security.AccessControl.RegistrySecurity" /> object that specifies the access control security for the new key.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="subkey" /> is null. </exception>
/// <exception cref="T:System.Security.SecurityException">The user does not have the permissions required to create or open the registry key. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="subkey" /> is longer than the maximum length allowed (255 characters). -or-<paramref name="permissionCheck" /> contains an invalid value.</exception>
/// <exception cref="T:System.ObjectDisposedException">The <see cref="T:Microsoft.Win32.RegistryKey" /> on which this method is being invoked is closed (closed keys cannot be accessed). </exception>
/// <exception cref="T:System.UnauthorizedAccessException">The current <see cref="T:Microsoft.Win32.RegistryKey" /> cannot be written to; for example, it was not opened as a writable key, or the user does not have the necessary access rights.</exception>
/// <exception cref="T:System.IO.IOException">The nesting level exceeds 510.-or-A system error occurred, such as deletion of the key, or an attempt to create a key in the <see cref="F:Microsoft.Win32.Registry.LocalMachine" /> root.</exception>
// Token: 0x0600071A RID: 1818 RVA: 0x00015B1C File Offset: 0x00013D1C
[ComVisible(false)]
public RegistryKey CreateSubKey(string subkey, RegistryKeyPermissionCheck permissionCheck, RegistrySecurity registrySecurity)
{
throw new NotImplementedException();
}
/// <summary>Deletes the specified subkey. The string <paramref name="subkey" /> is not case-sensitive.</summary>
/// <param name="subkey">The name of the subkey to delete. </param>
/// <exception cref="T:System.InvalidOperationException">The <paramref name="subkey" /> has child subkeys </exception>
/// <exception cref="T:System.ArgumentException">The <paramref name="subkey" /> parameter does not specify a valid registry key </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="subkey" /> is null</exception>
/// <exception cref="T:System.Security.SecurityException">The user does not have the permissions required to delete the key. </exception>
/// <exception cref="T:System.ObjectDisposedException">The <see cref="T:Microsoft.Win32.RegistryKey" /> being manipulated is closed (closed keys cannot be accessed). </exception>
/// <exception cref="T:System.UnauthorizedAccessException">The user does not have the necessary registry rights.</exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.RegistryPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x0600071B RID: 1819 RVA: 0x00015B24 File Offset: 0x00013D24
public void DeleteSubKey(string subkey)
{
this.DeleteSubKey(subkey, true);
}
/// <summary>Deletes the specified subkey. The string subkey is not case-sensitive.</summary>
/// <param name="subkey">The name of the subkey to delete. </param>
/// <param name="throwOnMissingSubKey">Indicates whether an exception should be raised if the specified subkey cannot be found. If this argument is true and the specified subkey does not exist, then an exception is raised. If this argument is false and the specified subkey does not exist, then no action is taken </param>
/// <exception cref="T:System.InvalidOperationException">
/// <paramref name="subkey" /> has child subkeys. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="subkey" /> does not specify a valid registry key and <paramref name="throwOnMissingSubKey" /> is true. </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="subkey" /> is null.</exception>
/// <exception cref="T:System.Security.SecurityException">The user does not have the permissions required to delete the key. </exception>
/// <exception cref="T:System.ObjectDisposedException">The <see cref="T:Microsoft.Win32.RegistryKey" /> being manipulated is closed (closed keys cannot be accessed). </exception>
/// <exception cref="T:System.UnauthorizedAccessException">The user does not have the necessary registry rights.</exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.RegistryPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x0600071C RID: 1820 RVA: 0x00015B30 File Offset: 0x00013D30
public void DeleteSubKey(string subkey, bool throwOnMissingSubKey)
{
this.AssertKeyStillValid();
this.AssertKeyNameNotNull(subkey);
this.AssertKeyNameLength(subkey);
if (!this.IsWritable)
{
throw new UnauthorizedAccessException("Cannot write to the registry key.");
}
RegistryKey registryKey = this.OpenSubKey(subkey);
if (registryKey == null)
{
if (throwOnMissingSubKey)
{
throw new ArgumentException("Cannot delete a subkey tree because the subkey does not exist.");
}
return;
}
else
{
if (registryKey.SubKeyCount > 0)
{
throw new InvalidOperationException("Registry key has subkeys and recursive removes are not supported by this method.");
}
registryKey.Close();
RegistryKey.RegistryApi.DeleteKey(this, subkey, throwOnMissingSubKey);
return;
}
}
/// <summary>Deletes a subkey and any child subkeys recursively. The string <paramref name="subkey" /> is not case-sensitive.</summary>
/// <param name="subkey">The subkey to delete. </param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="subkey" /> is null. </exception>
/// <exception cref="T:System.ArgumentException">Deletion of a root hive is attempted.-or-<paramref name="subkey" /> does not specify a valid registry subkey. </exception>
/// <exception cref="T:System.IO.IOException">An I/O error has occurred.</exception>
/// <exception cref="T:System.Security.SecurityException">The user does not have the permissions required to delete the key. </exception>
/// <exception cref="T:System.ObjectDisposedException">The <see cref="T:Microsoft.Win32.RegistryKey" /> being manipulated is closed (closed keys cannot be accessed). </exception>
/// <exception cref="T:System.UnauthorizedAccessException">The user does not have the necessary registry rights.</exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.RegistryPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x0600071D RID: 1821 RVA: 0x00015BB4 File Offset: 0x00013DB4
public void DeleteSubKeyTree(string subkey)
{
this.AssertKeyStillValid();
this.AssertKeyNameNotNull(subkey);
this.AssertKeyNameLength(subkey);
RegistryKey registryKey = this.OpenSubKey(subkey, true);
if (registryKey == null)
{
throw new ArgumentException("Cannot delete a subkey tree because the subkey does not exist.");
}
registryKey.DeleteChildKeysAndValues();
registryKey.Close();
this.DeleteSubKey(subkey, false);
}
/// <summary>Deletes the specified value from this key.</summary>
/// <param name="name">The name of the value to delete. </param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="name" /> is not a valid reference to a value. </exception>
/// <exception cref="T:System.Security.SecurityException">The user does not have the permissions required to delete the value. </exception>
/// <exception cref="T:System.ObjectDisposedException">The <see cref="T:Microsoft.Win32.RegistryKey" /> being manipulated is closed (closed keys cannot be accessed). </exception>
/// <exception cref="T:System.UnauthorizedAccessException">The <see cref="T:Microsoft.Win32.RegistryKey" /> being manipulated is read-only. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.RegistryPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x0600071E RID: 1822 RVA: 0x00015C04 File Offset: 0x00013E04
public void DeleteValue(string name)
{
this.DeleteValue(name, true);
}
/// <summary>Deletes the specified value from this key.</summary>
/// <param name="name">The name of the value to delete. </param>
/// <param name="throwOnMissingValue">Indicates whether an exception should be raised if the specified value cannot be found. If this argument is true and the specified value does not exist, then an exception is raised. If this argument is false and the specified value does not exist, then no action is taken </param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="name" /> is not a valid reference to a value and <paramref name="throwOnMissingValue" /> is true. -or- <paramref name="name" /> is null.</exception>
/// <exception cref="T:System.Security.SecurityException">The user does not have the permissions required to delete the value. </exception>
/// <exception cref="T:System.ObjectDisposedException">The <see cref="T:Microsoft.Win32.RegistryKey" /> being manipulated is closed (closed keys cannot be accessed). </exception>
/// <exception cref="T:System.UnauthorizedAccessException">The <see cref="T:Microsoft.Win32.RegistryKey" /> being manipulated is read-only. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.RegistryPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x0600071F RID: 1823 RVA: 0x00015C10 File Offset: 0x00013E10
public void DeleteValue(string name, bool throwOnMissingValue)
{
this.AssertKeyStillValid();
if (name == null)
{
throw new ArgumentNullException("name");
}
if (!this.IsWritable)
{
throw new UnauthorizedAccessException("Cannot write to the registry key.");
}
RegistryKey.RegistryApi.DeleteValue(this, name, throwOnMissingValue);
}
/// <summary>Returns the access control security for the current registry key.</summary>
/// <returns>A <see cref="T:System.Security.AccessControl.RegistrySecurity" /> object that describes the access control permissions on the registry key represented by the current <see cref="T:Microsoft.Win32.RegistryKey" />.</returns>
/// <exception cref="T:System.Security.SecurityException">The user does not have the necessary permissions.</exception>
/// <exception cref="T:System.ObjectDisposedException">The <see cref="T:Microsoft.Win32.RegistryKey" /> being manipulated is closed (closed keys cannot be accessed).</exception>
/// <exception cref="T:System.InvalidOperationException">The current key has been deleted.</exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.RegistryPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x06000720 RID: 1824 RVA: 0x00015C58 File Offset: 0x00013E58
public RegistrySecurity GetAccessControl()
{
throw new NotImplementedException();
}
/// <summary>Returns the specified sections of the access control security for the current registry key.</summary>
/// <returns>A <see cref="T:System.Security.AccessControl.RegistrySecurity" /> object that describes the access control permissions on the registry key represented by the current <see cref="T:Microsoft.Win32.RegistryKey" />.</returns>
/// <param name="includeSections">A bitwise combination of <see cref="T:System.Security.AccessControl.AccessControlSections" /> values that specifies the type of security information to get. </param>
/// <exception cref="T:System.Security.SecurityException">The user does not have the necessary permissions.</exception>
/// <exception cref="T:System.ObjectDisposedException">The <see cref="T:Microsoft.Win32.RegistryKey" /> being manipulated is closed (closed keys cannot be accessed).</exception>
/// <exception cref="T:System.InvalidOperationException">The current key has been deleted.</exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.RegistryPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x06000721 RID: 1825 RVA: 0x00015C60 File Offset: 0x00013E60
public RegistrySecurity GetAccessControl(AccessControlSections includeSections)
{
throw new NotImplementedException();
}
/// <summary>Retrieves an array of strings that contains all the subkey names.</summary>
/// <returns>An array of strings that contains the names of the subkeys for the current key.</returns>
/// <exception cref="T:System.Security.SecurityException">The user does not have the permissions required to read from the key. </exception>
/// <exception cref="T:System.ObjectDisposedException">The <see cref="T:Microsoft.Win32.RegistryKey" /> being manipulated is closed (closed keys cannot be accessed). </exception>
/// <exception cref="T:System.UnauthorizedAccessException">The user does not have the necessary registry rights.</exception>
/// <exception cref="T:System.IO.IOException">A system error occurred, for example the current key has been deleted.</exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.RegistryPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x06000722 RID: 1826 RVA: 0x00015C68 File Offset: 0x00013E68
public string[] GetSubKeyNames()
{
this.AssertKeyStillValid();
return RegistryKey.RegistryApi.GetSubKeyNames(this);
}
/// <summary>Retrieves an array of strings that contains all the value names associated with this key.</summary>
/// <returns>An array of strings that contains the value names for the current key.</returns>
/// <exception cref="T:System.Security.SecurityException">The user does not have the permissions required to read from the registry key. </exception>
/// <exception cref="T:System.ObjectDisposedException">The <see cref="T:Microsoft.Win32.RegistryKey" /> being manipulated is closed (closed keys cannot be accessed). </exception>
/// <exception cref="T:System.UnauthorizedAccessException">The user does not have the necessary registry rights.</exception>
/// <exception cref="T:System.IO.IOException">A system error occurred; for example, the current key has been deleted.</exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.RegistryPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x06000723 RID: 1827 RVA: 0x00015C7C File Offset: 0x00013E7C
public string[] GetValueNames()
{
this.AssertKeyStillValid();
return RegistryKey.RegistryApi.GetValueNames(this);
}
/// <summary>Opens a new <see cref="T:Microsoft.Win32.RegistryKey" /> that represents the requested key on a remote machine.</summary>
/// <returns>The requested <see cref="T:Microsoft.Win32.RegistryKey" />.</returns>
/// <param name="hKey">The HKEY to open, from the <see cref="T:Microsoft.Win32.RegistryHive" /> enumeration. </param>
/// <param name="machineName">The remote machine. </param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="hKey" /> is invalid.</exception>
/// <exception cref="T:System.IO.IOException">
/// <paramref name="machineName" /> is not found.</exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="machineName" /> is null. </exception>
/// <exception cref="T:System.Security.SecurityException">The user does not have the proper permissions to perform this operation. </exception>
/// <exception cref="T:System.UnauthorizedAccessException">The user does not have the necessary registry rights.</exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x06000724 RID: 1828 RVA: 0x00015C90 File Offset: 0x00013E90
[MonoTODO("Not implemented on unix")]
public static RegistryKey OpenRemoteBaseKey(RegistryHive hKey, string machineName)
{
if (machineName == null)
{
throw new ArgumentNullException("machineName");
}
return RegistryKey.RegistryApi.OpenRemoteBaseKey(hKey, machineName);
}
/// <summary>Retrieves the specified subkey for read or read/write access.</summary>
/// <returns>A <see cref="T:Microsoft.Win32.RegistryKey" /> object representing the subkey requested, or null if the operation failed.</returns>
/// <param name="name">The name or path of the subkey to create or open.</param>
/// <param name="permissionCheck">One of the <see cref="T:Microsoft.Win32.RegistryKeyPermissionCheck" /> values that specifies whether the key is opened for read or read/write access.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="name" /> is null</exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="name" /> is longer than the maximum length allowed (255 characters). -or-<paramref name="permissionCheck" /> contains an invalid value.</exception>
/// <exception cref="T:System.ObjectDisposedException">The <see cref="T:Microsoft.Win32.RegistryKey" /> is closed (closed keys cannot be accessed). </exception>
/// <exception cref="T:System.Security.SecurityException">The user does not have the permissions required to read the registry key. </exception>
// Token: 0x06000725 RID: 1829 RVA: 0x00015CB0 File Offset: 0x00013EB0
[ComVisible(false)]
public RegistryKey OpenSubKey(string name, RegistryKeyPermissionCheck permissionCheck)
{
throw new NotImplementedException();
}
/// <summary>Retrieves the specified subkey for read or read/write access, requesting the specified access rights.</summary>
/// <returns>A <see cref="T:Microsoft.Win32.RegistryKey" /> object representing the subkey requested, or null if the operation failed.</returns>
/// <param name="name">The name or path of the subkey to create or open.</param>
/// <param name="permissionCheck">One of the <see cref="T:Microsoft.Win32.RegistryKeyPermissionCheck" /> values that specifies whether the key is opened for read or read/write access.</param>
/// <param name="rights">A bitwise combination of <see cref="T:System.Security.AccessControl.RegistryRights" /> values that specifies the desired security access.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="name" /> is null</exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="name" /> is longer than the maximum length allowed (255 characters). -or-<paramref name="permissionCheck" /> contains an invalid value.</exception>
/// <exception cref="T:System.ObjectDisposedException">The <see cref="T:Microsoft.Win32.RegistryKey" /> is closed (closed keys cannot be accessed). </exception>
/// <exception cref="T:System.Security.SecurityException">
/// <paramref name="rights" /> includes invalid registry rights values.-or-The user does not have the requested permissions. </exception>
// Token: 0x06000726 RID: 1830 RVA: 0x00015CB8 File Offset: 0x00013EB8
[ComVisible(false)]
public RegistryKey OpenSubKey(string name, RegistryKeyPermissionCheck permissionCheck, RegistryRights rights)
{
throw new NotImplementedException();
}
/// <summary>Applies Windows access control security to an existing registry key.</summary>
/// <param name="registrySecurity">A <see cref="T:System.Security.AccessControl.RegistrySecurity" /> object that specifies the access control security to apply to the current subkey. </param>
/// <exception cref="T:System.UnauthorizedAccessException">The current <see cref="T:Microsoft.Win32.RegistryKey" /> object represents a key with access control security, and the caller does not have <see cref="F:System.Security.AccessControl.RegistryRights.ChangePermissions" /> rights.</exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="registrySecurity" /> is null.</exception>
/// <exception cref="T:System.ObjectDisposedException">The <see cref="T:Microsoft.Win32.RegistryKey" /> being manipulated is closed (closed keys cannot be accessed).</exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.RegistryPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x06000727 RID: 1831 RVA: 0x00015CC0 File Offset: 0x00013EC0
public void SetAccessControl(RegistrySecurity registrySecurity)
{
throw new NotImplementedException();
}
/// <summary>Retrieves a string representation of this key.</summary>
/// <returns>A string representing the key. If the specified key is invalid (cannot be found) then null is returned.</returns>
/// <exception cref="T:System.ObjectDisposedException">The <see cref="T:Microsoft.Win32.RegistryKey" /> being accessed is closed (closed keys cannot be accessed). </exception>
// Token: 0x06000728 RID: 1832 RVA: 0x00015CC8 File Offset: 0x00013EC8
public override string ToString()
{
this.AssertKeyStillValid();
return RegistryKey.RegistryApi.ToString(this);
}
// Token: 0x170000D4 RID: 212
// (get) Token: 0x06000729 RID: 1833 RVA: 0x00015CDC File Offset: 0x00013EDC
internal bool IsRoot
{
get
{
return this.hive != null;
}
}
// Token: 0x170000D5 RID: 213
// (get) Token: 0x0600072A RID: 1834 RVA: 0x00015CEC File Offset: 0x00013EEC
private bool IsWritable
{
get
{
return this.isWritable;
}
}
// Token: 0x170000D6 RID: 214
// (get) Token: 0x0600072B RID: 1835 RVA: 0x00015CF4 File Offset: 0x00013EF4
internal RegistryHive Hive
{
get
{
if (!this.IsRoot)
{
throw new NotSupportedException();
}
return (RegistryHive)((int)this.hive);
}
}
// Token: 0x170000D7 RID: 215
// (get) Token: 0x0600072C RID: 1836 RVA: 0x00015D14 File Offset: 0x00013F14
internal object Handle
{
get
{
return this.handle;
}
}
// Token: 0x0600072D RID: 1837 RVA: 0x00015D1C File Offset: 0x00013F1C
private void AssertKeyStillValid()
{
if (this.handle == null)
{
throw new ObjectDisposedException("Microsoft.Win32.RegistryKey");
}
}
// Token: 0x0600072E RID: 1838 RVA: 0x00015D34 File Offset: 0x00013F34
private void AssertKeyNameNotNull(string subKeyName)
{
if (subKeyName == null)
{
throw new ArgumentNullException("name");
}
}
// Token: 0x0600072F RID: 1839 RVA: 0x00015D48 File Offset: 0x00013F48
private void AssertKeyNameLength(string name)
{
if (name.Length > 255)
{
throw new ArgumentException("Name of registry key cannot be greater than 255 characters");
}
}
// Token: 0x06000730 RID: 1840 RVA: 0x00015D68 File Offset: 0x00013F68
private void DeleteChildKeysAndValues()
{
if (this.IsRoot)
{
return;
}
string[] subKeyNames = this.GetSubKeyNames();
foreach (string text in subKeyNames)
{
RegistryKey registryKey = this.OpenSubKey(text, true);
registryKey.DeleteChildKeysAndValues();
registryKey.Close();
this.DeleteSubKey(text, false);
}
string[] valueNames = this.GetValueNames();
foreach (string text2 in valueNames)
{
this.DeleteValue(text2, false);
}
}
// Token: 0x06000731 RID: 1841 RVA: 0x00015DF8 File Offset: 0x00013FF8
internal static string DecodeString(byte[] data)
{
string text = Encoding.Unicode.GetString(data);
int num = text.IndexOf('\0');
if (num != -1)
{
text = text.TrimEnd(new char[1]);
}
return text;
}
// Token: 0x06000732 RID: 1842 RVA: 0x00015E30 File Offset: 0x00014030
internal static IOException CreateMarkedForDeletionException()
{
throw new IOException("Illegal operation attempted on a registry key that has been marked for deletion.");
}
// Token: 0x06000733 RID: 1843 RVA: 0x00015E3C File Offset: 0x0001403C
private static string GetHiveName(RegistryHive hive)
{
switch (hive + -2147483648)
{
case (RegistryHive)0:
return "HKEY_CLASSES_ROOT";
case (RegistryHive)1:
return "HKEY_CURRENT_USER";
case (RegistryHive)2:
return "HKEY_LOCAL_MACHINE";
case (RegistryHive)3:
return "HKEY_USERS";
case (RegistryHive)4:
return "HKEY_PERFORMANCE_DATA";
case (RegistryHive)5:
return "HKEY_CURRENT_CONFIG";
case (RegistryHive)6:
return "HKEY_DYN_DATA";
default:
throw new NotImplementedException(string.Format("Registry hive '{0}' is not implemented.", hive.ToString()));
}
}
// Token: 0x040000EC RID: 236
private object handle;
// Token: 0x040000ED RID: 237
private object hive;
// Token: 0x040000EE RID: 238
private readonly string qname;
// Token: 0x040000EF RID: 239
private readonly bool isRemoteRoot;
// Token: 0x040000F0 RID: 240
private readonly bool isWritable;
// Token: 0x040000F1 RID: 241
private static readonly IRegistryApi RegistryApi;
}
}
@@ -0,0 +1,19 @@
using System;
namespace Microsoft.Win32
{
/// <summary>Specifies whether security checks are performed when opening registry keys and accessing their name/value pairs.</summary>
// Token: 0x02000076 RID: 118
public enum RegistryKeyPermissionCheck
{
/// <summary>The registry key inherits the mode of its parent. Security checks are performed when trying to access subkeys or values, unless the parent was opened with <see cref="F:Microsoft.Win32.RegistryKeyPermissionCheck.ReadSubTree" /> or <see cref="F:Microsoft.Win32.RegistryKeyPermissionCheck.ReadWriteSubTree" /> mode.</summary>
// Token: 0x040000F3 RID: 243
Default,
/// <summary>Security checks are not performed when accessing subkeys or values. A security check is performed when trying to open the current key, unless the parent was opened with <see cref="F:Microsoft.Win32.RegistryKeyPermissionCheck.ReadSubTree" /> or <see cref="F:Microsoft.Win32.RegistryKeyPermissionCheck.ReadWriteSubTree" />.</summary>
// Token: 0x040000F4 RID: 244
ReadSubTree,
/// <summary>Security checks are not performed when accessing subkeys or values. A security check is performed when trying to open the current key, unless the parent was opened with <see cref="F:Microsoft.Win32.RegistryKeyPermissionCheck.ReadWriteSubTree" />.</summary>
// Token: 0x040000F5 RID: 245
ReadWriteSubTree
}
}
@@ -0,0 +1,33 @@
using System;
using System.Runtime.InteropServices;
namespace Microsoft.Win32
{
/// <summary>Specifies the data types to use when storing values in the registry, or identifies the data type of a value in the registry.</summary>
// Token: 0x02000077 RID: 119
[ComVisible(true)]
public enum RegistryValueKind
{
/// <summary>Indicates an unsupported registry data type. For example, the Microsoft Win32 API registry data type REG_RESOURCE_LIST is unsupported. Use this value to specify that the <see cref="M:Microsoft.Win32.RegistryKey.SetValue(System.String,System.Object)" /> method should determine the appropriate registry data type when storing a name/value pair.</summary>
// Token: 0x040000F7 RID: 247
Unknown,
/// <summary>Specifies a null-terminated string. This value is equivalent to the Win32 API registry data type REG_SZ.</summary>
// Token: 0x040000F8 RID: 248
String,
/// <summary>Specifies a null-terminated string that contains unexpanded references to environment variables, such as %PATH%, that are expanded when the value is retrieved. This value is equivalent to the Win32 API registry data type REG_EXPAND_SZ.</summary>
// Token: 0x040000F9 RID: 249
ExpandString,
/// <summary>Specifies binary data in any form. This value is equivalent to the Win32 API registry data type REG_BINARY.</summary>
// Token: 0x040000FA RID: 250
Binary,
/// <summary>Specifies a 32-bit binary number. This value is equivalent to the Win32 API registry data type REG_DWORD.</summary>
// Token: 0x040000FB RID: 251
DWord,
/// <summary>Specifies an array of null-terminated strings, terminated by two null characters. This value is equivalent to the Win32 API registry data type REG_MULTI_SZ.</summary>
// Token: 0x040000FC RID: 252
MultiString = 7,
/// <summary>Specifies a 64-bit binary number. This value is equivalent to the Win32 API registry data type REG_QWORD.</summary>
// Token: 0x040000FD RID: 253
QWord = 11
}
}
@@ -0,0 +1,17 @@
using System;
namespace Microsoft.Win32
{
/// <summary>Specifies optional behavior when retrieving name/value pairs from a registry key.</summary>
// Token: 0x02000078 RID: 120
[Flags]
public enum RegistryValueOptions
{
/// <summary>No optional behavior is specified.</summary>
// Token: 0x040000FF RID: 255
None = 0,
/// <summary>A value of type <see cref="F:Microsoft.Win32.RegistryValueKind.ExpandString" /> is retrieved without expanding its embedded environment variables. </summary>
// Token: 0x04000100 RID: 256
DoNotExpandEnvironmentNames = 1
}
}
@@ -0,0 +1,31 @@
using System;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
namespace Microsoft.Win32.SafeHandles
{
/// <summary>Provides a base class for Win32 critical handle implementations in which the value of -1 indicates an invalid handle.</summary>
// Token: 0x0200006C RID: 108
public abstract class CriticalHandleMinusOneIsInvalid : CriticalHandle, IDisposable
{
/// <summary>Initializes a new instance of the <see cref="T:Microsoft.Win32.SafeHandles.CriticalHandleMinusOneIsInvalid" /> class.</summary>
// Token: 0x060006E4 RID: 1764 RVA: 0x00015420 File Offset: 0x00013620
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
protected CriticalHandleMinusOneIsInvalid()
: base((IntPtr)(-1))
{
}
/// <summary>Gets a value that indicates whether the handle is invalid.</summary>
/// <returns>true if the handle is not valid; otherwise, false.</returns>
// Token: 0x170000CD RID: 205
// (get) Token: 0x060006E5 RID: 1765 RVA: 0x00015430 File Offset: 0x00013630
public override bool IsInvalid
{
get
{
return this.handle == (IntPtr)(-1);
}
}
}
}
@@ -0,0 +1,31 @@
using System;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
namespace Microsoft.Win32.SafeHandles
{
/// <summary>Provides a base class for Win32 critical handle implementations in which the value of either 0 or -1 indicates an invalid handle.</summary>
// Token: 0x0200006D RID: 109
public abstract class CriticalHandleZeroOrMinusOneIsInvalid : CriticalHandle, IDisposable
{
/// <summary>Initializes a new instance of the <see cref="T:Microsoft.Win32.SafeHandles.CriticalHandleZeroOrMinusOneIsInvalid" /> class. </summary>
// Token: 0x060006E6 RID: 1766 RVA: 0x00015444 File Offset: 0x00013644
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
protected CriticalHandleZeroOrMinusOneIsInvalid()
: base((IntPtr)(-1))
{
}
/// <summary>Gets a value that indicates whether the handle is invalid.</summary>
/// <returns>true if the handle is not valid; otherwise, false.</returns>
// Token: 0x170000CE RID: 206
// (get) Token: 0x060006E7 RID: 1767 RVA: 0x00015454 File Offset: 0x00013654
public override bool IsInvalid
{
get
{
return this.handle == (IntPtr)(-1) || this.handle == IntPtr.Zero;
}
}
}
}
@@ -0,0 +1,34 @@
using System;
using System.IO;
namespace Microsoft.Win32.SafeHandles
{
/// <summary>Represents a wrapper class for a file handle. </summary>
// Token: 0x0200006E RID: 110
public sealed class SafeFileHandle : SafeHandleZeroOrMinusOneIsInvalid
{
/// <summary>Initializes a new instance of the <see cref="T:Microsoft.Win32.SafeHandles.SafeFileHandle" /> class. </summary>
/// <param name="preexistingHandle">An <see cref="T:System.IntPtr" /> object that represents the pre-existing handle to use.</param>
/// <param name="ownsHandle">true to reliably release the handle during the finalization phase; false to prevent reliable release (not recommended).</param>
// Token: 0x060006E8 RID: 1768 RVA: 0x00015480 File Offset: 0x00013680
public SafeFileHandle(IntPtr preexistingHandle, bool ownsHandle)
: base(ownsHandle)
{
base.SetHandle(preexistingHandle);
}
// Token: 0x060006E9 RID: 1769 RVA: 0x00015490 File Offset: 0x00013690
internal SafeFileHandle()
: base(true)
{
}
// Token: 0x060006EA RID: 1770 RVA: 0x0001549C File Offset: 0x0001369C
protected override bool ReleaseHandle()
{
MonoIOError monoIOError;
MonoIO.Close(this.handle, out monoIOError);
return monoIOError == MonoIOError.ERROR_SUCCESS;
}
}
}
@@ -0,0 +1,32 @@
using System;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
namespace Microsoft.Win32.SafeHandles
{
/// <summary>Provides a base class for Win32 safe handle implementations in which the value of -1 indicates an invalid handle.</summary>
// Token: 0x0200006F RID: 111
public abstract class SafeHandleMinusOneIsInvalid : SafeHandle, IDisposable
{
/// <summary>Initializes a new instance of the <see cref="T:Microsoft.Win32.SafeHandles.SafeHandleMinusOneIsInvalid" /> class, specifying whether the handle is to be reliably released. </summary>
/// <param name="ownsHandle">true to reliably release the handle during the finalization phase; false to prevent reliable release (not recommended).</param>
// Token: 0x060006EB RID: 1771 RVA: 0x000154BC File Offset: 0x000136BC
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
protected SafeHandleMinusOneIsInvalid(bool ownsHandle)
: base((IntPtr)0, ownsHandle)
{
}
/// <summary>Gets a value that indicates whether the handle is invalid.</summary>
/// <returns>true if the handle is not valid; otherwise, false.</returns>
// Token: 0x170000CF RID: 207
// (get) Token: 0x060006EC RID: 1772 RVA: 0x000154CC File Offset: 0x000136CC
public override bool IsInvalid
{
get
{
return this.handle == (IntPtr)(-1);
}
}
}
}
@@ -0,0 +1,32 @@
using System;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
namespace Microsoft.Win32.SafeHandles
{
/// <summary>Provides a base class for Win32 safe handle implementations in which the value of either 0 or -1 indicates an invalid handle.</summary>
// Token: 0x02000070 RID: 112
public abstract class SafeHandleZeroOrMinusOneIsInvalid : SafeHandle, IDisposable
{
/// <summary>Initializes a new instance of the <see cref="T:Microsoft.Win32.SafeHandles.SafeHandleZeroOrMinusOneIsInvalid" /> class, specifying whether the handle is to be reliably released. </summary>
/// <param name="ownsHandle">true to reliably release the handle during the finalization phase; false to prevent reliable release (not recommended).</param>
// Token: 0x060006ED RID: 1773 RVA: 0x000154E0 File Offset: 0x000136E0
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
protected SafeHandleZeroOrMinusOneIsInvalid(bool ownsHandle)
: base((IntPtr)0, ownsHandle)
{
}
/// <summary>Gets a value that indicates whether the handle is invalid.</summary>
/// <returns>true if the handle is not valid; otherwise, false.</returns>
// Token: 0x170000D0 RID: 208
// (get) Token: 0x060006EE RID: 1774 RVA: 0x000154F0 File Offset: 0x000136F0
public override bool IsInvalid
{
get
{
return this.handle == (IntPtr)(-1) || this.handle == (IntPtr)0;
}
}
}
}
@@ -0,0 +1,29 @@
using System;
using System.Runtime.ConstrainedExecution;
using System.Threading;
namespace Microsoft.Win32.SafeHandles
{
/// <summary>Represents a wrapper class for a wait handle. </summary>
// Token: 0x02000071 RID: 113
public sealed class SafeWaitHandle : SafeHandleZeroOrMinusOneIsInvalid
{
/// <summary>Initializes a new instance of the <see cref="T:Microsoft.Win32.SafeHandles.SafeWaitHandle" /> class. </summary>
/// <param name="existingHandle">An <see cref="T:System.IntPtr" /> object that represents the pre-existing handle to use.</param>
/// <param name="ownsHandle">true to reliably release the handle during the finalization phase; false to prevent reliable release (not recommended).</param>
// Token: 0x060006EF RID: 1775 RVA: 0x00015528 File Offset: 0x00013728
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public SafeWaitHandle(IntPtr existingHandle, bool ownsHandle)
: base(ownsHandle)
{
base.SetHandle(existingHandle);
}
// Token: 0x060006F0 RID: 1776 RVA: 0x00015538 File Offset: 0x00013738
protected override bool ReleaseHandle()
{
NativeEventCalls.CloseEvent_internal(this.handle);
return true;
}
}
}
+213
View File
@@ -0,0 +1,213 @@
using System;
using System.Globalization;
using System.IO;
namespace Microsoft.Win32
{
// Token: 0x0200007B RID: 123
internal class UnixRegistryApi : IRegistryApi
{
// Token: 0x06000752 RID: 1874 RVA: 0x0001709C File Offset: 0x0001529C
private static string ToUnix(string keyname)
{
if (keyname.IndexOf('\\') != -1)
{
keyname = keyname.Replace('\\', '/');
}
return keyname.ToLower();
}
// Token: 0x06000753 RID: 1875 RVA: 0x000170CC File Offset: 0x000152CC
private static bool IsWellKnownKey(string parentKeyName, string keyname)
{
return (parentKeyName == Registry.CurrentUser.Name || parentKeyName == Registry.LocalMachine.Name) && 0 == string.Compare("software", keyname, true, CultureInfo.InvariantCulture);
}
// Token: 0x06000754 RID: 1876 RVA: 0x0001711C File Offset: 0x0001531C
public RegistryKey CreateSubKey(RegistryKey rkey, string keyname)
{
return this.CreateSubKey(rkey, keyname, true);
}
// Token: 0x06000755 RID: 1877 RVA: 0x00017128 File Offset: 0x00015328
public RegistryKey OpenRemoteBaseKey(RegistryHive hKey, string machineName)
{
throw new NotImplementedException();
}
// Token: 0x06000756 RID: 1878 RVA: 0x00017130 File Offset: 0x00015330
public RegistryKey OpenSubKey(RegistryKey rkey, string keyname, bool writable)
{
KeyHandler keyHandler = KeyHandler.Lookup(rkey, true);
if (keyHandler == null)
{
return null;
}
RegistryKey registryKey = keyHandler.Probe(rkey, UnixRegistryApi.ToUnix(keyname), writable);
if (registryKey == null && UnixRegistryApi.IsWellKnownKey(rkey.Name, keyname))
{
registryKey = this.CreateSubKey(rkey, keyname, writable);
}
return registryKey;
}
// Token: 0x06000757 RID: 1879 RVA: 0x00017180 File Offset: 0x00015380
public void Flush(RegistryKey rkey)
{
KeyHandler keyHandler = KeyHandler.Lookup(rkey, false);
if (keyHandler == null)
{
return;
}
keyHandler.Flush();
}
// Token: 0x06000758 RID: 1880 RVA: 0x000171A4 File Offset: 0x000153A4
public void Close(RegistryKey rkey)
{
KeyHandler.Drop(rkey);
}
// Token: 0x06000759 RID: 1881 RVA: 0x000171AC File Offset: 0x000153AC
public object GetValue(RegistryKey rkey, string name, object default_value, RegistryValueOptions options)
{
KeyHandler keyHandler = KeyHandler.Lookup(rkey, true);
if (keyHandler == null)
{
return default_value;
}
if (keyHandler.ValueExists(name))
{
return keyHandler.GetValue(name, options);
}
return default_value;
}
// Token: 0x0600075A RID: 1882 RVA: 0x000171E0 File Offset: 0x000153E0
public void SetValue(RegistryKey rkey, string name, object value)
{
KeyHandler keyHandler = KeyHandler.Lookup(rkey, true);
if (keyHandler == null)
{
throw RegistryKey.CreateMarkedForDeletionException();
}
keyHandler.SetValue(name, value);
}
// Token: 0x0600075B RID: 1883 RVA: 0x0001720C File Offset: 0x0001540C
public void SetValue(RegistryKey rkey, string name, object value, RegistryValueKind valueKind)
{
KeyHandler keyHandler = KeyHandler.Lookup(rkey, true);
if (keyHandler == null)
{
throw RegistryKey.CreateMarkedForDeletionException();
}
keyHandler.SetValue(name, value, valueKind);
}
// Token: 0x0600075C RID: 1884 RVA: 0x00017238 File Offset: 0x00015438
public int SubKeyCount(RegistryKey rkey)
{
KeyHandler keyHandler = KeyHandler.Lookup(rkey, true);
if (keyHandler == null)
{
throw RegistryKey.CreateMarkedForDeletionException();
}
return Directory.GetDirectories(keyHandler.Dir).Length;
}
// Token: 0x0600075D RID: 1885 RVA: 0x00017268 File Offset: 0x00015468
public int ValueCount(RegistryKey rkey)
{
KeyHandler keyHandler = KeyHandler.Lookup(rkey, true);
if (keyHandler == null)
{
throw RegistryKey.CreateMarkedForDeletionException();
}
return keyHandler.ValueCount;
}
// Token: 0x0600075E RID: 1886 RVA: 0x00017290 File Offset: 0x00015490
public void DeleteValue(RegistryKey rkey, string name, bool throw_if_missing)
{
KeyHandler keyHandler = KeyHandler.Lookup(rkey, true);
if (keyHandler == null)
{
return;
}
if (throw_if_missing && !keyHandler.ValueExists(name))
{
throw new ArgumentException("the given value does not exist");
}
keyHandler.RemoveValue(name);
}
// Token: 0x0600075F RID: 1887 RVA: 0x000172D0 File Offset: 0x000154D0
public void DeleteKey(RegistryKey rkey, string keyname, bool throw_if_missing)
{
KeyHandler keyHandler = KeyHandler.Lookup(rkey, true);
if (keyHandler != null)
{
string text = Path.Combine(keyHandler.Dir, UnixRegistryApi.ToUnix(keyname));
if (Directory.Exists(text))
{
Directory.Delete(text, true);
KeyHandler.Drop(text);
}
else if (throw_if_missing)
{
throw new ArgumentException("the given value does not exist");
}
return;
}
if (!throw_if_missing)
{
return;
}
throw new ArgumentException("the given value does not exist");
}
// Token: 0x06000760 RID: 1888 RVA: 0x00017340 File Offset: 0x00015540
public string[] GetSubKeyNames(RegistryKey rkey)
{
KeyHandler keyHandler = KeyHandler.Lookup(rkey, true);
DirectoryInfo directoryInfo = new DirectoryInfo(keyHandler.Dir);
DirectoryInfo[] directories = directoryInfo.GetDirectories();
string[] array = new string[directories.Length];
for (int i = 0; i < directories.Length; i++)
{
DirectoryInfo directoryInfo2 = directories[i];
array[i] = directoryInfo2.Name;
}
return array;
}
// Token: 0x06000761 RID: 1889 RVA: 0x0001739C File Offset: 0x0001559C
public string[] GetValueNames(RegistryKey rkey)
{
KeyHandler keyHandler = KeyHandler.Lookup(rkey, true);
if (keyHandler == null)
{
throw RegistryKey.CreateMarkedForDeletionException();
}
return keyHandler.GetValueNames();
}
// Token: 0x06000762 RID: 1890 RVA: 0x000173C4 File Offset: 0x000155C4
public string ToString(RegistryKey rkey)
{
return rkey.Name;
}
// Token: 0x06000763 RID: 1891 RVA: 0x000173CC File Offset: 0x000155CC
private RegistryKey CreateSubKey(RegistryKey rkey, string keyname, bool writable)
{
KeyHandler keyHandler = KeyHandler.Lookup(rkey, true);
if (keyHandler == null)
{
throw RegistryKey.CreateMarkedForDeletionException();
}
return keyHandler.Ensure(rkey, UnixRegistryApi.ToUnix(keyname), writable);
}
}
}
@@ -0,0 +1,539 @@
using System;
using System.Collections;
using System.IO;
using System.Runtime.InteropServices;
using System.Security;
using System.Text;
namespace Microsoft.Win32
{
// Token: 0x0200007C RID: 124
internal class Win32RegistryApi : IRegistryApi
{
// Token: 0x06000765 RID: 1893
[DllImport("advapi32.dll", CharSet = CharSet.Unicode)]
private static extern int RegCreateKey(IntPtr keyBase, string keyName, out IntPtr keyHandle);
// Token: 0x06000766 RID: 1894
[DllImport("advapi32.dll", CharSet = CharSet.Unicode)]
private static extern int RegCloseKey(IntPtr keyHandle);
// Token: 0x06000767 RID: 1895
[DllImport("advapi32.dll", CharSet = CharSet.Unicode)]
private static extern int RegConnectRegistry(string machineName, IntPtr hKey, out IntPtr keyHandle);
// Token: 0x06000768 RID: 1896
[DllImport("advapi32.dll", CharSet = CharSet.Unicode)]
private static extern int RegFlushKey(IntPtr keyHandle);
// Token: 0x06000769 RID: 1897
[DllImport("advapi32.dll", CharSet = CharSet.Unicode)]
private static extern int RegOpenKeyEx(IntPtr keyBase, string keyName, IntPtr reserved, int access, out IntPtr keyHandle);
// Token: 0x0600076A RID: 1898
[DllImport("advapi32.dll", CharSet = CharSet.Unicode)]
private static extern int RegDeleteKey(IntPtr keyHandle, string valueName);
// Token: 0x0600076B RID: 1899
[DllImport("advapi32.dll", CharSet = CharSet.Unicode)]
private static extern int RegDeleteValue(IntPtr keyHandle, string valueName);
// Token: 0x0600076C RID: 1900
[DllImport("advapi32.dll", CharSet = CharSet.Unicode)]
private static extern int RegEnumKey(IntPtr keyBase, int index, StringBuilder nameBuffer, int bufferLength);
// Token: 0x0600076D RID: 1901
[DllImport("advapi32.dll", CharSet = CharSet.Unicode)]
private static extern int RegEnumValue(IntPtr keyBase, int index, StringBuilder nameBuffer, ref int nameLength, IntPtr reserved, ref RegistryValueKind type, IntPtr data, IntPtr dataLength);
// Token: 0x0600076E RID: 1902
[DllImport("advapi32.dll", CharSet = CharSet.Unicode)]
private static extern int RegSetValueEx(IntPtr keyBase, string valueName, IntPtr reserved, RegistryValueKind type, string data, int rawDataLength);
// Token: 0x0600076F RID: 1903
[DllImport("advapi32.dll", CharSet = CharSet.Unicode)]
private static extern int RegSetValueEx(IntPtr keyBase, string valueName, IntPtr reserved, RegistryValueKind type, byte[] rawData, int rawDataLength);
// Token: 0x06000770 RID: 1904
[DllImport("advapi32.dll", CharSet = CharSet.Unicode)]
private static extern int RegSetValueEx(IntPtr keyBase, string valueName, IntPtr reserved, RegistryValueKind type, ref int data, int rawDataLength);
// Token: 0x06000771 RID: 1905
[DllImport("advapi32.dll", CharSet = CharSet.Unicode)]
private static extern int RegQueryValueEx(IntPtr keyBase, string valueName, IntPtr reserved, ref RegistryValueKind type, IntPtr zero, ref int dataSize);
// Token: 0x06000772 RID: 1906
[DllImport("advapi32.dll", CharSet = CharSet.Unicode)]
private static extern int RegQueryValueEx(IntPtr keyBase, string valueName, IntPtr reserved, ref RegistryValueKind type, [Out] byte[] data, ref int dataSize);
// Token: 0x06000773 RID: 1907
[DllImport("advapi32.dll", CharSet = CharSet.Unicode)]
private static extern int RegQueryValueEx(IntPtr keyBase, string valueName, IntPtr reserved, ref RegistryValueKind type, ref int data, ref int dataSize);
// Token: 0x06000774 RID: 1908 RVA: 0x00017410 File Offset: 0x00015610
private static IntPtr GetHandle(RegistryKey key)
{
return (IntPtr)key.Handle;
}
// Token: 0x06000775 RID: 1909 RVA: 0x00017420 File Offset: 0x00015620
private static bool IsHandleValid(RegistryKey key)
{
return key.Handle != null;
}
// Token: 0x06000776 RID: 1910 RVA: 0x00017430 File Offset: 0x00015630
public object GetValue(RegistryKey rkey, string name, object defaultValue, RegistryValueOptions options)
{
RegistryValueKind registryValueKind = RegistryValueKind.Unknown;
int num = 0;
IntPtr handle = Win32RegistryApi.GetHandle(rkey);
int num2 = Win32RegistryApi.RegQueryValueEx(handle, name, IntPtr.Zero, ref registryValueKind, IntPtr.Zero, ref num);
if (num2 == 2 || num2 == 1018)
{
return defaultValue;
}
if (num2 != 234 && num2 != 0)
{
this.GenerateException(num2);
}
object obj;
if (registryValueKind == RegistryValueKind.String)
{
byte[] array;
num2 = this.GetBinaryValue(rkey, name, registryValueKind, out array, num);
obj = RegistryKey.DecodeString(array);
}
else if (registryValueKind == RegistryValueKind.ExpandString)
{
byte[] array2;
num2 = this.GetBinaryValue(rkey, name, registryValueKind, out array2, num);
obj = RegistryKey.DecodeString(array2);
if ((options & RegistryValueOptions.DoNotExpandEnvironmentNames) == RegistryValueOptions.None)
{
obj = Environment.ExpandEnvironmentVariables((string)obj);
}
}
else if (registryValueKind == RegistryValueKind.DWord)
{
int num3 = 0;
num2 = Win32RegistryApi.RegQueryValueEx(handle, name, IntPtr.Zero, ref registryValueKind, ref num3, ref num);
obj = num3;
}
else if (registryValueKind == RegistryValueKind.Binary)
{
byte[] array3;
num2 = this.GetBinaryValue(rkey, name, registryValueKind, out array3, num);
obj = array3;
}
else
{
if (registryValueKind != RegistryValueKind.MultiString)
{
throw new SystemException();
}
obj = null;
byte[] array4;
num2 = this.GetBinaryValue(rkey, name, registryValueKind, out array4, num);
if (num2 == 0)
{
obj = RegistryKey.DecodeString(array4).Split(new char[1]);
}
}
if (num2 != 0)
{
this.GenerateException(num2);
}
return obj;
}
// Token: 0x06000777 RID: 1911 RVA: 0x00017580 File Offset: 0x00015780
public void SetValue(RegistryKey rkey, string name, object value, RegistryValueKind valueKind)
{
Type type = value.GetType();
IntPtr handle = Win32RegistryApi.GetHandle(rkey);
int num2;
if (valueKind == RegistryValueKind.DWord && type == typeof(int))
{
int num = (int)value;
num2 = Win32RegistryApi.RegSetValueEx(handle, name, IntPtr.Zero, RegistryValueKind.DWord, ref num, 4);
}
else if (valueKind == RegistryValueKind.Binary && type == typeof(byte[]))
{
byte[] array = (byte[])value;
num2 = Win32RegistryApi.RegSetValueEx(handle, name, IntPtr.Zero, RegistryValueKind.Binary, array, array.Length);
}
else if (valueKind == RegistryValueKind.MultiString && type == typeof(string[]))
{
string[] array2 = (string[])value;
StringBuilder stringBuilder = new StringBuilder();
foreach (string text in array2)
{
stringBuilder.Append(text);
stringBuilder.Append('\0');
}
stringBuilder.Append('\0');
byte[] bytes = Encoding.Unicode.GetBytes(stringBuilder.ToString());
num2 = Win32RegistryApi.RegSetValueEx(handle, name, IntPtr.Zero, RegistryValueKind.MultiString, bytes, bytes.Length);
}
else if ((valueKind == RegistryValueKind.String || valueKind == RegistryValueKind.ExpandString) && type == typeof(string))
{
string text2 = string.Format("{0}{1}", value, '\0');
num2 = Win32RegistryApi.RegSetValueEx(handle, name, IntPtr.Zero, valueKind, text2, text2.Length * this.NativeBytesPerCharacter);
}
else
{
if (type.IsArray)
{
throw new ArgumentException("Only string and byte arrays can written as registry values");
}
throw new ArgumentException("Type does not match the valueKind");
}
if (num2 != 0)
{
this.GenerateException(num2);
}
}
// Token: 0x06000778 RID: 1912 RVA: 0x00017724 File Offset: 0x00015924
public void SetValue(RegistryKey rkey, string name, object value)
{
Type type = value.GetType();
IntPtr handle = Win32RegistryApi.GetHandle(rkey);
int num2;
if (type == typeof(int))
{
int num = (int)value;
num2 = Win32RegistryApi.RegSetValueEx(handle, name, IntPtr.Zero, RegistryValueKind.DWord, ref num, 4);
}
else if (type == typeof(byte[]))
{
byte[] array = (byte[])value;
num2 = Win32RegistryApi.RegSetValueEx(handle, name, IntPtr.Zero, RegistryValueKind.Binary, array, array.Length);
}
else if (type == typeof(string[]))
{
string[] array2 = (string[])value;
StringBuilder stringBuilder = new StringBuilder();
foreach (string text in array2)
{
stringBuilder.Append(text);
stringBuilder.Append('\0');
}
stringBuilder.Append('\0');
byte[] bytes = Encoding.Unicode.GetBytes(stringBuilder.ToString());
num2 = Win32RegistryApi.RegSetValueEx(handle, name, IntPtr.Zero, RegistryValueKind.MultiString, bytes, bytes.Length);
}
else
{
if (type.IsArray)
{
throw new ArgumentException("Only string and byte arrays can written as registry values");
}
string text2 = string.Format("{0}{1}", value, '\0');
num2 = Win32RegistryApi.RegSetValueEx(handle, name, IntPtr.Zero, RegistryValueKind.String, text2, text2.Length * this.NativeBytesPerCharacter);
}
if (num2 == 1018)
{
throw RegistryKey.CreateMarkedForDeletionException();
}
if (num2 != 0)
{
this.GenerateException(num2);
}
}
// Token: 0x06000779 RID: 1913 RVA: 0x00017890 File Offset: 0x00015A90
private int GetBinaryValue(RegistryKey rkey, string name, RegistryValueKind type, out byte[] data, int size)
{
byte[] array = new byte[size];
IntPtr handle = Win32RegistryApi.GetHandle(rkey);
int num = Win32RegistryApi.RegQueryValueEx(handle, name, IntPtr.Zero, ref type, array, ref size);
data = array;
return num;
}
// Token: 0x0600077A RID: 1914 RVA: 0x000178C4 File Offset: 0x00015AC4
public int SubKeyCount(RegistryKey rkey)
{
StringBuilder stringBuilder = new StringBuilder(1024);
IntPtr handle = Win32RegistryApi.GetHandle(rkey);
int num = 0;
for (;;)
{
int num2 = Win32RegistryApi.RegEnumKey(handle, num, stringBuilder, stringBuilder.Capacity);
if (num2 == 1018)
{
break;
}
if (num2 != 0)
{
if (num2 == 259)
{
return num;
}
this.GenerateException(num2);
}
num++;
}
throw RegistryKey.CreateMarkedForDeletionException();
}
// Token: 0x0600077B RID: 1915 RVA: 0x00017938 File Offset: 0x00015B38
public int ValueCount(RegistryKey rkey)
{
StringBuilder stringBuilder = new StringBuilder(1024);
IntPtr handle = Win32RegistryApi.GetHandle(rkey);
int num = 0;
for (;;)
{
RegistryValueKind registryValueKind = RegistryValueKind.Unknown;
int capacity = stringBuilder.Capacity;
int num2 = Win32RegistryApi.RegEnumValue(handle, num, stringBuilder, ref capacity, IntPtr.Zero, ref registryValueKind, IntPtr.Zero, IntPtr.Zero);
if (num2 == 1018)
{
break;
}
if (num2 != 0 && num2 != 234)
{
if (num2 == 259)
{
return num;
}
this.GenerateException(num2);
}
num++;
}
throw RegistryKey.CreateMarkedForDeletionException();
}
// Token: 0x0600077C RID: 1916 RVA: 0x000179D0 File Offset: 0x00015BD0
public RegistryKey OpenRemoteBaseKey(RegistryHive hKey, string machineName)
{
IntPtr intPtr = new IntPtr((int)hKey);
IntPtr intPtr2;
int num = Win32RegistryApi.RegConnectRegistry(machineName, intPtr, out intPtr2);
if (num != 0)
{
this.GenerateException(num);
}
return new RegistryKey(hKey, intPtr2, true);
}
// Token: 0x0600077D RID: 1917 RVA: 0x00017A04 File Offset: 0x00015C04
public RegistryKey OpenSubKey(RegistryKey rkey, string keyName, bool writable)
{
int num = 131097;
if (writable)
{
num |= 131078;
}
IntPtr handle = Win32RegistryApi.GetHandle(rkey);
IntPtr intPtr;
int num2 = Win32RegistryApi.RegOpenKeyEx(handle, keyName, IntPtr.Zero, num, out intPtr);
if (num2 == 2 || num2 == 1018)
{
return null;
}
if (num2 != 0)
{
this.GenerateException(num2);
}
return new RegistryKey(intPtr, Win32RegistryApi.CombineName(rkey, keyName), writable);
}
// Token: 0x0600077E RID: 1918 RVA: 0x00017A70 File Offset: 0x00015C70
public void Flush(RegistryKey rkey)
{
if (!Win32RegistryApi.IsHandleValid(rkey))
{
return;
}
IntPtr handle = Win32RegistryApi.GetHandle(rkey);
Win32RegistryApi.RegFlushKey(handle);
}
// Token: 0x0600077F RID: 1919 RVA: 0x00017A98 File Offset: 0x00015C98
public void Close(RegistryKey rkey)
{
if (!Win32RegistryApi.IsHandleValid(rkey))
{
return;
}
IntPtr handle = Win32RegistryApi.GetHandle(rkey);
Win32RegistryApi.RegCloseKey(handle);
}
// Token: 0x06000780 RID: 1920 RVA: 0x00017AC0 File Offset: 0x00015CC0
public RegistryKey CreateSubKey(RegistryKey rkey, string keyName)
{
IntPtr handle = Win32RegistryApi.GetHandle(rkey);
IntPtr intPtr;
int num = Win32RegistryApi.RegCreateKey(handle, keyName, out intPtr);
if (num == 1018)
{
throw RegistryKey.CreateMarkedForDeletionException();
}
if (num != 0)
{
this.GenerateException(num);
}
return new RegistryKey(intPtr, Win32RegistryApi.CombineName(rkey, keyName), true);
}
// Token: 0x06000781 RID: 1921 RVA: 0x00017B10 File Offset: 0x00015D10
public void DeleteKey(RegistryKey rkey, string keyName, bool shouldThrowWhenKeyMissing)
{
IntPtr handle = Win32RegistryApi.GetHandle(rkey);
int num = Win32RegistryApi.RegDeleteKey(handle, keyName);
if (num != 2)
{
if (num != 0)
{
this.GenerateException(num);
}
return;
}
if (shouldThrowWhenKeyMissing)
{
throw new ArgumentException("key " + keyName);
}
}
// Token: 0x06000782 RID: 1922 RVA: 0x00017B58 File Offset: 0x00015D58
public void DeleteValue(RegistryKey rkey, string value, bool shouldThrowWhenKeyMissing)
{
IntPtr handle = Win32RegistryApi.GetHandle(rkey);
int num = Win32RegistryApi.RegDeleteValue(handle, value);
if (num == 1018)
{
return;
}
if (num != 2)
{
if (num != 0)
{
this.GenerateException(num);
}
return;
}
if (shouldThrowWhenKeyMissing)
{
throw new ArgumentException("value " + value);
}
}
// Token: 0x06000783 RID: 1923 RVA: 0x00017BAC File Offset: 0x00015DAC
public string[] GetSubKeyNames(RegistryKey rkey)
{
IntPtr handle = Win32RegistryApi.GetHandle(rkey);
StringBuilder stringBuilder = new StringBuilder(1024);
ArrayList arrayList = new ArrayList();
int num = 0;
for (;;)
{
int num2 = Win32RegistryApi.RegEnumKey(handle, num, stringBuilder, stringBuilder.Capacity);
if (num2 == 0)
{
arrayList.Add(stringBuilder.ToString());
stringBuilder.Length = 0;
}
else
{
if (num2 == 259)
{
break;
}
this.GenerateException(num2);
}
num++;
}
return (string[])arrayList.ToArray(typeof(string));
}
// Token: 0x06000784 RID: 1924 RVA: 0x00017C40 File Offset: 0x00015E40
public string[] GetValueNames(RegistryKey rkey)
{
IntPtr handle = Win32RegistryApi.GetHandle(rkey);
ArrayList arrayList = new ArrayList();
int num = 0;
for (;;)
{
StringBuilder stringBuilder = new StringBuilder(1024);
int capacity = stringBuilder.Capacity;
RegistryValueKind registryValueKind = RegistryValueKind.Unknown;
int num2 = Win32RegistryApi.RegEnumValue(handle, num, stringBuilder, ref capacity, IntPtr.Zero, ref registryValueKind, IntPtr.Zero, IntPtr.Zero);
if (num2 == 0 || num2 == 234)
{
arrayList.Add(stringBuilder.ToString());
}
else
{
if (num2 == 259)
{
break;
}
if (num2 == 1018)
{
goto Block_3;
}
this.GenerateException(num2);
}
num++;
}
return (string[])arrayList.ToArray(typeof(string));
Block_3:
throw RegistryKey.CreateMarkedForDeletionException();
}
// Token: 0x06000785 RID: 1925 RVA: 0x00017D04 File Offset: 0x00015F04
private void GenerateException(int errorCode)
{
switch (errorCode)
{
case 2:
break;
default:
if (errorCode == 53)
{
throw new IOException("The network path was not found.");
}
if (errorCode != 87)
{
throw new SystemException();
}
break;
case 5:
throw new SecurityException();
}
throw new ArgumentException();
}
// Token: 0x06000786 RID: 1926 RVA: 0x00017D5C File Offset: 0x00015F5C
public string ToString(RegistryKey rkey)
{
return rkey.Name;
}
// Token: 0x06000787 RID: 1927 RVA: 0x00017D64 File Offset: 0x00015F64
internal static string CombineName(RegistryKey rkey, string localName)
{
return rkey.Name + "\\" + localName;
}
// Token: 0x04000109 RID: 265
private const int OpenRegKeyRead = 131097;
// Token: 0x0400010A RID: 266
private const int OpenRegKeyWrite = 131078;
// Token: 0x0400010B RID: 267
private const int Int32ByteSize = 4;
// Token: 0x0400010C RID: 268
private const int BufferMaxLength = 1024;
// Token: 0x0400010D RID: 269
private readonly int NativeBytesPerCharacter = Marshal.SystemDefaultCharSize;
}
}
@@ -0,0 +1,32 @@
using System;
namespace Microsoft.Win32
{
// Token: 0x0200007D RID: 125
internal class Win32ResultCode
{
// Token: 0x0400010E RID: 270
public const int Success = 0;
// Token: 0x0400010F RID: 271
public const int FileNotFound = 2;
// Token: 0x04000110 RID: 272
public const int AccessDenied = 5;
// Token: 0x04000111 RID: 273
public const int InvalidParameter = 87;
// Token: 0x04000112 RID: 274
public const int MoreData = 234;
// Token: 0x04000113 RID: 275
public const int NetworkPathNotFound = 53;
// Token: 0x04000114 RID: 276
public const int NoMoreEntries = 259;
// Token: 0x04000115 RID: 277
public const int MarkedForDeletion = 1018;
}
}