structkprobe { structhlist_nodehlist; /* list of kprobes for multi-handler support */ structlist_headlist; /*count the number of times this probe was temporarily disarmed */ unsignedlong nmissed; /* location of the probe point */ kprobe_opcode_t *addr; // hook函数的地址,需要hook中途指令才使用这个,一般都用symbol_name /* Allow user to indicate symbol name of the probe point */ constchar *symbol_name; //符号名 要Hook的内核函数 /* Offset into the symbol */ unsignedint offset; /* Called before addr is executed. */ kprobe_pre_handler_t pre_handler; //hook函数调用时触发 /* Called after addr is executed, unless... */ kprobe_post_handler_t post_handler; //hook函数调用后触发,注意,在这里修改返回值也没用,需要用kretprobe /* * ... called if executing addr causes a fault (eg. page fault). * Return 1 if it handled fault, otherwise kernel will see it. */ kprobe_fault_handler_t fault_handler; //执行失败时触发 /* * ... called if breakpoint trap occurs in probe handler. * Return 1 if it handled break, otherwise kernel will see it. */ kprobe_break_handler_t break_handler; //断点时触发 /* Saved opcode (which has been replaced with breakpoint) */ kprobe_opcode_t opcode; //保存的hook前原始指令 /* copy of the original instruction */ structarch_specific_insnainsn; /* * Indicates various status flags. * Protected by kprobe_mutex after this kprobe is registered. */ u32 flags; };