-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dispatcher.cpp
98 lines (80 loc) · 2 KB
/
Dispatcher.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//
// Created by hx1997 on 2018/3/7.
//
#include <cstdio>
#include <windows.h>
#include "RBoxInit.h"
#include "RBoxMessage.h"
#include "RBoxRun.h"
// Forward declarations
int DisplayMenu();
int RoutineRun();
int RoutineStop();
int RoutineOptions();
int RoutineExit();
Sandbox *box;
int DispatchRoutineEntry() {
// Display banner
printf("\t\t=========================\r\n");
printf("\t\tRightsBox Control\r\n");
printf("\t\tReleased by hx1997 under the MIT License, 2018\r\n");
printf("\t\t=========================\r\n");
printf("\r\n");
// Initialize
if (!(box = InitRightsBox()))
return -1;
// Display menu
BOOL bDontDisplayMenu = FALSE;
while (!bDontDisplayMenu) {
bDontDisplayMenu = DisplayMenu();
}
// Destroy Sandbox object
delete box;
return 0;
}
int DisplayMenu() {
// Menu
printf("\r\nMenu:\r\n");
printf("1.\tRun a program sandboxed\r\n");
printf("2.\tRun as...\r\n");
printf("3.\tStop sandbox\r\n");
printf("4.\tOptions\r\n");
printf("5.\tExit\r\n");
printf("Choose the action you want: ");
// Wait for input
WCHAR szChoice[5] = {};
_getws_s(szChoice, 5);
// Do action
if (lstrcmpW(szChoice, L"1") == 0) {
RoutineRun();
} else if (lstrcmpW(szChoice, L"2") == 0) {
//DisplayRunAsMenu();
} else if (lstrcmpW(szChoice, L"3") == 0) {
RoutineStop();
} else if (lstrcmpW(szChoice, L"4") == 0) {
RoutineOptions();
} else if (lstrcmpW(szChoice, L"5") == 0) {
RoutineExit();
return -1;
} else {
IssueMessage("Invalid command!", MSGTYPE_ERROR);
}
return 0;
}
int RoutineRun() {
int ret;
ret = (ERROR_SUCCESS != box->RunSandboxed(L"E:\\Dropbox\\Programs\\RightsBox\\bin\\RBStart.exe", true));
return ret;
}
int RoutineStop() {
box->StopSandbox();
return 0;
}
int RoutineOptions() {
//return ConfigSandbox();
return 0;
}
int RoutineExit() {
//int ret = StopSandbox();
return 0;
}