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

@ -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
{

View File

@ -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 ))

View File

@ -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;