Skip to content

Commit

Permalink
JclSysInfo causing programs freeze under Win8.1
Browse files Browse the repository at this point in the history
Under Windows 8.1 Embedded Industrial Enterprice (Build 9600) the GetWindowsMajorVersionNumber() causing:
`EConvertError: '' is not a valid integer value.`
It is reckless to call unsafe code from initialization part!
  • Loading branch information
PizzaProgram authored Sep 10, 2022
1 parent 339c1fe commit 47af4fe
Showing 1 changed file with 26 additions and 23 deletions.
49 changes: 26 additions & 23 deletions jcl/source/common/JclSysInfo.pas
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ TCpuInfo = record
EAMD2_LAHF = BIT_0; // LAHF/SAHF available in 64-bit mode
EAMD2_CMPLEGACY = BIT_1; // core multi-processing legacy mode
EAMD2_SVM = BIT_2; // Secure Virtual Machine
EAMD2_EXTAPICSPACE = BIT_3; // This bit indicates the presence of extended APIC register space starting at offset 400h from the “APIC Base Address Register,” as specified in the BKDG.
EAMD2_EXTAPICSPACE = BIT_3; // This bit indicates the presence of extended APIC register space starting at offset 400h from the “APIC Base Address Register,” as specified in the BKDG.
EAMD2_ALTMOVCR8 = BIT_4; // LOCK MOV CR0 means MOV CR8
EAMD2_ABM = BIT_5; // ABM: Advanced bit manipulation. LZCNT instruction support.
EAMD2_SSE4A = BIT_6; // EXTRQ, INSERTQ, MOVNTSS, and MOVNTSD instruction support.
Expand Down Expand Up @@ -5628,34 +5628,34 @@ function CPUID: TCpuInfo;
3:
CPUInfo.CpuName := 'AMD-K5 (Model 3)';
6:
CPUInfo.CpuName := 'AMD-K6® (Model 6)';
CPUInfo.CpuName := 'AMD-K6® (Model 6)';
7:
CPUInfo.CpuName := 'AMD-K6® (Model 7)';
CPUInfo.CpuName := 'AMD-K6® (Model 7)';
8:
CPUInfo.CpuName := 'AMD-K6®-2 (Model 8)';
CPUInfo.CpuName := 'AMD-K6®-2 (Model 8)';
9:
CPUInfo.CpuName := 'AMD-K6®-III (Model 9)';
CPUInfo.CpuName := 'AMD-K6®-III (Model 9)';
else
StrFmtA(CPUInfo.CpuName, PAnsiChar(AnsiString(LoadResString(@RsUnknownAMDModel))), [CPUInfo.Model]);
end;
6:
case CPUInfo.Model of
1:
CPUInfo.CpuName := 'AMD Athlon™ (Model 1)';
CPUInfo.CpuName := 'AMD Athlon™ (Model 1)';
2:
CPUInfo.CpuName := 'AMD Athlon™ (Model 2)';
CPUInfo.CpuName := 'AMD Athlon™ (Model 2)';
3:
CPUInfo.CpuName := 'AMD Duron™ (Model 3)';
CPUInfo.CpuName := 'AMD Duron™ (Model 3)';
4:
CPUInfo.CpuName := 'AMD Athlon™ (Model 4)';
CPUInfo.CpuName := 'AMD Athlon™ (Model 4)';
6:
CPUInfo.CpuName := 'AMD Athlon™ XP (Model 6)';
CPUInfo.CpuName := 'AMD Athlon™ XP (Model 6)';
7:
CPUInfo.CpuName := 'AMD Duron™ (Model 7)';
CPUInfo.CpuName := 'AMD Duron™ (Model 7)';
8:
CPUInfo.CpuName := 'AMD Athlon™ XP (Model 8)';
CPUInfo.CpuName := 'AMD Athlon™ XP (Model 8)';
10:
CPUInfo.CpuName := 'AMD Athlon™ XP (Model 10)';
CPUInfo.CpuName := 'AMD Athlon™ XP (Model 10)';
else
StrFmtA(CPUInfo.CpuName, PAnsiChar(AnsiString(LoadResString(@RsUnknownAMDModel))), [CPUInfo.Model]);
end;
Expand Down Expand Up @@ -6594,17 +6594,20 @@ procedure FinalizeSysInfo;
end;

initialization
InitSysInfo;
{$IFDEF UNITVERSIONING}
RegisterUnitVersion(HInstance, UnitVersioning);
{$ENDIF UNITVERSIONING}

try
InitSysInfo;
{$IFDEF UNITVERSIONING}
RegisterUnitVersion(HInstance, UnitVersioning);
{$ENDIF UNITVERSIONING}
except end;

finalization
{$IFDEF UNITVERSIONING}
UnregisterUnitVersion(HInstance);
{$ENDIF UNITVERSIONING}
FinalizeSysInfo;

try
{$IFDEF UNITVERSIONING}
UnregisterUnitVersion(HInstance);
{$ENDIF UNITVERSIONING}
FinalizeSysInfo;
except end;
{$ENDIF MSWINDOWS}

end.

0 comments on commit 47af4fe

Please sign in to comment.