Module: wine Branch: master Commit: 6475603985c511c29fd027079286bb99d60a6a4a URL: http://source.winehq.org/git/wine.git/?a=commit;h=6475603985c511c29fd0270792...
Author: Alexandre Julliard julliard@winehq.org Date: Thu Nov 29 15:32:49 2007 +0100
libwine: Work around the Mac OS dynamic loader support for PE files.
---
libs/wine/loader.c | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/libs/wine/loader.c b/libs/wine/loader.c index 2f78248..13eb84a 100644 --- a/libs/wine/loader.c +++ b/libs/wine/loader.c @@ -668,6 +668,25 @@ void *wine_dlopen( const char *filename, int flag, char *error, size_t errorsize #ifdef HAVE_DLOPEN void *ret; const char *s; + +#ifdef __APPLE__ + /* the Mac OS loader pretends to be able to load PE files, so avoid them here */ + unsigned char magic[2]; + int fd = open( filename, O_RDONLY ); + if (fd != -1) + { + if (pread( fd, magic, 2, 0 ) == 2 && magic[0] == 'M' && magic[1] == 'Z') + { + static const char msg[] = "MZ format"; + size_t len = min( errorsize, sizeof(msg) ); + memcpy( error, msg, len ); + error[len - 1] = 0; + close( fd ); + return NULL; + } + close( fd ); + } +#endif dlerror(); dlerror(); #ifdef __sun if (strchr( filename, ':' ))