flat assembler
Message board for the users of flat assembler.
Index
> Windows > My first Win32 dialog app, CPU-Y |
Author |
|
Hrstka 09 Jan 2025, 12:13
Quote: I don't know how to make the EDIT control locked, but not disabled. If disabled, cannot right click for menu. I still want the text can be copied, but not deleted. Anyway, my CPU has 4 cores, but your program shows 16. |
|||
09 Jan 2025, 12:13 |
|
Ali.Z 09 Jan 2025, 12:40
Hrstka wrote:
free upgrade _________________ Asm For Wise Humans |
|||
09 Jan 2025, 12:40 |
|
Mat Quasar 09 Jan 2025, 13:55
Hrstka wrote: Try ES_READONLY attribute. Thanks! It works correctly now! Hrstka wrote: Anyway, my CPU has 4 cores, but your program shows 16. First of all, thanks for testing! Very much appreciated. I checked the code (from @Core i7 member) and checked the manual, it seems the code is correct, i.e. call EAX=1 CPUID instruction, and then extract bits 23:16 from EBX register (shr 16, then take value of bl). But Intel said this value is the maximum number of logical processor supported.... Both AMD and Intel manual: Quote: AMD: Is your CPU Intel brand? I have no clue what's wrong here, except the code didn't check for Multi-threading feature bit. |
|||
09 Jan 2025, 13:55 |
|
Hrstka 09 Jan 2025, 14:07
Yes, it's Intel(R) Core(TM) i5-4570 CPU.
Later I can try it on AMD processor. |
|||
09 Jan 2025, 14:07 |
|
Mat Quasar 09 Jan 2025, 14:32
Hrstka wrote: Yes, it's Intel(R) Core(TM) i5-4570 CPU. Then I wait for your further feedback... |
|||
09 Jan 2025, 14:32 |
|
Hrstka 09 Jan 2025, 16:20
Works correctly on AMD.
|
|||
09 Jan 2025, 16:20 |
|
Mat Quasar 09 Jan 2025, 16:54
Hrstka wrote: Works correctly on AMD. |
|||
09 Jan 2025, 16:54 |
|
Core i7 09 Jan 2025, 16:57
Basic information about the CPU can be obtained in other ways:
1. In the system registry at the path: HKLM\HARDWARE\DESCRIPTION\System\CentralProcessor (there is even a Features mask here). Reading is possible using WinApi RegOpenKey() + RegGetValue() and others from Advapi32.dll. 2. Windows environment variables, using WinApi GetEnvironmentString\Variable() from Kernel32.dll. Here are some of the most interesting parameters that can be passed to this function: Code: COMPUTERNAME = xxx NUMBER_OF_PROCESSORS = 2 OS = Windows_NT PROCESSOR_ARCHITECTURE = AMD64 PROCESSOR_IDENTIFIER = Intel64 Family 6 Model 23 Stepping 10, GenuineIntel PROCESSOR_LEVEL = 6 PROCESSOR_REVISION = 170a USERDOMAIN = xxx-PC USERNAME = xxx 3. Direct query to the WMI toolkit. The WinApi WinExec() function can launch processes for execution. If you pass it the string "cmd.exe wmic cpu get /format:list > log.txt | exit" in the argument, then we will get a log file in the current directory, which can be displayed in the dialog box using the SetWindowText() function. However, the "log.txt" file is saved in UTF-16 encoding, and it will have to be converted to UTF-8 using the WideCharToMultiByte() function. The result will be something like this: Code: AddressWidth = 64 Architecture = 9 Availability = 3 Caption = Intel64 Family 6 Model 23 Stepping 10 CpuStatus = 1 CurrentClockSpeed = 2499 CurrentVoltage = 13 DataWidth = 64 Description = Intel64 Family 6 Model 23 Stepping 10 ExtClock = 200 Family = 2 L2CacheSize = 2048 L3CacheSize = 0 Level = 6 LoadPercentage = 1 Manufacturer = GenuineIntel MaxClockSpeed = 2499 Name = Pentium(R) Dual-Core CPU E5200 @ 2.50GHz NumberOfCores = 2 NumberOfLogicalProcessors = 2 ProcessorId = BFEBFBFF0001067A ProcessorType = 3 Revision = 5898 4. The number of cores can be read from the PEB structure: in the "NumberOfProcessors" field, or in the binary mask "ActiveProcessAffinityMask" (see WinApi GetProcessAffinityMask()). However, in different versions of Windows the field offsets are different, so this option is questionable, since it is difficult to calculate offsets dynamically. But in the KUSER_SHARED_DATA structure the field with the number of cores always has a static address. |
|||
09 Jan 2025, 16:57 |
|
Mat Quasar 09 Jan 2025, 17:34
Useful info for future reference. Thanks @Core i7.
|
|||
09 Jan 2025, 17:34 |
|
Core i7 09 Jan 2025, 18:11
Such programs as CPU-Z, Aspia, AIDA and others, in addition to displaying in the main window, allow you to save data to log files from the menu. These files contain much more information than in the window, and the software collects it from all possible pockets of the system. Also pay attention to the GetLogicalProcessorInformation() function from Kernel32.dll - there you can find the value of caches L1,2,3 and others.
|
|||
09 Jan 2025, 18:11 |
|
macomics 09 Jan 2025, 18:40
5. Reading /proc/cpuinfo...
|
|||
09 Jan 2025, 18:40 |
|
Mat Quasar 10 Jan 2025, 11:16
Latest CPUID Page 814 - 862 is updated in Dec 2024.
https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html
Last edited by Mat Quasar on 14 Jan 2025, 17:42; edited 1 time in total |
|||||||||||
10 Jan 2025, 11:16 |
|
revolution 10 Jan 2025, 12:02
Note that "reserved" means that the bits has no defined value that is reliable. If the CPU is older then those bits should be ignored by the code. Only read the value of the bits if the CPU is newer and defines the values.
You might be able to get away with assuming the reserved bits are set to zeros, but you might also find that they get some other value that isn't valid. It isn't trivial to decode the CPUID bits |
|||
10 Jan 2025, 12:02 |
|
Mat Quasar 10 Jan 2025, 12:10
revolution wrote: Note that "reserved" means that the bits has no defined value that is reliable. If the CPU is older then those bits should be ignored by the code. Only read the value of the bits if the CPU is newer and defines the values. OMG, you pointed out my mistake about assumption that reserved bits are zero..... |
|||
10 Jan 2025, 12:10 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.