Advertisement
Guest User

Untitled

a guest
Jun 18th, 2016
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .386
  2. .model flat, stdcall
  3. option casemap:none
  4.  
  5. WinMain proto :DWORD, :DWORD, :DWORD, :DWORD
  6.  
  7. include \masm32\include\windows.inc
  8. include \masm32\include\user32.inc
  9. include \masm32\include\kernel32.inc
  10.  
  11. includelib \masm32\lib\user32.lib
  12. includelib \masm32\lib\kernel32.lib
  13.  
  14. .data
  15.     ClassName db "SimpleWindow", 0
  16.     AppName   db "First WIndow", 0
  17.     Confirm   db "Are you really want to exit?", 0
  18. .data?
  19.     hInstance   HINSTANCE ?
  20.     CommandLine LPSTR ?
  21. .code
  22. start:
  23.     invoke GetModuleHandle, NULL
  24.     mov hInstance, eax
  25.     invoke GetCommandLine
  26.     mov CommandLine, eax
  27.     invoke WinMain, hInstance, NULL, CommandLine, SW_SHOWDEFAULT
  28.     invoke ExitProcess, eax
  29.  
  30. WinMain proc hInst:HINSTANCE, hPrevInst:HINSTANCE,
  31.              lpszCmdLine:LPSTR, nCmdShow:DWORD
  32.     local hWnd:HWND
  33.     local WndClass:WNDCLASSEX
  34.     local Msg:MSG
  35.    
  36.     mov WndClass.cbSize, sizeof WNDCLASSEX
  37.     mov WndClass.style, CS_HREDRAW or CS_VREDRAW
  38.     mov WndClass.lpfnWndProc, offset WndProc
  39.     mov WndClass.cbClsExtra, NULL
  40.     mov WndClass.cbWndExtra, NULL
  41.     push hInst
  42.     pop WndClass.hInstance
  43.     invoke LoadIcon, NULL, IDI_APPLICATION
  44.     mov WndClass.hIcon, eax
  45.     mov WndClass.hIconSm, eax
  46.     invoke LoadCursor, NULL, IDC_ARROW
  47.     mov WndClass.hCursor, eax
  48.     mov WndClass.hbrBackground, COLOR_WINDOW
  49.     mov WndClass.lpszMenuName, NULL
  50.     mov WndClass.lpszClassName, offset ClassName
  51.    
  52.     invoke RegisterClassEx, addr WndClass
  53.     invoke CreateWindowEx, NULL, addr ClassName, addr AppName,
  54.                            WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,
  55.                            CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
  56.                            NULL, NULL, hInst, NULL
  57.     mov hWnd, eax
  58.     invoke ShowWindow, hWnd, nCmdShow
  59.     invoke UpdateWindow, hWnd
  60.    
  61.     .while TRUE
  62.         invoke GetMessage, addr Msg, NULL, NULL, NULL
  63.         .break .if (!eax)
  64.         invoke TranslateMessage, addr Msg
  65.         invoke DispatchMessage, addr Msg
  66.     .endw
  67.     mov eax, Msg.wParam
  68.     ret
  69. WinMain endp
  70.  
  71. WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
  72.     .if uMsg == WM_DESTROY
  73.         invoke PostQuitMessage, NULL
  74.     .elseif uMsg == WM_CLOSE
  75.         invoke MessageBox, hWnd, offset Confirm, 0, MB_OKCANCEL
  76.         .if eax == IDOK
  77.             invoke PostQuitMessage, NULL
  78.             ret
  79.         .endif
  80.     .else
  81.         invoke DefWindowProc, hWnd, uMsg, wParam, lParam
  82.         ret
  83.     .endif
  84.     xor eax, eax
  85.     ret
  86. WndProc endp
  87. end start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement