server: Fix loading of IMAGE_OPTIONAL_HEADER.

Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Piotr Caban 2016-08-08 16:20:50 +02:00 committed by Alexandre Julliard
parent 5e7c892811
commit 84b3218ed6
2 changed files with 8 additions and 4 deletions

View File

@ -264,9 +264,13 @@ static void query_image_section( int id, const char *dll_name, const IMAGE_NT_HE
ok( image.CommittedStackSize == nt_header->OptionalHeader.SizeOfStackCommit || broken(truncated),
"%u: CommittedStackSize wrong %lx / %lx\n", id,
image.CommittedStackSize, (SIZE_T)nt_header->OptionalHeader.SizeOfStackCommit );
ok( image.SubSystemType == nt_header->OptionalHeader.Subsystem || broken(truncated),
"%u: SubSystemType wrong %08x / %08x\n", id,
image.SubSystemType, nt_header->OptionalHeader.Subsystem );
if (truncated)
ok( !image.SubSystemType || broken(truncated),
"%u: SubSystemType wrong %08x / 00000000\n", id, image.SubSystemType );
else
ok( image.SubSystemType == nt_header->OptionalHeader.Subsystem,
"%u: SubSystemType wrong %08x / %08x\n", id,
image.SubSystemType, nt_header->OptionalHeader.Subsystem );
ok( image.SubsystemVersionLow == nt_header->OptionalHeader.MinorSubsystemVersion,
"%u: SubsystemVersionLow wrong %04x / %04x\n", id,
image.SubsystemVersionLow, nt_header->OptionalHeader.MinorSubsystemVersion );

View File

@ -399,7 +399,7 @@ static unsigned int get_image_params( struct mapping *mapping, file_pos_t file_s
size = pread( unix_fd, &nt, sizeof(nt), pos );
if (size < sizeof(nt.Signature) + sizeof(nt.FileHeader)) return STATUS_INVALID_IMAGE_FORMAT;
/* zero out Optional header in the case it's not present or partial */
size = min( size, nt.FileHeader.SizeOfOptionalHeader );
size = min( size, sizeof(nt.Signature) + sizeof(nt.FileHeader) + nt.FileHeader.SizeOfOptionalHeader );
if (size < sizeof(nt)) memset( (char *)&nt + size, 0, sizeof(nt) - size );
if (nt.Signature != IMAGE_NT_SIGNATURE)
{