http://bugs.winehq.org/show_bug.cgi?id=3591
--- Comment #25 from Bernhard Reiter ockham@raz.or.at --- For py2exe to also work, I think there should be another loop iterating over a DLL's functions, nested in the one mentioned in the previous comment, and which invokes StatusRoutine with Status set to BindImportProcedure, and with the current function's name as Parameter.
BTW, I think I have found out the crucial function required to implement this to be ImageDirectoryEntryToDataEx [1] (with dir set to IMAGE_DIRECTORY_ENTRY_IMPORT). Similar iterations like the ones sketched here seem to be found in fixup_imports() (in dlls/ntdll/loader.c) or dump_dir_imported_functions() (in tools/winedump/pe.c, though that isn't using win API functions).
So I've tried to implement what I've described in this comment and the previous one, but unfortunately, I can't seem to figure out the very first part required: obtaining something that can be used as the "base" parameter for ImageDirectoryEntryToDataEx from the ImageName string passed to BindImageEx. I've tried LoadLibrary(ImageName), LoadLibraryExA(ImageName, NULL, LOAD_LIBRARY_AS_DATAFILE), and MapAndLoad(), but unfortunately, all of them seem to either import all the PE's symbols in a fashion that collides with the already loaded ones (in particular in a python-freezing context, like running "wine C:\Python27\python.exe setup.py build" with the test case attached to this bug report), or not load them in a way that can be used for ImageDirectoryEntryToDataEx. Maybe someone can help me figure out how to do this...
[1] http://source.winehq.org/WineAPI/.html