Marra_Kesh Дата: Суббота, 23.06.2012, 21:21 | Сообщение # 1
Постоянный
Зарегистрирован: 19.12.2009
Группа: Модераторы
Сообщений: 182
Статус: Offline
Code
format PE GUI 4.0 entry start include 'win32axp.inc' d equ dword w equ word FOO=WM_SHELLNOTIFY DIA = 256 R = (DIA / 2) HH = (R * 3 / 10) MH = (R * 5 / 10) SH = (R * 7 / 10) TH = (R / 5) TM = (R / 4) TT = (R / 3) TXT_H = (R / 10) TXT_W = (R / 12) STYLE = WS_CAPTION TIMER_ID = 1 WM_SHELLNOTIFY = WM_USER+5 IDM_ABOUT = 101 IDM_EXIT = 999 start: enter 48, 0 lea ebx, [ebp-sizeof.WNDCLASSEX] mov d[ebx+WNDCLASSEX.cbSize], sizeof.WNDCLASSEX mov d[ebx+WNDCLASSEX.style], CS_HREDRAW or CS_VREDRAW mov d[ebx+WNDCLASSEX.lpfnWndProc], wnd_proc and d[ebx+WNDCLASSEX.cbClsExtra], 0 and d[ebx+WNDCLASSEX.cbWndExtra], 0 push NULL call d[GetModuleHandle] mov [ebx+WNDCLASSEX.hInstance], eax push IDI_ASTERISK push 0 call d[LoadIcon] mov [ebx+WNDCLASSEX.hIcon], eax mov [ebx+WNDCLASSEX.hIconSm], eax push IDC_ARROW push 0 call d[LoadCursor] mov [ebx+WNDCLASSEX.hCursor], eax push 0x007f0000 call d[CreateSolidBrush] mov [_hbr_BG], eax mov [ebx+WNDCLASSEX.hbrBackground], eax and d[ebx+WNDCLASSEX.lpszMenuName], NULL mov d[ebx+WNDCLASSEX.lpszClassName], _class push ebx call d[RegisterClassEx] push 0 push d[ebx+WNDCLASSEX.hInstance] push 0 push 0 lea ebx, [ebp-sizeof.RECT] and d[ebx+RECT.left], 0 and d[ebx+RECT.top], 0 mov d[ebx+RECT.right], DIA mov d[ebx+RECT.bottom], DIA push 0 push FALSE push STYLE push ebx call d[AdjustWindowRect] mov ecx, [ebx+RECT.right] mov edx, [ebx+RECT.bottom] sub ecx, [ebx+RECT.left] sub edx, [ebx+RECT.top] push edx push ecx mov edi, edx mov esi, ecx push 10 push 10 push STYLE push _title push _class push 0 call d[CreateWindowEx] mov ebx, eax push eax call d[GetDC] push eax push eax call d[CreateCompatibleDC] mov d[_hdc_off_scr], eax pop eax push eax push edi push esi push eax call d[CreateCompatibleBitmap] mov d[_hbmp_off_scr], eax push eax push d[_hdc_off_scr] call d[SelectObject] push ebx call d[ReleaseDC] push 0x00ff0000 push 5 push PS_SOLID call d[CreatePen] mov [_hp_hand], eax push 0x0000ffff push 5 push PS_SOLID call d[CreatePen] mov [_hp_mark], eax push _face push DEFAULT_PITCH or FF_DECORATIVE push DEFAULT_QUALITY push CLIP_DEFAULT_PRECIS push OUT_DEFAULT_PRECIS push DEFAULT_CHARSET push FALSE push FALSE push FALSE push 0 push 0 push 0 push TXT_W push TXT_H call d[CreateFont] mov [_hfont], eax push NULL push 1000 push TIMER_ID push ebx call d[SetTimer] push SW_NORMAL push ebx call d[ShowWindow] lea ebx, [ebp-sizeof.MSG] jmp .get_msg .msg_loop: push ebx call d[TranslateMessage] push ebx call d[DispatchMessage] .get_msg: push 0 push 0 push 0 push ebx call d[GetMessage] test eax, eax jnz .msg_loop push d[ebx+MSG.wParam] call d[ExitProcess] wnd_proc: hwnd equ ebp+8 umsg equ ebp+12 wpar equ ebp+16 lpar equ ebp+20 push ebp mov ebp, esp sub esp, 88 push ebx push esi push edi mov eax, [umsg] cmp eax, WM_TIMER je .wm_timer cmp eax, WM_PAINT je .wm_paint cmp eax, WM_RBUTTONDOWN je .show_popup_menu cmp eax, WM_COMMAND je .wm_command cmp eax, WM_SHELLNOTIFY je .wm_shellnotify cmp eax, WM_CREATE je .wm_create cmp eax, WM_DESTROY je .wm_destroy .def_handler: push d[lpar] push d[wpar] push d[umsg] push d[hwnd] call d[DefWindowProc] jmp .def_handled .wm_timer: push d[_hdc_off_scr] push d[hwnd] call aclock push SRCCOPY push 0 push 0 push d[_hdc_off_scr] push DIA push DIA push 0 push 0 push d[hwnd] call d[GetDC] mov ebx, eax push eax call d[BitBlt] push ebx push d[hwnd] call d[ReleaseDC] jmp .handled .wm_paint: lea ebx, [ebp-sizeof.PAINTSTRUCT] push ebx push d[hwnd] call d[BeginPaint] push eax push d[hwnd] call aclock push ebx push d[hwnd] call d[EndPaint] jmp .handled .wm_command: cmp d[lpar], 0 jnz .handled cmp d[wpar], IDM_ABOUT je .idm_about cmp d[wpar], IDM_EXIT jne .handled push d[hwnd] call d[DestroyWindow] jmp .handled .idm_about: push MB_OK push _title push _about_msg push d[hwnd] call d[MessageBox] jmp .handled .wm_shellnotify: cmp d[wpar], IDI_ASTERISK jne .handled cmp d[lpar], WM_RBUTTONDOWN je .show_popup_menu cmp d[lpar], WM_LBUTTONDOWN jne .handled .show_hide: xor d[_hidden], 1 mov eax, SW_SHOW jz @F mov eax, SW_HIDE @@: push eax push d[hwnd] call d[ShowWindow] jmp .handled .show_popup_menu: lea ebx, [ebp-sizeof.POINT] push ebx call d[GetCursorPos] push d[hwnd] call d[SetForegroundWindow] push NULL push d[hwnd] push 0 push d[ebx+POINT.y] push d[ebx+POINT.x] push TPM_RIGHTALIGN push d[_hmenu] call d[TrackPopupMenu] push 0 push 0 push WM_NULL push d[hwnd] call d[PostMessage] jmp .handled .wm_create: mov ebx, _notify mov eax, [hwnd] mov [ebx+NOTIFYICONDATA.hWnd], eax push IDI_ASTERISK push 0 call d[LoadIcon] mov [ebx+NOTIFYICONDATA.hIcon], eax push ebx push NIM_ADD call d[Shell_NotifyIcon] call d[CreatePopupMenu] mov [_hmenu], eax push _about push IDM_ABOUT push MF_STRING push eax call [AppendMenu] push 0 push 0 push MF_SEPARATOR push d[_hmenu] call [AppendMenu] push _exit push IDM_EXIT push MF_STRING push d[_hmenu] call [AppendMenu] jmp .handled .wm_destroy: push _notify push NIM_DELETE call d[Shell_NotifyIcon] push d[_hmenu] call d[DestroyMenu] push 0 call [PostQuitMessage] ;jmp .handled .handled: xor eax, eax .def_handled: pop edi pop esi pop ebx leave ret 16 aclock: hwnd equ ebp+8 hdc equ ebp+12 now equ ebp-sizeof.SYSTEMTIME rect equ now-sizeof.RECT x0 equ rect-4 y0 equ x0-4 x equ y0-4 y equ x-4 ang equ y-4 tmp equ ang-4 tx equ tmp-4 ty equ tx-4 buff equ ty-16 push ebp mov ebp, esp sub esp, 80 push ebx push esi lea edx, [rect] push edx push d[hwnd] call d[GetClientRect] push d[_hbr_BG] push d[hdc] call d[SelectObject] push NULL_PEN call d[GetStockObject] push eax push d[hdc] call d[SelectObject] mov ecx, [rect+RECT.right] mov edx, [rect+RECT.bottom] sub ecx, [rect+RECT.left] sub edx, [rect+RECT.top] push edx push ecx push 0 push 0 sar ecx, 1 sar edx, 1 mov [x0], ecx mov [y0], edx push d[hdc] call d[Rectangle] push TRANSPARENT push d[hdc] call d[SetBkMode] push TA_CENTER call d[SetTextAlign] push 0x0000ff00 push d[hdc] call d[SetTextColor] push d[_hfont] push d[hdc] call d[SelectObject] xor ebx, ebx mov d[ang], 30 .num_tick_loop: inc ebx fldpi mov d[tmp], 180 fidiv d[tmp] fimul d[ang] fsincos mov d[tmp], R-TT-TXT_H-3 fimul d[tmp] fistp d[ty] fimul d[tmp] fistp d[tx] lea esi, [buff] push ebx push _fs_u push esi call d[sprintf] add esp, 12 mov ecx, [x0] mov edx, [y0] add ecx, [tx] sub edx, [ty] mov [rect+RECT.left], ecx mov [rect+RECT.top], edx mov [rect+RECT.right], ecx mov [rect+RECT.bottom], edx sub d[rect+RECT.left], TXT_W*2 sub d[rect+RECT.top], TXT_H add d[rect+RECT.right], TXT_W*2 add d[rect+RECT.bottom], TXT_H lea edx, [rect] push DT_SINGLELINE or DT_CENTER or DT_VCENTER push edx push 2 push esi push d[hdc] call d[DrawText] add d[ang], 30 cmp ebx, 12 jne .num_tick_loop lea edx, [now] push edx call d[GetLocalTime] DIGITAL_TIME = 1 if DIGITAL_TIME movsx edx, w[now+SYSTEMTIME.wSecond] movsx ecx, w[now+SYSTEMTIME.wMinute] movsx eax, w[now+SYSTEMTIME.wHour] push edx push ecx push eax push _fs_hms push esi call d[sprintf] add esp, 20 and d[rect+RECT.left], 0 and d[rect+RECT.top], HH mov d[rect+RECT.right], DIA mov d[rect+RECT.bottom], DIA lea edx, [rect] push DT_SINGLELINE or DT_CENTER or DT_VCENTER push edx push 8 push esi push d[hdc] call d[DrawText] end if push NULL push d[y0] push d[x0] push d[hdc] call d[MoveToEx] push d[_hp_hand] push d[hdc] call d[SelectObject] fldpi mov d[tmp], 180 fidiv d[tmp] FRACTIONAL_HOURS = 1 if FRACTIONAL_HOURS movsx eax, w[now+SYSTEMTIME.wMinute] mov [tmp], eax fild d[tmp] mov d[tmp], 60 fidiv d[tmp] movsx eax, w[now+SYSTEMTIME.wHour] mov [tmp], eax fiadd d[tmp] fmulp st1, st0 else movsx eax, w[now+SYSTEMTIME.wHour] mov [tmp], eax fimul d[tmp] end if mov d[tmp], 30 fimul d[tmp] fsincos mov d[tmp], HH fimul d[tmp] fistp d[y] fimul d[tmp] fistp d[x] mov ecx, [x0] mov edx, [y0] add ecx, [x] sub edx, [y] push edx push ecx push d[hdc] call d[LineTo] push NULL push d[y0] push d[x0] push d[hdc] call d[MoveToEx] fldpi mov d[tmp], 180 fidiv d[tmp] movsx eax, w[now+SYSTEMTIME.wMinute] mov [tmp], eax fimul d[tmp] mov d[tmp], 6 fimul d[tmp] fsincos mov d[tmp], MH fimul d[tmp] fistp d[y] fimul d[tmp] fistp d[x] mov ecx, [x0] mov edx, [y0] add ecx, [x] sub edx, [y] push edx push ecx push d[hdc] call d[LineTo] push NULL push d[y0] push d[x0] push d[hdc] call d[MoveToEx] fldpi mov d[tmp], 180 fidiv d[tmp] movsx eax, w[now+SYSTEMTIME.wSecond] mov [tmp], eax fimul d[tmp] mov d[tmp], 6 fimul d[tmp] fsincos mov d[tmp], SH fimul d[tmp] fistp d[y] fimul d[tmp] fistp d[x] mov ecx, [x0] mov edx, [y0] add ecx, [x] sub edx, [y] push edx push ecx push d[hdc] call d[LineTo] push d[_hp_mark] push d[hdc] call d[SelectObject] and d[ang], 0 .tick_loop: fldpi mov d[tmp], 180 fidiv d[tmp] fimul d[ang] fsincos fld st1 fld st1 mov d[tmp], R-TT fimul d[tmp] fistp d[ty] fimul d[tmp] fistp d[tx] mov d[tmp], R-TH xor edx, edx mov eax, [ang] mov ecx, 30 div ecx test edx, edx jz @F mov d[tmp], R-TM @@: fimul d[tmp] fistp d[y] fimul d[tmp] fistp d[x] mov ecx, [x0] mov edx, [y0] add ecx, [x] sub edx, [y] push NULL push edx push ecx push d[hdc] call d[MoveToEx] mov ecx, [x0] mov edx, [y0] add ecx, [tx] sub edx, [ty] push edx push ecx push d[hdc] call d[LineTo] add d[ang], 6 cmp d[ang], 360 jbe .tick_loop pop esi pop ebx leave ret 8 section '.data' data readable writable _notify NOTIFYICONDATA sizeof.NOTIFYICONDATA, 0, IDI_ASTERISK,\ NIF_ICON or NIF_MESSAGE or NIF_TIP,\ WM_SHELLNOTIFY, 0, <"Analog Clock (By Mann)",0> _hidden dd 0 _hmenu dd 0 _hdc_off_scr dd 0 _hbmp_off_scr dd 0 _hfont dd 0 _hbr_BG dd 0 _hp_hand dd 0 _hp_mark dd 0 NL equ 13,10 _about_msg db NL db "AClock 0.5 - Analog Clock",NL,NL db "Released under GNU GPL",NL,NL db "By Mann",NL,NL db "mailto:smart.bits@yahoo.com",NL,NL,NL db 0 _title db "AClock",0 _class db "AClockClass",0 _face db "Fixedsys" _about db "&About",0 _exit db "E&xit",0 _fs_u db "%02u",0 _fs_hms db "%02u:%02u:%02u",0 section '.idata' import data readable writable library kernel32,'kernel32.dll',\ user32,'user32.dll',\ gdi32,'gdi32.dll',\ shell32,'shell32.dll',\ msvcrt,'msvcrt.dll' include 'api/kernel32.inc' include 'api/user32.inc' include 'api/gdi32.inc' include 'api/shell32.inc' import msvcrt,\ sprintf,'sprintf'
Первоисточник где-то в Интернете...
Сообщение отредактировал Marra_Kesh - Суббота, 23.06.2012, 21:22