Article View: comp.os.ms-windows.programming.mfc
Article #1Hook functions, or change function pointers/code
From: Joseph Boctor
Date: Fri, 11 Aug 2000 00:00
Date: Fri, 11 Aug 2000 00:00
32 lines
2249 bytes
2249 bytes
Hi All!
THIS IS VERY URGENT PLEASE HELP
I have two function, I want to hook one function to the other.
ie
func1(); // would actually go to func1()
func2(); // would also go to func2()
// hooking function is called
hook(func1, func2);
func1(); // would go to func1();
func2(); // ***** now would go to func1() as well
unhook();
func1(); // would again go to func1()
func2(); // would go to func2()
now the code that have works in debug mode in vc++ 6, but when I try to
execute it, it gives an access violation error.
I basically make a point to the function code of both functions
( BYTE * lpfunc1 = (BYTE *)func1;
BYTE * lpfunc2 = (BYTE *)func2; )
now I go to change the begining of the function by adding a assembly jmp
instruction to func2.
( *((BYTE *) lpfunc1 + 0) = 0x66;
*((DWORD *) lpfunc1 + 4) = *lpfunc2; )
it works perfect in debug mode and when I try to run the executable, it
doesn't work at all.
Please let me know if I am doing something wrong, or if you have any idea
about another way of doing this.
Thanx a lot
THIS IS VERY URGENT PLEASE HELP
Joe
Technical Details
Message-ID:
<iOXk5.10118$c5.509442@news2.rdc1.on.home.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 100b1c,a107c7141dc4f396,start X-Google-Attributes: gid100b1c,public X-Google-Thread: fccee,a107c7141dc4f396,start X-Google-Attributes: gidfccee,public X-Google-Thread: fa859,a107c7141dc4f396,start X-Google-Attributes: gidfa859,public X-Google-Thread: 10461f,a107c7141dc4f396,start X-Google-Attributes: gid10461f,public X-Google-Thread: 10015c,a107c7141dc4f396,start X-Google-Attributes: gid10015c,public From: "Joseph Boctor" <boctorj@hotmail.com> Subject: Hook functions, or change function pointers/code Date: 2000/08/11 Message-ID: <iOXk5.10118$c5.509442@news2.rdc1.on.home.com> X-Deja-AN: 657257561 X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 X-Complaints-To: abuse@home.net X-Trace: news2.rdc1.on.home.com 966019342 24.42.7.203 (Fri, 11 Aug 2000 11:42:22 PDT) Organization: Excite@Home - The Leader in Broadband X-MSMail-Priority: Normal NNTP-Posting-Date: Fri, 11 Aug 2000 11:42:22 PDT Newsgroups: comp.os.ms-windows.programming.mfc,fido.win32,fido7.inter.win32,microsoft.public.win32,microsoft.public.win32.programmer