我有这个简单程序的示例代码,它检查鼠标位置,写下X和Y坐标,并检查鼠标左键是否按下。
.386
.model flat, stdcall
option casemap :none
include bones.inc
.code
start:
invoke GetModuleHandle, NULL
mov hInstance, eax
invoke InitCommonControls
invoke DialogBoxParam, hInstance, IDD_MAIN, 0, offset DlgProc, 0
invoke ExitProcess, eax
DlgProc proc hWin:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
mov eax,uMsg
.if eax == WM_INITDIALOG
.elseif eax == WM_LBUTTONDOWN ; when left button is down
invoke SetDlgItemText, hWin, 1001, addr Msg1
.elseif eax == WM_LBUTTONUP ; when left button is up
invoke SetDlgItemText, hWin, 1001, addr Msg2
.elseif eax == WM_MOUSEMOVE
xor ecx, ecx ; clear ecx register
mov cx, WORD PTR lParam ; copy low-word of lParam to cx <---- this is line that is bothering me
invoke SetDlgItemInt, hWin, 1002, ecx, FALSE ; set integer in control
xor ecx, ecx ; zerujemy rejestr ecx
mov cx, WORD PTR lParam+2 ; copy high-word of lParam to cx <--- this line is bothering me as well
invoke SetDlgItemInt, hWin, 1003, ecx, FALSE ; set integer in control
.elseif eax == WM_CLOSE
invoke EndDialog, hWin, 0
.endif
xor eax,eax
ret
DlgProc endp
end start
1) 这行到底是什么:MOV-CX,WORD-PTR-SS:[EBP+14]?
2) 那么,在我的屏幕截图中,如果EBP值是(0001 1001 1111 1011 1011 0000)(19FBB0h)是低字(0000 0000 0001 1001)和高字(1111 1011 1011 0000)?如果不是,我该怎么学习?
4) 为什么选择mov cx,文字PTR LPRAM+2?这个+2困扰着我。如果lParam是DWORD(32位),为什么偏移量是+2?是否应该是+16才能获得高单词?
提前谢谢你
include windows.inc
include user32.inc
include kernel32.inc
include comctl32.inc ;windows common controls
includelib user32.lib
includelib kernel32.lib
includelib comctl32.lib ;windows common controls
DlgProc PROTO :DWORD,:DWORD,:DWORD,:DWORD
.const
IDD_MAIN equ 1000
.data
Msg1 db "Lewy przycisk myszy jest wciÅniÄty",0
Msg2 db "Lewy przycisk myszy jest zwolniony",0
.data?
hInstance dd ?