Chinaunix首页 | 论坛 | 博客
  • 博客访问: 5760350
  • 博文数量: 675
  • 博客积分: 20301
  • 博客等级: 上将
  • 技术积分: 7671
  • 用 户 组: 普通用户
  • 注册时间: 2005-12-31 16:15
文章分类

全部博文(675)

文章存档

2012年(1)

2011年(20)

2010年(14)

2009年(63)

2008年(118)

2007年(141)

2006年(318)

分类: LINUX

2008-01-17 18:10:28

sales are assholes, engineers are dicks. assholes always ask dicks to do dirty things, when it's done, assholes are happy, while engineers are covered with shit all over them.

sale: "please modify this driver, make it not work on other OS."
me: "why?"
after 0.1 second...
me: "i see."
me: "where is the source code?"
sale: "no source code"
me: "i cannot modify the binary without the source code."
sale: "can you just hide the driver somewhere?"
me: "they will find it anyway."
sale: "anyway, i just want it tomorrow."
me: "OK, let me think what i can do."

OK, basic knowledge of linking and ELF is not totally useless. here is how to do that:

support the original driver is foo.ko,

1. rename the __this_module to something else (e.g. __THIS_module)

2. write some code to replace the original __this_module symbol:

struct module __this_module
__attribute__((section(".gnu.linkonce.this_module"))) = {
.name = __stringify(KBUILD_MODNAME),
.init = new_module_init,
.exit = cleanup_module,
};

3. in new_module_init(), check if OS is ours, if NOT, puke. otherwise, call the original module_init():

static int is_ax(void)
{
        if (strstr(system_utsname.release, "AX") == NULL)
                return 0;
        else
                return 1;
}

static int new_module_init(void)
{
        int err = -1;
        if (is_ax())
                err = original_init();
        return err;
}

4. link foo.ko with the code generated in step 2 and 3. build a new driver module.

that's it. simple and evil.

when you dive deep into technical issues, the notion of ethic simply disappears, so you wont go crazy.

阅读(2350) | 评论(3) | 转发(1) |
0

上一篇:linux forward的实现

下一篇:atoi()的问题

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

tekkamanninja2011-10-24 15:36:58

这种要求对于sales来说很正常,但是engineer会觉得很恶心。
但是sales考虑的是利益,天经地义,没有钱就养不起engineers

但是这种技术方法值得参考~~~

chinaunix网友2008-04-11 13:11:36

考,太恶心了

chinaunix网友2008-04-11 13:11:36

考,太恶心了