1

当我编译这个文件时,它会抛出以下错误。

kit.c: In function ‘hide_pid’://rootkit.c:109:9: error: assignment of member ‘readdir’ in read-only kit.c:
In function ‘restore’ 127
error: assignment of member ‘readdir’ in read-only object

有人知道为什么吗?

int hide_pid(readdir_t *orig_readdir, readdir_t new_readdir)
{
        struct file *filep;

        /*open /proc */
        if((filep = filp_open("/proc",O_RDONLY,0))==NULL)
        {
                return -1;
        }
        /*store proc's readdir*/
        if(orig_readdir)
                *orig_readdir = filep->f_op->readdir;

        /*set proc's readdir to new_readdir*/ //ERROR IN THE LINE BELOW
        filep->f_op->readdir=new_readdir;

        filp_close(filep,0);

        return 0;
}


int restore (readdir_t orig_readdir)
{
        struct file *filep;

        /*open /proc */
if ((filep = filp_open("/proc", O_RDONLY, 0)) == NULL) {
                return -1;
        }

        /*restore /proc's readdir*/ //ERROR BELOW
        filep->f_op->readdir = orig_readdir;

        filp_close(filep, 0);

        return 0;
}
4

1 回答 1

2

定义 ops 向量 (f_op) 的结构可能在其 readdir 字段的定义中使用了 const - 也可能是所有其他字段。设置自己的操作向量比替换现有操作向量中的一两个方法要正常得多。

于 2013-05-01T02:54:14.340 回答