Published in


How to fix the error 0xc0000006 External Exception in a Delphi Application — Part 2

PE (portable executable) header flags for Delphi

Drag & drop of Delphi project into a project group

We noticed an issue that occurs when a Delphi package DPKs that contain PEFlags are added to a Delphi project group by a drag & drop action (dragging the project of the package into the project group). In this case it may happen that the local path of Winapi.Windows.pas (C:\Program files (x86)\Embarcadero\…) is added into the DPROJ file. If the project is saved, the path is also added to the DPK file. To avoid this behavior it is necessary to activate the PEflag in a different way than the one I explained in the first part of this article. The tick is to use the value $0800 instead of the constant name IMAGE_FILE_NET_RUN_FROM_SWAP as you can see in the following piece of code:

{$SetPEFlags $0800}
<DCCReference Include = "C:\Program files (x86)\Embarcadero\Rad Studio\10.0\source\rtl\win\Winapi.Windows.pas"/>

Third party modules (BPL)

At a customer where the compilation directive was set on all Application modules, the error kept appearing. The case study led us to suspect that the error was due to external modules (not compiled by us) with no IMAGE_FILE_NET_RUN_FROM_SWAP flag, so we thought about using the EDITBIN tool to edit those external modules. This tool allows you to edit files such as BPL, EXE, etc. to add various options, including /SWAPRUN: NET (which corresponds to the IMAGE_FILE_NET_RUN_FROM_SWAP directive) without having to recompile the project. We also thought that it would be better to run EDITBIN right away not only on external BPL, EXE etc. but also on Delphi ones (rtl, vcl, etc.).



Everything connected with Tech & Code. Follow to join our 1M+ monthly readers

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store