News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Defining Windows API functions

Started by sinsi, January 03, 2025, 02:29:55 PM

Previous topic - Next topic

sinsi

Can I assume that the 32-bit declaration _imp__CreateWindowExW@48 is the equivalent of a (made up) 64-bit _imp__CreateWindowExW@96?
i.e 48/sizeof(dword) --- 96/sizeof(qword).

zedd151

Says Google (AI bot)

QuoteWhen using CreateWindowExW in 64-bit code, the parameters remain the same as in 32-bit code. However, there are a few things you need to be aware of:
1. Pointer Sizes:
In 64-bit code, pointers are 64 bits wide. This means that any parameters that are pointers (e.g., lpClassName, lpWindowName, hInstance) will be 64-bit values.
2. Data Alignment:
64-bit Windows uses 8-byte alignment for structures. This means that the members of structures passed to CreateWindowExW (e.g., WNDCLASSEX) must be properly aligned.
3. Callback Functions:
If you're using a callback function (e.g., WNDPROC), you need to make sure it's compiled as 64-bit code and that the function pointer is declared correctly.
Here's a breakdown of the parameters:
C++

HWND CreateWindowExW(
  DWORD    dwExStyle,      // Extended window styles
  LPCWSTR  lpClassName,    // Pointer to registered class name
  LPCWSTR  lpWindowName,  // Pointer to window name
  DWORD    dwStyle,        // Window styles
  int      x,              // Horizontal position of the window
  int      y,              // Vertical position of the window
  int      nWidth,          // Width of the window
  int      nHeight,        // Height of the window
  HWND      hWndParent,    // Handle to the parent window
  HMENU    hMenu,          // Handle to the window menu
  HINSTANCE hInstance,      // Handle to the instance of the module
  LPVOID    lpParam        // Pointer to window creation data
);
Key Points:
No changes to parameter types: The types of the parameters remain the same in 64-bit code.
Pointer size changes: Pointers are 8 bytes in 64-bit, which affects parameters like lpClassName, lpWindowName, and hInstance.
Alignment matters: Structures passed to the function must be 8-byte aligned.

dwExStyle and dwStyle are dwords from the look of it. The "int's" ought to be qwords in 64 bit, afaics.
Hope this helps.

Sucks not having a prototype, like masm32 does.
:cool:

TimoVJL

Quote from: sinsi on January 03, 2025, 02:29:55 PMCan I assume that the 32-bit declaration _imp__CreateWindowExW@48 is the equivalent of a (made up) 64-bit _imp__CreateWindowExW@96?
i.e 48/sizeof(dword) --- 96/sizeof(qword).
64-bit Windows don't have decoration, as it have only one calling convention.
May the source be with you

sinsi

Quote from: zedd151 on January 03, 2025, 02:47:58 PMThis means that the members of structures passed to CreateWindowExW (e.g., WNDCLASSEX)
That is enough for me to blacklist ChatGPT.

Quote from: TimoVJL on January 03, 2025, 03:08:44 PM64-bit Windows don't have decoration, as it have only one calling convention.
That's why I said (made up).

The question remains, CreateWindowEx (and any API call) has the same number of parameters for 32- and 64-bit.


zedd151

:cool:

TimoVJL

Quote from: sinsi on January 03, 2025, 03:28:14 PMThe question remains, CreateWindowEx (and any API call) has the same number of parameters for 32- and 64-bit.
same param count
May the source be with you

sinsi

 :cool:
On the same note, constants are the same?
I know the definition of "constant" but remember MS redefining boolean as 0, 1, or other.

TimoVJL

May the source be with you

sinsi

I was referring to this
When will GetMessage return -1?

QuoteThe solution (if that's what you want to call it) was to have GetMessage return the not-really-a-BOOL-but-we'll-pretend-it-is value -1 to signal an invalid parameter error.