-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtrick_kallysms.c
57 lines (50 loc) · 1.33 KB
/
trick_kallysms.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
* @file trick_kallysms.c
*
* I made a very nice trick :D see trick_kallysms.c module.
* After inserting export_symbols.c module I took the address
* of SOHAIB_CONUT symbol from /proc/kallsyms file, then
* I used it as a hard code in trick_kallysms.c :))
*
*/
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kdev_t.h>
#include <linux/fs.h>
#include <linux/cdev.h>
#include <linux/device.h>
extern int SOHAIB_CONUT;
void sohaib_shared_func(void);
static int __init smalinux_driver_init(void)
{
int * p;
/*
*
* You need to get the address of SOHAIB_CONUT from
* cat /proc/kallsyms | grep SOHAIB_
* and assign it to pointer p :))
* you could make it dynamically:
* p = &SOHAIB_CONUT;
*
* */
p = 0xffffffffc1a0f400; // p = &SOHAIB_CONUT;
*p = 500;
printk("use_symbols: module loaded!!");
sohaib_shared_func();
printk("sohaib_count: %d", SOHAIB_CONUT);
return 0;
}
static void __exit smalinux_driver_exit(void)
{
pr_info("use_symbols: module unloaded!!");
}
/**
* Definitions
*****************************************************/
module_init(smalinux_driver_init);
module_exit(smalinux_driver_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("smalinux <[email protected]>");
MODULE_DESCRIPTION("EXPORT_SYMBOL Driver - share some symbols");
MODULE_VERSION("1.2");