Home > other >  32 assembly to write the SDK in the middle of the window displays the current time, and updates per
32 assembly to write the SDK in the middle of the window displays the current time, and updates per

Time:09-21

386
.The model flat, stdcall
Option casemap: none

The include Windows. Inc
The include user32. Inc
The include kernel32. Inc

Includelib user32. Lib
Includelib kernel32. Lib

.data
G_Hello db 'hello word! ', 0
G_Title db 'Win32, 0
G_hInst dd?
SzFormat db 'on % d % d % d % d: % d: % d', 0

The code

WndProc proto hWnd: hWnd, message: UINT, wParam: wParam, lParam: lParam
MyRegisterClass proto hInstance, hInstance
InitInstance proto hInstance, hInstance

WinMain proc hInstance, hInstance

The LOCAL @ MSG: MSG

Invoke MyRegisterClass, hInstance


Invoke InitInstance, hInstance
If! Eax
Mov eax, FALSE
Ret
The endif

Invoke GetMessage, addr @ MSG, NULL, 0, 0
. While eax
Invoke TranslateMessage, addr @ MSG
Invoke DispatchMessage, addr @ MSG

Invoke GetMessage, addr @ MSG, NULL, 0, 0
The endw
Mov eax, @ MSG. WParam
Ret
WinMain endp

MyRegisterClass proc hInstance, hInstance
The LOCAL @ wcex: modifed WNDCLASSEX

Invoke RtlZeroMemory addr @ wcex, sizeof modifed WNDCLASSEX

Mov @ wcex cbSize, sizeof modifed WNDCLASSEX
Mov @ wcex style, CS_HREDRAW or CS_VREDRAW
Mov @ wcex lpfnWndProc, offset WndProc
; Mov @ wcex. CbClsExtra, 0
; Mov @ wcex. CbWndExtra, 0
Push hInstance
Pop. @ wcex hInstance
; Mov @ wcex. HIcon,
; Mov @ wcex hCursor,
Mov @ wcex. HbrBackground, COLOR_WINDOW + 1
; Mov @ wcex lpszMenuName,
Mov @ wcex lpszClassName, offset g_Hello
; Mov @ wcex hIconSm,

Invoke RegisterClassEx, addr @ wcex
Ret
MyRegisterClass endp

InitInstance proc hInstance, hInstance
The LOCAL @ hWnd: hWnd
Push hInstance
Pop g_hInst
Invoke CreateWindowEx, NULL, offset g_Hello, offset g_Title, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL
Mov @ hWnd, eax
If! @ hWnd
Mov eax, FALSE
Ret
The endif
Invoke ShowWindow, @ hWnd, SW_SHOW
Invoke UpdateWindow, @ hWnd
Mov eax, TRUE
Ret
InitInstance endp

; Void CALLBACK MyTimerCallBack (HWND HWND, UINT message, UINT iTimerID, dwords dwTime)
MyTimerCallBack proc hWnd: hWnd, message: UINT, iTimerID: UINT, dwTime: DWORD
The LOCAL @ szBuffer [40] : dword
The LOCAL @ HDC: HDC
The LOCAL @ ps: PAINTSTRUCT
The LOCAL @ rt: the RECT
The LOCAL @ stSYSTEMTIME: SYSTEMTIME
The LOCAL @ rectHigh: word
The LOCAL @ rectWidth: word
; The LOCAL

Invoke GetLocalTime, addr @ stSYSTEMTIME
Invoke GetDC, hWnd
Mov @ HDC, eax
; Invoke wsprintf addr @ szBuffer, offset szFormat, @ t.w Year, @ t.w Month, @ t.w Day, @ t.w Hour, @ t.w Minute, @ t.w Second
Invoke GetClientRect hWnd, addr @ rt
Mov ax, @ stSYSTEMTIME wYear
Movzx eax, ax
Mov @ szBuffer, eax
Mov ax, @ stSYSTEMTIME wMonth
Movzx eax, ax
Mov @ szBuffer + 4, eax
Mov ax, @ stSYSTEMTIME wDay
Movzx eax, ax
Mov @ szBuffer + 8, eax
Mov ax, @ stSYSTEMTIME wHour
Movzx eax, ax
Mov @ szBuffer + 12, eax
Mov ax, @ stSYSTEMTIME wMinute
Movzx eax, ax
Mov @ szBuffer + 16, eax
Mov ax, @ stSYSTEMTIME wSecond
Movzx eax, ax
Mov @ szBuffer + 20, eax
Invoke wsprintf addr @ szBuffer, offset szFormat, @ szBuffer, @ szBuffer + 4, @ szBuffer + 8, @ szBuffer + 12, @ szBuffer + 16, @ szBuffer + 20
Xor eax, eax
Mov @ szBuffer + 24, eax

Invoke DrawText, @ HDC, addr @ szBuffer, 20, addr @ rt, DT_CENTER

MyTimerCallBack endp

WndProc proc hWnd: hWnd, message: UINT, wParam: wParam, lParam: lParam
The LOCAL @ HDC: HDC
The LOCAL @ ps: PAINTSTRUCT
The LOCAL @ rt: the RECT
The LOCAL @ szHello [100] : byte
. If the message==WM_PAINT
Invoke BeginPaint, hWnd, addr @ ps
Mov @ HDC, eax

invoke SetTimer hWnd, 0, 0100 MyTimerCallBack

Invoke EndPaint, hWnd, addr @ ps
. Elseif message==WM_DESTROY
Invoke the PostQuitMessage, 0
. The else
Invoke DefWindowProc hWnd, message, wParam, lParam
Ret
The endif
Xor eax, eax
Ret

WndProc endp

START:
Invoke GetModuleHandle, NULL
Invoke WinMain, eax
Ret
The end START

No comments I also just learn personal advice just write over the SDK so better write again because this is the homework first wuhan secco sharp reverse hope students don't copy see more directly, and write a n experienced person,,, not good at hope bosses advice
  • Related