private RegistryNode GetRegistryNode(string name1, string name2) { RegistryNode level1 = null; RegistryNode level2 = null; foreach (RegistryNode node in Root.Children) { if (node.Name.ToLower().Equals(name1.ToLower())) { level1 = node; break; } } if ((level1 == null) || (level1.Type != RegistryNodeType.Directory)) { return(null); } foreach (RegistryNode node in level1.Children) { if (node.Name.ToLower().Equals(name2.ToLower())) { level2 = node; break; } } return(level2); }
/// <summary> /// Constructor with company name, product name & registry node to configure. The properties can be stored under the: <ul> /// <li> HKEY_CURRENT_USER\Software\companyName\productName\ node, or </li> /// <li> HKEY_LOCAL_MACHINE\Software\companyName\productName\ node, or </li> /// <li> HKEY_LOCAL_MACHINE\Software\WOW6432Node\companyName\productName\ node for 64bit setups, when 32bit binary used. </li></ul> /// </summary> /// <param name="companyName">The company name. Used as parent key.</param> /// <param name="productName">The product name. Used as child key of the company's name.</param> /// <param name="regNode">Registy Node (HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE) selection to use.</param> public RegistryIni(string companyName, string productName, RegistryNode regNode) { this.companyName = companyName; this.productName = productName; this.regNode = regNode; Init(); }
public Registry() { Root = new RegistryNode(); Root.Type = RegistryNodeType.Directory; Root.Name = ""; Root.Children = new RegistryNode[0]; }
public int[] GetArray(string name1, string name2, int[] def) { RegistryNode node = GetRegistryNode(name1, name2); if ((node == null) || (node.Type != RegistryNodeType.Array)) { return(def); } return((int[])node.ValueA.Clone()); }
public double GetFloat(string name1, string name2, double def) { RegistryNode node = GetRegistryNode(name1, name2); if ((node == null) || (node.Type != RegistryNodeType.Float)) { return(def); } return(node.ValueF); }
public int GetInt(string name1, string name2, int def) { RegistryNode node = GetRegistryNode(name1, name2); if ((node == null) || (node.Type != RegistryNodeType.Int)) { return(def); } return(node.ValueI); }
public string GetString(string name1, string name2, string def) { RegistryNode node = GetRegistryNode(name1, name2); if ((node == null) || (node.Type != RegistryNodeType.String)) { return(def); } return(node.ValueS); }
public Registry(string filename) { try { MemoryStream ms = ResourceManager.OpenRead(filename); if (ms == null) { Core.Abort("Couldn't load \"{0}\"", filename); return; } BinaryReader msb = new BinaryReader(ms); if (msb.ReadUInt32() != RegistrySignature) { ms.Close(); Core.Abort("Couldn't load \"{0}\" (not a registry file)", filename); return; } uint root_offset = msb.ReadUInt32(); uint root_size = msb.ReadUInt32(); uint reg_flags = msb.ReadUInt32(); uint reg_eatsize = msb.ReadUInt32(); uint reg_junk = msb.ReadUInt32(); Root = new RegistryNode(); Root.Type = RegistryNodeType.Directory; Root.Name = ""; Root.Children = new RegistryNode[root_size]; if (!TreeTraverse(ms, msb, Root, root_offset, root_offset + root_size, 0x1C + 0x20 * reg_eatsize)) { ms.Close(); Core.Abort("Couldn't load \"{0}\" (invalid registry file)", filename); return; } ms.Close(); } catch (IOException) { Core.Abort("Couldn't load \"{0}\"", filename); } }
public Registry() { _rootNode = new RegistryNode(null, string.Empty, _syncObj); }
private static bool TreeTraverse(MemoryStream ms, BinaryReader msb, RegistryNode node, uint first, uint last, uint data_origin) { for (uint i = first; i < last; i++) { ms.Seek(0x18 + 0x20 * i, SeekOrigin.Begin); uint e_unk1 = msb.ReadUInt32(); uint e_offset = msb.ReadUInt32(); // 0x1C uint e_count = msb.ReadUInt32(); // 0x18 uint e_type = msb.ReadUInt32(); // 0x14 string e_name = Core.UnpackByteString(866, msb.ReadBytes(16)); RegistryNode subnode = new RegistryNode(); node.Children[i - first] = subnode; subnode.Name = e_name; if (e_type == 0) // string value { subnode.Type = RegistryNodeType.String; ms.Seek(data_origin + e_offset, SeekOrigin.Begin); subnode.ValueS = Encoding.GetEncoding(866).GetString(msb.ReadBytes((int)e_count)); } else if (e_type == 2) // dword value { subnode.Type = RegistryNodeType.Int; subnode.ValueI = (int)e_offset; } else if (e_type == 4) // float value { // well, we gotta rewind and read it again // C-style union trickery won't work subnode.Type = RegistryNodeType.Float; ms.Seek(-0x1C, SeekOrigin.Current); subnode.ValueF = msb.ReadDouble(); } else if (e_type == 6) // int array { if ((e_count % 4) != 0) { return(false); } uint e_acount = e_count / 4; subnode.Type = RegistryNodeType.Array; subnode.ValueA = new int[e_acount]; ms.Seek(data_origin + e_offset, SeekOrigin.Begin); for (uint j = 0; j < e_acount; j++) { subnode.ValueA[j] = msb.ReadInt32(); } } else if (e_type == 1) // directory { subnode.Type = RegistryNodeType.Directory; subnode.Children = new RegistryNode[e_count]; if (!TreeTraverse(ms, msb, subnode, e_offset, e_offset + e_count, data_origin)) { return(false); } } } return(true); }
public void Add(RegistryNode node) { this.nodes.Add(node); }
/// <summary> /// Constructor with company name, product name & registry node to configure. The properties can be stored under the: <ul> /// <li> HKEY_CURRENT_USER\Software\companyName\productName\ node, or </li> /// <li> HKEY_LOCAL_MACHINE\Software\companyName\productName\ node, or </li> /// <li> HKEY_LOCAL_MACHINE\Software\WOW6432Node\companyName\productName\ node for 64bit setups, when 32bit binary used. </li></ul> /// </summary> /// <param name="companyName">The company name. Used as parent key.</param> /// <param name="productName">The product name. Used as child key of the company's name.</param> /// <param name="regNode">Registy Node (HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE) selection to use.</param> public RegistryIni(string companyName, string productName, RegistryNode regNode) { this.companyName = companyName ; this.productName = productName ; this.regNode = regNode ; Init() ; }
/// <summary> /// Constructor with product name & registry node to configure. The properties can be stored under the: <ul> /// <li> HKEY_CURRENT_USER\Software\productName\ node, or </li> /// <li> HKEY_LOCAL_MACHINE\Software\productName\ node, or </li> /// <li> HKEY_LOCAL_MACHINE\Software\WOW6432Node\productName\ node for 64bit setups, when 32bit binary used. </li></ul> /// </summary> /// <param name="productName">The product name. Used as parent key.</param> /// <param name="regNode">Registy Node (HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE) selection to use.</param> public RegistryIni(string productName, RegistryNode regNode) : this(null, productName, regNode) { }
public void AddNode(RegistryNode registryNode) { _nodes.Add(registryNode); }
public static extern Variable Registry(IntPtr ctx, RegistryNode subtype);