Fixed Issue 59.
authormoel.mich
Sat, 15 May 2010 10:38:47 +0000
changeset 11269d29f1a2307
parent 111 2b8a8cf92c3a
child 113 62a2848ec0a6
Fixed Issue 59.
Hardware/CPU/CPUID.cs
     1.1 --- a/Hardware/CPU/CPUID.cs	Fri May 14 22:30:06 2010 +0000
     1.2 +++ b/Hardware/CPU/CPUID.cs	Sat May 15 10:38:47 2010 +0000
     1.3 @@ -104,11 +104,17 @@
     1.4  
     1.5        uint eax, ebx, ecx, edx;
     1.6  
     1.7 +      if (thread >= 32)
     1.8 +        throw new ArgumentException();
     1.9        UIntPtr mask = (UIntPtr)(1L << thread);
    1.10  
    1.11        if (WinRing0.CpuidTx(CPUID_0, 0,
    1.12            out eax, out ebx, out ecx, out edx, mask)) {
    1.13 -        maxCpuid = eax;
    1.14 +        if (eax > 0)
    1.15 +          maxCpuid = eax;
    1.16 +        else
    1.17 +          return;
    1.18 +
    1.19          StringBuilder vendorBuilder = new StringBuilder();
    1.20          AppendRegister(vendorBuilder, ebx);
    1.21          AppendRegister(vendorBuilder, edx);
    1.22 @@ -127,14 +133,18 @@
    1.23          }
    1.24          eax = ebx = ecx = edx = 0;
    1.25          if (WinRing0.CpuidTx(CPUID_EXT, 0,
    1.26 -          out eax, out ebx, out ecx, out edx, mask))
    1.27 -          maxCpuidExt = eax - CPUID_EXT;
    1.28 +          out eax, out ebx, out ecx, out edx, mask)) {
    1.29 +          if (eax > CPUID_EXT)
    1.30 +            maxCpuidExt = eax - CPUID_EXT;
    1.31 +          else
    1.32 +            return;
    1.33 +        }
    1.34        } else {
    1.35          throw new ArgumentException();
    1.36        }
    1.37  
    1.38 -      if (maxCpuid == 0 || maxCpuidExt == 0)
    1.39 -        return;
    1.40 +      maxCpuid = Math.Min(maxCpuid, 1024);
    1.41 +      maxCpuidExt = Math.Min(maxCpuidExt, 1024);   
    1.42  
    1.43        cpuidData = new uint[maxCpuid + 1, 4];
    1.44        for (uint i = 0; i < (maxCpuid + 1); i++)