STACKFRAME macro is interesting. If i use STACKFRAME macro at the very beginning like in the examples of Mikl__ code compiles but does not run.
Final workaround -maybe- I put STACKFRAME macro just before DlgProc and everything is fine.
OPTION DOTNAME ; required for macro files
option casemap:none ; case sensitive
; _____________________________________________________________________________
; MASM64 macros
include \masm64\macros64\vasily.inc ; main macro file
include \masm64\macros64\macros64.inc ; auxillary macro file
; _____________________________________________________________________________
; include files
include \masm64\include64\win64.inc ; main include file
include \masm64\include64\kernel32.inc
include \masm64\include64\user32.inc
include \masm64\include64\comctl32.inc
;STACKFRAME ; create a default stack frame
; _____________________________________________________________________________
; libraries
includelib \masm64\lib64\user32.lib
includelib \masm64\lib64\kernel32.lib
includelib \masm64\lib64\comctl32.lib
; _____________________________________________________________________________
; constant variables
.const
; Main Dialog
IDD_DIALOG EQU 1000
; _____________________________________________________________________________
; initialized variables
.data
.code
WinMainCRTStartup proc hInstance:HINSTANCE, hPrevInstance:HINSTANCE, lpCmdLine:LPSTR, nCmdShow:DWORD
invoke InitCommonControls
invoke DialogBoxParam,hInstance, IDD_DIALOG, 0, addr DlgProc, NULL
invoke ExitProcess,NULL
WinMainCRTStartup endp
STACKFRAME
DlgProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
;LOCAL hWnd:HWND
;LOCAL uMsg:UINT
;LOCAL wParam:WPARAM
;LOCAL lParam:LPARAM
;mov hWnd,rcx
;mov uMsg,edx
;mov wParam,r8
;mov lParam,r9
.if uMsg==WM_INITDIALOG
; code that runs before dialog shows up
.elseif uMsg==WM_COMMAND
; code of controls, buttons, checkboxes...
.elseif uMsg==WM_CLOSE
invoke EndDialog,hWnd,0
ret
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret
DlgProc endp
end
Why it doesn't work if i write STACKFRAME at the beginning(look above code, i have commented it out)
Now look Mikl__'s tute03 code. The STACKFRAME macro is above and everything works fine:
OPTION DOTNAME ; required for macro files
option casemap:none ; case sensitive
include \masm64\include64\win64.inc ; main include file
include \masm64\macros64\vasily.inc ; main macro file
include \masm64\macros64\macros64.inc ; auxillary macro file
STACKFRAME ; create a default stack frame
;include \masm64\m64lib\m64lib.inc ; include file for m64lib library
; ------------------------
; system API include64 files
; ------------------------
include \masm64\include64\kernel32.inc
include \masm64\include64\user32.inc
;includelib \masm64\m64lib\m64lib.lib ; m64lib library
; ------------------------
; system API library files
; ------------------------
includelib \masm64\lib64\kernel32.lib
includelib \masm64\lib64\user32.lib
.data
ClassName db "SimpleWin64Class", 0 ; the name of our window class
AppName db "Our First Window", 0 ; the name of our window
.data?
hIcon dq ?
hCursor dq ?
;OPTION PROLOGUE:rbpFramePrologue
;OPTION EPILOGUE:rbpFrameEpilogue
.code
WinMainCRTStartup proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
LOCAL wc:WNDCLASSEX
LOCAL msg:MSG
LOCAL hwnd:HWND
invoke LoadIcon,hInst,IDI_APPLICATION
mov hIcon, rax
invoke LoadCursor,hInst,IDC_ARROW
mov hCursor, rax
mov wc.cbSize, sizeof WNDCLASSEX
mov wc.style, CS_HREDRAW or CS_VREDRAW
lea rdi, WndProc
mov wc.lpfnWndProc, rdi;offset WndProc
mov wc.cbClsExtra, 0
mov wc.cbWndExtra, 0
mov wc.hInstance, 0;hInst
mov rax, hIcon
mov wc.hIcon, rax;hIcon
mov rbx, hCursor
mov wc.hCursor, rbx;hCursor
mov wc.hbrBackground, COLOR_WINDOW + 1
mov wc.lpszMenuName, 0
lea rdi, ClassName
mov wc.lpszClassName, rdi;offset ClassName
mov wc.hIconSm, rax;hIcon
invoke RegisterClassEx, addr wc
invoke CreateWindowEx,NULL,addr ClassName,addr AppName,WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,0,NULL
mov hwnd, rax
invoke ShowWindow,hwnd, SW_SHOWNORMAL
invoke UpdateWindow,hwnd
.while TRUE
invoke GetMessage,addr msg, NULL,0,0
.if (rax == 0)
.break
.endif
invoke TranslateMessage,addr msg
invoke DispatchMessage,addr msg
.endw
mov rax, msg.wParam
ret
WinMainCRTStartup endp
WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
.if uMsg==WM_CLOSE
invoke MessageBox,hWnd,addr ClassName, addr AppName,MB_OK
invoke ExitProcess,NULL
.elseif uMsg==WM_DESTROY
invoke PostQuitMessage,NULL
.else
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.endif
xor eax,eax
ret
WndProc endp
end