contributed by < ChunYoLin >
實驗平台
| CPU | Distro | Kernel | 
|---|---|---|
| i7-6700 | Ubuntu 21.04-LTS | 5.11.0-25-generic | 
interface使用character device 作為介面, device_write parse使用者輸入, 針對add做hide_process, del做unhide_process
init_hookinit_hook 初始化ftrace_hook成員, 主要利用 kallsyms_lookup_name 找到 find_ge_pid 並寫入hook的成員orig pointer.
hook_installkallsyms_lookup_name 去assign orig pointer, 不太理解為何需要再做一次, 這裡多了error handling, init_hook 的assign或許可以不需要.hook_install 初始化ftrace_ops, ftrace_ops的成員func為此ftrace的callback function, 這裡將 hook_ftrace_thunk assign給他.ftrace_set_filter_ip 使得hook->ops only be called from function of hook->addressIf a callback is only to be called from specific functions, a filter must be set up. The filters are added by name, or ip if it is known.
register_ftrace_function to enable hook->ops, 若失敗使用 ftrace_set_filter_ip將remove parameter設成1來回復先前的註冊hook_ftrace_thunkhook_find_ge_pid instead of original find_ge_pid.hook_find_ge_pidjj