mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* reg: kprobe method
@ 2007-05-31 12:35 Tej Parkash
  0 siblings, 0 replies; only message in thread
From: Tej Parkash @ 2007-05-31 12:35 UTC (permalink / raw)
  To: linux-kernel

hi all

there is some problem in adding simple printk using kprobe method

i m posting the my code anybody can suggest how to make it work

#include<linux/kernel.h>
#include<linux/version.h>
#include<linux/module.h>
#include<linux/init.h>
#include<linux/kprobes.h>
#include<linux/kallsyms.h>

MODULE_AUTHOR("TEJ");
MODULE_LICENSE("GPL");
//MODULE_PARM(int,val,I_IRUGO);

struct kprobe kp;
static int handler_pre(struct kprobe *p, struct pt_regs *regs)
{
 printk("my name is tej parkash dhiman");
        return 0;
}


void handler_post(struct kprobe *p, struct pt_regs *regs, unsigned long flags)
{
        printk("mast hai na tej ash ker");
}

static int init_mod(void)
{

struct kprobe kp;
kp.post_handler=handler_post;
kp.pre_handler=handler_pre;

kp.addr = (kprobe_opcode_t *) 0xc0278e50; //add for __sock_create

if(kp.addr== NULL) {
                printk("kallsyms_lookup_name could not find address
for the specified symbol name\n");
                return 0;
                    }

register_kprobe(&kp);
printk("Module is inserted");
return 0;
}
void exit_mod(void)
{
unregister_kprobe(&kp);
printk("module is removed");
}
module_init(init_mod);
module_exit(exit_mod);

thanks
TEJ

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-05-31 12:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-31 12:35 reg: kprobe method Tej Parkash

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®