Jump to content

Intercept dynamic library methods with LD PRELOAD: Difference between revisions

m
no edit summary
mNo edit summary
mNo edit summary
 
Line 1: Line 1:
=Introduction=
==Introduction==
Let's say you have a binary called 'main' which was compiled against a shared memory 'libprint1.so', which has a method called print_msg() which prints 'hello from print1'. This looks like this
Let's say you have a binary called 'main' which was compiled against a shared memory 'libprint1.so', which has a method called print_msg() which prints 'hello from print1'. This looks like this


main.c
===main.c===
<syntaxhighlight lang="C" >
<syntaxhighlight lang="C" >
#include "print.h"
#include "print.h"
Line 13: Line 13:
</syntaxhighlight>
</syntaxhighlight>


print.h
===print.h===
<syntaxhighlight lang="C" >
<syntaxhighlight lang="C" >
#ifndef RR_PRINT_H
#ifndef RR_PRINT_H
Line 26: Line 26:
</syntaxhighlight>
</syntaxhighlight>


print1.c
===print1.c===
<syntaxhighlight lang="C" >
<syntaxhighlight lang="C" >
#include "print.h"
#include "print.h"
Line 51: Line 51:
Let's change the message of print_msg()  
Let's change the message of print_msg()  


print2.c
===print2.c===
<syntaxhighlight lang="C" >
<syntaxhighlight lang="C" >
#include "print.h"
#include "print.h"
Cookies help us deliver our services. By using our services, you agree to our use of cookies.