-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLicenceLoader.cpp
More file actions
73 lines (60 loc) · 2.4 KB
/
LicenceLoader.cpp
File metadata and controls
73 lines (60 loc) · 2.4 KB
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
#include "stdafx.h"
#include "LicenceLoader.h"
#define LICENCE_PATH L"DreamVR\\Preferences\\licenses.txt"
std::string LicenceLoader::licence = "";
void LicenceLoader::Initialize() {
TryLoadLicence();
if(LicenceLoader::licence == "") {
Console::Y(L"Please setup licence.");
while(true) {
Console::Y(L"Checking for licence changes in 5 seconds...");
Sleep(5000);
LicenceLoader::TryLoadLicence();
if(LicenceLoader::licence != "") {
break;
}
if(!Console::IsOpen()) {
exit(0);
}
}
}
Console::G(L"Found potential licence. Continuing...");
}
void LicenceLoader::TryLoadLicence() {
if(!Utils::fileExists(LICENCE_PATH))
return;
std::ifstream infile(LICENCE_PATH);
if(infile.good()) {
std::string sLine;
std::getline(infile, sLine);
licence = sLine;
}
infile.close();
if(licence.length() != 19 || licence[4] != '-' || licence[9] != '-' || licence[14] != '-') {
Console::Y(L"Provided licence doesn't seem valid, please fix it.");
Console::Y(L"Licence should match the following pattern: XXXX-XXXX-XXXX-XXXX");
licence = "";
}
}
std::string LicenceLoader::MakeLicenceJSON() {
//std::string serialNumber = ProcUtils::GetValue("wmic baseboard get serialnumber");
//std::string cpuName = ProcUtils::GetValue("wmic cpu get name");
//std::string cpuId = ProcUtils::GetValue("wmic cpu get ProcessorId");
//std::string windowsUniqueID = ProcUtils::GetValue("wmic csproduct get UUID");
//std::string computerName = ProcUtils::GetValue("wmic computersystem get name");
//std::string computerModel = ProcUtils::GetValue("wmic computersystem get model");
std::string json = "";
json += "{";
//json += "\"MotherBoardSerial\": \"" + serialNumber + "\"" + ",";
//json += "\"WindowsUniqueID\": \"" + windowsUniqueID + "\"" + ",";
//json += "\"ProcessorName\": \"" + cpuName + "\"" + ",";
//json += "\"ProcessorID\": \"" + cpuId + "\"" + ",";
//json += "\"ComputerName\": \"" + computerName + "\"" + ",";
//json += "\"ComputerUniqueID\": \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\",";
////json += "\"ComputerUniqueID\": \"" + "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + "\"" + ",";
json += "\"Licence\": \"" + licence + "\"";
json += "}";
//ConsoleUtils::Log(json.c_str());
//ConsoleUtils::Log(computerModel.c_str());
return json;
}