kernel32: Add a 64-bit flag to the MODULE_GetBinaryType return value.

This commit is contained in:
Alexandre Julliard 2009-08-12 15:50:47 +02:00
parent 4a59ac76f1
commit 8c11d71f0f
2 changed files with 17 additions and 9 deletions

View File

@ -92,6 +92,7 @@ extern LONG CALLBACK INSTR_vectored_handler( EXCEPTION_POINTERS *ptrs );
#define BINARY_UNIX_LIB 0x06
#define BINARY_TYPE_MASK 0x0f
#define BINARY_FLAG_DLL 0x10
#define BINARY_FLAG_64BIT 0x20
/* module.c */
extern WCHAR *MODULE_get_dll_load_path( LPCWSTR module );

View File

@ -233,15 +233,19 @@ DWORD MODULE_GetBinaryType( HANDLE hfile, void **res_start, void **res_end )
struct
{
unsigned char magic[4];
unsigned char ignored[12];
unsigned char class;
unsigned char data;
unsigned char version;
unsigned char ignored[9];
unsigned short type;
unsigned short machine;
} elf;
struct
{
unsigned long magic;
unsigned long cputype;
unsigned long cpusubtype;
unsigned long filetype;
unsigned int magic;
unsigned int cputype;
unsigned int cpusubtype;
unsigned int filetype;
} macho;
IMAGE_DOS_HEADER mz;
} header;
@ -256,11 +260,12 @@ DWORD MODULE_GetBinaryType( HANDLE hfile, void **res_start, void **res_end )
if (!memcmp( header.elf.magic, "\177ELF", 4 ))
{
DWORD flags = (header.elf.class == 2) ? BINARY_FLAG_64BIT : 0;
/* FIXME: we don't bother to check byte order, architecture, etc. */
switch(header.elf.type)
{
case 2: return BINARY_UNIX_EXE;
case 3: return BINARY_UNIX_LIB;
case 2: return flags | BINARY_UNIX_EXE;
case 3: return flags | BINARY_UNIX_LIB;
}
return BINARY_UNKNOWN;
}
@ -268,9 +273,11 @@ DWORD MODULE_GetBinaryType( HANDLE hfile, void **res_start, void **res_end )
/* Mach-o File with Endian set to Big Endian or Little Endian */
if (header.macho.magic == 0xfeedface || header.macho.magic == 0xcefaedfe)
{
DWORD flags = (header.macho.cputype >> 24) == 1 ? BINARY_FLAG_64BIT : 0;
switch(header.macho.filetype)
{
case 0x8: /* MH_BUNDLE */ return BINARY_UNIX_LIB;
case 2: return flags | BINARY_UNIX_EXE;
case 8: return flags | BINARY_UNIX_LIB;
}
return BINARY_UNKNOWN;
}
@ -321,7 +328,7 @@ DWORD MODULE_GetBinaryType( HANDLE hfile, void **res_start, void **res_end )
case IMAGE_NT_OPTIONAL_HDR64_MAGIC:
if (res_start) *res_start = NULL;
if (res_end) *res_end = NULL;
return ret;
return ret | BINARY_FLAG_64BIT;
}
}
return BINARY_DOS;