首页 > 其他 > 详细

获得系统调用表卡死

时间:2021-04-09 12:35:06      阅读:15      评论:0      收藏:0      [点我收藏+]
     #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

 

获得系统调用表卡死

原文:https://www.cnblogs.com/hshy/p/14636443.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!