-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
66 lines (57 loc) · 1.38 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
66
#define MEW_NOTUSE_THROWS
#include <iostream>
#include "mewall.h"
#include "virtual.hpp"
#if defined(_WIN32)
#include <windows.h>
#include <libloaderapi.h>
#endif
// #include <stdafx.h>
#include <iostream>
using namespace std;
#if _WIN32_WINNT < 0x0500
#undef _WIN32_WINNT
#define _WIN32_WINNT 0x0500
#endif
#ifdef _WIN32
#include <windows.h>
#include "Wincon.h"
#endif
#define HELP_PAGE \
"Usage:\n" \
"> ./nanvm <path/to/file>\n" \
"Flags:\n" \
"-h, --help\t\tShow this help page\n"
int main(int argc, char** argv) {
mew::args __args(argc, argv);
__args.normalize();
// __args.print();
if (
!__args.has_needs(1) ||
__args.has("-h") ||
__args.has("--help")
) {
printf(HELP_PAGE); exit(0);
}
// auto libs = __args.getStartsWith("-L");
// mew::stack<mew::_dll_hinstance, 8U> hdlls;
// for (int i = 0; i < libs.size(); i++) {
// hdlls.push(mew::LoadDll(libs.at(i)));
// }
const char* path = __args.getNextPath();
MewUserAssert(mew::is_exists(path),"path is not exsist");
Virtual::VirtualMachine vm;
Virtual::Code* code = Virtual::Code_LoadFromFile(path);
// vm.hdlls = hdlls;
int exit_code = Virtual::Execute(vm, *code);
#ifdef _WIN32
HWND consoleWnd = GetConsoleWindow();
DWORD dwProcessId;
GetWindowThreadProcessId(consoleWnd, &dwProcessId);
if (GetCurrentProcessId()==dwProcessId) {
printf("\n");
system("pause");
}
#endif
return exit_code;
}