Well I have been playing around with frames now for about a couple of days and
I thought up an interesting question while I was driving home. Here is a normal
everyday function to move a window to a new position...
Where mainhwnd is defined globally in the data section. This is being called
(in template.asm) from WindowProc. The way I understand it, X is @ ebp+8,
and Y is at ebp+12. If WindowProc is defined as:
proc WindowProc, hwnd,wmsg,wparam,lparam
then is it possible to point further up using ebp and grab the hwnd thats
already on the stack? Something like this I would assume...
I realise this is perhaps a poor example and little to no gain can be had
in this case, but if this can be done I can see it reducing the amount of
gobals needed as most of them more than likely are already on the stack
somewhere anyways...
Maybe what I am trying to do will cause a stack overflow? Seems I have
heard that term from somewhere...
I thought up an interesting question while I was driving home. Here is a normal
everyday function to move a window to a new position...
MoveWindow:
; params
virtual at ebp+8
.arg1 dd ?
.arg2 dd ?
X equ .arg1
Y equ .arg2
end virtual
enter 0, 0
; main
invoke SetWindowPos, [mainhwnd], 0, [X], [Y], 0, 0, SWP_NOSIZE
; end main
leave
retn 8
Where mainhwnd is defined globally in the data section. This is being called
(in template.asm) from WindowProc. The way I understand it, X is @ ebp+8,
and Y is at ebp+12. If WindowProc is defined as:
proc WindowProc, hwnd,wmsg,wparam,lparam
then is it possible to point further up using ebp and grab the hwnd thats
already on the stack? Something like this I would assume...
MoveWindow:
; params
virtual at ebp+8
.arg1 dd ?
.arg2 dd ?
.padding rb 12
.prevhwnd dd ?
X equ .arg1
Y equ .arg2
hwnd equ .prevhwnd
end virtual
enter 0, 0
; main
invoke SetWindowPos, [hwnd], 0, [X], [Y], 0, 0, SWP_NOSIZE
; end main
leave
retn 8
I realise this is perhaps a poor example and little to no gain can be had
in this case, but if this can be done I can see it reducing the amount of
gobals needed as most of them more than likely are already on the stack
somewhere anyways...
Maybe what I am trying to do will cause a stack overflow? Seems I have
heard that term from somewhere...
You cannot cause the stack overflow when you are just reading the stack. Overflow would occur only when you push too much on it.