COMMENT #
Copyright (C) JAEHYUK CHO
All rights reserved.
Code by JaeHyuk Cho <mailto:minzkn@minzkn.com>
#
; Process type --------------------------------
.386 ; 386 CPU 사용 예고
.MODEL FLAT,STDCALL ; 표준 규칙
OPTION CASEMAP:NONE ; 반드시 필요함
; Window project default ----------------------
INCLUDE C:\masm32\include\windows.inc
INCLUDE C:\masm32\include\user32.inc
INCLUDE C:\masm32\include\kernel32.inc
;INCLUDE E:\masm32\include\windows.inc
;INCLUDE E:\masm32\include\user32.inc
;INCLUDE E:\masm32\include\kernel32.inc
; Link library --------------------------------
INCLUDELIB C:\masm32\lib\user32.lib
INCLUDELIB C:\masm32\lib\kernel32.lib
;INCLUDELIB E:\masm32\lib\user32.lib
;INCLUDELIB E:\masm32\lib\kernel32.lib
; Proto region --------------------------------
WinMain PROTO :DWORD, :DWORD, :DWORD, :DWORD
WndProc PROTO :DWORD, :DWORD, :DWORD, :DWORD
; Data select ---------------------------------
.DATA
g_instance DD 0
g_command_line DD 0
g_class_name DB "minzknWin32Engine", 0
g_title_name DB "당신은 누구요?", 0
g_confirm_exit DB "종료하려고요?", 0
g_confirm_exit_title DB "확인좀 하겠습니다.", 0
g_hello DB "어라? 윈도우 나올라구 그래.", 0
; Code zone -----------------------------------
.CODE
START: ; Win32 startup code
INVOKE GetModuleHandle, NULL
MOV g_instance, EAX
INVOKE GetCommandLine
MOV g_command_line, EAX
INVOKE WinMain, g_instance, NULL, g_command_line, SW_SHOWDEFAULT
INVOKE ExitProcess, eax
JMP $
WinMain PROC s_instance:DWORD, ; 나는 누구다 !
s_prev_instance:DWORD, ; 호환때문에
s_command_line:DWORD, ; 이것을 덧붙여서...
s_command_show:DWORD ; 어떻게 보여지라구?
LOCAL s_window_class_ex : WNDCLASSEX ; 윈도우 학급 확장
LOCAL s_message : MSG ; 메세지전달 매개체
LOCAL s_window : DWORD ; 주 윈도우
mov s_window_class_ex.cbSize, sizeof(WNDCLASSEX)
mov s_window_class_ex.style, CS_HREDRAW OR CS_VREDRAW
mov s_window_class_ex.lpfnWndProc, offset WndProc
mov s_window_class_ex.cbClsExtra, NULL
mov s_window_class_ex.cbWndExtra, NULL
mov eax, s_instance
mov s_window_class_ex.hInstance, eax
mov s_window_class_ex.hbrBackground, COLOR_BTNFACE + 1
mov s_window_class_ex.lpszMenuName, NULL
mov s_window_class_ex.lpszClassName, offset g_class_name
mov s_window_class_ex.hIcon, NULL
mov s_window_class_ex.hCursor, NULL
mov s_window_class_ex.hIconSm, 0
INVOKE RegisterClassEx, ADDR s_window_class_ex
; Window 등록
INVOKE CreateWindowEx,
0,
ADDR g_class_name,
ADDR g_title_name,
WS_OVERLAPPED OR WS_CAPTION OR WS_SYSMENU OR WS_MAXIMIZEBOX OR WS_MINIMIZEBOX OR WS_BORDER OR WS_THICKFRAME,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, s_instance, NULL
mov s_window, eax
; 봐라
INVOKE ShowWindow, s_window, SW_SHOWNORMAL
; 한번더 봐야되..
INVOKE UpdateWindow, s_window
WinLoop:
INVOKE GetMessage, ADDR s_message, NULL, 0, 0 ; 뭐가 도착했을까?
or eax, eax
jz WinExitLoop
INVOKE TranslateMessage, ADDR s_message ; 키보드 니가 처리해
INVOKE DispatchMessage, ADDR s_message ; WndProc 에게 나의 죽음을 알려라~
jmp WinLoop
WinExitLoop:
; 내가 무슨 상태인지 상부에 보고하자~
mov eax, s_message.wParam
ret
WinMain ENDP
; WinProc callback function -------------------
WndProc PROC s_window:DWORD,
s_message:DWORD,
s_wparam:DWORD,
s_lparam:DWORD
.if s_message == WM_CREATE
; 윈도우 생성했는데 뭐할까?
INVOKE MessageBox, s_window, ADDR g_hello, ADDR g_hello, MB_OK OR MB_ICONQUESTION
xor eax, eax
ret
.elseif s_message == WM_CLOSE
; 윈도우 종료하기 직전인데...
INVOKE MessageBox, s_window, ADDR g_confirm_exit, ADDR g_confirm_exit_title, MB_YESNO OR MB_ICONQUESTION
CMP EAX, IDYES
JNE ExitCancel
INVOKE DestroyWindow, s_window ; 나 종료할려고 하는데...
ExitCancel:
xor eax, eax
ret
.elseif s_message == WM_DESTROY
INVOKE PostQuitMessage, NULL ; 진짜 종료할거야...
xor eax, eax
ret
.endif
INVOKE DefWindowProc, s_window, s_message, s_wparam, s_lparam
ret
WndProc ENDP
END START
; End of source