-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_main.c
More file actions
40 lines (35 loc) · 902 Bytes
/
Copy pathtest_main.c
File metadata and controls
40 lines (35 loc) · 902 Bytes
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
#include <assert.h>
#include <stdio.h>
#include "memtool.h"
process_id_t get_process_id() {
#ifdef PLATFORM_WINDOWS
return GetCurrentProcessId();
#else
return getpid();
#endif
}
void test_open_process() {
printf("Testing open_process...\n");
//grab own process id
process_id_t pid = get_process_id();
printf("PID: %d\n", pid);
ProcessHandle* handle = open_process(pid);
printf("Handle: %p\n", handle);
assert(handle != NULL);
close_process(handle);
}
void test_read_process_maps() {
printf("Testing read_process_maps...\n");
process_id_t pid = get_process_id();
printf("PID: %d\n", pid);
ProcessMap* map = read_process_maps(pid);
printf("Map: %p\n", map);
assert(map != NULL);
free(map);
}
int main() {
test_open_process();
test_read_process_maps();
printf("All tests passed!\n");
return 0;
}