flat assembler
Message board for the users of flat assembler.

Index > Windows > What size is the ATOM returned by RegisterClassEx in 64 bit

Author
Thread Post new topic Reply to topic
TightCoderEx



Joined: 14 Feb 2013
Posts: 58
Location: Alberta
TightCoderEx
This is my version of populating WNDCLASSEX.
Code:
                xor     ebx, ebx                ; More effective than push 0
                mov     edx, IDI_APPLICATION
                invoke  LoadIcon, rbx, rdx
                push    rax                     ; hIconSm
                mov     r15, rax
                push    AppName                 ; lpszClassName
                push    rbx                     ; lpszMenuName
                push    COLOR_APPWORKSPACE + 1  ; hbrBackground
                mov     edx, IDC_ARROW
                invoke  LoadCursor, rbx, edx
                push    rax                     ; hCursor
                push    r15                     ; hIcon
                invoke  GetModuleHandle, rbx
                push    rax                     ; hInstance
                push    rbx                     ; cbWndExtra &  cbClsExtra
                push    MainWndProc             ; lpfnWndProc
                mov     eax, CS_HREDRAW + CS_VREDRAW
                shl     rax, 32
                mov      al, sizeof.WNDCLASSEX
                push    rax                     ; cbSize & style
                mov     ecx, esp                ; Establish pointer to WNDCLASSEX
                invoke  RegisterClassEx, rcx
                test    ax, ax
    

I've noticed in many examples such as TEMPLATE.ASM 64 bit values are being tested. From what I've gleaned testing even in 64 bit the integer ATOM is only 16 bits, hence I test AX instead of EAX or RAX.

The reason I ask is that I made a mistake initially setting cbWndExtra & cbClsExtra to 64 bit values. RegisterClassEx returned 7fffffd0000 and tracing through this app and others, I don't ever recall the return value being larger than 16 bits when there isn't an error. Therefore testing 32 or 64 bit values will never yield an error.

Is there a fault in this assumption?
Post 14 Jun 2013, 20:34
View user's profile Send private message Visit poster's website Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
Quote:
An atom. For more information, see About Atom Tables.
This type is declared in WinDef.h as follows:
Code:
typedef WORD ATOM;    


-- http://msdn.microsoft.com/en-us/library/windows/desktop/aa383751(v=vs.85).aspx

According to a user comment posted on: http://msdn.microsoft.com/en-us/library/windows/desktop/ms633587(v=vs.85).aspx

Quote:
never test the return value of RegisterClass() or RegisterClassEx()
Since a class an only be registered once the second caller will fail if it tries to register the class again.

Instead of trying to detect this using GetClassInfo(), a solution that does not work in a multi-threaded program due to a race condition; it is better to simply ignore the return value from this function and pick up the failure when CreateWindow() is called as that will fail due to "class not registered".
Post 14 Jun 2013, 21:42
View user's profile Send private message Reply with quote
TightCoderEx



Joined: 14 Feb 2013
Posts: 58
Location: Alberta
TightCoderEx
Thanks. Especially helpful is link to data types as I don't have any of these headers.
Post 14 Jun 2013, 23:01
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< 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-2020, Tomasz Grysztar.

Powered by rwasa.