- 论坛徽章:
- 0
|
最近新学内核模块
我的代码如下:
- #define MODULE
- #define __KERNEL__
- #if CONFIG_MODVERSIONS==1
- #define MODVERSIONS
- #include <linux/modversions.h>
- #endif
- #include <linux/kernel.h>
- #include <linux/module.h>
- #include <asm/unistd.h>
- #include <sys/syscall.h>
- #define SYS_mkdir 39
- extern void* sys_call_table[];
- int (*orig_mkdir)(const char *path);
- int hacked_mkdir(const char *path)
- {
- /* printk("hello world\n"); */
- return 0;
- }
- int init_module(void)
- {
- orig_mkdir=sys_call_table[SYS_mkdir];
- sys_call_table[SYS_mkdir]=hacked_mkdir;
- return 0;
- }
- void cleanup_module(void)
- {
- sys_call_table[SYS_mkdir]=orig_mkdir;
- }
复制代码
INSMOD 就有错误,我是在LINUX2.6下做的,不对可是不知道怎么改
insmod hack.o
hack.o: unresolved symbol sys_call_table
hack.o:
Hint: You are trying to load a module without a GPL compatible license
and it has unresolved symbols. The module may be trying to access
GPLONLY symbols but the problem is more likely to be a coding or
user error. Contact the module supplier for assistance, only they
can help you. |
|