static Processor() { uint eax = 0, ebx = 0, ecx = 0, edx = 0; Ols ols = new Ols(); ols.Cpuid(0x0000000, ref eax, ref ebx, ref ecx, ref edx); _vendor = Uint_to_string(ebx) + Uint_to_string(edx) + Uint_to_string(ecx); ols.Cpuid(0x0000001, ref eax, ref ebx, ref ecx, ref edx); _stepping = (byte)((eax >> 0) & 0x0Fb); _model = (byte)((eax >> 4) & 0xF); _family = (byte)((eax >> 8) & 0xF); _type = (byte)((eax >> 12) & 0x3); byte _ext_model = (byte)((eax >> 16) & 0xF); byte _ext_family = (byte)((eax >> 20) & 0xFF); if (_family == 0xF) { _family += _ext_family; _model += (byte)(_ext_model << 4); } else if (_family == 0x6) { _model += (byte)(_ext_model << 4); } _logical_core_count = (byte)(ebx >> 16); }
// Return [realCores, logicalCores] public int[] GetCoreCount() { uint eax = 0, ebx = 0, ecx = 0, edx = 0; int logicalCores = 0; int threadsPerCore = 1; int[] count = { 0, 1 }; if (Ols.Cpuid(0x00000001, ref eax, ref ebx, ref ecx, ref edx) == 1) { logicalCores = Convert.ToInt32((ebx >> 16) & 0xFF); if (Ols.Cpuid(0x8000001E, ref eax, ref ebx, ref ecx, ref edx) == 1) { threadsPerCore = Convert.ToInt32(ebx >> 8 & 0xF) + 1; } } if (threadsPerCore == 0) { count[0] = logicalCores; } else { count[0] = logicalCores / threadsPerCore; } count[1] = logicalCores; return(count); }
public uint GetPkgType() { uint eax = 0, ebx = 0, ecx = 0, edx = 0; if (Ols.Cpuid(0x80000001, ref eax, ref ebx, ref ecx, ref edx) == 1) { return(ebx >> 28); } return(0); }
public int GetCpuNodes() { uint eax = 0, ebx = 0, ecx = 0, edx = 0; if (Ols.Cpuid(0x8000001E, ref eax, ref ebx, ref ecx, ref edx) == 1) { return(Convert.ToInt32(ecx >> 8 & 0x7) + 1); } return(1); }
public uint GetCpuId() { uint eax = 0, ebx = 0, ecx = 0, edx = 0; if (Ols.Cpuid(0x00000001, ref eax, ref ebx, ref ecx, ref edx) == 1) { return(eax); } return(0); }
public SMU.CpuFamily GetCpuFamily() { uint eax = 0, ebx = 0, ecx = 0, edx = 0; if (Ols.Cpuid(0x00000001, ref eax, ref ebx, ref ecx, ref edx) == 1) { SMU.CpuFamily family = (SMU.CpuFamily)(GetBits(eax, 8, 4) + GetBits(eax, 20, 7)); return(family); } return(SMU.CpuFamily.UNSUPPORTED); }
public string GetCpuName() { string model = ""; uint eax = 0, ebx = 0, ecx = 0, edx = 0; if (RyzenAccesss.Cpuid(0x80000002, ref eax, ref ebx, ref ecx, ref edx) == 1) { model = model + IntToStr(eax) + IntToStr(ebx) + IntToStr(ecx) + IntToStr(edx); } if (RyzenAccesss.Cpuid(0x80000003, ref eax, ref ebx, ref ecx, ref edx) == 1) { model = model + IntToStr(eax) + IntToStr(ebx) + IntToStr(ecx) + IntToStr(edx); } if (RyzenAccesss.Cpuid(0x80000004, ref eax, ref ebx, ref ecx, ref edx) == 1) { model = model + IntToStr(eax) + IntToStr(ebx) + IntToStr(ecx) + IntToStr(edx); } return(model.Trim()); }
private CpuFamily GetCpuFamily() { uint eax = 0, ebx = 0, ecx = 0, edx = 0; if (ols.Cpuid(0x00000001, ref eax, ref ebx, ref ecx, ref edx) == 1) { CpuFamily family = (CpuFamily)(GetBits(eax, 8, 4) + GetBits(eax, 20, 7)); return(family); } else { MessageBox.Show("Could not get CPU Family. Aborting.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); ExitApplication(); } return(CpuFamily.UNSUPPORTED); }
static bool GetCPUInfo() { // vendor uint[] reg = new uint[4]; Ols.Cpuid(0, ref reg[0], ref reg[1], ref reg[2], ref reg[3]); var temp = reg[2]; reg[2] = reg[3]; reg[3] = temp; var buffer = new StringBuilder(12); buffer.Length = 12; for (int i = 4; i < 16; i++) { var b = (reg[i / 4] >> (8 * (i % 4))) & 0xFF; char c = (char)b; buffer[i - 4] = c; } if (buffer.ToString() == "GenuineIntel") { Ols.Cpuid(1, ref reg[0], ref reg[1], ref reg[2], ref reg[3]); // Processor ID etc var Family = ((reg[0] & 0x0FF00000) >> 20) + ((reg[0] & 0x0F00) >> 8); var Model = ((reg[0] & 0x0F0000) >> 12) + ((reg[0] & 0xF0) >> 4); if (Family == 0x6 && (Model == 0x1e || Model == 0x1a || Model == 0x1f || Model == 0x2e)) { return(true); } } return(false); }
public WinRing0() { try { //----------------------------------------------------------------------------- // Initialize //----------------------------------------------------------------------------- Ols ols = new Ols(); // Check support library sutatus switch (ols.GetStatus()) { case (uint)Ols.Status.NO_ERROR: break; case (uint)Ols.Status.DLL_NOT_FOUND: MessageBox.Show("Status Error!! DLL_NOT_FOUND"); Environment.Exit(0); break; case (uint)Ols.Status.DLL_INCORRECT_VERSION: MessageBox.Show("Status Error!! DLL_INCORRECT_VERSION"); Environment.Exit(0); break; case (uint)Ols.Status.DLL_INITIALIZE_ERROR: MessageBox.Show("Status Error!! DLL_INITIALIZE_ERROR"); Environment.Exit(0); break; } // Check WinRing0 status switch (ols.GetDllStatus()) { case (uint)Ols.OlsDllStatus.OLS_DLL_NO_ERROR: break; case (uint)Ols.OlsDllStatus.OLS_DLL_DRIVER_NOT_LOADED: MessageBox.Show("DLL Status Error!! OLS_DRIVER_NOT_LOADED"); Environment.Exit(0); break; case (uint)Ols.OlsDllStatus.OLS_DLL_UNSUPPORTED_PLATFORM: MessageBox.Show("DLL Status Error!! OLS_UNSUPPORTED_PLATFORM"); Environment.Exit(0); break; case (uint)Ols.OlsDllStatus.OLS_DLL_DRIVER_NOT_FOUND: MessageBox.Show("DLL Status Error!! OLS_DLL_DRIVER_NOT_FOUND"); Environment.Exit(0); break; case (uint)Ols.OlsDllStatus.OLS_DLL_DRIVER_UNLOADED: MessageBox.Show("DLL Status Error!! OLS_DLL_DRIVER_UNLOADED"); Environment.Exit(0); break; case (uint)Ols.OlsDllStatus.OLS_DLL_DRIVER_NOT_LOADED_ON_NETWORK: MessageBox.Show("DLL Status Error!! DRIVER_NOT_LOADED_ON_NETWORK"); Environment.Exit(0); break; case (uint)Ols.OlsDllStatus.OLS_DLL_UNKNOWN_ERROR: MessageBox.Show("DLL Status Error!! OLS_DLL_UNKNOWN_ERROR"); Environment.Exit(0); break; } uint eax = 0, ebx = 0, ecx = 0, edx = 0; ols.Cpuid(0, ref eax, ref ebx, ref ecx, ref edx); if ((ebx == 0x756e6547) && (ecx == 0x6c65746e) && (edx == 0x49656e69)) { this.div = 1; } ManagementObjectSearcher search = new ManagementObjectSearcher("SELECT ExtClock FROM Win32_Processor"); //建立WMI的类 foreach (ManagementObject mo in search.Get()) { Originbusspeed = (uint)mo["ExtClock"] * 1.0f; } if (ols.Rdmsr(0xCE, ref eax, ref edx) == 1) { MaxTurboFre = (eax & 0xFF00) >> 8; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); Environment.Exit(0); } }