来看看,这段程序错在哪!!
.386
.model flat, stdcall
option casemap:none
;/////////////////////////////////////////////////
;包含文件
include windows.inc
include kernel32.inc
include gdi32.inc
include user32.inc
includelib kernel32.lib
includelib gdi32.lib
includelib user32.lib
;/////////////////////////////////////////////////
;定义资源
DLG_MAIN equ 1h
ICO_MAIN equ 1h
IDC_SHOWCOORDINATE equ 1001h
IDC_ALLOW equ 1002h
IDC_TOP equ 1003h
IDC_EXIT equ 1004h
;/////////////////////////////////////////////////
.data?
hInstance dd ?
hWindowDc dd ?
.const
szFormat db "pos:%d,%d ", 0
;/////////////////////////////////////////////////
.code
_ProcMain proc uses bx esi ebx hWnd, uMsg, wParam, lParam
local @szContent[1024]:byte
.if uMsg == WM_CLOSE
invoke EndDialog, hWnd, NULL
.elseif uMsg == WM_INITDIALOG
invoke LoadIcon, hInstance, ICO_MAIN
invoke SendMessage, hWnd, WM_SETICON, ICON_BIG, eax
.elseif uMsg == WM_COMMAND
mov eax, wParam
.if ax == IDC_ALLOW
;//未补充
.elseif ax == IDC_TOP
invoke IsDlgButtonChecked, hWnd, IDC_TOP
.if eax == BST_CHECKED
invoke SetWindowPos, hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE
.else
invoke SetWindowPos, hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE
.endif
.elseif ax == IDC_EXIT
invoke EndDialog, hWnd, NULL
.endif
.elseif uMsg == WM_MOUSEMOVE
mov eax, lParam
mov bx, ax
shr eax, 16
invoke wsprintf, addr @szContent, addr szFormat, ax, eax
invoke MessageBox, NULL, addr @szContent, addr @szContent, MB_OK
; invoke GetDC, NULL
; mov hWindowDc, eax
; invoke TextOut, hWindowDc, ax, bx,
.else
mov eax, FALSE
ret
.endif
mov eax, TRUE
ret
_ProcMain endp
start:
invoke GetModuleHandle, NULL
mov hInstance, eax
invoke DialogBoxParam, hInstance, DLG_MAIN, NULL, offset _ProcMain, NULL
invoke ExitProcess, NULL
;/////////////////////////////////////////////////
end start
这段程序目的是要输出地址,但是X可行,而Y却异常,好像是是地址。
如果我这样写
invoke wsprintf, addr @szContent, offset szFormat, ax
invoke MessageBox, NULL, addr @szContent, addr @szContent, MB_OK
invoke wsprintf, addr @szContent, offset szFormat, eax
invoke MessageBox, NULL, addr @szContent, addr @szContent, MB_OK
此时eax 又好像输出正常,真搞不懂这是为什么。!