+ -
当前位置:首页 → 问答吧 → 请教--截获系统调用

请教--截获系统调用

时间: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;
}

作者: 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;

}

---------------


照这个例子来做!

作者: ZeroC   发布时间: 2003-05-10

hehe

作者: keenor   发布时间: 2003-05-10

不是抄, 我已经说了,是参考的, 要不,你写一个给我们学习学习 OK?

作者: ZeroC   发布时间: 2003-05-10

热门下载

更多