forked from a0rtega/pafish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vbox.c
159 lines (143 loc) · 4.06 KB
/
vbox.c
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#include <windows.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include "vbox.h"
int vbox_reg_key1() {
HKEY regkey;
LONG retu;
char value[1024];
int i;
DWORD size;
size = sizeof(value);
retu = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "HARDWARE\\DEVICEMAP\\Scsi\\Scsi Port 0\\Scsi Bus 0\\Target Id 0\\Logical Unit Id 0", 0, KEY_READ, ®key);
if (retu == ERROR_SUCCESS) {
retu = RegQueryValueEx(regkey, "Identifier", NULL, NULL, (BYTE*)value, &size);
if (retu == ERROR_SUCCESS) {
for (i = 0; i < strlen(value); i++) { /* case-insensitive */
value[i] = toupper(value[i]);
}
if (strstr(value, "VBOX") != NULL) {
return 0;
}
else {
return 1;
}
}
else {
return 1;
}
}
else {
return 1;
}
}
int vbox_reg_key2() {
HKEY regkey;
LONG retu;
char value[1024];
int i;
DWORD size;
size = sizeof(value);
retu = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "HARDWARE\\Description\\System", 0, KEY_READ, ®key);
if (retu == ERROR_SUCCESS) {
retu = RegQueryValueEx(regkey, "SystemBiosVersion", NULL, NULL, (BYTE*)value, &size);
if (retu == ERROR_SUCCESS) {
for (i = 0; i < strlen(value); i++) { /* case-insensitive */
value[i] = toupper(value[i]);
}
if (strstr(value, "VBOX") != NULL) {
return 0;
}
else {
return 1;
}
}
else {
return 1;
}
}
else {
return 1;
}
}
int vbox_reg_key3() {
HKEY regkey;
LONG retu;
retu = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Oracle\\VirtualBox Guest Additions", 0, KEY_READ, ®key);
if (retu == ERROR_SUCCESS) {
return 0;
}
else {
return 1;
}
}
int vbox_reg_key4() {
HKEY regkey;
LONG retu;
char value[1024];
int i;
DWORD size;
size = sizeof(value);
retu = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "HARDWARE\\Description\\System", 0, KEY_READ, ®key);
if (retu == ERROR_SUCCESS) {
retu = RegQueryValueEx(regkey, "VideoBiosVersion", NULL, NULL, (BYTE*)value, &size);
if (retu == ERROR_SUCCESS) {
for (i = 0; i < strlen(value); i++) { /* case-insensitive */
value[i] = toupper(value[i]);
}
if (strstr(value, "VIRTUALBOX") != NULL) {
return 0;
}
else {
return 1;
}
}
else {
return 1;
}
}
else {
return 1;
}
}
int vbox_reg_key5(){
HKEY regkey;
LONG retu;
char dwValue[1024];
DWORD dwSize;
DWORD lpcMaxSubKeyLen;
int dwIndex;
retu = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall", 0, KEY_READ, ®key);
if( retu == ERROR_SUCCESS){
DWORD dwSize = sizeof(dwValue);
RegQueryInfoKey(regkey,NULL,NULL,NULL,&lpcMaxSubKeyLen,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
for(dwIndex=0; dwIndex< lpcMaxSubKeyLen; dwIndex++){
dwSize = sizeof(dwValue);
retu = RegEnumKeyEx(regkey,dwIndex,dwValue,&dwSize,NULL,NULL,NULL,NULL);
if( retu == ERROR_SUCCESS){
if (strstr(CharUpper(dwValue),"VIRTUALBOX") != NULL){
return 0;
}
}
else {
return 1;
}
}
RegCloseKey(regkey);
}
else {
return 1;
}
}
int vbox_sysfile1() {
DWORD ret;
ret = GetFileAttributes("C:\\WINDOWS\\system32\\drivers\\VBoxMouse.sys");
//printf("Debug: %s \n", ret);
if (ret != INVALID_FILE_ATTRIBUTES) {
return 0;
}
else {
return 1;
}
}