http://bugs.winehq.org/show_bug.cgi?id=3591
--- Comment #24 from Bernhard Reiter ockham@raz.or.at --- Back with a somewhat more detailed analysis:
As for py2exe and cx_Freeze, the assumptions in my previous comment seem to be largely correct, see their implementations of the StatusRoutine function:
https://bitbucket.org/anthony_tuininga/cx_freeze/src/de3e8865616a1048d17e951...
http://sourceforge.net/p/py2exe/svn/HEAD/tree/trunk/py2exe/source/py2exe_uti...
In both cases, BindImageEx is called with BIND_NO_BOUND_IMPORTS | BIND_NO_UPDATE | BIND_ALL_IMAGES as Flags, which I think means that no actual changes to the image's virtual address table are done, but they're only used to determine which DLLs are used by the image.
So for cx_Freeze, it would be apparently enough for Wine's BindImageEx stub to iterate over all DLLs whose functions are used by the image, i.e. the exe or dll passed as the ImageName parameter, and call StatusRoutine with the Reason parameter set to BindImportModule, and DllName set to the DLL, while the "Parameter" and "virtualAddress" arguments aren't required for it to work. The part I don't know yet is how to get the list of DLLs required by the Image, but I suppose that some function in dlls/ntdll/ (maybe loader.c ?) could be used to do that. (It can't be that hard anyway as it's possible to display them by running i686-w64-mingw32-objdump -p myimage.exe)
(Py2exe also requires StatusRoutine called with BindImportProcedure as Reason, and will in that case check if Parameter is set to PyImport_ImportModule before it does something, so that's possibly a little bit more complicated to implement.)
I'm now hoping for some Wine guru to pick this up and implement BindImageEx as described above so that at least cx_Freeze will work...