-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.cpp
65 lines (61 loc) · 1.48 KB
/
main.cpp
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
59
60
61
62
63
64
65
#include "Core/ProcessManager.h"
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <elf.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <stdint.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string>
//[TODO]: Move the argparse & options section to its own file & add docs
struct Options{
bool help = false;
//change to (int)verbosity level in future if project becomes too big
bool verbose = false;
int process_id = -1;
bool scan = false;
bool info = true;
};
//[TODO] : Add docs
Options argparse(int argc, char **argv){
Options args;
for (int i=1; i<argc; i++){
if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")){
args.help = true;
break;
}
if(!strcmp(argv[i], "-v") || !strcmp(argv[i], "--verbose")){
args.verbose = true;
continue;
}
if( !strcmp(argv[i], "-p")){
if(argc < i+2) {
printf("No process ID specified!");
break;
}
else {
args.process_id = std::stoi(argv[i+1]);
continue;
}
}
//[TODO] : Add more options as the project improves
}
return args;
}
int main(int argc, char **argv){
if (argc<2){
printf("Read docs doofus! Try with -h or --help\n");
return 0;
}
Options args = argparse(argc, argv);
if(args.help){
printf("Usage :\n\tmilf [options] -p [PID_of_process]\nOptions :\n\t-v : Verbose output\n");
}
if(args.process_id != -1){
ProcessManager manager = ProcessManager(args.process_id);
}
printf("[TODO] : Perform the actions specified based on the args.\n");
}