获得系统调用表卡死

     #include <linux/module.h>

    #include <linux/kernel.h>


    // 中断描述符表寄存器结构

    struct

    {

    unsigned short limit;

    unsigned int base;

    } __attribute__((packed)) idtr;



    // 中断描述符表结构

    struct

    {

    unsigned short off1;

    unsigned short sel;

    unsigned char none, flags;

    unsigned short off2;

    } __attribute__((packed)) idt;


    // 查找sys_call_table的地址

    void disp_sys_call_table(void)

    {

    unsigned int sys_call_off;

    unsigned int sys_call_table;

    char* p;

    int i;


    // 获取中断描述符表寄存器的地址

    asm("sidt %0":"=m"(idtr));

    printk("addr of idtr: %x\n", &idtr);


    // 获取0x80中断处理程序的地址

    memcpy(&idt, idtr.base+8*0x80, sizeof(idt));

    sys_call_off=((idt.off2<<16)|idt.off1);

    printk("addr of idt 0x80: %x\n", sys_call_off);


    // 从0x80中断服务例程中搜索sys_call_table的地址

    p=sys_call_off;

    for (i=0; i<100; i++)

    {

    if (p=='\xff' && p[i+1]=='\x14' && p[i+2]=='\x85')

    {

    sys_call_table=*(unsigned int*)(p+i+3);

    printk("addr of sys_call_table: %x\n", sys_call_table);

    return ;

    }

    }

    }


    // 模块载入时被调用

    static int __init init_get_sys_call_table(void)

    {

    disp_sys_call_table();

    return 0;

    }


    module_init(init_get_sys_call_table);


    // 模块卸载时被调用

    static void __exit exit_get_sys_call_table(void)

    {

    }


    module_exit(exit_get_sys_call_table);
 

 直接卡死 一样

 

https://blog.csdn.net/weixin_34273479/article/details/94255496

 

posted on 2021-04-09 11:37  lydstory  阅读(66)  评论(0)    收藏  举报

导航