|
1 | 1 | #include <Windows.h>
|
2 | 2 | #include <powerbase.h>
|
3 | 3 | #include <tbs.h>
|
| 4 | +#include <intrin.h> |
4 | 5 | #include <string>
|
5 | 6 | #include <iostream>
|
6 | 7 | #include <fstream>
|
@@ -118,7 +119,7 @@ int main(int, char* argv[])
|
118 | 119 | std::cout << "S Mode check passed!" << std::endl;
|
119 | 120 | }
|
120 | 121 |
|
121 |
| - // 1 Ghz, 64-bit, dual core CPU |
| 122 | + // 1 Ghz, 64-bit, dual core, known CPU |
122 | 123 | {
|
123 | 124 | std::cout << "CPU checking..." << std::endl;
|
124 | 125 |
|
@@ -190,16 +191,65 @@ int main(int, char* argv[])
|
190 | 191 | nSpeedCheckCounter++;
|
191 | 192 | }
|
192 | 193 | }
|
| 194 | + HeapFree(hProcHeap, 0, lpBuffer); |
193 | 195 |
|
194 | 196 | if (nSpeedCheckCounter < 2)
|
195 | 197 | {
|
196 |
| - HeapFree(hProcHeap, 0, lpBuffer); |
197 | 198 | std::cerr << "System processor speed is less than minimum requirement!" << std::endl;
|
198 | 199 | std::system("PAUSE");
|
199 | 200 | return EXIT_FAILURE;
|
200 | 201 | }
|
201 | 202 |
|
202 |
| - HeapFree(hProcHeap, 0, lpBuffer); |
| 203 | + const auto dwRevision = sysInfo.wProcessorRevision >> 8; |
| 204 | + const auto byRevision = LOBYTE(sysInfo.wProcessorRevision); |
| 205 | + |
| 206 | + int CPUIDINF[4]{ 0 }; |
| 207 | + __cpuid(CPUIDINF, 0); |
| 208 | + |
| 209 | + std::string stVendor; |
| 210 | + stVendor += std::string(reinterpret_cast<const char*>(&CPUIDINF[1]), sizeof(CPUIDINF[1])); |
| 211 | + stVendor += std::string(reinterpret_cast<const char*>(&CPUIDINF[3]), sizeof(CPUIDINF[3])); |
| 212 | + stVendor += std::string(reinterpret_cast<const char*>(&CPUIDINF[2]), sizeof(CPUIDINF[2])); |
| 213 | + |
| 214 | + std::cout << "\tProcessor level: " << sysInfo.wProcessorLevel << " revision: " << dwRevision << " " << byRevision << " vendor: " << stVendor << std::endl; |
| 215 | + |
| 216 | + // Reversed checks from Windows's tool |
| 217 | + if (stVendor == "AuthenticAMD") |
| 218 | + { |
| 219 | + if (sysInfo.wProcessorLevel < 0x17 || sysInfo.wProcessorLevel == 23 && !((dwRevision - 1) & 0xFFFFFFEF)) |
| 220 | + { |
| 221 | + std::cerr << "Unsupported AMD CPU detected!" << std::endl; |
| 222 | + std::system("PAUSE"); |
| 223 | + return EXIT_FAILURE; |
| 224 | + } |
| 225 | + } |
| 226 | + else if (stVendor == "GenuineIntel") |
| 227 | + { |
| 228 | + if (sysInfo.wProcessorLevel == 6) |
| 229 | + { |
| 230 | + if ((dwRevision < 0x5F && dwRevision != 85) || |
| 231 | + (dwRevision == 142 && byRevision == 9) || |
| 232 | + (dwRevision == 158 && byRevision == 9)) |
| 233 | + { |
| 234 | + std::cerr << "Unsupported Intel CPU detected!" << std::endl; |
| 235 | + std::system("PAUSE"); |
| 236 | + return EXIT_FAILURE; |
| 237 | + } |
| 238 | + } |
| 239 | + } |
| 240 | + else if (stVendor.find("Qualcomm") == std::string::npos) |
| 241 | + { |
| 242 | + std::cerr << "Unknown CPU vendor detected!" << std::endl; |
| 243 | + std::system("PAUSE"); |
| 244 | + return EXIT_FAILURE; |
| 245 | + } |
| 246 | + else if (!IsProcessorFeaturePresent(PF_ARM_V81_ATOMIC_INSTRUCTIONS_AVAILABLE)) |
| 247 | + { |
| 248 | + std::cerr << "Unsupported Qualcomm CPU detected!" << std::endl; |
| 249 | + std::system("PAUSE"); |
| 250 | + return EXIT_FAILURE; |
| 251 | + } |
| 252 | + |
203 | 253 | std::cout << "CPU check passed!" << std::endl;
|
204 | 254 | }
|
205 | 255 |
|
|
0 commit comments