Why is there no window?
struc WNDCLASS
.style: resd 1
.lpfnWndProc: resq 1
.cbClsExtra: resd 1
.cbWndExtra: resd 1
.hInstance: resq 1
.hIcon: resq 1
.hCursor: resq 1
.hbrBackground: resq 1
.lpszMenuName: resq 1
.lpszClassName: resq 1
endstruc
struc MSG
.hWnd: resq 1
.message: resd 1
.wParam: resq 1
.lParam. resq 1
.time: resd 1
.ptx: resd 1
.pty: resd 1
endstruc
extern LoadIconA
extern LoadCursorA
extern RegisterClassA
extern CreateWindowExA
extern ShowWindow
extern UpdateWindow
extern GetMessageA
extern TranslateMessage
extern DispatchMessageA
extern DefWindowProcA
extern MessageBoxA
extern PostQuitMessage
section .data
wc: istruc WNDCLASS
iend
Msg: istruc MSG
iend
MyWndClass db "MyWindowClass", 0
WndTitle db "window", 0
EndMessage db "OH, PLEASE NOT!", 0
section .text
global Start
Start:
sub rsp, 0x68
mov [rsp+0x70], rcx
mov [rsp+0x78], rdx
mov [rsp+0x80], r8
mov [rsp+0x88], r9d
mov dword [wc + WNDCLASS.style], 3
mov qword [wc + WNDCLASS.lpfnWndProc], WndProc
xor rax, rax
mov dword [wc + WNDCLASS.cbClsExtra], eax
mov dword [wc + WNDCLASS.cbWndExtra], eax
mov rax, [rsp+0x70]
mov qword [wc + WNDCLASS.hInstance], rax
xor rcx, rcx
mov rdx, 32512
call LoadIconA
mov qword [wc + WNDCLASS.hIcon], rax
xor rcx, rcx
mov rdx, 32512
call LoadCursorA
mov qword [wc + WNDCLASS.hCursor], rax
mov qword [wc + WNDCLASS.hbrBackground], 6
xor rax, rax
mov qword [wc + WNDCLASS.lpszMenuName], rax
mov qword [wc + WNDCLASS.lpszClassName], MyWndClass
mov rcx, wc
call RegisterClassA
xor rcx, rcx
mov rdx, MyWndClass
mov r8, WndTitle
mov r9d, 0x00CF0000
mov dword [rsp+0x20], 300
mov dword [rsp+0x28], 200
mov dword [rsp+0x30], 300
mov dword [rsp+0x38], 200
xor rax, rax
mov qword [rsp+0x40], rax
mov qword [rsp+0x48], rax
mov rax, qword [rsp+0x70]
mov qword [rsp+0x50], rax
xor rax, rax
mov qword [rsp+0x58], rax
call CreateWindowExA
mov qword [rsp+0x68], rax
mov rcx, rax
mov edx, dword [rsp+0x88]
call ShowWindow
mov rcx, qword [rsp+0x68]
call UpdateWindow
jmp MessageLoop
HandleMessage:
mov rcx, Msg
call TranslateMessage
mov rcx, Msg
call DispatchMessageA
MessageLoop:
mov rcx, Msg
xor rdx, rdx
xor r8, r8
xor r9, r9
call GetMessageA
test rax, rax
jnz HandleMessage
xor rax, rax
add rsp, 0x68
ret
WndProc:
sub rsp, 0x68
mov qword [rsp+0x70], rcx
mov dword [rsp+0x78], edx
mov qword [rsp+0x80], r8
mov qword [rsp+0x88], r9
cmp edx, 2
je quit
jmp not_interesting
quit:
xor rcx, rcx
mov rdx, EndMessage
mov r8, MyWndClass
mov r9, 0x30
call MessageBoxA
xor rcx, rcx
call PostQuitMessage
xor rax, rax
add rsp, 0x68
ret
not_interesting:
mov rcx, qword [rsp+0x70]
mov edx, dword [rsp+0x78]
mov r8, qword [rsp+0x80]
mov r9, qword [rsp+0x88]
call DefWindowProcA
add rsp, 0x68
ret