- 论坛徽章:
- 0
|
我来补充下。还有一种情况可以说也包括在LZ讲的里面了,不过单独再说下,也许更清楚。
下面这个程序也会产生SIGMENTATION FAULT- ioperm(0xc1da, 1,1);
- outw(3, 0xc1da);
复制代码 为什么呢?因为IOPERM这里只允许了一个字节的读写,而在后面的OUTW中,企图读写一个WORD。
22楼的情况也类似,CR3在用户态是不允许访问的。
注:IOPERM 的说明
int ioperm(unsigned long from, unsigned long num, int turn_on);
Description
Ioperm sets the port access permission bits for the process for num bytes starting from port address from to the value turn_on. The use of ioperm() requires root privileges.
PS:我用GDB调试的时候,由于是用内嵌汇编写的代码,GDB总是停在第一行MOVW的地方,搞得我郁闷了好久。最后总算发现是由于OUTW指令引起的 |
|