public void CreateInherit()
        {
            RegistryHive hive = RegistryHive.Create(new MemoryStream());
            Store        s    = Store.Initialize(hive.Root);

            BcdObject obj = s.CreateInherit(InheritType.ApplicationObjects);

            Assert.AreNotEqual(Guid.Empty, obj.Identity);

            Assert.AreEqual(ObjectType.Inherit, obj.ObjectType);

            Assert.IsTrue(obj.IsInheritableBy(ObjectType.Application));
            Assert.IsFalse(obj.IsInheritableBy(ObjectType.Device));

            BcdObject reGet = s.GetObject(obj.Identity);

            Assert.AreEqual(obj.Identity, reGet.Identity);
        }
Пример #2
0
        /*        internal string Flatten()
         * {
         *  if (Data == null)
         *      return String.Empty;
         *
         *  string output = String.Empty;
         *
         *  foreach (var path in Data)
         *  {
         *      output += String.Format("[{0}]\n", path.Key);
         *      foreach (var item in path.Value)
         *      {
         *          string tmp = String.Format(@"""{0}""={1}:""", item.Key, item.Value.Type);
         *          string value = item.Value.Value.ToString();
         *          var realVal = item.Value.Value;
         *          switch (item.Value.Type)
         *          {
         *              case RegistryValueType.Binary:
         *              case RegistryValueType.Dword:
         *              case RegistryValueType.ExpandString:
         *              case RegistryValueType.MultiString:
         *              case RegistryValueType.QWord:
         *              case RegistryValueType.String:
         *                  tmp += value.Replace("\n", "\\\n");
         *                  break;
         *              //case RegistryValueType.Unknown:
         *              case RegistryValueType.None:
         *              default:
         *                  throw new ParseErrorException(String.Format("Unable to output value of '{0}::{1}'. Unable to identify value type.", path.Key, item.Key));
         *          }
         *          tmp += "\"\n";
         *          output += tmp;
         *      }
         *  }
         *  return output;
         * }
         */

        internal void WriteToStream(Stream Output)
        {
            //Output.Write(Flatten());
            RegistryHive Out;

            try { Out = new RegistryHive(Output, DiscUtils.Ownership.None); }
            catch (Exception e) { Out = RegistryHive.Create(Output, DiscUtils.Ownership.None); }

            var root = Out.Root;

            foreach (var path in Data)
            {
                var currentKey = root.CreateSubKey(path.Key);
                foreach (var val in path.Value)
                {
                    currentKey.SetValue(val.Key, val.Value.Value, val.Value.Type);
                }
            }
        }
        public void DeviceValue_Mbr()
        {
            SparseMemoryStream ms = new SparseMemoryStream();

            ms.SetLength(80 * 1024 * 1024);
            BiosPartitionTable pt = BiosPartitionTable.Initialize(ms, Geometry.FromCapacity(ms.Length));

            pt.Create(WellKnownPartitionType.WindowsNtfs, true);
            VolumeManager volMgr = new VolumeManager(ms);

            RegistryHive hive = RegistryHive.Create(new MemoryStream());
            Store        s    = Store.Initialize(hive.Root);
            BcdObject    obj  = s.CreateInherit(InheritType.AnyObject);

            Element el = obj.AddElement(WellKnownElement.LibraryApplicationDevice, ElementValue.ForDevice(Guid.Empty, volMgr.GetPhysicalVolumes()[0]));

            el = obj.GetElement(WellKnownElement.LibraryApplicationDevice);

            Assert.IsNotNullOrEmpty(el.Value.ToString());
        }
Пример #4
0
 public void Create_Null()
 {
     Assert.Throws <ArgumentNullException>(() => RegistryHive.Create((Stream)null));
 }
Пример #5
0
 public RegistryKeyTest()
 {
     hive = RegistryHive.Create(new MemoryStream());
 }