Range check error in DEBUG mode in WIN64 VCL applications
DGH2112 opened this issue · 0 comments
Hi,
I'm using VCL Styles Utils which uses DDetours. Until recently I was working with a circa year and a half old version of both libraries but decided to update yesterday. After updating, the Win32 version of my app works okay but the WIn64 version of my app throws the below exception. I've managed to replicate the issue with a basis new Win64 VCL application (DPR code provided below). The line that raises the first exception is:
DDetours.pas 1040: Offset := Int64(UInt64(PInst^.Branch.Target) - UInt64(PQ) - 6);
Initially, I could not replicate the error until I turned on Overflow Checking in the compiler options. All my debug application run with Range, Overflow and IO checking on. I'm thinking that the above should be wrapped in {$Q-} if it is intended that range checking should be switched off. I did this as a test but further, similar lines, threw exceptions so this might need to be applied to the whole unit.
BTW: I'm using RAD Studio 10.4.1 Enterprise.
Exception Message from IDE Event Log
First chance exception at $00007FFD4A033B29. Exception class EIntOverflow with message 'Integer overflow at (000000000076CFEF{Win64DDetours.exe}) [0000000000B6CFEF] DDetours.CorrectJ (Line 1040, "DDetours.pas") + $14'. Process Win64DDetours.exe (11456)
Call Stack from IDE
:00007FFD4A033B29 ; C:\WINDOWS\System32\KERNELBASE.dll
System._RaiseAtExcept(???,???)
EInject._IntOverHook
DDetours.CorrectJ($7EE5EF0,$7FFD4C330023)
DDetours.MapInsts($7FFD4C1A70B0,$7FFD4C330020,5)
DDetours.InsertDescriptor($7FFD4C1A70B0,$7EE5C80)
DDetours.InstallHook($7FFD4C1A70B0,$C10B30,nil,[])
DDetours.InterceptCreate($7FFD4C1A70B0,$C10B30,nil,[])
DDetours.InterceptCreate('user32.dll','GetSysColorBrush',$C10B30,nil,[])
Vcl.Styles.Hooks.Vcl.Styles.Hooks
System.InitUnits
System._StartExe(???,???)
SysInit._InitExe(???)
Win64DDetours.Win64DDetours
:00007FFD4C4B7C24 ; C:\WINDOWS\System32\KERNEL32.DLL
:00007FFD4CD2D4D1 ; <UNKNOWN>
** DPR Code**
program Win64DDetours;
uses
VCL.Forms,
VCL.Dialogs,
DDetours,
Vcl.Styles.Fixes,
Vcl.Styles.Hooks,
MainForm in 'MainForm.pas' {Form1};
{$R *.res}
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.