format PE GUI 4.0
entry start

include 'win32w.inc'

section '.data' data readable writable

_class		TCHAR	'test',0
_title		TCHAR	'test window',0

wc WNDCLASS	0,WindowProc,0,0,NULL,NULL,NULL,COLOR_BTNFACE+1,NULL,_class
msg	MSG

section '.text' code readable executable

start:
	invoke	GetModuleHandle,0
	MOV		[wc.hInstance],eax
	invoke	LoadIcon,0,IDI_APPLICATION
	MOV		[wc.hIcon],eax
	invoke	LoadCursor,0,IDC_ARROW
	MOV		[wc.hCursor],eax
	invoke	RegisterClass,wc
	invoke	CreateWindowEx,0,_class,_title,WS_VISIBLE+WS_DLGFRAME+WS_SYSMENU,128,128,256,192,NULL,NULL,[wc.hInstance],NULL


	
msg_loop:
	invoke	GetMessage,msg,NULL,0,0
	cmp	eax,1
	jb	Exit
	jne	msg_loop
	invoke	TranslateMessage,msg
	invoke	DispatchMessage,msg
	JMP		msg_loop
	
	
proc WindowProc,hwnd,uMsg,wParam,lParam
	CMP	[uMsg],WM_DESTROY
	JE	.destroy
.defwndproc:
	invoke	DefWindowProc,[hwnd],[uMsg],[wParam],[lParam]
	JMP		.finish
.destroy:
	invoke	PostQuitMessage,0
	XOR		eax,eax
.finish:
	RET
endp

Exit:
	invoke	ExitProcess,[msg.wParam]

section 'idata' import data readable

library kernel32, 'KERNEL32.DLL',\
		user32, 'USER32.DLL',\
		gdi32, 'GDI32.DLL'
		
include 'api\kernel32.inc'
include	'api\gdi32.inc'
include	'api\user32.inc'