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

This commit is contained in:
Alexandre Julliard 2014-08-22 12:44:24 +02:00
parent cf4404cfbb
commit ea1689e7b0
3 changed files with 18 additions and 4 deletions

View File

@ -77,6 +77,7 @@ enum binary_type
#define BINARY_FLAG_DLL 0x01 #define BINARY_FLAG_DLL 0x01
#define BINARY_FLAG_64BIT 0x02 #define BINARY_FLAG_64BIT 0x02
#define BINARY_FLAG_FAKEDLL 0x04
struct binary_info struct binary_info
{ {

View File

@ -339,6 +339,9 @@ void MODULE_get_binary_info( HANDLE hfile, struct binary_info *info )
{ {
if (len >= sizeof(ext_header.nt.FileHeader)) 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->type = BINARY_PE;
info->arch = ext_header.nt.FileHeader.Machine; info->arch = ext_header.nt.FileHeader.Machine;
if (ext_header.nt.FileHeader.Characteristics & IMAGE_FILE_DLL) 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; info->flags |= BINARY_FLAG_64BIT;
break; 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 )) else if (!memcmp( &ext_header.os2.ne_magic, "NE", 2 ))

View File

@ -2342,9 +2342,10 @@ static BOOL create_process_impl( LPCWSTR app_name, LPWSTR cmd_line, LPSECURITY_A
else switch (binary_info.type) else switch (binary_info.type)
{ {
case BINARY_PE: 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, 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, retv = create_process( hFile, name, tidy_cmdline, envW, cur_dir, process_attr, thread_attr,
inherit, flags, startup_info, info, unixdir, &binary_info, FALSE ); inherit, flags, startup_info, info, unixdir, &binary_info, FALSE );
break; break;