Alexandre Julliard : kernel32: Add detection of fake dlls when determining a binary type.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Aug 22 13:48:40 CDT 2014


Module: wine
Branch: master
Commit: ea1689e7b06a5f03a882bde9ee566939e9171330
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=ea1689e7b06a5f03a882bde9ee566939e9171330

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Fri Aug 22 12:44:24 2014 +0200

kernel32: Add detection of fake dlls when determining a binary type.

---

 dlls/kernel32/kernel_private.h |  5 +++--
 dlls/kernel32/module.c         | 12 ++++++++++++
 dlls/kernel32/process.c        |  5 +++--
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/dlls/kernel32/kernel_private.h b/dlls/kernel32/kernel_private.h
index 5c6c197..76611d7 100644
--- a/dlls/kernel32/kernel_private.h
+++ b/dlls/kernel32/kernel_private.h
@@ -75,8 +75,9 @@ enum binary_type
     BINARY_UNIX_LIB
 };
 
-#define BINARY_FLAG_DLL   0x01
-#define BINARY_FLAG_64BIT 0x02
+#define BINARY_FLAG_DLL     0x01
+#define BINARY_FLAG_64BIT   0x02
+#define BINARY_FLAG_FAKEDLL 0x04
 
 struct binary_info
 {
diff --git a/dlls/kernel32/module.c b/dlls/kernel32/module.c
index 514b6be..ca4cf41 100644
--- a/dlls/kernel32/module.c
+++ b/dlls/kernel32/module.c
@@ -339,6 +339,9 @@ void MODULE_get_binary_info( HANDLE hfile, struct binary_info *info )
         {
             if (len >= sizeof(ext_header.nt.FileHeader))
             {
+                static const char fakedll_signature[] = "Wine placeholder DLL";
+                char buffer[sizeof(fakedll_signature)];
+
                 info->type = BINARY_PE;
                 info->arch = ext_header.nt.FileHeader.Machine;
                 if (ext_header.nt.FileHeader.Characteristics & IMAGE_FILE_DLL)
@@ -356,6 +359,15 @@ void MODULE_get_binary_info( HANDLE hfile, struct binary_info *info )
                     info->flags |= BINARY_FLAG_64BIT;
                     break;
                 }
+
+                if (header.mz.e_lfanew >= sizeof(header.mz) + sizeof(fakedll_signature) &&
+                    SetFilePointer( hfile, sizeof(header.mz), NULL, SEEK_SET ) == sizeof(header.mz) &&
+                    ReadFile( hfile, buffer, sizeof(fakedll_signature), &len, NULL ) &&
+                    len == sizeof(fakedll_signature) &&
+                    !memcmp( buffer, fakedll_signature, sizeof(fakedll_signature) ))
+                {
+                    info->flags |= BINARY_FLAG_FAKEDLL;
+                }
             }
         }
         else if (!memcmp( &ext_header.os2.ne_magic, "NE", 2 ))
diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c
index 2566ac4..301c64a 100644
--- a/dlls/kernel32/process.c
+++ b/dlls/kernel32/process.c
@@ -2342,9 +2342,10 @@ static BOOL create_process_impl( LPCWSTR app_name, LPWSTR cmd_line, LPSECURITY_A
     else switch (binary_info.type)
     {
     case BINARY_PE:
-        TRACE( "starting %s as Win%d binary (%p-%p, arch %04x)\n",
+        TRACE( "starting %s as Win%d binary (%p-%p, arch %04x%s)\n",
                debugstr_w(name), (binary_info.flags & BINARY_FLAG_64BIT) ? 64 : 32,
-               binary_info.res_start, binary_info.res_end, binary_info.arch );
+               binary_info.res_start, binary_info.res_end, binary_info.arch,
+               (binary_info.flags & BINARY_FLAG_FAKEDLL) ? ", fakedll" : "" );
         retv = create_process( hFile, name, tidy_cmdline, envW, cur_dir, process_attr, thread_attr,
                                inherit, flags, startup_info, info, unixdir, &binary_info, FALSE );
         break;




More information about the wine-cvs mailing list