Fix a bug in the CPU detection code that could result in an infinite loop, if the CPU doesn't provide 'Extended Function CPUID Information'. Core of this problem is that VC's __cpuid() intrinsic has the parameters defined as 'int', but returns values of type 'unsigned int'.
This commit is contained in:
parent
0fd4b56a87
commit
8016e186dc
@ -25,8 +25,8 @@
|
|||||||
#define VER_LAMEXP_MAJOR 4
|
#define VER_LAMEXP_MAJOR 4
|
||||||
#define VER_LAMEXP_MINOR_HI 0
|
#define VER_LAMEXP_MINOR_HI 0
|
||||||
#define VER_LAMEXP_MINOR_LO 0
|
#define VER_LAMEXP_MINOR_LO 0
|
||||||
#define VER_LAMEXP_BUILD 293
|
#define VER_LAMEXP_BUILD 298
|
||||||
#define VER_LAMEXP_SUFFIX Beta-3
|
#define VER_LAMEXP_SUFFIX Beta-4
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tools versions
|
* Tools versions
|
||||||
|
@ -373,18 +373,30 @@ lamexp_cpu_t lamexp_detect_cpu_features(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
__cpuid(CPUInfo, 0x80000000);
|
__cpuid(CPUInfo, 0x80000000);
|
||||||
int nExIds = CPUInfo[0];
|
int nExIds = max(min(CPUInfo[0], 0x80000004), 0x80000000);
|
||||||
|
|
||||||
for(int i = 0x80000000; i <= nExIds; ++i)
|
for(int i = 0x80000002; i <= nExIds; ++i)
|
||||||
{
|
{
|
||||||
__cpuid(CPUInfo, i);
|
__cpuid(CPUInfo, i);
|
||||||
if(i == 0x80000002) memcpy(CPUBrandString, CPUInfo, sizeof(CPUInfo));
|
switch(i)
|
||||||
else if(i == 0x80000003) memcpy(CPUBrandString + 16, CPUInfo, sizeof(CPUInfo));
|
{
|
||||||
else if(i == 0x80000004) memcpy(CPUBrandString + 32, CPUInfo, sizeof(CPUInfo));
|
case 0x80000002:
|
||||||
|
memcpy(CPUBrandString, CPUInfo, sizeof(CPUInfo));
|
||||||
|
break;
|
||||||
|
case 0x80000003:
|
||||||
|
memcpy(CPUBrandString + 16, CPUInfo, sizeof(CPUInfo));
|
||||||
|
break;
|
||||||
|
case 0x80000004:
|
||||||
|
memcpy(CPUBrandString + 32, CPUInfo, sizeof(CPUInfo));
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy_s(features.brand, 0x40, CPUBrandString);
|
strcpy_s(features.brand, 0x40, CPUBrandString);
|
||||||
|
|
||||||
|
if(strlen(features.brand) < 1) strcpy_s(features.brand, 0x40, "Unknown");
|
||||||
|
if(strlen(features.vendor) < 1) strcpy_s(features.vendor, 0x40, "Unknown");
|
||||||
|
|
||||||
#if !defined(_M_X64 ) && !defined(_M_IA64)
|
#if !defined(_M_X64 ) && !defined(_M_IA64)
|
||||||
if(!IsWow64ProcessPtr || !GetNativeSystemInfoPtr)
|
if(!IsWow64ProcessPtr || !GetNativeSystemInfoPtr)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user