免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2117 | 回复: 3
打印 上一主题 下一主题

[FreeBSD] NULL和AUE_NULL的问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-03-22 18:46 |只看该作者 |倒序浏览
我从ROOTKIT那本书上抄的代码,sc_example那个例子。
  1. #include <sys/types.h>
  2. #include <sys/param.h>
  3. #include <sys/proc.h>
  4. #include <sys/module.h>
  5. #include <sys/sysent.h>
  6. #include <sys/kernel.h>
  7. #include <sys/systm.h>

  8. /* The system call's arguments. */
  9. /* 系统调用的参数. */

  10. struct sc_example_args {
  11.         char *str;
  12. };

  13. /* The system call function. */
  14. /* 系统调用函数. */
  15. static int
  16. sc_example(struct thread *td, void *syscall_args)
  17. {
  18.         struct sc_example_args *uap;
  19.         uap = (struct sc_example_args *)syscall_args;

  20.         printf("%s\n", uap->str);

  21.         return(0);
  22. }

  23. /* The sysent for the new system call. */
  24. /* 为新的系统调用准备的sysent结构. */
  25. static struct sysent sc_example_sysent = {
  26.         1,                         /* number of arguments */
  27.         sc_example                 /* implementing function */
  28. };

  29. /* The offset in sysent[] where the system call is to be allocated. */
  30. /* 系统调用在sysent[]中所处的偏移量. */
  31. static int offset = NO_SYSCALL;

  32. /* The function called at load/unload. */
  33. /* 装载/卸载阶段调用的函数. */
  34. static int
  35. load(struct module *module, int cmd, void *arg)
  36. {
  37.         int error = 0;

  38.         switch (cmd) {
  39.                 case MOD_LOAD:
  40.                 uprintf("System call loaded at offset %d.\n", offset);
  41.                 break;

  42.         case MOD_UNLOAD:
  43.                 uprintf("System call unloaded from offset %d.\n", offset);
  44.                 break;

  45.         default:
  46.                 error = EOPNOTSUPP;
  47.                 break;
  48.         }

  49.         return(error);
  50. }

  51. 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 编辑 ]

论坛徽章:
2
亥猪
日期:2014-03-19 16:36:35午马
日期:2014-11-23 23:48:46
2 [报告]
发表于 2008-03-22 19:57 |只看该作者
星期1在来看 :wink:

论坛徽章:
0
3 [报告]
发表于 2008-03-22 20:17 |只看该作者
谢谢g大叔

论坛徽章:
2
射手座
日期:2014-02-23 22:37:05技术图书徽章
日期:2014-04-26 15:36:27
4 [报告]
发表于 2013-01-27 11:45 |只看该作者
回复 2# gvim


    = = 版主   同问这个问题
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP