1. cat /boot/System.map | grep modules
Get the address of modules symbol from system.map file. modules symbol points to a list_head structure, which is the head of double- and circular- linked list of all the modules.
2. take a look at linux-src/include/linux/module.h
struct module {}
contains all the useful information about module structure
3. Here is code in kernel module to print out all the module names.
static int hello_init(void)
{
printk("start list all the modules\n");
// Get this magic address from system.map
struct list_head * module_h = (struct list_head*) 0xc06e1880;
int count = 100;
struct list_head *list_h = module_h->next;
struct module *m;
while(count--)
{
if(list_h == module_h)
break;
m = list_entry(list_h, struct module, list);
printk("name: %s\n", m->name);
list_h = list_h->next;
}
printk("count is %d\n", count);
printk("\nhello, world\n");
return 0;
}
No comments:
Post a Comment