#include <linux/module.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/syscalls.h>
#include <linux/kallsyms.h>


int kallsymcall(void *data , const char *namebuff, struct module *mu,unsigned long address)
{
    printk("name=%s address=%p\n",namebuff,(void*)address);
    return 0;
}

static int __init  hello_init(void)
{
    //内核函数来查找导出符号信息
   (void)kallsyms_on_each_symbol(kallsymcall,NULL);


   return 0;
}


static void __exit hello_exit(void)
{
    return;
}
module_init(hello_init);
module_exit(hello_exit);

MODULE_LICENSE("GPL");


/*********************************************Makefile**********************************/

PWD = $(shell pwd)
VERSION = $(shell uname -r)
KPATH = /lib/modules/$(VERSION)/build
obj-m := init.o

default:
        make -C  $(KPATH) SUBDIRS=$(PWD) modules        

clean:
        make -C  $(KPATH) SUBDIRS=$(PWD) clean

Logo

更多推荐