function overwrite 
Author Message
 function overwrite

Hi there,

is it possible to "overwrite" a function with another function, for
example overwrite printf() with printfOwn() (has the same parameters
as printf).

Maybe there's a tricky way with function pointers ???

        yours
        Herman



Sat, 17 Apr 1999 03:00:00 GMT  
 function overwrite

Quote:

>Hi there,
>is it possible to "overwrite" a function with another function, for
>example overwrite printf() with printfOwn() (has the same parameters
>as printf).

What about coding your own printf() and linking it to the code.
Some linkers will not try to link externals which are already
solved from the lib to the code, othere will. In the second case
you must otherwise you can extract the original printf() from
your lib and add your own printf() intead.

h.f.s.
--
Hans Friedrich Steffani
Institut fuer Elektrische Maschinen und Antriebe, TU Chemnitz-Zwickau

http://www.tu-chemnitz.de/~hfst/



Sun, 18 Apr 1999 03:00:00 GMT  
 function overwrite


Quote:

>is it possible to "overwrite" a function with another function, for
>example overwrite printf() with printfOwn() (has the same parameters
>as printf).

>Maybe there's a tricky way with function pointers ???

Maybe...  BUT there IS a SIMPLE way using the macro preprocessor:

#define printf  printfOwn

Then you can use the vprintf, vfprintf, vsprintf functions (maybe) to
ease your programming task in your printfOwn function...

NOTE:  I generally prefer to actually define the arguments in the macro
       but this is not practical for functions that take a variable
       number of arguments therefore we ONLY define the function name.

 _ __                      _    ,   _ _ _
' )  )     /         _/_  ' )  /   ' ) ) )
 /--' ____/___/> __  /     /--/     / / / __,_  __  o _   ______
/  \_(_) /_) (__/ (_<__   /  ( o   / ' (_(_) (_/ (_<_/_)_(_) / <_

Robert H. Morrison                Tel: +49 721 9628 167
Software Developer                Fax: +49 721 9628 261



Sun, 18 Apr 1999 03:00:00 GMT  
 function overwrite



Quote:
" writes:


>>is it possible to "overwrite" a function with another function, for
>>example overwrite printf() with printfOwn() (has the same parameters
>>as printf).

>>Maybe there's a tricky way with function pointers ???

>Maybe...  BUT there IS a SIMPLE way using the macro preprocessor:

>#define printf  printfOwn

That isn't guaranteed to work because stdio.h is allowed to define a
macro for printf.

#undef printf
#define printf  printfOwn

(do this after including stdio.h) should be safe.

--
-----------------------------------------


-----------------------------------------



Sun, 18 Apr 1999 03:00:00 GMT  
 function overwrite

Quote:

>is it possible to "overwrite" a function with another function, for
>example overwrite printf() with printfOwn() (has the same parameters
>as printf).

Herman,

   #define printf printfOwn at the top of your source file.

                                                        Chris Parker



Sun, 18 Apr 1999 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. function pointers, casting, call stack overwriting

2. function pointers, casting, call stack overwriting

3. memory overwrite on leaving function

4. Debugger shows function calls overwriting other variables data!

5. Securely overwriting files.

6. Linker error: Build does not overwrite referenced dll

7. to overwrite data in a text file

8. Can I overwrite the system macro?

9. Find and Replace, Not Find and Overwrite

10. How do i overwrite ValueType.ToString

11. need help with data overwrite problem.

12. Locate overwritten memory in MSVC++ 5???

 

 
Powered by phpBB® Forum Software