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.
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.
I can't see anything wrong in this code. Perhaps you're not handling the messages correctly.
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
...
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
...
Try using:
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.
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.
Thanks:) It's really easier and useful :)
Yeah nice one Syn.
Yea, if you plan on doing this for 64-bit change 8 to 48 and EBP/ESP to RBP/RSP
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.
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.