Hi

I think that I have a dirty solution (but I must worn you that I am a programmer, not a Linux expert) - add global pointer to a function (the type of the function should be the type of the function you want to call). A more elegant way (and more complicated) would be to use non global pointer.
- initialize that pointer to NULL
- in the original function check the pointer, if it is not null call the function pointed by the pointer - on loading your new function, change the global pointer to the function address (now you can also change the function or remove it by manipulating the pointer)

Have fun
Shahar
_____________________________________________________________________________________________

I am looking for old Vinyl record.
If you have any that you don't need please send me mail to [EMAIL PROTECTED]

Thanks
Shahar

----- Original Message ----- From: "Tzahi Fadida" <[EMAIL PROTECTED]>
To: "Baruch Even" <[EMAIL PROTECTED]>
Cc: "Linux-IL" <linux-il@linux.org.il>
Sent: Wednesday, February 21, 2007 14:46
Subject: Re: Decorating a kernel function


On Wednesday 21 February 2007 08:19, Baruch Even wrote:
* Tzahi Fadida <[EMAIL PROTECTED]> [070221 02:38]:
I'm not aware of a way to do what you ask (redirect the function to you
and be able to call it), you can however look at kprobe which is part of
the kernel. kprobe allows you to stick trap points into the kernel and
be called at that point, I don't remember the exact name but they have a
method to stick the probe at the end of the function (and also at the
beginning or arbitrary location).

I've used this method to trace methods and it's fairly expensive since
it uses int3 trap points to do its work but if performance is not
critical for you it should be fine.

kprobe is what i was looking for. Actually, jprobe so i cal also view the
function parameters i am attaching to. The problem is that kprobe does not
appear on the uml(user mode linux) list in menuconfig which probably means it
is not supported there. -> i need to compile a real kernel or use vmware or
something like that. I prefer to continue to use uml.
Let's say i do wish to change the kernel code. How do i add a code that will
refer to my module once it is loaded? I.e. i wish to add a stub in that
function in the kernel that will call a function in my module if it is up.


Baruch

--
Regards,
Tzahi.
--
Tzahi Fadida
Blog: http://tzahi.blogsite.org | Home Site: http://tzahi.webhop.info
WARNING TO SPAMMERS: see at
http://members.lycos.co.uk/my2nis/spamwarning.html

======================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]


=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to