public CpuDetailsControl(ICpuId cpuId) { if (cpuId == null) { throw new ArgumentNullException(nameof(cpuId)); } InitializeComponent(); lblCpuVendor.Text = cpuId.CpuVendor.ToString(); lblVendorId.Text = cpuId.VendorId; lblDescription.Text = cpuId.Description; if (cpuId is ICpuIdX86 x86Cpu) { lblBrand.Text = x86Cpu.BrandString; lblProcessorSignature.Text = string.Format("{0:X}h", x86Cpu.ProcessorSignature); lblFamily.Text = string.Format("{0:X}h", x86Cpu.Family); lblModel.Text = string.Format("{0:X}h", x86Cpu.Model); lblStepping.Text = string.Format("{0}", x86Cpu.Stepping); lblProcessorType.Text = string.Format("{0}", x86Cpu.ProcessorType); lblHypervisor.Text = GetHypervisor(x86Cpu) ?? "-"; } }
private string GetDefaultFileName() { string machine = Environment.MachineName.ToLowerInvariant(); ICpuId firstCpu = cpuIdTree1.Cores[0]; if (firstCpu is CpuId.Intel.ICpuIdX86 x86cpu) { if (string.IsNullOrWhiteSpace(firstCpu.Description)) { if (m_IsLocal) { return(string.Format("{0}{1:X07} ({2}).xml", firstCpu.VendorId, x86cpu.ProcessorSignature, machine)); } return(string.Format("{0}{1:X07}.xml", firstCpu.VendorId, x86cpu.ProcessorSignature)); } if (m_IsLocal) { return(string.Format("{0}{1:X07} ({2}, {3}).xml", firstCpu.VendorId, x86cpu.ProcessorSignature, firstCpu.Description, machine)); } return(string.Format("{0}{1:X07} ({2}).xml", firstCpu.VendorId, x86cpu.ProcessorSignature, firstCpu.Description)); } if (string.IsNullOrWhiteSpace(firstCpu.Description)) { if (m_IsLocal) { return(string.Format("{0} ({1}).xml", firstCpu.VendorId, machine)); } return(string.Format("{0}.xml", firstCpu.VendorId)); } if (m_IsLocal) { return(string.Format("{0} ({1}, {2}).xml", firstCpu.VendorId, firstCpu.Description, machine)); } return(string.Format("{0} ({1}).xml", firstCpu.VendorId, firstCpu.Description)); }
public CpuFeaturesControl(ICpuId cpuId) { if (cpuId == null) { throw new ArgumentNullException(nameof(cpuId)); } InitializeComponent(); foreach (string feature in cpuId.Features) { string desc = cpuId.Features.Description(feature); ListViewItem lvi = new ListViewItem() { Checked = cpuId.Features[feature], Text = feature, }; if (desc != null) { lvi.SubItems.Add(desc); } lvwFeatures.Items.Add(lvi); } hdrFeature.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); hdrDescription.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); }
private void DumpCpu(ICpuId cpu) { Console.WriteLine("CPU Vendor: {0}", cpu.CpuVendor); Console.WriteLine("CPU Vendor Id: {0}", cpu.VendorId); Console.WriteLine("CPU Description: {0}", cpu.Description); if (cpu is CpuId.Intel.ICpuIdX86 x86cpu) { Console.WriteLine("x86: Brand: {0}", x86cpu.BrandString); Console.WriteLine("x86: Signature: {0:X}h", x86cpu.ProcessorSignature); Console.WriteLine("x86: Family: {0:X}h", x86cpu.Family); Console.WriteLine("x86: Model: {0:X}h", x86cpu.Model); Console.WriteLine("x86: Type: {0}", x86cpu.ProcessorType); Console.WriteLine("x86: Stepping: {0:X}h", x86cpu.Stepping); foreach (var reg in x86cpu.Registers) { Console.WriteLine("{0:X8} {1:X8}: {2:X8} {3:X8} {4:X8} {5:X8}", reg.Function, reg.SubFunction, reg.Result[0], reg.Result[1], reg.Result[2], reg.Result[3]); } } foreach (string feature in cpu.Features) { Console.WriteLine("Feature: [{0}] {1} ({2})", cpu.Features[feature] ? "X" : "-", feature, cpu.Features.Description(feature)); } }
private TreeNode BuildTreeNode(ICpuId cpuId, int nodeNumber) { string nodeName; if (cpuId is ICpuIdX86 x86cpuId && x86cpuId.Topology.ApicId != -1) { nodeName = string.Format("Node: APIC {0:X8}", x86cpuId.Topology.ApicId); }
public void IntelCreateFromXmlConstructorFile() { CpuIdXmlFactory factory = new CpuIdXmlFactory(MultiCpu); ICpuId cpu = factory.Create(); Assert.That(cpu, Is.Not.Null); Assert.That(cpu.Description, Is.EqualTo("Intel(R) Core(TM) i7-9700 CPU @ 3.00GHz")); }
public void IntelCreateFromXmlFileProperty() { CpuIdXmlFactory factory = new CpuIdXmlFactory { FileName = MultiCpu }; ICpuId cpu = factory.Create(); Assert.That(cpu, Is.Not.Null); Assert.That(cpu.Description, Is.EqualTo("Intel(R) Core(TM) i7-9700 CPU @ 3.00GHz")); }
private static ICpuIdX86 GetCpu(string fileName) { string fullPath = Path.Combine(TestResources, fileName); CpuIdXmlFactory factory = new CpuIdXmlFactory(); ICpuId cpu = factory.Create(fullPath); ICpuIdX86 x86cpu = cpu as ICpuIdX86; Assert.That(x86cpu, Is.Not.Null); Assert.That(x86cpu.Topology.CoreTopology.IsReadOnly, Is.True); return(x86cpu); }
public void CurrentCpuId() { ICpuIdFactory factory = new CpuIdFactory(); ICpuId cpu = factory.Create(); Assert.That(cpu, Is.Not.Null); DumpCpu(cpu); if (cpu is CpuId.Intel.ICpuIdX86 x86cpu) { Assert.That(x86cpu.Topology.CoreTopology.IsReadOnly, Is.True); } }
private static GenericIntelCpu GetCpu(string fileName) { string fullPath = Path.Combine(TestResources, fileName); CpuIdXmlFactory factory = new CpuIdXmlFactory(); ICpuId cpu = factory.Create(fullPath); GenericIntelCpu x86cpu = cpu as GenericIntelCpu; Assert.That(cpu, Is.Not.Null); Assert.That(cpu.CpuVendor, Is.EqualTo(CpuVendor.Unknown)); Assert.That(cpu.VendorId, Is.EqualTo(" ")); Assert.That(x86cpu.Topology.CoreTopology.IsReadOnly, Is.True); Assert.That(x86cpu.Topology.CoreTopology.Count, Is.EqualTo(0)); Assert.That(x86cpu.Topology.CacheTopology.IsReadOnly, Is.True); Assert.That(x86cpu.Topology.CacheTopology.Count, Is.EqualTo(0)); return(x86cpu); }
public static int Main() { ICpuIdFactory cpuFactory = new CpuIdFactory(); ICpuId firstCpu = cpuFactory.Create(); IEnumerable <ICpuId> cpus = cpuFactory.CreateAll(); string fileName; if (firstCpu is CpuId.Intel.ICpuIdX86 x86cpu) { if (string.IsNullOrWhiteSpace(firstCpu.Description)) { fileName = string.Format("{0}{1:X07} ({2}).xml", firstCpu.VendorId, x86cpu.ProcessorSignature, Environment.MachineName); } else { fileName = string.Format("{0}{1:X07} ({2}, {3}).xml", firstCpu.VendorId, x86cpu.ProcessorSignature, firstCpu.Description, Environment.MachineName); } } else { if (string.IsNullOrWhiteSpace(firstCpu.Description)) { fileName = string.Format("{0} ({1}).xml", firstCpu.VendorId, Environment.MachineName); } else { fileName = string.Format("{0} ({1}, {2}).xml", firstCpu.VendorId, firstCpu.Description, Environment.MachineName); } } try { CpuIdXmlFactory.Save(fileName, cpus); Console.WriteLine("Wrote output to: {0}", fileName); return(0); } catch (Exception ex) { Console.WriteLine("Error writing to: {0}", fileName); Console.WriteLine(" -> {0}", ex.Message); return(1); } }
public ICpuId Create() { OSArchitecture architecture = Win32.GetArchitecture(); switch (architecture) { case OSArchitecture.x64: case OSArchitecture.x86: case OSArchitecture.x86_x64: LoadLibrary(); X86CpuIdFactory factory = new X86CpuIdFactory(); ICpuId cpu = factory.Create(); if (cpu is ICpuIdX86 x86cpu) { x86cpu.Topology.CoreTopology.IsReadOnly = true; } return(cpu); default: throw new PlatformNotSupportedException("Architecture is not supported"); } }