I have this problem, this code crashes as soon as it gets mouse focus, the crash occurs when I process the WM_MOUSEMOVE, if I remove the "Bug Code" the program runns ok (no crash).
I can't figure out why it crashes (except it has something to do with and edi), it only now it crashes when I try to read the value of to edi and the window has the mouseover it.

The red code is an attempt to mov to edi, via eax. When I used this instead of the first blue code line the computer crashed hard (Black Screen of Death with a dark stripe on the top of the screen). I tried to run it twice and the same crash occured...

[size=9][COLOR=#404040]...[/COLOR]

proc WndProc, hWnd,uMsg,wParam,lParam
hdc dd ?
ps PAINTSTRUCT
hfont dd ?
enter
mov eax, [uMsg]
cmp eax, WM_DESTROY
jne @F
[COLOR=#404040]...[/COLOR]
jmp WndProcEnd
@@: cmp eax, WM_PAINT
jne @F
[COLOR=#404040]...[/COLOR]
jmp WndProcEnd
@@:
; <!> Bug Code Starts Here <!>
cmp eax, WM_MOUSEMOVE
jne @F
;xPos = LOWORD(lParam); // horizontal position of cursor
;yPos = HIWORD(lParam); // vertical position of cursor
mov eax, [lParam]
movzx ebx, ax ; ebx = Xpos
shr eax, 16 ; eax = Ypos


[COLOR=red][b]; These lines must never ever be uncommented!!!
; my PC crashed twice when I tried to run those two lines:
;...........xchg eax, edi
;...........mov eax, [Ypos]
;...........xchg eax, edi[/B][/COLOR]

[COLOR=blue]
mov edi, [Ypos] ; <-- OllyDbg says it's here it crashes when uncommented, and it just crashes here
mov esi, [Xpos]
mov [Ypos], eax
mov [Xpos], ebx
[/COLOR]
invoke GetDC,[hWnd]
mov ebx, eax

;mov dword [hDCCC], eax
;call DrawArrow ; call an arrow-drawing function

invoke ReleaseDC, [hWnd], ebx

mov [Ypos], edi
mov [Xpos], esi

jmp WndProcEnd
; <!> Bug Code Ends Here <!>
@@: ; .else
invoke DefWindowProc, [hWnd],[uMsg],[wParam],[lParam]
return
WndProcEnd: ; .endif
xor eax,eax
return
;------------------------------------------------------------------------
section '.data' data readable writeable
Xpos dd 50+75
Ypos dd 50+50-1
[COLOR=#404040]...[/COLOR]
[/SIZE]
Posted on 2002-12-07 14:05:04 by scientica
You have to preserve ebx esi edi:
...

proc WndProc, hWnd,uMsg,wParam,lParam
hdc dd ?
ps PAINTSTRUCT
hfont dd ?
enter
mov eax, [uMsg]
cmp eax, WM_DESTROY
jne @F
...
jmp WndProcEnd
@@: cmp eax, WM_PAINT
jne @F
...
jmp WndProcEnd
@@:
; <!> Bug Code Starts Here <!>
cmp eax, WM_MOUSEMOVE
jne @F
push ebx
push esi
push edi
;xPos = LOWORD(lParam); // horizontal position of cursor
;yPos = HIWORD(lParam); // vertical position of cursor
mov eax, [lParam]
movzx ebx, ax ; ebx = Xpos
shr eax, 16 ; eax = Ypos


; These lines must never ever be uncommented!!!
; my PC crashed twice when I tried to run those two lines:
;...........xchg eax, edi
;...........mov eax, [Ypos]
;...........xchg eax, edi


mov edi, [Ypos] ; <-- OllyDbg says it's here it crashes when uncommented, and it just crashes here
mov esi, [Xpos]
mov [Ypos], eax
mov [Xpos], ebx

invoke GetDC,[hWnd]
mov ebx, eax

;mov dword [hDCCC], eax
;call DrawArrow ; call an arrow-drawing function

invoke ReleaseDC, [hWnd], ebx

mov [Ypos], edi
mov [Xpos], esi
pop edi
pop esi
pop ebx
jmp WndProcEnd
; <!> Bug Code Ends Here <!>
@@: ; .else
invoke DefWindowProc, [hWnd],[uMsg],[wParam],[lParam]
return
WndProcEnd: ; .endif
xor eax,eax
return
;------------------------------------------------------------------------
section '.data' data readable writeable
Xpos dd 50+75
Ypos dd 50+50-1
...
Posted on 2002-12-07 14:28:25 by comrade
Ok, that solved it. Thaks comrade!

Why didn't I see that? :o :stupid:
Posted on 2002-12-08 05:52:18 by scientica