This works for me.
;#############################################################################################################
WinMainW proc public
local wMsg:MSG
add rsp,-28h
and rsp,-10h
FNINIT
invoke GetModuleHandle, null
mov hInstance, rax
invoke InitializeWindow
invoke RtlZeroMemory, &wMsg, sizeof(MSG)
mov rax, g_hwnd
mov wMsg.hwnd, rax
MsgLoop:
invoke GetMessage, &wMsg, null, 0, 0
or eax, eax
je short MainExit
invoke TranslateMessage, &wMsg
invoke DispatchMessage, &wMsg
jmp short MsgLoop
MainExit:
mov rcx, null
call ExitProcess
ret
WinMainW endp
;#############################################################################################################