Delphi 64 位代码挂钩可用于运行时 VCL 风格 AV?

Del*_*Guy 5 delphi 64-bit vcl-styles delphi-10.2-tokyo

看起来如果没有 Delphi Tokyo 修复,可能就没有用户解决方案,但这似乎值得一问。

使该 AV 可复制的最简单方法。

  1. 启动一个新的 VCL 项目。
  2. 将平台更改为 64 位。
  3. 与运行时包链接。
  4. 将样式设置为“Amakrits”。
  5. 添加高熵 ASLR 标志。注意 - 这会暴露出许多 Win64 错误。

我的Dpr文件看起来像这样(主单元中没有代码)。

program MaskedCrash2;

{$SETPEOPTFLAGS $160} //High Entropy ASLR Flag causes issues with incorrect 64-bit programs.

uses
  Vcl.Forms,
  MaskedCrashed2MainUnt in 'MaskedCrashed2MainUnt.pas' {Form3},
  Vcl.Themes,
  Vcl.Styles;

{$R *.res}

begin
  Application.Initialize;
  Application.MainFormOnTaskbar := True;
  TStyleManager.TrySetStyle('Amakrits');
  Application.CreateForm(TForm3, Form3);
  Application.Run;
end.
Run Code Online (Sandbox Code Playgroud)

该 AV 出现在 Delphi Tokyo 的 StyleUtils.inc 中procedure TseBitmapLink.CheckingMasked(const Margin: TRect);

尽管我最近在 StyleUtils.inc 的顶部发现了警告:

//TODO -oUnassigned -cImplement : x64 : Implement PlatformNotImplemented in this unit or disable for x64.
Run Code Online (Sandbox Code Playgroud)

这部分代码在Delphi Berlin中非常稳定。正如此处的帖子所示,对话框是另一回事。我已将有问题的代码提交到质量门户。

注意:为了获得高熵 ASLR(如进程资源管理器所示),需要使用运行时包并设置高熵位(20 美元),DEP 为 40 美元,ASLR 为 100 美元。

除了使程序更安全之外,使用高熵 ASLR 肯定有助于发现 Windows 消息中的错误(例如使用 Integer 强制转换SendMessage等)。当切换到 64 位时,使用高熵 ASLR 发现了我的代码中的许多被屏蔽的错误。

重新编译运行时包似乎不可能,并且正确建议使用运行时挂钩。

然而,该方法procedure TseBitmapLink.CheckingMasked(const Margin: TRect); 包含在实现部分:

implementation

uses
  System.Types, System.UITypes, System.SysUtils, Winapi.UxTheme, Vcl.StdCtrls, Vcl.ComCtrls,
  Vcl.Mask, Vcl.GraphUtil, Vcl.ImgList, Vcl.Menus, Vcl.Grids, Vcl.CategoryButtons,
  Vcl.ButtonGroup, Vcl.ExtCtrls, Vcl.Consts, Vcl.SysStyles;

{$I StyleUtils.inc}
{$I StyleAPI.inc}
Run Code Online (Sandbox Code Playgroud)

那么有没有办法使用运行时挂钩,因为TseBitmapLink使用运行时包的最终用户无法使用它?

它是否正确?

有人对保留 High Entropy ASLR 和 Delphi Tokyo 有什么建议吗?

抱歉花了这么长时间,试图完成。