Represents a Boot Configuration Database object (application, device or inherited settings).
        public void FriendlyName()
        {
            RegistryHive hive = RegistryHive.Create(new MemoryStream());
            Store        s    = Store.Initialize(hive.Root);
            BcdObject    obj  = s.CreateInherit(InheritType.AnyObject);

            Assert.AreEqual(obj.Identity.ToString("B"), obj.FriendlyName);
        }
        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"));
        }
        public void RemoveElement_NonExistent()
        {
            RegistryHive hive = RegistryHive.Create(new MemoryStream());
            Store        s    = Store.Initialize(hive.Root);
            BcdObject    obj  = s.CreateInherit(InheritType.AnyObject);

            obj.RemoveElement(WellKnownElement.LibraryApplicationPath);
        }
        public void RemoveObject()
        {
            RegistryHive hive = RegistryHive.Create(new MemoryStream());
            Store        s    = Store.Initialize(hive.Root);

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

            s.RemoveObject(obj.Identity);
        }
Example #5
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 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 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 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 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 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 CreateDevice()
        {
            RegistryHive hive = RegistryHive.Create(new MemoryStream());
            Store        s    = Store.Initialize(hive.Root);

            BcdObject obj = s.CreateDevice();

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

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

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

            Assert.AreEqual(obj.Identity, reGet.Identity);
        }
        public void CreateApplication()
        {
            RegistryHive hive = RegistryHive.Create(new MemoryStream());
            Store        s    = Store.Initialize(hive.Root);

            BcdObject obj = s.CreateApplication(ApplicationImageType.WindowsBoot, ApplicationType.BootManager);

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

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

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

            Assert.AreEqual(obj.Identity, reGet.Identity);
        }
        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 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);
        }
        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());
        }
Example #17
0
        /// <summary>
        /// Creates an application object.
        /// </summary>
        /// <param name="imageType">The image type of the application</param>
        /// <param name="appType">The application's type</param>
        /// <returns>The object representing the new application</returns>
        public BcdObject CreateApplication(ApplicationImageType imageType, ApplicationType appType)
        {
            Guid obj = _store.CreateObject(Guid.NewGuid(), BcdObject.MakeApplicationType(imageType, appType));

            return(new BcdObject(_store, obj));
        }
Example #18
0
        /// <summary>
        /// Creates an 'inherit' object that contains common settings.
        /// </summary>
        /// <param name="id">The identity of the object to create</param>
        /// <param name="inheritType">The type of object the settings apply to</param>
        /// <returns>The object representing the new settings</returns>
        public BcdObject CreateInherit(Guid id, InheritType inheritType)
        {
            Guid obj = _store.CreateObject(id, BcdObject.MakeInheritType(inheritType));

            return(new BcdObject(_store, obj));
        }