Apparently, Delphi (any version) does not support safe exception handlers (/SAFESEH switch in Visual Studio). This results in a warning when using Windows Desktop App Certification Kit on Windows 8. Per certification requirements for Windows 8 desktop apps:
Your app must be compiled using the /SafeSEH flag to ensure safe exceptions handling
Obviously Delphi lacks this switch, so it cannot be done. My questions are:
Is my understanding correct, that even though the Kit displays only a warning (not fail), since this is a "must" requirement, any Delphi app today cannot be certified for Windows 8 and therefore cannot be included in the Windows app store?
Can SafeSEH tables be added to a PE file after the compilation somehow (e.g. extracting needed info from the map file or debug symbols), or we absolutely need a compiler/linker support for this, and therefore must wait till Embarcadero implements this feature?
To clearify, my application is Windows 32-bit desktop application (64-bit compatible), not Metro application.
I cannot answer question 1. However, I find it hard to imagine that the use of the word must could mean that the rule was optional.
As for question 2, you would need support from the compiler/linker. You cannot reasonably expect to back fit this with a PE editing post-link tool. Consider the following code:
The compiler emits the following:
Now, the real exception handler is
HandleOnException
, implemented inSystem.pas
. But, the address pushed onto the stack is$0041c3c9
, an address local to the code containing thetry/except
block. This means that in order to create a SafeSEH PE section you would need to locate each and everytry/except
in your code. Whilst that is obviously feasible, I don't think it is tractable.I rather imagined that the SEH exception handlers for the x86 compiler would be just the
_HandleXXX
functions declared inSystem.pas
. In which case it would be easy enough to add a PE section listing just those functions as a post-link step. However, since every singletry/except
has its own local exception handler, I now believe that only the compiler author can realistically hope to add the SafeSEH PE section.There is, so far as I can see, no QC report that requests
SafeSEH
support for the x86 Windows compiler. I suggest that you log a QC report, and an official support case.Update: Well done to @haimg for succeeding where I failed and managing to locate a QC report: QC#106781.