Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1134081
  • 博文数量: 221
  • 博客积分: 10152
  • 博客等级: 上将
  • 技术积分: 1518
  • 用 户 组: 普通用户
  • 注册时间: 2005-07-22 10:42
文章分类

全部博文(221)

文章存档

2018年(1)

2015年(6)

2014年(3)

2013年(4)

2012年(1)

2011年(5)

2010年(14)

2009年(10)

2008年(28)

2007年(33)

2006年(114)

2005年(2)

我的朋友

分类: LINUX

2006-10-23 15:54:28

#include
#include
#include
#include

DECLARE_MUTEX(test_lock);

MODULE_LICENSE("GPL");

static char old_code[5];
static char ret_code[] = {0xE9,0x00,0x00,0x00,0x00};//jmp 到我们的代码

void (*old_free_module)(struct module *mod);

void my_free_module(struct module *mod)
{
 down(&test_lock);
 memcpy(old_free_module,old_code,5);
 printk("no,i do't want to free module %s\n",mod->name);
 old_free_module(mod);
 memcpy(old_free_module,ret_code,5);
 up(&test_lock);
}
int test_init(void)
{
 long *p = &ret_code[1];
 long offset;
 old_free_module = kallsyms_lookup_name("free_module");
 if(!old_free_module)
  return -1;
 
 offset = my_free_module - old_free_module;
 if(offset>0)
  *p = offset - 5;

 printk("%lx\n",*p);
 memcpy(old_code,old_free_module,5);
 memcpy(old_free_module,ret_code,5);
 return 0;
}
void test_exit(void)
{
 memcpy(old_free_module,old_code,5);
}
module_init(test_init);
module_exit(test_exit);
阅读(1415) | 评论(0) | 转发(0) |
0

上一篇:core 文件

下一篇:Linux下的多线程编程

给主人留下些什么吧!~~