AddElement() public method

Adds an element in this object.
public AddElement ( WellKnownElement id, DiscUtils.BootConfig.ElementValue initialValue ) : DiscUtils.BootConfig.Element
id WellKnownElement The identity of the element to add.
initialValue DiscUtils.BootConfig.ElementValue The initial value of the element.
return DiscUtils.BootConfig.Element
        public void AddElement_WrongType()
        {
            RegistryHive hive = RegistryHive.Create(new MemoryStream());
            Store        s    = Store.Initialize(hive.Root);
            BcdObject    obj  = s.CreateInherit(InheritType.AnyObject);

            obj.AddElement(WellKnownElement.LibraryApplicationDevice, ElementValue.ForString(@"\a\path\to\nowhere"));
        }
Example #2
0
        public void FriendlyName()
        {
            RegistryHive hive = RegistryHive.Create(new MemoryStream());
            Store        s    = Store.Initialize(hive.Root);
            BcdObject    obj  = s.CreateInherit(InheritType.AnyObject);

            Element el = obj.AddElement(WellKnownElement.LibraryApplicationPath, ElementValue.ForString(@"a\path\to\nowhere"));

            Assert.AreEqual("{path}", el.FriendlyName);
        }
        public void RemoveElement()
        {
            RegistryHive hive = RegistryHive.Create(new MemoryStream());
            Store        s    = Store.Initialize(hive.Root);
            BcdObject    obj  = s.CreateInherit(InheritType.AnyObject);

            obj.AddElement(WellKnownElement.LibraryApplicationPath, ElementValue.ForString(@"\a\path\to\nowhere"));
            obj.RemoveElement(WellKnownElement.LibraryApplicationPath);

            Assert.IsFalse(obj.HasElement(WellKnownElement.LibraryApplicationPath));
        }
        public void BooleanValue()
        {
            RegistryHive hive = RegistryHive.Create(new MemoryStream());
            Store        s    = Store.Initialize(hive.Root);
            BcdObject    obj  = s.CreateInherit(InheritType.AnyObject);

            Element el = obj.AddElement(WellKnownElement.LibraryAutoRecoveryEnabled, ElementValue.ForBoolean(true));

            el = obj.GetElement(WellKnownElement.LibraryAutoRecoveryEnabled);

            Assert.AreEqual(true.ToString(), el.Value.ToString());
        }
        public void IntegerListValue()
        {
            RegistryHive hive = RegistryHive.Create(new MemoryStream());
            Store        s    = Store.Initialize(hive.Root);
            BcdObject    obj  = s.CreateInherit(InheritType.AnyObject);

            Element el = obj.AddElement(WellKnownElement.LibraryBadMemoryList, ElementValue.ForIntegerList(new long[] { 1234, 4132 }));

            el = obj.GetElement(WellKnownElement.LibraryBadMemoryList);

            Assert.IsNotNullOrEmpty(el.Value.ToString());
        }
        public void IntegerValue()
        {
            RegistryHive hive = RegistryHive.Create(new MemoryStream());
            Store        s    = Store.Initialize(hive.Root);
            BcdObject    obj  = s.CreateInherit(InheritType.AnyObject);

            Element el = obj.AddElement(WellKnownElement.LibraryTruncatePhysicalMemory, ElementValue.ForInteger(1234));

            el = obj.GetElement(WellKnownElement.LibraryTruncatePhysicalMemory);

            Assert.AreEqual("1234", el.Value.ToString());
        }
        public void DeviceValue_BootDevice()
        {
            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.ForBootDevice());

            el = obj.GetElement(WellKnownElement.LibraryApplicationDevice);

            Assert.IsNotNullOrEmpty(el.Value.ToString());
        }
        public void GuidValue()
        {
            Guid testGuid = Guid.NewGuid();

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

            Element el = obj.AddElement(WellKnownElement.BootMgrDefaultObject, ElementValue.ForGuid(testGuid));

            el = obj.GetElement(WellKnownElement.BootMgrDefaultObject);

            Assert.AreEqual(testGuid.ToString("B"), el.Value.ToString());
        }
        public void GuidListValue()
        {
            Guid testGuid1 = Guid.NewGuid();
            Guid testGuid2 = Guid.NewGuid();

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

            Element el = obj.AddElement(WellKnownElement.BootMgrDisplayOrder, ElementValue.ForGuidList(new Guid[] { testGuid1, testGuid2 }));

            el = obj.GetElement(WellKnownElement.BootMgrDisplayOrder);

            Assert.AreEqual(testGuid1.ToString("B") + "," + testGuid2.ToString("B"), el.Value.ToString());
        }
        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());
        }