# HG changeset patch # User moel.mich # Date 1273919927 0 # Node ID 69d29f1a2307bb4094dd245dc7d727390cc53ab8 # Parent 2b8a8cf92c3a1188560a16b29d262b3febd282ab Fixed Issue 59. diff -r 2b8a8cf92c3a -r 69d29f1a2307 Hardware/CPU/CPUID.cs --- a/Hardware/CPU/CPUID.cs Fri May 14 22:30:06 2010 +0000 +++ b/Hardware/CPU/CPUID.cs Sat May 15 10:38:47 2010 +0000 @@ -104,11 +104,17 @@ uint eax, ebx, ecx, edx; + if (thread >= 32) + throw new ArgumentException(); UIntPtr mask = (UIntPtr)(1L << thread); if (WinRing0.CpuidTx(CPUID_0, 0, out eax, out ebx, out ecx, out edx, mask)) { - maxCpuid = eax; + if (eax > 0) + maxCpuid = eax; + else + return; + StringBuilder vendorBuilder = new StringBuilder(); AppendRegister(vendorBuilder, ebx); AppendRegister(vendorBuilder, edx); @@ -127,14 +133,18 @@ } eax = ebx = ecx = edx = 0; if (WinRing0.CpuidTx(CPUID_EXT, 0, - out eax, out ebx, out ecx, out edx, mask)) - maxCpuidExt = eax - CPUID_EXT; + out eax, out ebx, out ecx, out edx, mask)) { + if (eax > CPUID_EXT) + maxCpuidExt = eax - CPUID_EXT; + else + return; + } } else { throw new ArgumentException(); } - if (maxCpuid == 0 || maxCpuidExt == 0) - return; + maxCpuid = Math.Min(maxCpuid, 1024); + maxCpuidExt = Math.Min(maxCpuidExt, 1024); cpuidData = new uint[maxCpuid + 1, 4]; for (uint i = 0; i < (maxCpuid + 1); i++)