forked from Jiang-Night/Kernel_driver_hack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess.c
More file actions
50 lines (42 loc) · 1.09 KB
/
Copy pathprocess.c
File metadata and controls
50 lines (42 loc) · 1.09 KB
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
#include "process.h"
#include <linux/sched.h>
#include <linux/module.h>
#include <linux/tty.h>
#include <linux/mm.h>
#include <linux/version.h>
#define ARC_PATH_MAX 256
extern struct mm_struct *get_task_mm(struct task_struct *task);
#if(LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 61))
extern void mmput(struct mm_struct *);
#endif
uintptr_t get_module_base(pid_t pid, char* name)
{
struct pid* pid_struct;
struct task_struct* task;
struct mm_struct* mm;
struct vm_area_struct *vma;
pid_struct = find_get_pid(pid);
if (!pid_struct) {
return false;
}
task = get_pid_task(pid_struct, PIDTYPE_PID);
if (!task) {
return false;
}
mm = get_task_mm(task);
if (!mm) {
return false;
}
mmput(mm);
for (vma = mm->mmap; vma; vma = vma->vm_next) {
char buf[ARC_PATH_MAX];
char *path_nm = "";
if (vma->vm_file) {
path_nm = file_path(vma->vm_file, buf, ARC_PATH_MAX-1);
if (!strcmp(kbasename(path_nm), name)) {
return vma->vm_start;
}
}
}
return 0;
}