This repository has been archived by the owner on Aug 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
57 lines (54 loc) · 2.16 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
#include <iostream>
#include "cxxopts.hpp"
#include "SymbolsReader.h"
#include "UserFile.h"
std::string getFileByArg(const cxxopts::ParseResult &r, const char *arg) {
return r[arg].as<std::string>();
}
int main(int argc, char *argv[]) {
cxxopts::Options options("tdh", "trapdoor develop helper");
options.add_options()
//input file
("s,sym", "input symbol files", cxxopts::value<std::string>())
("p,pdb", "input pdb file", cxxopts::value<std::string>())
("j,json", "input json file", cxxopts::value<std::string>())
("u,user", "input json file", cxxopts::value<std::string>())
//function
("h,help", "helpe info")
("d,dump", "dump symbol file from pdb")
("e,export", "export json file from symbol file")
("c,check", "check json file according to the json and the sym file")
("g,generate", "generate C++ header file from json");
auto result = options.parse(argc, argv);
if (result.count("d")) {
auto pdbFile = result["p"].as<std::string>();
auto symFile = result["s"].as<std::string>();
const std::string command = "cvdump -headers -p " + pdbFile + " > " + symFile;
return system(command.c_str());
} else if (result.count("e")) {
auto symFile = result["s"].as<std::string>();
auto jsonFile = result["j"].as<std::string>();
SymbolsReader reader;
reader.InitFromCvdump(symFile);
reader.Save(jsonFile);
return 0;
} else if (result.count("c")) {
auto userFile = result["u"].as<std::string>();
auto jsonFile = result["j"].as<std::string>();
SymbolsReader reader;
reader.Load(jsonFile);
UserFile uFile(userFile);
uFile.checkExist(reader);
return 0;
} else if (result.count("g")) {
auto userFile = result["u"].as<std::string>();
auto jsonFile = result["j"].as<std::string>();
SymbolsReader reader;
reader.Load(jsonFile);
UserFile uFile(userFile);
uFile.geneteCppHeader(reader);
} else if (result.count("h")) {
std::cout << options.help();
}
return 0;
}