Hello. Well, here is a result of my attempt to make it work. Now I'm stuck probably due a Linux limitation to mmap not aligned to the page size data. Anybody with more clues? Changelog: Relax a bit PE consistence checks. Return BINARY_DOS type if extended header was not recognized. -- Dmitry.
diff -u cvs/hq/wine/loader/module.c wine/loader/module.c --- cvs/hq/wine/loader/module.c Sat Aug 17 18:42:28 2002 +++ wine/loader/module.c Thu Aug 22 13:12:01 2002 @@ -635,15 +635,14 @@ */ if (!memcmp( magic, "PE\0\0", 4 )) { - IMAGE_NT_HEADERS nt; + IMAGE_FILE_HEADER FileHeader; - if (SetFilePointer( hfile, header.mz.e_lfanew, NULL, SEEK_SET ) != -1 && - ReadFile( hfile, &nt, sizeof(nt), &len, NULL ) && len == sizeof(nt)) + if (ReadFile( hfile, &FileHeader, sizeof(FileHeader), &len, NULL ) && len == sizeof(FileHeader)) { - if (nt.FileHeader.Characteristics & IMAGE_FILE_DLL) return BINARY_PE_DLL; + if (FileHeader.Characteristics & IMAGE_FILE_DLL) return BINARY_PE_DLL; return BINARY_PE_EXE; } - return BINARY_UNKNOWN; + return BINARY_DOS; } if (!memcmp( magic, "NE", 2 )) @@ -666,7 +665,7 @@ } } /* Couldn't read header, so abort. */ - return BINARY_UNKNOWN; + return BINARY_DOS; } /* Unknown extended header, but this file is nonetheless DOS-executable. */ diff -u cvs/hq/wine/memory/virtual.c wine/memory/virtual.c --- cvs/hq/wine/memory/virtual.c Sat Aug 17 18:42:29 2002 +++ wine/memory/virtual.c Thu Aug 22 15:00:03 2002 @@ -645,7 +645,7 @@ DWORD size; /* a few sanity checks */ - size = sec->VirtualAddress + ROUND_SIZE( sec->VirtualAddress, sec->Misc.VirtualSize ); + size = sec->VirtualAddress + ROUND_SIZE( 0, sec->Misc.VirtualSize ); if (sec->VirtualAddress > total_size || size > total_size || size < sec->VirtualAddress) { ERR_(module)( "Section %.8s too large (%lx+%lx/%lx)\n", diff -u cvs/hq/wine/server/mapping.c wine/server/mapping.c --- cvs/hq/wine/server/mapping.c Mon Jun 3 13:01:48 2002 +++ wine/server/mapping.c Thu Aug 22 13:21:12 2002 @@ -211,8 +211,13 @@ if (read( fd, &dos, sizeof(dos) ) != sizeof(dos)) goto error; if (dos.e_magic != IMAGE_DOS_SIGNATURE) goto error; if (lseek( fd, dos.e_lfanew, SEEK_SET ) == -1) goto error; - if (read( fd, &nt, sizeof(nt) ) != sizeof(nt)) goto error; + + if (read( fd, &nt.Signature, sizeof(nt.Signature) ) != sizeof(nt.Signature)) goto error; if (nt.Signature != IMAGE_NT_SIGNATURE) goto error; + if (read( fd, &nt.FileHeader, sizeof(nt.FileHeader) ) != sizeof(nt.FileHeader)) goto error; + /* zero out Optional header in the case it's not present or partial */ + memset(&nt.OptionalHeader, 0, sizeof(nt.OptionalHeader)); + if (read( fd, &nt.OptionalHeader, nt.FileHeader.SizeOfOptionalHeader) != nt.FileHeader.SizeOfOptionalHeader) goto error; /* load the section headers */