[<prev] [next>] [day] [month] [year] [list]
Message-ID: <2bd9ebfa0705310535j412f11f4tfd2b44a5a4d04cfc@mail.gmail.com>
Date: Thu, 31 May 2007 18:05:34 +0530
From: "Tej Parkash" <tejparkash.d@...il.com>
To: linux-kernel@...r.kernel.org
Subject: reg: kprobe method
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 majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists