当清单添加为资源时,Delphi 5 导致 EAccessViolation

发布于 2024-12-09 13:48:34 字数 3564 浏览 0 评论 0原文

这是我最近发现的最有趣的问题之一。 我们有一个遗留的 Delphi 5 程序(Rave Reports 4 引用阻止升级到 D2007)。

当程序使用我们的模板生成的版本资源进行编译时,它可以正常工作。当模板生成的清单资源也添加到程序的 dpr 时,就会出现问题。

Manifest 是一个“通用”ASCII 文件:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">

  <assemblyIdentity
    name="Name"
    processorArchitecture="x86"
    version="2.0.0.0"
    type="win32"/>

  <description>Desc</description>

  <dependency>
      <dependentAssembly>
          <assemblyIdentity
              type="win32"
              name="Microsoft.Windows.Common-Controls"
              version="6.0.0.0"
              processorArchitecture="x86"
              publicKeyToken="6595b64144ccf1df"
              language="*"
          />
      </dependentAssembly>
  </dependency>

  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level="asInvoker" uiAccess="false"/>
      </requestedPrivileges>
    </security>
  </trustInfo>

  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> 
    <application> 
      <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/> 
      <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
    </application> 
  </compatibility>

</assembly>

在 App.dpr 中有一个清单资源引用:

{$R 'manifest.res' 'manifest.rc'}

Manifest 通过调用进行编译:

C:\Program Files\Borland\Delphi5\Bin\brcc32.exe manifest.rc

并且当程序启动时引发以下异常:

exception class   : EAccessViolation
exception message : Access violation at address 75A1A890 in module 'KERNELBASE.dll'. Read of address 00000001.

主线程的调用堆栈:

main thread ($1144):
75a1a890 +007 KERNELBASE.dll
75a1a97c +069 KERNELBASE.dll          WideCharToMultiByte
73f28764 +048 comctl32.dll            #342
777741f4 +016 user32.dll              CallWindowProcA
00092de2 +0ca app.exe        Controls TWinControl.DefaultHandler
0009336c +01c app.exe        Controls TWinControl.WMNotify
000c2454 +024 app.exe        ComCtrls TCustomListView.WMNotify
00090249 +111 app.exe        Controls TControl.WndProc
00092d0a +1d2 app.exe        Controls TWinControl.WndProc
000c39ea +072 app.exe        ComCtrls TCustomListView.WndProc
0009290c +02c app.exe        Controls TWinControl.MainWndProc
000a5880 +014 app.exe        Forms    StdWndProc
77757690 +044 user32.dll              SendMessageW
777741f4 +016 user32.dll              CallWindowProcA
000c1e6f +0c7 app.exe        ComCtrls TCustomListView.HeaderWndProc
000a5880 +014 app.exe        Forms    StdWndProc
7763642b +02b ntdll.dll               KiUserCallbackDispatcher
77753573 +00a user32.dll              DispatchMessageA
000ae8c7 +083 app.exe        Forms    TApplication.ProcessMessage
000ae8fe +00a app.exe        Forms    TApplication.HandleMessage
000aeb09 +081 app.exe        Forms    TApplication.Run
00186ecf +077 app.exe        mca      initialization
75b61192 +010 kernel32.dll            BaseThreadInitThunk

链接的 comctl32.dll:

73f00000 comctl32.dll            6.10.7600.16385    C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7600.16385_none_421189da2b7fabfc

来自什么我可以看到该问题与一些 Delphi 5 与 comctl32.dll 控件不兼容有关。我将 Delphi VCL 更新到最新版本。除了迁移到 D2007 之外还有其他解决方案吗?

This is one of most interesting problems I have found recently.
We have a legacy Delphi 5 program (Rave Reports 4 references are preventing from upgrading to D2007).

When program is compiled with our template-generated version resource it works fine. The problem arises when also template-generated manifest resource is added to a program's dpr.

Manifest is a "generic", ASCII file:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">

  <assemblyIdentity
    name="Name"
    processorArchitecture="x86"
    version="2.0.0.0"
    type="win32"/>

  <description>Desc</description>

  <dependency>
      <dependentAssembly>
          <assemblyIdentity
              type="win32"
              name="Microsoft.Windows.Common-Controls"
              version="6.0.0.0"
              processorArchitecture="x86"
              publicKeyToken="6595b64144ccf1df"
              language="*"
          />
      </dependentAssembly>
  </dependency>

  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level="asInvoker" uiAccess="false"/>
      </requestedPrivileges>
    </security>
  </trustInfo>

  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> 
    <application> 
      <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/> 
      <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
    </application> 
  </compatibility>

</assembly>

In App.dpr there is a manifest resource reference:

{$R 'manifest.res' 'manifest.rc'}

Manifest is compiled by calling:

C:\Program Files\Borland\Delphi5\Bin\brcc32.exe manifest.rc

And when program is started following exception is raised:

exception class   : EAccessViolation
exception message : Access violation at address 75A1A890 in module 'KERNELBASE.dll'. Read of address 00000001.

Call stack for main thread:

main thread ($1144):
75a1a890 +007 KERNELBASE.dll
75a1a97c +069 KERNELBASE.dll          WideCharToMultiByte
73f28764 +048 comctl32.dll            #342
777741f4 +016 user32.dll              CallWindowProcA
00092de2 +0ca app.exe        Controls TWinControl.DefaultHandler
0009336c +01c app.exe        Controls TWinControl.WMNotify
000c2454 +024 app.exe        ComCtrls TCustomListView.WMNotify
00090249 +111 app.exe        Controls TControl.WndProc
00092d0a +1d2 app.exe        Controls TWinControl.WndProc
000c39ea +072 app.exe        ComCtrls TCustomListView.WndProc
0009290c +02c app.exe        Controls TWinControl.MainWndProc
000a5880 +014 app.exe        Forms    StdWndProc
77757690 +044 user32.dll              SendMessageW
777741f4 +016 user32.dll              CallWindowProcA
000c1e6f +0c7 app.exe        ComCtrls TCustomListView.HeaderWndProc
000a5880 +014 app.exe        Forms    StdWndProc
7763642b +02b ntdll.dll               KiUserCallbackDispatcher
77753573 +00a user32.dll              DispatchMessageA
000ae8c7 +083 app.exe        Forms    TApplication.ProcessMessage
000ae8fe +00a app.exe        Forms    TApplication.HandleMessage
000aeb09 +081 app.exe        Forms    TApplication.Run
00186ecf +077 app.exe        mca      initialization
75b61192 +010 kernel32.dll            BaseThreadInitThunk

Linked comctl32.dll:

73f00000 comctl32.dll            6.10.7600.16385    C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7600.16385_none_421189da2b7fabfc

From what I can see the problem is bound with some Delphi 5 incompatibilities with comctl32.dll controls. I updated Delphi VCL to most recent one. Is there any other solution than just migrating to D2007 ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

永言不败 2024-12-16 13:48:34

如果我没记错的话,你需要的不仅仅是清单。您还需要 Mike Lischke 的主题管理器组件 。这段代码最终进入了 Delphi 7。

You need more that just the manifest if I recall correctly. You also need Mike Lischke's theme manager component. This code eventually found its way into Delphi 7.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文