rendered paste bodyformat PE GUI 4.0
entry start
include 'win32w.inc'
section '.data' data readable writeable
_class TCHAR 'FASMWIN32',0
_btncls TCHAR 'BUTTON',0
_lstcls TCHAR 'LISTBOX',0
_btntxt TCHAR 'EXIT',0
_btntxt2 TCHAR 'lower',0
_title TCHAR 'Win32 program template',0
_error TCHAR 'Startup failed.',0
_outfile TCHAR 'out.txt',0
wc WNDCLASS 0,WindowProc,0,0,0,0,0,COLOR_BTNFACE+1,0,_class
msg MSG
hwnd dd ?
hbtn dd ?
hbtn2 dd ?
hlst dd ?
hfile dd ?
result dw ?
section '.code' 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
test eax,eax
jz error
invoke CreateWindowEx,0,_class,_title,WS_VISIBLE+WS_DLGFRAME+WS_SYSMENU,128,128,256,192,0,0,[wc.hInstance],0
test eax,eax
jz error
msg_loop:
invoke GetMessage,msg,0,0,0
cmp eax,1
jb end_loop
jne msg_loop
invoke TranslateMessage,msg
invoke DispatchMessage,msg
jmp msg_loop
error:
invoke MessageBox,0,_error,0,MB_ICONERROR+MB_OK
end_loop:
invoke ExitProcess,[msg.wParam]
proc WindowProc hwnd,wmsg,wparam,lparam
local str[128]:BYTE
push ebx esi edi
cmp [wmsg],WM_COMMAND
je .wmcommand
cmp [wmsg],WM_CREATE
je .wmcreate
cmp [wmsg],WM_DESTROY
je .wmdestroy
cmp [wmsg],WM_DROPFILES
je .wmdropfiles
.defwndproc:
invoke DefWindowProc,[hwnd],[wmsg],[wparam],[lparam]
jmp .finish
.wmcommand:
mov eax,[hbtn]
cmp eax,[lparam]
je .wmdestroy
mov eax,[hbtn2]
cmp eax,[lparam]
jne .finish
invoke MessageBox,0,0,0,MB_OK
jmp .finish
.wmcreate:
invoke CreateWindowEx,0,_btncls,_btntxt,WS_VISIBLE+WS_CHILD+BS_PUSHBUTTON,1,1,64,32,[hwnd],0,[wc.hInstance],0
mov [hbtn],eax
invoke CreateWindowEx,0,_btncls,_btntxt2,WS_VISIBLE+WS_CHILD+BS_PUSHBUTTON,67,1,64,32,[hwnd],0,[wc.hInstance],0
mov [hbtn2],eax
invoke CreateWindowEx,WS_EX_ACCEPTFILES,_lstcls,_btntxt2,WS_VISIBLE+WS_CHILD+BS_PUSHBUTTON,1,35,128,128,[hwnd],0,[wc.hInstance],0
mov [hlst],eax
jmp .finish
.wmdestroy:
invoke PostQuitMessage,0
xor eax,eax
jmp .finish
.wmdropfiles:
;invoke MessageBox,0,0,0,MB_OK
;invoke DragQueryFile,[wparam],0,szdfn,128
;mov eax,[wparam]
;invoke DragQueryFile,eax,0,addr str,128
mov eax,[wparam]
invoke DragQueryFile,[wparam],-1,0,0
;invoke MessageBox,hWin,szDropFileName,0,MB_OK
.finish:
pop edi esi ebx
ret
endp
section '.idata' import data readable writeable
library kernel32,'KERNEL32.DLL',\
user32,'USER32.DLL'
include 'api\kernel32.inc'
include 'api\user32.inc'