summaryrefslogtreecommitdiff
path: root/emulate/emulate.cpp
diff options
context:
space:
mode:
authorDennis Brentjes <d.brentjes@gmail.com>2016-09-19 17:38:23 +0200
committerDennis Brentjes <d.brentjes@gmail.com>2016-10-04 22:18:23 +0200
commitc29ae7a65c636b8d1fa37c6589278dcdee97658f (patch)
treea0ad6583a1f954a179349e0b27d58d7c945c59b5 /emulate/emulate.cpp
parentabd5cfdd4a6c8e9979b2deb3c48304fb3d63a44c (diff)
downloadopenwar-c29ae7a65c636b8d1fa37c6589278dcdee97658f.tar.gz
openwar-c29ae7a65c636b8d1fa37c6589278dcdee97658f.tar.bz2
openwar-c29ae7a65c636b8d1fa37c6589278dcdee97658f.zip
Started working on a x86 emulator.
Diffstat (limited to 'emulate/emulate.cpp')
-rw-r--r--emulate/emulate.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/emulate/emulate.cpp b/emulate/emulate.cpp
new file mode 100644
index 0000000..4254dcf
--- /dev/null
+++ b/emulate/emulate.cpp
@@ -0,0 +1,51 @@
+
+#include "emulator.hpp"
+
+#include <boost/program_options.hpp>
+#include <boost/filesystem/path.hpp>
+#include <boost/filesystem/operations.hpp>
+
+int main(int argc, char* argv[]) {
+ boost::program_options::options_description description;
+ description.add_options()
+ ("help,h", "produces this help message")
+ ("exe,e", boost::program_options::value<std::string>(), "The LE executable to parse the header for.")
+ ;
+
+ boost::program_options::variables_map vm;
+ boost::program_options::store(boost::program_options::parse_command_line(argc, argv, description), vm);
+ boost::program_options::notify(vm);
+
+ if(vm.count("help")) {
+ std::cout << description << std::endl;
+ return 0;
+ }
+
+ boost::filesystem::path file_path;
+ if(vm.count("exe")) {
+ std::string exe_file = vm["exe"].as<std::string>();
+
+ if(boost::filesystem::exists(exe_file)) {
+ if(!boost::filesystem::is_directory(exe_file)) {
+ file_path = exe_file;
+ } else {
+ std::cerr << exe_file << " is a folder" << std::endl;
+ std::cerr << std::endl;
+ std::cerr << description << std::endl;
+ return -1;
+ }
+ } else {
+ std::cerr << "file: " << exe_file << " does not exist" << std::endl;
+ std::cerr << std::endl;
+ std::cerr << description << std::endl;
+ return -1;
+ }
+ } else {
+ std::cerr << "Option \"exe_file\" is required";
+ std::cerr << std::endl;
+ std::cerr << description << std::endl;
+ return -1;
+ }
+
+ emulate(file_path.string());
+} \ No newline at end of file