|
|
发表于 2006-1-3 14:41:49
|
显示全部楼层
[php]
#ifndef __KERNEL__
#define __KERNEL__
#endif
#ifndef MODULE
#define MODULE
#endif
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/unistd.h>
#include <linux/linkage.h>
#include <linux/syscalls.h>
#include <asm/current.h>
//extern void* sys_call_table[];
/*
* After version 2.4.18, the symbol sys_call_table is not exported,
* but you can get the address from the file System.map, Just like
* this `grep sys_call_table /boot/System.map'.
*/
void** sys_call_table = (void **)0xc03835c0;
long (*orig_mkdir)(const char *path, int mode);
asmlinkage long hacked_mkdir(const char *path, int mode)
{
struct task_struct *ts;
ts = current;
printk("sys_mkdir(%s, %d) is called by (uid = %d, pid = %d)\n",
path, mode, ts->uid, ts->pid);
return orig_mkdir(path, mode);
}
static int hacked_init(void)
{
orig_mkdir=sys_call_table[__NR_mkdir];
sys_call_table[__NR_mkdir]=hacked_mkdir;
return 0;
}
static void hacked_exit(void)
{
sys_call_table[__NR_mkdir]=orig_mkdir; /*set mkdir syscall to the origal
one*/
}
module_init(hacked_init);
module_exit(hacked_exit);
MODULE_LICENSE("GPL2");
MODULE_AUTHOR("xiaosuo@gmail.com");
[/php] |
|