ECMerge ActiveX and the NX flag

Last week, we had the joy to play with a strange bug in ECMerge ActiveX.

The ActiveX works correctly on our XP and Vista 32/64… but not on some client computers. The problem appeared with a message similar to “cannot use windowless control”… but ECMerge is a windowed ActiveX control, which makes the message completely inappropriate.

This is the (not so) famous NXCOMPAT flag bug in ATL 7.1 (maybe applicable to pre-7.1 as well but I don’t know).  Why this bug? because ATL 7.1 uses code generation and does not flag the generated code as executable, it is there that the NXCOMPAT flag comes: if you run on a processor which can handle the NX flag, the executable you run has the NXCOMPAT flag and your Windows OS has also the NX flag handling, the ActiveX built with ATL 7.1. won’t run. In fact, the ActiveX will cause exceptions (data not executable) during the creation of its window, hence the ‘windowless’ message.

The good news is that most applications do not really need the NXCOMPAT flag because they won’t load unknown ActiveX controls and can fully trust those for which they were designed, this is usually the case when you use ECMerge… so there is a work-around: recent platform SDK (or Visual Studio) contains a tool called EDITBIN.EXE and this tool has a /NXCOMPAT:NO parameter which disables NX compatibility for the executable.

Hope it will help other ActiveX builders, and ECMerge users :)

Armel

0 Responses to “ECMerge ActiveX and the NX flag”



  1. No Comments Yet

Leave a Reply