Linux论坛's Archiver

《开源》旗舰电子杂志2009年第1期火热下载!

ygmok8088 发表于 2008-8-27 11:14

截获linux 2.4.20-8 系统调用函数write时死机,高手请帮忙解决一下

截获linux 2.4.20-8 系统调用函数write时死机,高手请帮忙解决一下
把write换成mkdir就一切正常,且mkdir就成了空操作
源码:
#ifndef MODULE
  #define MODULE
#endif
#ifndef __KERNEL__
  #define __KERNEL__
#endif
#include <linux/module.h>
#include <linux/kernel.h>
#include <asm/unistd.h>
#include <sys/syscall.h>
#include <linux/types.h>
#include <linux/dirent.h>
#include <linux/string.h>
#include <linux/fs.h>

MODULE_LICENSE("GPL");


int **sys_call_table=(int **)0xc030a0f0; /*sys_call_table is exported, so we can access it*/
static unsigned long orig_write;//(int fd,char * buf,size_t count);


int hacked_write(int fd,char * buf,size_t count)
{

return 0; /*everything is ok, but he new systemcall does nothing*/
}
int init_module(void) /*module setup*/
{
orig_write=sys_call_table[SYS_write];
sys_call_table[SYS_write]=hacked_write;
return 0;
}
void cleanup_module(void) /*module shutdown*/
{
sys_call_table[SYS_write]=orig_write; /*set mkdir syscall to the origal one*/
}

页: [1]

Powered by Discuz! Archiver 7.0.0  © 2001-2009 Comsenz Inc.