Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi 5 causes EAccessViolation when manifest is added as a resource

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 ?

like image 297
too Avatar asked Oct 12 '11 12:10

too


1 Answers

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.

like image 152
David Heffernan Avatar answered Sep 19 '22 21:09

David Heffernan