server: Check the supported machines list to validate an image mapping.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
d7fecebe93
commit
8d50c34655
|
@ -642,7 +642,7 @@ static unsigned int get_image_params( struct mapping *mapping, file_pos_t file_s
|
||||||
off_t pos;
|
off_t pos;
|
||||||
int size, opt_size;
|
int size, opt_size;
|
||||||
size_t mz_size, clr_va, clr_size;
|
size_t mz_size, clr_va, clr_size;
|
||||||
unsigned int i, cpu_mask = get_supported_cpu_mask();
|
unsigned int i;
|
||||||
|
|
||||||
/* load the headers */
|
/* load the headers */
|
||||||
|
|
||||||
|
@ -671,17 +671,9 @@ static unsigned int get_image_params( struct mapping *mapping, file_pos_t file_s
|
||||||
switch (nt.opt.hdr32.Magic)
|
switch (nt.opt.hdr32.Magic)
|
||||||
{
|
{
|
||||||
case IMAGE_NT_OPTIONAL_HDR32_MAGIC:
|
case IMAGE_NT_OPTIONAL_HDR32_MAGIC:
|
||||||
switch (nt.FileHeader.Machine)
|
if (!is_machine_32bit( nt.FileHeader.Machine )) return STATUS_INVALID_IMAGE_FORMAT;
|
||||||
{
|
if (!is_machine_supported( nt.FileHeader.Machine )) return STATUS_INVALID_IMAGE_FORMAT;
|
||||||
case IMAGE_FILE_MACHINE_I386:
|
|
||||||
if (cpu_mask & (CPU_FLAG(CPU_x86) | CPU_FLAG(CPU_x86_64))) break;
|
|
||||||
return STATUS_INVALID_IMAGE_FORMAT;
|
|
||||||
case IMAGE_FILE_MACHINE_ARMNT:
|
|
||||||
if (cpu_mask & (CPU_FLAG(CPU_ARM) | CPU_FLAG(CPU_ARM64))) break;
|
|
||||||
return STATUS_INVALID_IMAGE_FORMAT;
|
|
||||||
default:
|
|
||||||
return STATUS_INVALID_IMAGE_FORMAT;
|
|
||||||
}
|
|
||||||
clr_va = nt.opt.hdr32.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].VirtualAddress;
|
clr_va = nt.opt.hdr32.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].VirtualAddress;
|
||||||
clr_size = nt.opt.hdr32.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].Size;
|
clr_size = nt.opt.hdr32.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].Size;
|
||||||
|
|
||||||
|
@ -710,18 +702,10 @@ static unsigned int get_image_params( struct mapping *mapping, file_pos_t file_s
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IMAGE_NT_OPTIONAL_HDR64_MAGIC:
|
case IMAGE_NT_OPTIONAL_HDR64_MAGIC:
|
||||||
if (!(cpu_mask & CPU_64BIT_MASK)) return STATUS_INVALID_IMAGE_WIN_64;
|
if (!is_machine_64bit( supported_machines[0] )) return STATUS_INVALID_IMAGE_WIN_64;
|
||||||
switch (nt.FileHeader.Machine)
|
if (!is_machine_64bit( nt.FileHeader.Machine )) return STATUS_INVALID_IMAGE_FORMAT;
|
||||||
{
|
if (!is_machine_supported( nt.FileHeader.Machine )) return STATUS_INVALID_IMAGE_FORMAT;
|
||||||
case IMAGE_FILE_MACHINE_AMD64:
|
|
||||||
if (cpu_mask & (CPU_FLAG(CPU_x86) | CPU_FLAG(CPU_x86_64))) break;
|
|
||||||
return STATUS_INVALID_IMAGE_FORMAT;
|
|
||||||
case IMAGE_FILE_MACHINE_ARM64:
|
|
||||||
if (cpu_mask & (CPU_FLAG(CPU_ARM) | CPU_FLAG(CPU_ARM64))) break;
|
|
||||||
return STATUS_INVALID_IMAGE_FORMAT;
|
|
||||||
default:
|
|
||||||
return STATUS_INVALID_IMAGE_FORMAT;
|
|
||||||
}
|
|
||||||
clr_va = nt.opt.hdr64.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].VirtualAddress;
|
clr_va = nt.opt.hdr64.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].VirtualAddress;
|
||||||
clr_size = nt.opt.hdr64.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].Size;
|
clr_size = nt.opt.hdr64.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].Size;
|
||||||
|
|
||||||
|
|
|
@ -244,6 +244,21 @@ extern unsigned short supported_machines[8];
|
||||||
extern void init_registry(void);
|
extern void init_registry(void);
|
||||||
extern void flush_registry(void);
|
extern void flush_registry(void);
|
||||||
|
|
||||||
|
static inline int is_machine_32bit( unsigned short machine )
|
||||||
|
{
|
||||||
|
return machine == IMAGE_FILE_MACHINE_I386 || machine == IMAGE_FILE_MACHINE_ARMNT;
|
||||||
|
}
|
||||||
|
static inline int is_machine_64bit( unsigned short machine )
|
||||||
|
{
|
||||||
|
return machine == IMAGE_FILE_MACHINE_AMD64 || machine == IMAGE_FILE_MACHINE_ARM64;
|
||||||
|
}
|
||||||
|
static inline int is_machine_supported( unsigned short machine )
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
for (i = 0; i < supported_machines_count; i++) if (supported_machines[i] == machine) return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* signal functions */
|
/* signal functions */
|
||||||
|
|
||||||
extern void start_watchdog(void);
|
extern void start_watchdog(void);
|
||||||
|
|
|
@ -1341,12 +1341,6 @@ int is_cpu_supported( enum cpu_type cpu )
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return the cpu mask for supported cpus */
|
|
||||||
unsigned int get_supported_cpu_mask(void)
|
|
||||||
{
|
|
||||||
return supported_cpus & get_prefix_cpu_mask();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* create a new thread */
|
/* create a new thread */
|
||||||
DECL_HANDLER(new_thread)
|
DECL_HANDLER(new_thread)
|
||||||
{
|
{
|
||||||
|
|
|
@ -120,7 +120,6 @@ extern int thread_get_inflight_fd( struct thread *thread, int client );
|
||||||
extern struct token *thread_get_impersonation_token( struct thread *thread );
|
extern struct token *thread_get_impersonation_token( struct thread *thread );
|
||||||
extern int set_thread_affinity( struct thread *thread, affinity_t affinity );
|
extern int set_thread_affinity( struct thread *thread, affinity_t affinity );
|
||||||
extern int is_cpu_supported( enum cpu_type cpu );
|
extern int is_cpu_supported( enum cpu_type cpu );
|
||||||
extern unsigned int get_supported_cpu_mask(void);
|
|
||||||
extern int suspend_thread( struct thread *thread );
|
extern int suspend_thread( struct thread *thread );
|
||||||
extern int resume_thread( struct thread *thread );
|
extern int resume_thread( struct thread *thread );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue