flat assembler
Message board for the users of flat assembler.

Index > Windows > My first Win32 dialog app, CPU-Y

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
Mat Quasar



Joined: 15 Dec 2024
Posts: 87
Mat Quasar 21 Feb 2025, 07:39
Roman wrote:
Very old CPU. SSE 4.1 not supported.
SSE 4.1 was announced in 2006.

You must buy new CPU !


It is indeed old... but I have no budget for new computer.

I bought this used laptop for about USD 60 two years ago, which is enough for my low-end needs.

Unless I go for mobile app development, then I need fast computer.
Post 21 Feb 2025, 07:39
View user's profile Send private message Reply with quote
Mat-Quasar



Joined: 02 Mar 2025
Posts: 73
Mat-Quasar 11 Apr 2025, 13:30
This is a new optional update for CPU-Y, in XP style, with modification to the tab character in listbox not available in download in page 1.

Previous style is ugly Win 3.11 , all white, I didn't know before yesterday.

I add "4.0" after "format PE GUI" and add XP manifest resource.


Description: New XP style
Filesize: 6.46 KB
Viewed: 458 Time(s)

cpuid_xp.PNG


Description: Update on 11 Apr 2025
Download
Filename: cpuy.ASM
Filesize: 9.11 KB
Downloaded: 33 Time(s)

Post 11 Apr 2025, 13:30
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1412
Location: Piraeus, Greece
Picnic 18 Apr 2025, 09:10
Nice project! Sharing some feedback in return – this is from my PC.

Image

_________________
Hobby BASIC Interpreter
Post 18 Apr 2025, 09:10
View user's profile Send private message Visit poster's website Reply with quote
Mat-Quasar



Joined: 02 Mar 2025
Posts: 73
Mat-Quasar 18 Apr 2025, 09:51
Picnic wrote:
Nice project! Sharing some feedback in return – this is from my PC.

Image


Thank you very much for trying the program and giving feedback.

So many "yes" to the processor features! Smile
Post 18 Apr 2025, 09:51
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 1097
Location: Russia
macomics 18 Apr 2025, 10:28
But with other fonts, you still lose alignment in the List. It's still worth looking towards OwnerDraw and drawing text columns manually.

ADD: I ran your program on Linux under Wine.


Description:
Filesize: 57.04 KB
Viewed: 349 Time(s)

Снимок экрана_20250418_142700.png


Post 18 Apr 2025, 10:28
View user's profile Send private message Reply with quote
Core i7



Joined: 14 Nov 2024
Posts: 47
Location: Socket on motherboard
Core i7 18 Apr 2025, 12:21
the code does not correctly detect the capabilities and number of cores - spend the weekend fixing the errors


Description:
Filesize: 110.47 KB
Viewed: 328 Time(s)

CpuTest.png


Post 18 Apr 2025, 12:21
View user's profile Send private message Reply with quote
Mat-Quasar



Joined: 02 Mar 2025
Posts: 73
Mat-Quasar 18 Apr 2025, 12:41
macomics wrote:
But with other fonts, you still lose alignment in the List. It's still worth looking towards OwnerDraw and drawing text columns manually.

ADD: I ran your program on Linux under Wine.


Thanks for testing! I don't know how to draw manually, maybe just use multi-column listbox like ListView is better.
Post 18 Apr 2025, 12:41
View user's profile Send private message Reply with quote
Mat-Quasar



Joined: 02 Mar 2025
Posts: 73
Mat-Quasar 18 Apr 2025, 12:48
Core i7 wrote:
the code does not correctly detect the capabilities and number of cores - spend the weekend fixing the errors


Thank you for helping to test. Suddenly got 3 fellow coders help to test, I am happy!
About the processor features detection, I mentioned in Page 1 that it will show correct values in Windows 10 only, since you running in earlier version of Windows, the capabilities from SSSE3 to AVX512F are not supported in detection by IsProcessorFeaturePresent API.
About the number of cores, actually I use your code. In Page 1, I mentioned that in Intel CPU, the number actually means maximum number of logical processor supported, only in AMD CPU it is number of cores.
Maybe I should show a tooltip for the listbox (supported in Windows 10 or later) and number of cores edit control.
Post 18 Apr 2025, 12:48
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20571
Location: In your JS exploiting you and your system
revolution 18 Apr 2025, 12:55
There are many CPU capabilities that the OS must enable before they are available for use. This is also reflected in the CPUID bits that a user program sees. So even if a CPU supports feature X, the OS must also enable it before a user program will see the CPUID bits set that claim feature X is supported.

Is summary, both the OS and CPU need to work together to show all the capabilities of the silicon. If an OS is "old" it might not know about feature X and thus won't enable it, then all user programs can't detect or use feature X.
Post 18 Apr 2025, 12:55
View user's profile Send private message Visit poster's website Reply with quote
Core i7



Joined: 14 Nov 2024
Posts: 47
Location: Socket on motherboard
Core i7 18 Apr 2025, 14:03
Mat-Quasar, the correct number of cores can be read from the PEB structure, or taken from the system environment variables using the GetEnvironmentVariable() function. Try this:

Code:
format   pe64 console
entry    start
include 'win64ax.inc'
;//-------------------
.data
buff    db  0
;//------------------
section '.text' code readable executable
start:  sub      rsp,8

        invoke  GetEnvironmentVariable,<'USERNAME',0>,buff,256
       cinvoke  printf,<10,' User.....: %s',0>,buff

        invoke  GetEnvironmentVariable,<'PROCESSOR_IDENTIFIER',0>,buff,256
       cinvoke  printf,<10,' Cpu arch.: %s',0>,buff

        invoke  GetEnvironmentVariable,<'PROCESSOR_REVISION',0>,buff,256
       cinvoke  printf,<10,' Cpu rev..: %s',0>,buff

        invoke  GetEnvironmentVariable,<'NUMBER_OF_PROCESSORS',0>,buff,256
       cinvoke  printf,<10,' Cpu cores: %s',10,0>,buff

        mov     rsi,[gs:0x60]
        mov     eax,[rsi + 0xb8]
       cinvoke  printf,<10,' Cpu cores: %d  <--- in PEB struct',0>,rax

       cinvoke  _getch
       cinvoke  exit,0
 
;//----------
section '.idata' import data readable
library  msvcrt, 'msvcrt.dll', kernel32,'kernel32.dll'
import   msvcrt, printf,'printf',_getch,'_getch',exit,'exit'
include 'api\kernel32.inc'    
Post 18 Apr 2025, 14:03
View user's profile Send private message Reply with quote
Mat-Quasar



Joined: 02 Mar 2025
Posts: 73
Mat-Quasar 18 Apr 2025, 15:02
Core i7 wrote:
Try this:

Code:
        mov     rsi,[gs:0x60]
        mov     eax,[rsi + 0xb8]
       cinvoke  printf,<10,' Cpu cores: %d  <--- in PEB struct',0>,rax
    


Cool! It worked. If I recall correctly, for 32-bit, it is fs:0x30?

I might consider to incorporate this in future release of CPU-Y (if any). Thanks.
Post 18 Apr 2025, 15:02
View user's profile Send private message Reply with quote
Core i7



Joined: 14 Nov 2024
Posts: 47
Location: Socket on motherboard
Core i7 18 Apr 2025, 15:13
Code:
; for x32: 
;-----------
   mov   esi,[fs:0x30]      ; PEB
   mov   eax,[esi + 0x64]   ; PEB --> NumberOfProcessors    
Post 18 Apr 2025, 15:13
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 1097
Location: Russia
macomics 18 Apr 2025, 21:25
Mat-Quasar wrote:
Thanks for testing! I don't know how to draw manually, maybe just use multi-column listbox like ListView is better.


https://learn.microsoft.com/en-us/windows/win32/controls/list-box-styles

Everything was described a long time ago with usage examples. You just need to specify LBS_MULTICOLUMN flag or LBS_OWNERDRAWFIXED flag.

MSND-List box styles-LBS_MULTICOLUMN wrote:
LBS_MULTICOLUMN
Specifies a multi-column list box that is scrolled horizontally. The list box automatically calculates the width of the columns, or an application can set the width by using the LB_SETCOLUMNWIDTH message. If a list box has the LBS_OWNERDRAWFIXED style, an application can set the width when the list box sends the WM_MEASUREITEM message.
A list box with the LBS_MULTICOLUMN style cannot scroll vertically it ignores any WM_VSCROLL messages it receives.
The LBS_MULTICOLUMN and LBS_OWNERDRAWVARIABLE styles cannot be combined. If both are specified, LBS_OWNERDRAWVARIABLE is ignored.
MSND-List box styles-LBS_OWNERDRAWFIXED wrote:
LBS_OWNERDRAWFIXED
Specifies that the owner of the list box is responsible for drawing its contents and that the items in the list box are the same height. The owner window receives a WM_MEASUREITEM message when the list box is created and a WM_DRAWITEM message when a visual aspect of the list box has changed.


https://learn.microsoft.com/en-us/windows/win32/controls/lb-setcolumnwidth
MSDN-Window messages-LB_SETCOLUMNWIDTH wrote:
Sets the width, in pixels, of all columns in a multiple-column list box.

Parameters
* wParam

Specifies the width, in pixels, of all columns.

* lParam

This parameter is not used.

Return value
This message does not return a value.


https://learn.microsoft.com/en-us/windows/win32/controls/wm-measureitem
MSDN-Window messages-WM_MEASUREITEM wrote:
Sent to the owner window of a combo box, list box, list-view control, or menu item when the control or menu is created.

A window receives this message through its WindowProc function.

Code:
WM_MEASUREITEM

    WPARAM wParam;
    LPARAM lParam;     


Parameters
* wParam

Contains the value of the CtlID member of the MEASUREITEMSTRUCT structure pointed to by the lParam parameter. This value identifies the control that sent the WM_MEASUREITEM message. If the message was sent by a menu, this parameter is zero. If the value is nonzero or the value is zero and the value of the CtlType member of the MEASUREITEMSTRUCT pointed to by lParam is not ODT_MENU, the message was sent by a combo box or by a list box. If the value is nonzero, and the value of the itemID member of the MEASUREITEMSTRUCT pointed to by lParam is (UINT) 1, the message was sent by a combo edit field.

* lParam

Pointer to a MEASUREITEMSTRUCT structure that contains the dimensions of the owner-drawn control or menu item.

Return value
If an application processes this message, it should return TRUE.

Remarks
When the owner window receives the WM_MEASUREITEM message, the owner fills in the MEASUREITEMSTRUCT structure pointed to by the lParam parameter of the message and returns; this informs the system of the dimensions of the control. If a list box or combo box is created with the LBS_OWNERDRAWVARIABLE or CBS_OWNERDRAWVARIABLE style, this message is sent to the owner for each item in the control; otherwise, this message is sent once.

The system sends the WM_MEASUREITEM message to the owner window of combo boxes and list boxes created with the OWNERDRAWFIXED style before sending the WM_INITDIALOG message. As a result, when the owner receives this message, the system has not yet determined the height and width of the font used in the control; function calls and calculations requiring these values should occur in the main function of the application or library.


https://learn.microsoft.com/en-us/windows/win32/controls/wm-drawitem

MSDN-Window messages-WM_DRAWITEM wrote:
Sent to the parent window of an owner-drawn button, combo box, list box, or menu when a visual aspect of the button, combo box, list box, or menu has changed.

A window receives this message through its WindowProc function.

Code:
WM_DRAWITEM

    WPARAM wParam;
    LPARAM lParam;    


Parameters
* wParam

Specifies the identifier of the control that sent the WM_DRAWITEM message. If the message was sent by a menu, this parameter is zero.

* lParam

Pointer to a DRAWITEMSTRUCT structure containing information about the item to be drawn and the type of drawing required.

Return value
If an application processes this message, it should return TRUE.

Remarks
By default, the DefWindowProc function draws the focus rectangle for an owner-drawn list box item.

The itemAction member of the DRAWITEMSTRUCT structure specifies the drawing operation that an application should perform.

Before returning from processing this message, an application should ensure that the device context identified by the hDC member of the DRAWITEMSTRUCT structure is in the default state.
Post 18 Apr 2025, 21:25
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.