Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- section .text
- global _start
- _start:
- push ebp
- mov ebp, esp
- sub esp, MSG_size + 16
- %define msg ebp - MSG_size
- %define rect ebp - MSG_size - 16
- mov dword [rect], 0
- mov dword [rect + 4], 0
- mov dword [rect + 8], MAXX
- mov dword [rect + 12], MAXY
- push 0
- call GetModuleHandleA
- mov [hInstance], eax
- call register_class
- push 0
- push 0
- push MAIN_WND_STYLE
- lea eax, [rect]
- push eax
- call AdjustWindowRectEx
- push 0
- push dword [hInstance]
- push 0
- push 0
- mov eax, [rect + 12]
- sub eax, [rect + 4]
- push eax
- mov eax, [rect + 8]
- sub eax, [rect]
- push eax
- push 100 ; top
- push 200 ; left
- push MAIN_WND_STYLE
- push szTitle
- push szClassName
- push 0
- call CreateWindowExA
- mov [hMainWnd], eax
- push SW_SHOWNORMAL
- push eax
- call ShowWindow
- push dword [hMainWnd]
- call UpdateWindow
- .process:
- lea eax, [msg]
- push 0
- push 0
- push 0
- push eax
- call GetMessageA
- test eax, eax
- jz .end
- lea eax, [msg]
- push eax
- call TranslateMessage
- lea eax, [msg]
- push eax
- call DispatchMessageA
- jmp .process
- .end:
- mov esp, ebp
- pop ebp
- push 0
- call ExitProcess
- register_class:
- push ebp
- mov ebp, esp
- sub esp, WNDCLASSEX_size
- %define wc ebp - WNDCLASSEX_size
- mov dword [wc + WNDCLASSEX.cbSize], WNDCLASSEX_size
- mov dword [wc + WNDCLASSEX.style], CS_HREDRAW | CS_VREDRAW
- mov dword [wc + WNDCLASSEX.lpfnWndProc], wndproc
- mov dword [wc + WNDCLASSEX.cbClsExtra], 0
- mov dword [wc + WNDCLASSEX.cbWndExtra], 0
- mov eax, [hInstance]
- mov dword [wc + WNDCLASSEX.hInstance], eax
- mov dword [wc + WNDCLASSEX.hbrBackground], COLOR_WINDOW + 1
- mov dword [wc + WNDCLASSEX.lpszMenuName], 0
- mov dword [wc + WNDCLASSEX.lpszClassName], szClassName
- push IDI_APPLICATION
- push 0
- call LoadIconA
- mov dword [wc + WNDCLASSEX.hIcon], eax
- mov dword [wc + WNDCLASSEX.hIconSm], eax
- push IDC_CROSS
- push 0
- call LoadCursorA
- mov dword [wc + WNDCLASSEX.hCursor], eax
- lea eax, [wc]
- push eax
- call RegisterClassExA
- mov esp, ebp
- pop ebp
- ret
- wndproc:
- push ebp
- mov ebp, esp
- %define hWnd ebp + 8
- %define uMsg ebp + 12
- %define wParam ebp + 16
- %define lParam ebp + 20
- sub esp, PAINTSTRUCT_size + 4
- %define ps ebp - PAINTSTRUCT_size
- %define hdc ebp - PAINTSTRUCT_size - 4
- mov eax, [uMsg]
- cmp eax, WM_DESTROY
- jz .destroy
- cmp eax, WM_CREATE
- jz .create
- jmp .default
- .create:
- ; init logic
- jmp .endinit
- .destroy:
- push 0
- call PostQuitMessage
- jmp .endinit
- .default:
- push dword [ebp + 20]
- push dword [ebp + 16]
- push dword [ebp + 12]
- push dword [ebp + 8]
- call DefWindowProcA
- jmp .endwndproc
- .endinit:
- xor eax, eax
- .endwndproc:
- mov esp, ebp
- pop ebp
- ret 16
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement