Linux使用者空間擷取系統調用表地址(1)

來源:互聯網
上載者:User

一、代碼及實現

一)使用者空間原始碼

#include

#include

#include

#include

#include

#include

#include

#include

#include

#define CALLOFF 100 //讀取100位元組

struct {

unsigned short limit;

unsigned int base;

} __attribute__ ((packed)) idtr;  //這個結構表示IDTR寄存器,這個寄存器中儲存中斷描述符表 的地址

struct {

unsigned short off1;

unsigned short sel;

unsigned char none,flags;

unsigned short off2;

} __attribute__ ((packed)) idt;  //中斷描述符表中的內容:中斷門描述符

unsigned int old_readkmem (int fd, void * buf,size_t off,unsigned int size) //用read方式讀取kmem中一定長度內容

{

if (lseek64(fd, (unsigned long long)off,SEEK_SET)!=off)

{

perror("fd lseek error");

return 0;

}

if (read(fd, buf,size)!=size)

{

perror("fd read error");

return 0;

}

}

unsigned long readkmem (int fd, void * buf, size_t off, unsigned int size)//用mmap方式從kmem中讀取一定長度內容

{

size_t  moff, roff;

size_t   sz = getpagesize();

char * kmap;

unsigned long ret_old = old_readkmem(fd, buf, off, size); //先用老方法讀取,不行再用mmap


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.