🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.os.ms-windows.programming.mfc
1 messages
1 total messages Started by Joseph Boctor Fri, 11 Aug 2000 00:00
Hook functions, or change function pointers/code
#1
Author: Joseph Boctor
Date: Fri, 11 Aug 2000 00:00
32 lines
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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads