@@ -1290,13 +1290,13 @@ struct VM {
12901290
12911291 struct threadcount {
12921292 static u32 threadcount_cache;
1293- static bool cached;
1294- static void store (u32 count) {
1295- threadcount_cache = count;
1296- cached = true ;
1293+ static u32 fetch () {
1294+ if (threadcount_cache != 0 ) {
1295+ return threadcount_cache;
1296+ }
1297+ threadcount_cache = std::thread::hardware_concurrency ();
1298+ return threadcount_cache;
12971299 }
1298- static u32 fetch () { return threadcount_cache; }
1299- static bool is_cached () { return cached; }
13001300 };
13011301
13021302 struct hyperx {
@@ -9461,18 +9461,31 @@ struct VM {
94619461 for (size_t i = 0 ; i < sizeof (vendor_ascii) / sizeof (*vendor_ascii); ++i) {
94629462 const char * vasc = vendor_ascii[i];
94639463 const wchar_t * vw = vendor_wide[i];
9464+
94649465 const bool inPKDef = buf_contains_vendor_specific (pkDefaultBuf, pkDefaultLen, vasc, vw);
94659466 const bool inKEKDef = buf_contains_vendor_specific (kekDefaultBuf, kekDefaultLen, vasc, vw);
9467+
94669468 if (!inPKDef && !inKEKDef) continue ;
9467- const bool inPK = buf_contains_vendor_specific (pkBuf, pkLen, vasc, vw);
9468- const bool inKEK = buf_contains_vendor_specific (kekBuf, kekLen, vasc, vw);
9469- if (!inPK && !inKEK) {
9470- debug (" NVRAM: Vendor string found in PKDefault/KEKDefault but missing from active PK/KEK" );
9469+
9470+ const bool inPKActive = buf_contains_vendor_specific (pkBuf, pkLen, vasc, vw);
9471+ const bool inKEKActive = buf_contains_vendor_specific (kekBuf, kekLen, vasc, vw);
9472+
9473+ if (inPKDef && !inPKActive) {
9474+ debug (" NVRAM: Vendor string found in PKDefault but missing from active PK" );
94719475 if (pkBuf && pkBuf != stackBuf) { PVOID b = pkBuf; SIZE_T z = 0 ; pNtFreeVirtualMemory (hCurrentProcess, &b, &z, 0x8000 ); }
94729476 if (kekBuf && kekBuf != stackBuf) { PVOID b = kekBuf; SIZE_T z = 0 ; pNtFreeVirtualMemory (hCurrentProcess, &b, &z, 0x8000 ); }
94739477 if (pkDefaultBuf && pkDefaultBuf != stackBuf) { PVOID b = pkDefaultBuf; SIZE_T z = 0 ; pNtFreeVirtualMemory (hCurrentProcess, &b, &z, 0x8000 ); }
94749478 if (kekDefaultBuf && kekDefaultBuf != stackBuf) { PVOID b = kekDefaultBuf; SIZE_T z = 0 ; pNtFreeVirtualMemory (hCurrentProcess, &b, &z, 0x8000 ); }
9475- cleanup (); return core::add (brands::QEMU);
9479+ cleanup (); return true ;
9480+ }
9481+
9482+ if (inKEKDef && !inKEKActive) {
9483+ debug (" NVRAM: Vendor string found in KEKDefault but missing from active KEK" );
9484+ if (pkBuf && pkBuf != stackBuf) { PVOID b = pkBuf; SIZE_T z = 0 ; pNtFreeVirtualMemory (hCurrentProcess, &b, &z, 0x8000 ); }
9485+ if (kekBuf && kekBuf != stackBuf) { PVOID b = kekBuf; SIZE_T z = 0 ; pNtFreeVirtualMemory (hCurrentProcess, &b, &z, 0x8000 ); }
9486+ if (pkDefaultBuf && pkDefaultBuf != stackBuf) { PVOID b = pkDefaultBuf; SIZE_T z = 0 ; pNtFreeVirtualMemory (hCurrentProcess, &b, &z, 0x8000 ); }
9487+ if (kekDefaultBuf && kekDefaultBuf != stackBuf) { PVOID b = kekDefaultBuf; SIZE_T z = 0 ; pNtFreeVirtualMemory (hCurrentProcess, &b, &z, 0x8000 ); }
9488+ cleanup (); return true ;
94769489 }
94779490 }
94789491 }
@@ -10183,6 +10196,7 @@ struct VM {
1018310196 [[nodiscard]] static bool clock () {
1018410197 // The RTC (ACPI/CMOS RTC) timer can't be always detected via SetupAPI, it needs AML decode of the DSDT firmware table
1018510198 // The HPET (PNP0103) timer presence is already checked on VM::FIRMWARE
10199+ // Here, we check for the PIT/AT timer (PC-class System Timer)
1018610200 constexpr wchar_t pattern[] = L" pnp0100" ;
1018710201 constexpr size_t patLen = (sizeof (pattern) / sizeof (wchar_t )) - 1 ;
1018810202
@@ -10806,13 +10820,11 @@ struct VM {
1080610820 , [[maybe_unused]] const std::source_location& loc = std::source_location::current()
1080710821#endif
1080810822 ) {
10809- // return and force caching early if the technique is not supported
1081010823 if (util::is_unsupported (flag_bit)) {
1081110824 memo::cache_store (flag_bit, false , 0 );
1081210825 return false ;
1081310826 }
1081410827
10815- // lambda to manage exceptions
1081610828 auto throw_error = [&](const char * text) -> void {
1081710829 std::stringstream ss;
1081810830 #if (VMA_CPP >= 20 && !CLANG)
@@ -10822,7 +10834,6 @@ struct VM {
1082210834 throw std::invalid_argument (std::string (text) + ss.str ());
1082310835 };
1082410836
10825- // check if flag is out of range
1082610837 if (flag_bit > enum_size) {
1082710838 throw_error (" Flag argument must be a valid" );
1082810839 }
@@ -10846,30 +10857,25 @@ struct VM {
1084610857 return data.result ;
1084710858 }
1084810859
10849- const core::technique& pair = core::technique_table[flag_bit];
10860+ if (flag_bit < technique_end) {
10861+ const core::technique& pair = core::technique_table[flag_bit];
1085010862
10851- // check if the flag exists (has a function pointer)
10852- if (!pair.run ) {
10853- throw_error (" Flag is not known or not implemented" );
10854- }
10863+ if (!pair.run ) {
10864+ throw_error (" Flag is not known or not implemented" );
10865+ }
1085510866
10856- // initialise and run the technique
10857- bool result = false ;
10858- if (pair.run ) {
10859- result = pair.run ();
10867+ bool result = pair.run ();
10868+ if (result) detected_count_num++;
1086010869
10861- if (result) {
10862- detected_count_num++;
10863- }
10864- }
1086510870 #ifdef __VMAWARE_DEBUG__
1086610871 total_points += pair.points ;
1086710872 #endif
1086810873
10869- // store the technique result in the cache table
10870- memo::cache_store (flag_bit, result, pair.points );
10874+ memo::cache_store (flag_bit, result, pair.points );
10875+ return result;
10876+ }
1087110877
10872- return result ;
10878+ return false ;
1087310879 }
1087410880
1087510881
0 commit comments