public void AddElement_WrongType() { RegistryHive hive = RegistryHive.Create(new MemoryStream()); Store s = Store.Initialize(hive.Root); BcdObject obj = s.CreateInherit(InheritType.AnyObject); Assert.Throws <ArgumentException>(() => obj.AddElement(WellKnownElement.LibraryApplicationDevice, ElementValue.ForString(@"\a\path\to\nowhere"))); }
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.Equal("{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.False(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.Equal(true.ToString(), 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.Equal("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.NotNull(el.Value.ToString()); Assert.NotEmpty(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.NotNull(el.Value.ToString()); Assert.NotEmpty(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.Equal(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.Equal(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.NotNull(el.Value.ToString()); Assert.NotEmpty(el.Value.ToString()); }