UASM (a MASM clone) 64 bit Visual Studio 2022 solution with ICC. I want to use the CONSOLE_CURSOR_INFO struct that is defined in the WinAPI. I know how to use it by copying its declaration from the Documentation.
This is a partial UASM program without the main function and it works.
.CODE
USE64
INCLUDELIB Kernel32.lib
EXTERNDEF __imp_SetConsoleCursorInfo :QWORD
.CONST
ALIGN 4
; Cursor size.
CONSOLE_CURSOR_INFO STRUCT
dwSize DWORD 100 ; Fully filled.
bVisible BOOL 1 ; Visible. BOOL is defined as DWORD in another file.
CONSOLE_CURSOR_INFO ENDS
.DATA
ALIGN 4
MyCursorD CONSOLE_CURSOR_INFO {}
.CODE
mov rcx, rax ; rax already have handle from GetStdHandle of STD_OUTPUT_HANDLE.
lea rdx, MyCursorD ; *lpConsoleCursorInfo.
call __imp_SetConsoleCursorInfo
How can I access the WinAPI CONSOLE_CURSOR_INFO struct without explicitly copying it and its members to my program the same way I used EXTERNDEF to access the WinAPI function? Is there an EXTERN or EXTERNDEF that I can use?
I tried many combinations of EXTERN and EXTERNDEF and even tried Windows 11 Copilot. It always failed with a syntax error of MyCursorD.
Since the struct is defined in the .CONST section and already has the values I need, is there a way to use it as const without creating the MyCursorD variable in the .DATA section?