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
|
||||||
|
@ -345,7 +345,7 @@ lamexp_cpu_t lamexp_detect_cpu_features(void)
|
|||||||
int CPUInfo[4] = {-1};
|
int CPUInfo[4] = {-1};
|
||||||
char CPUIdentificationString[0x40];
|
char CPUIdentificationString[0x40];
|
||||||
char CPUBrandString[0x40];
|
char CPUBrandString[0x40];
|
||||||
|
|
||||||
memset(&features, 0, sizeof(lamexp_cpu_t));
|
memset(&features, 0, sizeof(lamexp_cpu_t));
|
||||||
memset(&systemInfo, 0, sizeof(SYSTEM_INFO));
|
memset(&systemInfo, 0, sizeof(SYSTEM_INFO));
|
||||||
memset(CPUIdentificationString, 0, sizeof(CPUIdentificationString));
|
memset(CPUIdentificationString, 0, sizeof(CPUIdentificationString));
|
||||||
@ -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)
|
||||||
{
|
{
|
||||||
|
@ -153,7 +153,7 @@ int lamexp_main(int argc, char* argv[])
|
|||||||
LAMEXP_DELETE(fileListModel);
|
LAMEXP_DELETE(fileListModel);
|
||||||
LAMEXP_DELETE(metaInfo);
|
LAMEXP_DELETE(metaInfo);
|
||||||
LAMEXP_DELETE(settingsModel);
|
LAMEXP_DELETE(settingsModel);
|
||||||
|
|
||||||
//Final clean-up
|
//Final clean-up
|
||||||
qDebug("Shutting down, please wait...\n");
|
qDebug("Shutting down, please wait...\n");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user