Guest User

Untitled

a guest
Apr 20th, 2018
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.79 KB | None | 0 0
  1. format PE GUI 4.0
  2. entry start
  3.  
  4. include 'include\win32a.inc'
  5.  
  6. section '.data' data readable writeable
  7. wHMain dd ?
  8. wHInstance dd ?
  9.  
  10. wTitle db 'Tutorial 3',0 ;name of our window
  11. wClsName db 'TUT03',0 ;name of our window class
  12.  
  13. wMsg MSG
  14. wCls WNDCLASS
  15.  
  16. section '.code' code readable executable
  17. start:
  18. ; +------------------------------+
  19. ; | registering the window class |
  20. ; +------------------------------+
  21. invoke GetModuleHandle,NULL
  22. mov [wHInstance],eax
  23. mov [wCls.hInstance],eax
  24. mov [wCls.style],CS_HREDRAW or CS_VREDRAW
  25. mov [wCls.lpfnWndProc],window_procedure
  26. mov [wCls.lpszClassName],wClsName
  27. mov [wCls.hbrBackground],COLOR_WINDOW+1
  28. invoke LoadIcon,NULL,IDI_APPLICATION
  29. mov [wCls.hIcon],eax
  30. invoke LoadCursor,NULL,IDC_ARROW
  31. mov [wCls.hCursor],eax
  32. invoke RegisterClass,wCls
  33.  
  34. ; +--------------------------+
  35. ; | creating the main window |
  36. ; +--------------------------+
  37. invoke CreateWindowEx,\
  38. 0,\
  39. wClsName,\
  40. wTitle,\
  41. WS_OVERLAPPEDWINDOW,\
  42. CW_USEDEFAULT,\
  43. CW_USEDEFAULT,\
  44. CW_USEDEFAULT,\
  45. CW_USEDEFAULT,\
  46. NULL,\
  47. NULL,\
  48. [wHInstance],\
  49. NULL
  50. mov [wHMain],eax
  51. invoke ShowWindow,[wHMain],SW_SHOW
  52. ; +---------------------------+
  53. ; | entering the message loop |
  54. ; +---------------------------+
  55. window_message_loop_start:
  56. invoke GetMessage,wMsg,NULL,0,0
  57. or eax,eax
  58. je window_message_loop_end
  59. invoke TranslateMessage,wMsg
  60. invoke DispatchMessage,wMsg
  61. jmp window_message_loop_start
  62.  
  63. window_message_loop_end:
  64. invoke ExitProcess,0
  65.  
  66. ; +----------------------+
  67. ; | the window procedure |
  68. ; +----------------------+
  69. proc window_procedure,hWnd,uMsg,wParam,lParam
  70. push ebx esi edi ;eventhough the API would preserved, but play safe :p
  71. cmp [uMsg],WM_DESTROY
  72. je wmDESTROY
  73.  
  74. wmDEFAULT:
  75. invoke DefWindowProc,[hWnd],[uMsg],[wParam],[lParam]
  76. jmp wmBYE
  77. wmDESTROY:
  78. invoke PostQuitMessage,0
  79.  
  80. wmBYE:
  81. pop edi esi ebx
  82. ret
  83. endp
  84.  
  85. section '.idata' import data readable writeable
  86. library KERNEL32, 'KERNEL32.DLL',\
  87. USER32, 'USER32.DLL'
  88.  
  89. import KERNEL32,\
  90. GetModuleHandle, 'GetModuleHandleA',\
  91. ExitProcess, 'ExitProcess'
  92.  
  93. import USER32,\
  94. RegisterClass, 'RegisterClassA',\
  95. CreateWindowEx, 'CreateWindowExA',\
  96. DefWindowProc, 'DefWindowProcA',\
  97. ShowWindow, 'ShowWindow',\
  98. LoadCursor, 'LoadCursorA',\
  99. LoadIcon, 'LoadIconA',\
  100. GetMessage, 'GetMessageA',\
  101. TranslateMessage, 'TranslateMessage',\
  102. DispatchMessage, 'DispatchMessageA',\
  103. PostQuitMessage, 'PostQuitMessage'
Add Comment
Please, Sign In to add comment