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 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 RemoveObject()
        {
            RegistryHive hive = RegistryHive.Create(new MemoryStream());
            Store        s    = Store.Initialize(hive.Root);

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

            s.RemoveObject(obj.Identity);
        }
Exemplo n.º 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 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());
        }
Exemplo n.º 13
0
        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());
        }