forked from Jiang-Night/Kernel_driver_hack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
executable file
·55 lines (46 loc) · 1.05 KB
/
main.cpp
File metadata and controls
executable file
·55 lines (46 loc) · 1.05 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
51
52
53
54
55
#include <unistd.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <time.h>
#include "driver.hpp"
uint64_t get_tick_count64()
{
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return (ts.tv_sec * 1000 + ts.tv_nsec / (1000 * 1000));
}
pid_t get_name_pid(char *name)
{
FILE *fp;
pid_t pid;
char cmd[0x100] = "pidof ";
strcat(cmd, name);
fp = popen(cmd, "r");
fscanf(fp, "%d", &pid);
pclose(fp);
return pid;
}
int main(int argc, char const *argv[])
{
uintptr_t base = 0;
uint64_t result = 0;
char module_name[0x100] = "libunity.so";
pid_t pid = get_name_pid((char *)"com.tencent.tmgp.sgame");
printf("pid = %d\n", pid);
driver->initialize(pid);
base = driver->get_module_base(module_name);
printf("base = %lx\n", base);
{
size_t number = 1;
uint64_t now = get_tick_count64();
for (size_t i = 0; i < number; i++)
{
result = driver->read<uint64_t>(base);
}
printf("Read %ld times cost = %lfs\n", number,
(double)(get_tick_count64() - now) / 1000);
}
printf("result = %lx\n", result);
return 0;
}