1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
| .386
.model flat, stdcall
option casemap:none
include windows.inc
include user32.inc
includelib user32.lib
include kernel32.inc
includelib kernel32.lib
WinMain PROTO :DWORD, :DWORD, :DWORD, :DWORD
.data
ClassName BYTE "SimpleWinClass",0 ;classe de fenetre
AppName BYTE "Fenetre!",0 ;string titre!
.data?
hInstance HINSTANCE ?
CommandLine LPSTR ?
.code
start:
invoke GetModuleHandle, NULL
mov ModuleHandle, eax
invoke GetCommandLine,
call CommandLine, eax
invoke WinMain, hInstance, NULL, CommandLine, SW_SHOWDEFAULT
invoke ExitProcess, eax
WinMain proc hInst:HINSTANCE, hPrevInst:HINSTANCE,
CmdLine:LPSTR,cMDSHOW:DWORD
LOCAL wc:WNDCLASSEX ;wc, classe de fenetre
LOCAL msg:MSG ;message systeme (communique entre l<utilisateur et les fenetres!)
LOCAL hwnd:HWND ;handle de fenetre ?
;44-59 initialise la windowsClass
mov wc.cbSize,SIZEOF WNDCLASSEX ;cbSize, taille en octets de WNDCLASSEX
mov wc.style, CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc, OFFSET wndProc ;pointe vers la fonction qui traite les evenements utilisateurs
mov wc.cbClsExtra, NULL ;nombre d'octets supplementaire en fonction de la structure
mov wc.cbWndWxtra, NULL ;nombre d'octets supplementaire en fonction de window instance!
push hInstance
pop wc.hInstance
mov wc.hbrBackground, COLOR+WINDOW+1
mov wc.lpszMenuName,NULL
mov wc.lpszClassName, OFFSET ClassName
invoke LoadIcon, NULL, IDI_APPLICATION
mov wc.hIcon,eax
mov wc.hIconSm,eax
invoke LoadCursor, NULL, IDC_ARROW
mov wc.hCursor, eax
invoke RegisterClassEx, addr wc
invoke CreateWindowEx, Null,\ ; structure de fenetre (default dans ce cas ci)
ADDR ClassName,\
ADDR AppName,\
WS_OVERLAPPEDWINDOW,\
CW_USEDEFAULT,\
CW_USEDEFAULT,\
CW_USEDEFAULT,\
CW_USEDEFAULT,\
NULL,\
NULL,\
hInst,\
NULL,
mov hwnd,eax
invoke ShowWindow, hwnd, CmdShow
invoke UpdateWindow, hwnd
.WHILE TRUE
invoke GetMessage, ADDR msg, NULL,0,0
.BREAK .IF (!eax)
invoke TranslateMessage, ADDR msg
invoke DispachMessage, ADDR msg
.ENDW
mov eax, msg.wParam
ret
WinMain endp
WndProc pric hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
.IF uMsg==WM_DESTROY
.ELSE
invoke DefWindowProc, hWd,uMsg,wParam, lParam
ret
.ENDIF
xor eax,eax
ret
WndProc endp
end start |
Partager