Я не спешу особо никуда, хотелось бы поработать с GDI+ Ни чего не отрисовывается, где-то ошибся Код (ASM): format PE64 GUI 6.0 entry start include 'win64a.inc' section '.code' code readable executable ;---------------------------------------------------------------------- start: sub rsp,8 ; Make stack dqword aligned invoke GetModuleHandle,0 mov [wc.hInstance],rax mov [wc.cbSize],sizeof.WNDCLASSEX mov [wc.style],CS_HREDRAW or CS_VREDRAW mov [wc.lpfnWndProc],WindowProc mov [wc.cbClsExtra],0 invoke LoadIcon,0,IDI_APPLICATION mov [wc.hIcon],rax mov [wc.hIconSm],rax invoke LoadCursor,0,IDC_ARROW mov [wc.hCursor],rax mov [wc.hbrBackground],COLOR_WINDOW+1 mov [wc.lpszMenuName],NULL mov [wc.lpszClassName],szTitle invoke RegisterClassEx,wc invoke CreateWindowEx,0,szTitle,szTitle,WS_OVERLAPPED + WS_VISIBLE + WS_CAPTION + WS_SYSMENU + WS_MINIMIZEBOX ,CW_USEDEFAULT,CW_USEDEFAULT,444,444,NULL,NULL,[wc.hInstance],NULL msg_loop: invoke GetMessage,msg,NULL,0,0 or rax,rax je exit invoke TranslateMessage,msg invoke DispatchMessage,msg jmp msg_loop exit: invoke ExitProcess,[msg.wParam] ;---------------------------------------------------------------------- proc WindowProc hwnd,wmsg,wparam,lparam mov [hwnd],rcx mov [wmsg],rdx mov [wparam],r8 mov [lparam],r9 cmp [wmsg],WM_CREATE je .create cmp [wmsg],WM_TIMER je .timer cmp [wmsg],WM_PAINT je .paint cmp [wmsg],WM_DESTROY jne .defwndproc invoke PostQuitMessage,0 jmp .exit .defwndproc: invoke DefWindowProc,[hwnd],[wmsg],[wparam],[lparam] ret .create: mov [GdiplusSInput.GdiplusVersion],1 mov [GdiplusSInput.DebugEventCallback],0 mov [GdiplusSInput.SuppressBackgroundThread],0 mov [GdiplusSInput.SuppressExternalCodecs],0 invoke GdiplusStartup,GdiplusToken,GdiplusSInput,0 invoke GdipCreatePen1,0ff0000ffh,40400000h,UnitPixel,hPen invoke GetLocalTime,systime .timer: .paint: invoke BeginPaint,wc.hInstance,ps invoke GdipCreateFromHDC,[ps.hdc],hGraphics invoke GdipSetSmoothingMode,hGraphics,SmoothingModeAntiAlias invoke GdipGraphicsClear,hGraphics,0ffffffffh invoke GdipDrawEllipseI,hGraphics,hPen,100,100,200,200 invoke GdipDeleteGraphics,hGraphics invoke EndPaint,wc.hInstance,ps .exit: ret endp ;---------------------------------------------------------------------- section '.data' data readable writeable szTitle db 'CLOCK',0 UnitPixel = 2 SmoothingModeAntiAlias = 4 hPen dq ? GdiplusToken dq ? hGraphics dq ? struct GdiplusStartupInput GdiplusVersion dd ? DebugEventCallback dq ? SuppressBackgroundThread dd ? SuppressExternalCodecs dd ? ends wc WNDCLASSEX msg MSG systime SYSTEMTIME GdiplusSInput GdiplusStartupInput ps PAINTSTRUCT ;---------------------------------------------------------------------- section '.idata' import data readable writeable library kernel,'KERNEL32.DLL',\ user,'USER32.DLL',\ gdiplus,'GDIPLUS.DLL' import gdiplus,\ GdiplusStartup,'GdiplusStartup',\ GdipCreatePen1,'GdipCreatePen1',\ GdipCreateFromHDC,'GdipCreateFromHDC',\ GdipSetSmoothingMode,'GdipSetSmoothingMode',\ GdipGraphicsClear,'GdipGraphicsClear',\ GdipDrawEllipseI,'GdipDrawEllipseI',\ GdipDeleteGraphics,'GdipDeleteGraphics' import kernel,\ ExitProcess,'ExitProcess',\ GetModuleHandle,'GetModuleHandleA',\ GetLocalTime,'GetLocalTime' import user,\ BeginPaint,'BeginPaint',\ EndPaint,'EndPaint',\ PostQuitMessage,'PostQuitMessage',\ LoadIcon,'LoadIconA',\ LoadCursor,'LoadCursorA',\ RegisterClassEx,'RegisterClassExA',\ CreateWindowEx,'CreateWindowExA',\ DefWindowProc,'DefWindowProcA',\ GetMessage,'GetMessageA',\ TranslateMessage,'TranslateMessage',\ DispatchMessage,'DispatchMessageA' запутался наверное а скобках [ ], адреса и значения переменных если вообще программа доходит до нужного места, не видно ни в IDA ни в x64dbg
Код (ASM): format PE64 GUI 6.0 entry start include 'win64a.inc' section '.code' code readable executable ;---------------------------------------------------------------------- start: sub rsp,8 ; Make stack dqword aligned invoke GetModuleHandle,0 mov [wc.hInstance],rax mov [wc.cbSize],sizeof.WNDCLASSEX mov [wc.style],CS_HREDRAW or CS_VREDRAW mov [wc.lpfnWndProc],WindowProc mov [wc.cbClsExtra],0 invoke LoadIcon,0,IDI_APPLICATION mov [wc.hIcon],rax mov [wc.hIconSm],rax invoke LoadCursor,0,IDC_ARROW mov [wc.hCursor],rax mov [wc.hbrBackground],COLOR_WINDOW+1 mov [wc.lpszMenuName],NULL mov [wc.lpszClassName],szTitle invoke RegisterClassEx,wc invoke CreateWindowEx,0,szTitle,szTitle,WS_OVERLAPPED + WS_VISIBLE + WS_CAPTION + WS_SYSMENU + WS_MINIMIZEBOX ,CW_USEDEFAULT,CW_USEDEFAULT,444,444,NULL,NULL,[wc.hInstance],NULL msg_loop: invoke GetMessage,msg,NULL,0,0 or rax,rax je exit invoke TranslateMessage,msg invoke DispatchMessage,msg jmp msg_loop exit: invoke ExitProcess,[msg.wParam] ;---------------------------------------------------------------------- proc WindowProc hwnd,wmsg,wparam,lparam mov [hwnd],rcx mov [wmsg],rdx mov [wparam],r8 mov [lparam],r9 cmp [wmsg],WM_CREATE je .create cmp [wmsg],WM_TIMER je .timer cmp [wmsg],WM_PAINT je .paint cmp [wmsg],WM_DESTROY jne .defwndproc invoke PostQuitMessage,0 jmp .exit .defwndproc: invoke DefWindowProc,[hwnd],[wmsg],[wparam],[lparam] ret .create: mov [GdiplusSInput.GdiplusVersion],1 mov [GdiplusSInput.DebugEventCallback],0 mov [GdiplusSInput.SuppressBackgroundThread],0 mov [GdiplusSInput.SuppressExternalCodecs],0 invoke GdiplusStartup,GdiplusToken,GdiplusSInput,0 invoke GdipCreatePen1,0ff0000ffh,float dword 3.0,UnitPixel,hPen invoke GetLocalTime,systime jmp .exit .timer: jmp .exit .paint: invoke BeginPaint,[hwnd],ps invoke GdipCreateFromHDC,[ps.hdc],hGraphics invoke GdipSetSmoothingMode,[hGraphics],SmoothingModeAntiAlias invoke GdipGraphicsClear,[hGraphics],0ffffffffh invoke GdipDrawEllipseI,[hGraphics],[hPen],100,100,200,200 invoke GdipDeleteGraphics,[hGraphics] invoke EndPaint,[hwnd],ps .exit: ret endp ;---------------------------------------------------------------------- section '.data' data readable writeable szTitle db 'CLOCK',0 UnitPixel = 2 SmoothingModeAntiAlias = 4 hPen dq ? GdiplusToken dq ? hGraphics dq ? struct GdiplusStartupInput GdiplusVersion dd ? DebugEventCallback dq ? SuppressBackgroundThread dd ? SuppressExternalCodecs dd ? ends wc WNDCLASSEX msg MSG systime SYSTEMTIME GdiplusSInput GdiplusStartupInput ps PAINTSTRUCT ;---------------------------------------------------------------------- section '.idata' import data readable writeable library kernel,'KERNEL32.DLL',\ user,'USER32.DLL',\ gdiplus,'GDIPLUS.DLL' import gdiplus,\ GdiplusStartup,'GdiplusStartup',\ GdipCreatePen1,'GdipCreatePen1',\ GdipCreateFromHDC,'GdipCreateFromHDC',\ GdipSetSmoothingMode,'GdipSetSmoothingMode',\ GdipGraphicsClear,'GdipGraphicsClear',\ GdipDrawEllipseI,'GdipDrawEllipseI',\ GdipDeleteGraphics,'GdipDeleteGraphics' import kernel,\ ExitProcess,'ExitProcess',\ GetModuleHandle,'GetModuleHandleA',\ GetLocalTime,'GetLocalTime' import user,\ BeginPaint,'BeginPaint',\ EndPaint,'EndPaint',\ PostQuitMessage,'PostQuitMessage',\ LoadIcon,'LoadIconA',\ LoadCursor,'LoadCursorA',\ RegisterClassEx,'RegisterClassExA',\ CreateWindowEx,'CreateWindowExA',\ DefWindowProc,'DefWindowProcA',\ GetMessage,'GetMessageA',\ TranslateMessage,'TranslateMessage',\ DispatchMessage,'DispatchMessageA'
Код (ASM): .386 .model flat, stdcall option casemap :none include \masm32\include\windows.inc include \masm32\include\gdiplus.inc include \masm32\include\user32.inc include \masm32\include\kernel32.inc includelib \masm32\lib\gdiplus.lib includelib \masm32\lib\user32.lib includelib \masm32\lib\kernel32.lib DialogProc proto :DWORD,:DWORD,:DWORD,:DWORD DrawHand proto :DWORD, :DWORD,:DWORD GdiplusStartupInput STRUCT GdiplusVersion dd ? DebugEventCallback dd ? SuppressBackgroundThread dd ? SuppressExternalCodecs dd ? GdiplusStartupInput ENDS UnitPixel equ 2 SmoothingModeAntiAlias equ 4 .data DLG_TEMP dd WS_OVERLAPPEDWINDOW XOR WS_THICKFRAME OR DS_CENTER, WS_EX_APPWINDOW dw 0, 0, 0, 200, 200, 0, 0, 0 hPen dd ? lToken dd ? tGpInput GdiplusStartupInput {1, 0, 0, 0} l12 dd 12 l360 dd 360 l60 dd 60 lDegOffset dd 90 .code start: invoke GetModuleHandle, NULL; invoke DialogBoxIndirectParam, eax, offset DLG_TEMP, NULL, offset DialogProc, NULL; invoke ExitProcess, 0 DialogProc proc hwndDlg :DWORD, uMsg :DWORD, wParam :DWORD, lParam :DWORD LOCAL ps:PAINTSTRUCT LOCAL hGraphics:DWORD LOCAL angle:DWORD LOCAL locTime:SYSTEMTIME xor eax, eax .if uMsg == WM_INITDIALOG invoke GdiplusStartup, offset lToken, offset tGpInput, NULL invoke GdipCreatePen1, 0ff0000ffh, 40400000h, UnitPixel, offset hPen invoke SetTimer, hwndDlg, 1, 1000, NULL .elseif uMsg == WM_TIMER invoke InvalidateRect, hwndDlg, NULL, 0 .elseif uMsg == WM_PAINT invoke BeginPaint, hwndDlg, ADDR ps invoke GdipSetPenWidth, hPen, 40A00000h invoke GdipSetPenColor, hPen, 0ffff0000h invoke GdipCreateFromHDC, ps.hdc, ADDR hGraphics invoke GdipSetSmoothingMode, hGraphics, SmoothingModeAntiAlias invoke GdipGraphicsClear, hGraphics, 0ffffffffh invoke GdipDrawEllipseI, hGraphics, hPen, 100, 100, 200, 200 invoke GetLocalTime, ADDR locTime invoke GdipSetPenWidth, hPen, 40400000h ; Часовая стрелка fild l360 fild l12 fild locTime.wHour fild locTime.wMinute fidiv l60 faddp st(1), st fprem fdivrp st(1), st fmulp st(1), st fisub lDegOffset fstp angle invoke DrawHand, hGraphics, angle, 75 invoke GdipSetPenColor, hPen, 0ff0000ffh ; Минутная стрелка fild l360 fild l60 fild locTime.wMinute fild locTime.wSecond fidiv l60 faddp st(1), st fdivrp st(1), st fmulp st(1), st fisub lDegOffset fstp angle invoke DrawHand, hGraphics, angle, 90 invoke GdipSetPenWidth, hPen, 3F800000h ; Секундная стрелка fild l360 fild locTime.wSecond fidiv l60 fmulp st(1), st fisub lDegOffset fstp angle invoke DrawHand, hGraphics, angle, 90 invoke GdipDeleteGraphics, hGraphics invoke EndPaint, hwndDlg, ADDR ps .elseif uMsg == WM_CLOSE invoke KillTimer, hwndDlg, 1 invoke GdipDeletePen, hPen invoke GdiplusShutdown, lToken invoke EndDialog, hwndDlg, 0 .endif ret DialogProc endp DrawHand proc hGraphics:DWORD, Angle:DWORD, Scale:DWORD invoke GdipResetWorldTransform, hGraphics invoke GdipRotateWorldTransform, hGraphics, Angle, 0 invoke GdipTranslateWorldTransform, hGraphics, 43480000h, 43480000h, 1 invoke GdipDrawLineI, hGraphics, hPen, 0, 0, Scale,00 ret DrawHand endp end start
Код (ASM): format PE64 GUI 5.0 width_of_watch = 256 height_of_watch = width_of_watch half_of_width_of_watch = width_of_watch/2 half_height_of_watch = hight_of_watch/2 entry WinMain include 'win64a.inc' section '.text' code readable executable writeable proc WinMain local msg:MSG mov esi,400000h; hInstance для FASM mov eax,10027h; вернула LoadIcon, у вас может быть другое значение xor ebx,ebx mov edi,_class push rax ;hIcon push rdi ;lpszClassName push rbx ;lpszMenuName push COLOR_WINDOWTEXT ;hbrBackground push 10003h ; вернула LoadCursor, у вас может быть другое значение push rax ;hIcon push rsi push rbx push WindowProc push sizeof.WNDCLASSEX ;cbSize & style mov ecx,esp call [RegisterClassEx] mov [rbp-28h],rbx mov [rbp-30h],rsi mov [rbp-38h],rbx mov [rbp-40h],rbx shl esi,9 mov eax,width_of_watch mov [rbp-48h],rax mov [rbp-50h],rax mov [rbp-58h],rsi; CW_DEFAULT mov [rbp-60h],rsi; CW_DEFAULT mov r9d,WS_VISIBLE+WS_DLGFRAME+WS_SYSMENU mov r8d,edi mov edx,edi xor ecx,ecx call [CreateWindowEx] lea edi,[msg] msg_loop:mov ecx,edi xor edx,edx xor r8,r8 xor r9,r9 call [GetMessage] mov ecx,edi call [DispatchMessage] jmp msg_loop endp proc WindowProc hwnd:QWORD,wmsg:QWORD,wparam:QWORD,lparam:QWORD local ps:PAINTSTRUCT local hdc:QWORD local hpen:QWORD local hPenOld:QWORD local hBrush:QWORD local hBrushOld:QWORD local X:DWORD local Y:DWORD mov [hwnd],rcx cmp edx,WM_CREATE je wmCREATE cmp edx,WM_TIMER je wmTIMER cmp edx,WM_PAINT je wmPAINT cmp edx,WM_DESTROY je wmDESTROY .defwndproc:leave jmp [NtdllDefWindowProc] wmDESTROY: xor ecx,ecx;уничтожаем таймер #0 call [KillTimer] xor ecx,ecx call [RtlExitUserProcess] wmCREATE: xor r9,r9 mov r8d,1000 ;WM_TIMER=1 sec xor edx,edx ;таймер #0 call [SetTimer] fninit fldz jmp wmBYE wmTIMER: mov r8d,TRUE xor edx,edx call [InvalidateRect] jmp wmBYE wmPAINT:lea edx,[ps] call [BeginPaint] mov [hdc],rax ;секундная стрелка mov ecx,PS_SOLID mov edx,2 mov r8d,6464FFh;R=255 G=B=100 call [CreatePen] mov [hpen],rax mov edx,eax;hpen mov rcx,[hdc] call [SelectObject] mov [hPenOld],rax xor r9,r9;NULL mov edx,half_of_width_of_watch mov r8d,edx;half_height_of_watch mov rcx,[hdc] call [MoveToEx] fld st fsincos fimul [temp2] fistp [X] fimul [temp2] fistp [Y] fadd [temp] ;увеличили angle на 6 градусов mov edx,half_of_width_of_watch mov r8d,edx ;half_height_of_watch sub r8d,[Y] sub edx,[X] mov rcx,[hdc] call [LineTo] mov rdx,[hPenOld] mov rcx,[hdc] call [SelectObject] mov rcx,[hpen] call [DeleteObject] ;минутная стрелка mov ecx,PS_SOLID mov edx,3 mov r8d,808080h;R=G=B=128 call [CreatePen] mov [hpen],rax mov edx,eax;hpen mov rcx,[hdc] call [SelectObject] mov [hPenOld],rax xor r9,r9;NULL mov edx,half_of_width_of_watch mov r8d,edx ;half_height_of_watch mov rcx,[hdc] call [MoveToEx] mov r8d,65 mov edx,155 mov rcx,[hdc] call [LineTo] mov rdx,[hPenOld] mov rcx,[hdc] call [SelectObject] mov rcx,[hpen] call [DeleteObject] ;заглушка в центре циферблата mov ecx,PS_SOLID mov edx,3 mov r8d,0AAAAAAh;R=G=B=170 call [CreatePen] mov [hpen],rax mov edx,eax;hpen mov rcx,[hdc] call [SelectObject] mov [hPenOld],rax mov ecx,505050h;R=G=B=80 call [CreateSolidBrush] mov [hBrush],rax mov edx,eax;hBrush mov rcx,[hdc] call [SelectObject] mov [hBrushOld],rax mov rcx,[hdc] mov edx,half_of_width_of_watch-6 mov r8d,edx mov r9d,half_of_width_of_watch+6 mov [rbp-60h],r9;125 call [Ellipse] mov rcx,[hdc] mov rdx,[hBrushOld] call [SelectObject] mov rcx,[hBrush] call [DeleteObject] mov rcx,[hwnd] lea edx,[ps] call [EndPaint] wmBYE: leave retn endp ;----------------------------------------------- temp dd 0.10471975511965977461542144610932;(pi/180)*6=pi/30 =6 градусов в радианах temp2 dd 100 ; длина секундной стрелки _class TCHAR 'watch x64',0 section '.idata' import data readable writeable library ntdll,'ntdll.DLL',\ user32,'USER32.DLL',\ gdi32,'GDI32.DLL' import ntdll,\ RtlExitUserProcess,'RtlExitUserProcess',\ NtdllDefWindowProc,'NtdllDefWindowProc_A' import user32,\ BeginPaint,'BeginPaint',\ EndPaint,'EndPaint',\ RegisterClassEx,'RegisterClassExA',\ CreateWindowEx,'CreateWindowExA',\ DispatchMessage,'DispatchMessageA',\ GetMessage,'GetMessageA',\ InvalidateRect,'InvalidateRect',\ KillTimer,'KillTimer',\ SetTimer,'SetTimer' import gdi32,\ CreatePen,'CreatePen',\ CreateSolidBrush,'CreateSolidBrush',\ DeleteObject,'DeleteObject',\ Ellipse,'Ellipse',\ LineTo,'LineTo',\ MoveToEx,'MoveToEx',\ SelectObject,'SelectObject' Движение минутной и часовой стрелки добавишь по аналогии
Не компилируется: width_of_watch = 256 height_of_watch = width_of_watch half_of_width_of_watch = width_of_watch/2 half_height_of_watch = height_of_watch/2
пропущена буква "е" "width_of_watch = 256 height_of_watch = width_of_watch half_of_width_of_watch = width_of_watch/2 half_height_of_watch = height_of_watch/2"
Orbit, какую, какую стрелку? Чего там рассчитывать? Круг = 360 градусов. Каждую секунду стрелка поворачивается на 360/60=6 градусов. Переводишь градусы в радианы и добавляешь (pi/180)*6=pi/30=0.10471975511965977461542144610932 каждую секунду к переменной angle, вызываешь fsincos(angle), умножаешь длину стрелки на sin и на cos, выводишь на экран
Orbit, а в #24 не "исходничек" под fasm? даже минутная стрелка есть, добавь часовую стрелку и каждую секунду поворачивай минутную стрелку на 0,1 градуса (pi/1800=0,00174532925199432957692369076849), а часовую на 0,000029088820866572159615394846141477
Mikl___, http://www.purebasic.com/ Вин, лин и маки под обе разрядности и активный. При этом это очень мощный транслятор. Тоесть абстрактные выражения басик переводит в сурец асм и далее его собирает. Именно с этого думаю и стоит начинать новичку. Так он может крайне просто найти соответствие высоко абстрактным конструкциям, написав апп в десяток строк. Это хороший и годный путь. А с нуля что то собирать на асм и отлаживать - это сложный путь, при этом нужно немного учить огромного размера матчасть и находить в ней соотвествия.
А почему тем же самым, но не заниматься с компилятором Си? Васик очень неоднозначный язык, считаю изучение его бессмысленной тратой времени.