- 论坛徽章:
- 0
|
我从ROOTKIT那本书上抄的代码,sc_example那个例子。
- #include <sys/types.h>
- #include <sys/param.h>
- #include <sys/proc.h>
- #include <sys/module.h>
- #include <sys/sysent.h>
- #include <sys/kernel.h>
- #include <sys/systm.h>
- /* The system call's arguments. */
- /* 系统调用的参数. */
- struct sc_example_args {
- char *str;
- };
- /* The system call function. */
- /* 系统调用函数. */
- static int
- sc_example(struct thread *td, void *syscall_args)
- {
- struct sc_example_args *uap;
- uap = (struct sc_example_args *)syscall_args;
- printf("%s\n", uap->str);
- return(0);
- }
- /* The sysent for the new system call. */
- /* 为新的系统调用准备的sysent结构. */
- static struct sysent sc_example_sysent = {
- 1, /* number of arguments */
- sc_example /* implementing function */
- };
- /* The offset in sysent[] where the system call is to be allocated. */
- /* 系统调用在sysent[]中所处的偏移量. */
- static int offset = NO_SYSCALL;
- /* The function called at load/unload. */
- /* 装载/卸载阶段调用的函数. */
- static int
- load(struct module *module, int cmd, void *arg)
- {
- int error = 0;
- switch (cmd) {
- case MOD_LOAD:
- uprintf("System call loaded at offset %d.\n", offset);
- break;
- case MOD_UNLOAD:
- uprintf("System call unloaded from offset %d.\n", offset);
- break;
- default:
- error = EOPNOTSUPP;
- break;
- }
- return(error);
- }
- SYSCALL_MODULE(sc_example, &offset, &sc_example_sysent, load, NULL);
复制代码
最后这个NULL,编译的时候说AUE_NULL未定义。
自己定义一个,#define NULL 0,编译的时候说NULL重定义了,AUE_NULL未定义。
find /usr/include -type f -name "*.h" -exec grep -H "#define[[:space:]]\+NULL" {} \;
找到了一个文件,sys/_null.h,包含之后,编译,还是说AUE_NULL未定义。
find /usr/include -type f -name "*.h" -exec grep -H "#define[[:space:]]\+AUE_NULL" {} \;
找到bsm/audit_kevent.h,加上,没问题。
自己定义一个AUE_NULL,没问题了。
为什么呢?为什么NULL非要是AUE_NULL才行呢?谁知道给讲讲吧。
[ 本帖最后由 prolj 于 2008-3-22 18:49 编辑 ] |
|