Hi !
First of all I wish you a Merry Christmas !  :)

I have a main window and a child control (EditBox). I want handle the EditBox's messages but I can't.
When the user presses ENTER in the EditBox a "Hello" message should appear.

push dword GWL_WNDPROC
push dword
call
mov , eax
; Subclassing
push EditWndProc
push dword GWL_WNDPROC
push dword
call

I think the problem is, that I don't give correctly the address of the new WNDPROC.
Can someone write down how should I call the SetWindowLongA WinAPI function ?
Thanks in advance.
Posted on 2008-12-26 07:56:05 by Robby
I can't see anything wrong in this code. Perhaps you're not handling the messages correctly.
Posted on 2008-12-26 09:41:52 by ti_mo_n
Now it calls the new WNDPROC. But from this new WNDPROC I can't get the message. I don't know in which address is it.

MessageBuffer dd 0,0,0,0,0,0,0

...

MessagePumpStart:
push dword 0
push dword 0
push dword 0;
push dword MessageBuffer
call
or eax,eax
jz WM_QUIT_received
push dword MessageBuffer
call
push dword MessageBuffer
call
jmp MessagePumpStart


WM_QUIT_received:
push dword 0
call

...

EditWndProc:
cmp dword ,WM_KEYUP          ; MSGmsg equ 4, +4 is required because of the pushed EIP
jne tryDestroy

...
Posted on 2008-12-26 10:15:13 by Robby
Try using:

EditWndProc:
STRUC EditWndProcArgs
.hWnd RESD 1
.uMsg RESD 1
.wParam RESD 1
.lParam RESD 1
ENDSTRUC
PUSH EBP
MOV EBP, ESP
CMP DWORD , WM_KEYUP
JNE tryDestroy

; ... All your code for EditWndProc here ...

LEAVE
RET


It's an easier to read method of doing procedures in NASM that I tend to suggest for people starting out that don't want to use the NASMX project.
Posted on 2008-12-30 20:44:59 by Synfire
Thanks:) It's really easier and useful :)
Posted on 2008-12-31 01:59:34 by Robby
Yeah nice one Syn.
Posted on 2008-12-31 22:16:27 by Homer
Yea, if you plan on doing this for 64-bit change 8 to 48 and EBP/ESP to RBP/RSP

MyProc:
STRUC MyProcArgs
.arga RESD 1
.argb RESD 1
ENDSTRUC
PUSH RBP
MOV RBP, RSP
MOV EAX, DWORD
; ....


Same method can be used for working with local variables, just replace the + between the EBP/RBP and 8/48 to a - to access the local data. eg.

P.S.
Fixed the above code. I put STRUC after the identifier when I first typed it out, it's correct now.
Posted on 2009-01-01 20:56:05 by Synfire