Skip to content

Commit 6cf289e

Browse files
committed
symbol lookup
1 parent e9d8201 commit 6cf289e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

module/procowner.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ int (*xlate)(const char *name, struct proc_dir_entry **ret, const char **residua
1111
struct proc_dir_entry* (*subdir_find)(struct proc_dir_entry *dir, const char *name, unsigned int len);
1212
void* subdir_lock;
1313
const char *(*syms_lookup)(unsigned long addr, unsigned long *symbolsize, unsigned long *offset, char **modname, char *namebuf);
14+
int (*symbol_name)(unsigned long addr, char *symname);
1415

1516
struct proc_dir_entry {
1617
unsigned int low_ino;
@@ -59,6 +60,8 @@ static void get_owner(const char* fname) {
5960
printk(KERN_INFO MOD "Name: %s, proc fops: %p\n", de->name, de->proc_fops);
6061
tmpstr = syms_lookup((size_t)(de->proc_fops), &symbolsize, &offset, &modname, namebuf);
6162
printk(KERN_INFO MOD "Modname: %s\n", modname);
63+
symbol_name((size_t)(de->proc_fops), namebuf);
64+
printk(KERN_INFO MOD "Symbol: %s\n", namebuf);
6265
}
6366
spin_unlock(subdir_lock);
6467

@@ -68,7 +71,7 @@ static void get_owner(const char* fname) {
6871
// ----------------------------------------------------------------------------------------------------------
6972
static int proc_read(struct seq_file *m, void *v) {
7073
seq_printf(m, "test\n");
71-
get_owner("uptime");
74+
get_owner("kallsyms");
7275

7376
return 0;
7477
}
@@ -112,6 +115,11 @@ static int __init procowner_init(void)
112115
printk(KERN_INFO MOD "kallsyms_lookup not found!\n");
113116
return -ENODEV;
114117
}
118+
symbol_name = kallsyms_lookup_name("lookup_symbol_name");
119+
if(!symbol_name) {
120+
printk(KERN_INFO MOD "lookup_symbol_name not found!\n");
121+
return -ENODEV;
122+
}
115123

116124
return 0;
117125
}

0 commit comments

Comments
 (0)