reg: kprobe method

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux