Module: wine Branch: master Commit: f244c3b5ebfae0bcbe13b127c4b3abd356a22f7e URL: https://source.winehq.org/git/wine.git/?a=commit;h=f244c3b5ebfae0bcbe13b127c...
Author: Alexandre Julliard julliard@winehq.org Date: Sat Feb 9 15:23:47 2019 +0100
server: Add custom flag for fake dlls in PE image information.
Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/ntdll/virtual.c | 2 +- include/wine/server_protocol.h | 3 ++- server/mapping.c | 20 +++++++++++++++----- server/protocol.def | 1 + 4 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c index 030c658..c008db7 100644 --- a/dlls/ntdll/virtual.c +++ b/dlls/ntdll/virtual.c @@ -3200,7 +3200,7 @@ void virtual_fill_image_information( const pe_image_info_t *pe_info, SECTION_IMA info->DllCharacteristics = pe_info->dll_charact; info->Machine = pe_info->machine; info->ImageContainsCode = pe_info->contains_code; - info->u.ImageFlags = pe_info->image_flags; + info->u.ImageFlags = pe_info->image_flags & ~IMAGE_FLAGS_WineFakeDll; info->LoaderFlags = pe_info->loader_flags; info->ImageFileSize = pe_info->file_size; info->CheckSum = pe_info->checksum; diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h index 48c9723..63f65cd 100644 --- a/include/wine/server_protocol.h +++ b/include/wine/server_protocol.h @@ -714,6 +714,7 @@ typedef struct #define IMAGE_FLAGS_ImageDynamicallyRelocated 0x04 #define IMAGE_FLAGS_ImageMappedFlat 0x08 #define IMAGE_FLAGS_BaseBelow4gb 0x10 +#define IMAGE_FLAGS_WineFakeDll 0x80
struct rawinput_device { @@ -6553,6 +6554,6 @@ union generic_reply struct terminate_job_reply terminate_job_reply; };
-#define SERVER_PROTOCOL_VERSION 571 +#define SERVER_PROTOCOL_VERSION 572
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */ diff --git a/server/mapping.c b/server/mapping.c index bc59b21..37c17b0 100644 --- a/server/mapping.c +++ b/server/mapping.c @@ -555,11 +555,17 @@ static int load_clr_header( IMAGE_COR20_HEADER *hdr, size_t va, size_t size, int /* retrieve the mapping parameters for an executable (PE) image */ static unsigned int get_image_params( struct mapping *mapping, file_pos_t file_size, int unix_fd ) { - IMAGE_DOS_HEADER dos; + static const char fakedll_signature[] = "Wine placeholder DLL"; + IMAGE_COR20_HEADER clr; IMAGE_SECTION_HEADER sec[96]; struct { + IMAGE_DOS_HEADER dos; + char buffer[sizeof(fakedll_signature)]; + } mz; + struct + { DWORD Signature; IMAGE_FILE_HEADER FileHeader; union @@ -570,15 +576,17 @@ static unsigned int get_image_params( struct mapping *mapping, file_pos_t file_s } nt; off_t pos; int size; - size_t clr_va, clr_size; + size_t mz_size, clr_va, clr_size; unsigned int i, cpu_mask = get_supported_cpu_mask();
/* load the headers */
if (!file_size) return STATUS_INVALID_FILE_FOR_SECTION; - if (pread( unix_fd, &dos, sizeof(dos), 0 ) != sizeof(dos)) return STATUS_INVALID_IMAGE_NOT_MZ; - if (dos.e_magic != IMAGE_DOS_SIGNATURE) return STATUS_INVALID_IMAGE_NOT_MZ; - pos = dos.e_lfanew; + size = pread( unix_fd, &mz, sizeof(mz), 0 ); + if (size < sizeof(mz.dos)) return STATUS_INVALID_IMAGE_NOT_MZ; + if (mz.dos.e_magic != IMAGE_DOS_SIGNATURE) return STATUS_INVALID_IMAGE_NOT_MZ; + mz_size = size; + pos = mz.dos.e_lfanew;
size = pread( unix_fd, &nt, sizeof(nt), pos ); if (size < sizeof(nt.Signature) + sizeof(nt.FileHeader)) return STATUS_INVALID_IMAGE_FORMAT; @@ -691,6 +699,8 @@ static unsigned int get_image_params( struct mapping *mapping, file_pos_t file_s mapping->image.gp = 0; /* FIXME */ mapping->image.file_size = file_size; mapping->image.loader_flags = clr_va && clr_size; + if (mz_size == sizeof(mz) && !memcmp( mz.buffer, fakedll_signature, sizeof(fakedll_signature) )) + mapping->image.image_flags |= IMAGE_FLAGS_WineFakeDll;
/* load the section headers */
diff --git a/server/protocol.def b/server/protocol.def index 73e0868..e65b984 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -730,6 +730,7 @@ typedef struct #define IMAGE_FLAGS_ImageDynamicallyRelocated 0x04 #define IMAGE_FLAGS_ImageMappedFlat 0x08 #define IMAGE_FLAGS_BaseBelow4gb 0x10 +#define IMAGE_FLAGS_WineFakeDll 0x80
struct rawinput_device {