diff --git a/samples/kprobes/kprobe_example.c b/samples/kprobes/kprobe_example.c index ebf5e0c..f0ce4e6 100644 --- a/samples/kprobes/kprobe_example.c +++ b/samples/kprobes/kprobe_example.c @@ -13,11 +13,17 @@ #include #include #include +#include + +static char func_name[NAME_MAX] = "do_fork"; +module_param_string(func, func_name, NAME_MAX, S_IRUGO); +MODULE_PARM_DESC(func, "Function to kprobe"); + +static unsigned int offset; +module_param(offset, uint, S_IRUGO); /* For each probe you need to allocate a kprobe structure */ -static struct kprobe kp = { - .symbol_name = "do_fork", -}; +static struct kprobe kp; /* kprobe pre_handler: called just before the probed instruction is executed */ static int handler_pre(struct kprobe *p, struct pt_regs *regs) @@ -76,6 +82,8 @@ static int handler_fault(struct kprobe *p, struct pt_regs *regs, int trapnr) static int __init kprobe_init(void) { int ret; + kp.symbol_name = func_name; + kp.offset = offset; kp.pre_handler = handler_pre; kp.post_handler = handler_post; kp.fault_handler = handler_fault;