Commit 84b3218e authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

server: Fix loading of IMAGE_OPTIONAL_HEADER.

parent 5e7c8928
......@@ -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 );
......
......@@ -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)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment