The MASM Forum Archive 2004 to 2012

General Forums => The Laboratory => Topic started by: alpha on December 24, 2004, 01:46:02 PM

Title: subclass procedure
Post by: alpha on December 24, 2004, 01:46:02 PM
i know that this is not very important but i am just curious if it can be done

LRESULT APIENTRY newproc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp){
     return CallWindowProc(oldproc, hwnd, msg, wp, lp);
}


this works in asm

oldproc dd 0

newproc:
push [esp+16]
push [esp+16]
push [esp+16]
push [esp+16]
push oldproc
call _imp__CallWindowProcA@20
ret 16


trying to reuse the params instead of pushing them again..where is wrong?

nproc:
mov eax,oldproc
mov ecx,[esp]
mov oldproc,ecx
mov [esp],eax
call _imp__CallWindowProcA@20
sub esp,4
mov eax,oproc
mov [esp],eax
ret
Title: Re: subclass procedure
Post by: hutch-- on December 24, 2004, 07:55:40 PM
I have seen it done by jumping to the API procedure name but its dangerous code. With the jump, you do not alter the stack parameters where if you use CALL you change the stack pointer (ESP).