Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .386
- .model flat, stdcall
- option casemap:none
- WinMain proto :DWORD, :DWORD, :DWORD, :DWORD
- include \masm32\include\windows.inc
- include \masm32\include\user32.inc
- include \masm32\include\kernel32.inc
- includelib \masm32\lib\user32.lib
- includelib \masm32\lib\kernel32.lib
- .data
- ClassName db "SimpleWindow", 0
- AppName db "First WIndow", 0
- Confirm db "Are you really want to exit?", 0
- .data?
- hInstance HINSTANCE ?
- CommandLine LPSTR ?
- .code
- start:
- invoke GetModuleHandle, NULL
- mov hInstance, eax
- invoke GetCommandLine
- mov CommandLine, eax
- invoke WinMain, hInstance, NULL, CommandLine, SW_SHOWDEFAULT
- invoke ExitProcess, eax
- WinMain proc hInst:HINSTANCE, hPrevInst:HINSTANCE,
- lpszCmdLine:LPSTR, nCmdShow:DWORD
- local hWnd:HWND
- local WndClass:WNDCLASSEX
- local Msg:MSG
- mov WndClass.cbSize, sizeof WNDCLASSEX
- mov WndClass.style, CS_HREDRAW or CS_VREDRAW
- mov WndClass.lpfnWndProc, offset WndProc
- mov WndClass.cbClsExtra, NULL
- mov WndClass.cbWndExtra, NULL
- push hInst
- pop WndClass.hInstance
- invoke LoadIcon, NULL, IDI_APPLICATION
- mov WndClass.hIcon, eax
- mov WndClass.hIconSm, eax
- invoke LoadCursor, NULL, IDC_ARROW
- mov WndClass.hCursor, eax
- mov WndClass.hbrBackground, COLOR_WINDOW
- mov WndClass.lpszMenuName, NULL
- mov WndClass.lpszClassName, offset ClassName
- invoke RegisterClassEx, addr WndClass
- invoke CreateWindowEx, NULL, addr ClassName, addr AppName,
- WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,
- CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
- NULL, NULL, hInst, NULL
- mov hWnd, eax
- invoke ShowWindow, hWnd, nCmdShow
- invoke UpdateWindow, hWnd
- .while TRUE
- invoke GetMessage, addr Msg, NULL, NULL, NULL
- .break .if (!eax)
- invoke TranslateMessage, addr Msg
- invoke DispatchMessage, addr Msg
- .endw
- mov eax, Msg.wParam
- ret
- WinMain endp
- WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
- .if uMsg == WM_DESTROY
- invoke PostQuitMessage, NULL
- .elseif uMsg == WM_CLOSE
- invoke MessageBox, hWnd, offset Confirm, 0, MB_OKCANCEL
- .if eax == IDOK
- invoke PostQuitMessage, NULL
- ret
- .endif
- .else
- invoke DefWindowProc, hWnd, uMsg, wParam, lParam
- ret
- .endif
- xor eax, eax
- ret
- WndProc endp
- end start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement