- 論壇徽章:
- 0
|
我來補充下。還有一種情況可以說也包括在LZ講的里面了,不過單獨再說下,也許更清楚。
下面這個程序也會產(chǎn)生SIGMENTATION FAULT- ioperm(0xc1da, 1,1);
- outw(3, 0xc1da);
復制代碼 為什么呢?因為IOPERM這里只允許了一個字節(jié)的讀寫,而在后面的OUTW中,企圖讀寫一個WORD。
22樓的情況也類似,CR3在用戶態(tài)是不允許訪問的。
注: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調(diào)試的時候,由于是用內(nèi)嵌匯編寫的代碼,GDB總是停在第一行MOVW的地方,搞得我郁悶了好久。最后總算發(fā)現(xiàn)是由于OUTW指令引起的 |
|