请教--截获系统调用
时间:2003-04-17
来源:互联网
我的内核模块很简单,就是截获mkdir系统调用,在创建目录之前打印出系统调用号,编译通过了,可是执行时出错,错误信息如下:
test.o:unresolved symbol sys_call_table
test.o:
Hint:You are trying to load a module without a GPL compatible license and it has unresolved symbols.Contact the module supplier for assistance only they can help you.
我的源代码如下,请高手给于指点,谢谢了!我很急!!!
#define MODULE
#define __KERNEL__
#include <linux/module.h>
#include <linux/kernel.h>
#include <asm/unistd.h>
#include <linux/string.h>
#include <linux/fs.h>
#include <linux/slab.h>
extern void *sys_call_table[];
int (*old_mkdir)(const char *path);
int hacked_mkdir(const char *path)
{
printk("This is a hacked program!-->syscall number isd\n",__NR_mkdir);
return old_mkdir(path);
}
int init_module(void)
{
old_mkdir=sys_call_table[sys_mkdir];
sys_call_table[sys_mkdir]=(void *)hacked_mkdir;
return 0;
}
void cleanup_module(void)
{
sys_call_table[sys_mkdir]=(void *)old_mkdir;
}
test.o:unresolved symbol sys_call_table
test.o:
Hint:You are trying to load a module without a GPL compatible license and it has unresolved symbols.Contact the module supplier for assistance only they can help you.
我的源代码如下,请高手给于指点,谢谢了!我很急!!!
#define MODULE
#define __KERNEL__
#include <linux/module.h>
#include <linux/kernel.h>
#include <asm/unistd.h>
#include <linux/string.h>
#include <linux/fs.h>
#include <linux/slab.h>
extern void *sys_call_table[];
int (*old_mkdir)(const char *path);
int hacked_mkdir(const char *path)
{
printk("This is a hacked program!-->syscall number isd\n",__NR_mkdir);
return old_mkdir(path);
}
int init_module(void)
{
old_mkdir=sys_call_table[sys_mkdir];
sys_call_table[sys_mkdir]=(void *)hacked_mkdir;
return 0;
}
void cleanup_module(void)
{
sys_call_table[sys_mkdir]=(void *)old_mkdir;
}
作者: bhlyy1976 发布时间: 2003-04-17
add MODULE_LICENSE("GPL"); at the end of u .c file
作者: cheungming 发布时间: 2003-04-30
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#ifndef __KERNEL__
#define __KERNEL__
#endif
#ifndef MODULE
#define MODULE
#endif
/* SAME TO U
extern void* sys_call_table[];
int (*orig_system)(const char *path);
int find_system(const char *path)
{
return 0;
}
int init_module(void)
{
orig_system=sys_call_table[SYS_system];
sys_call_table[SYS_system]=find_system;
return 0;
}
void cleanup_module(void)
{
sys_call_table[SYS_system]=orig_system;
}
---------------
照这个例子来做!
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#ifndef __KERNEL__
#define __KERNEL__
#endif
#ifndef MODULE
#define MODULE
#endif
/* SAME TO U
extern void* sys_call_table[];
int (*orig_system)(const char *path);
int find_system(const char *path)
{
return 0;
}
int init_module(void)
{
orig_system=sys_call_table[SYS_system];
sys_call_table[SYS_system]=find_system;
return 0;
}
void cleanup_module(void)
{
sys_call_table[SYS_system]=orig_system;
}
---------------
照这个例子来做!
作者: ZeroC 发布时间: 2003-05-10
hehe
作者: keenor 发布时间: 2003-05-10
不是抄, 我已经说了,是参考的, 要不,你写一个给我们学习学习 OK?
作者: ZeroC 发布时间: 2003-05-10
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28