TShellTreeView component in Vcl.Shell.ShellCtrls unit causes an access violation in TWinControl.DefaultHandler() on Win64 platform at application startup when the form initializes.
To reproduce the bug:
Create a new VCL Forms application and put a
TShellTreeViewcomponent onto the form. Or, alternatively paste this minimal project source into a file named 'ShellTreeViewTest.dpr' and open the project with the Delphi IDE:program ShellTreeViewTest; uses Vcl.Forms, Vcl.Controls, Vcl.Shell.ShellCtrls; var Form: TForm; begin Application.Initialize; Application.CreateForm(TForm, Form); with TShellTreeView.Create(Form) do Parent := Form; Application.Run; end.Then add platform "Windows 64 bit" to the project.
Compile and run.
I use Delphi 11.1 Alexandria.
- The access violation raises only if "Support high-entropy 64-bit address space layout randomization (ASLR)" is enabled in the Project options/Linking tab. It is enabled by default, so the bug is reproducible in Delphi 11.
- But in Delphi XE2 there is no such checkbox in the project options.
The AV is caused by the
TCustomShellTreeView.FImagesfield being declared as anInteger; it is initialized by a call toSHGetFileInfo(), which returns aDWORD_PTR. ReplacingFImages: IntegerwithFImages: DWORD_PTRsolves the problem.The
TCustomShellComboBox.FImages,TCustomShellListView.FLargeImages, andTCustomShellListView.FSmallImagesfields also need to be changed accordingly.