server: Return more specific error status for NE binaries.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2018-09-25 16:52:00 +02:00
parent 0dcfc97fcb
commit 622aeeba6a
3 changed files with 24 additions and 2 deletions

View File

@ -972,6 +972,24 @@ static void test_Loader(void)
nt_header.Signature = IMAGE_OS2_SIGNATURE;
status = map_image_section( &nt_header, &section, section_data, __LINE__ );
ok( status == STATUS_INVALID_IMAGE_NE_FORMAT, "NtCreateSection error %08x\n", status );
for (i = 0; i < 16; i++)
{
((IMAGE_OS2_HEADER *)&nt_header)->ne_exetyp = i;
status = map_image_section( &nt_header, &section, section_data, __LINE__ );
switch (i)
{
case 2:
ok( status == STATUS_INVALID_IMAGE_WIN_16, "NtCreateSection %u error %08x\n", i, status );
break;
case 5:
ok( status == STATUS_INVALID_IMAGE_PROTECT, "NtCreateSection %u error %08x\n", i, status );
break;
default:
ok( status == STATUS_INVALID_IMAGE_NE_FORMAT, "NtCreateSection %u error %08x\n", i, status );
break;
}
}
((IMAGE_OS2_HEADER *)&nt_header)->ne_exetyp = ((IMAGE_OS2_HEADER *)&nt_header_template)->ne_exetyp;
nt_header.Signature = 0xdeadbeef;
status = map_image_section( &nt_header, &section, section_data, __LINE__ );

View File

@ -587,8 +587,11 @@ static unsigned int get_image_params( struct mapping *mapping, file_pos_t file_s
if (size < sizeof(nt)) memset( (char *)&nt + size, 0, sizeof(nt) - size );
if (nt.Signature != IMAGE_NT_SIGNATURE)
{
if (*(WORD *)&nt.Signature == IMAGE_OS2_SIGNATURE) return STATUS_INVALID_IMAGE_NE_FORMAT;
return STATUS_INVALID_IMAGE_PROTECT;
IMAGE_OS2_HEADER *os2 = (IMAGE_OS2_HEADER *)&nt;
if (os2->ne_magic != IMAGE_OS2_SIGNATURE) return STATUS_INVALID_IMAGE_PROTECT;
if (os2->ne_exetyp == 2) return STATUS_INVALID_IMAGE_WIN_16;
if (os2->ne_exetyp == 5) return STATUS_INVALID_IMAGE_PROTECT;
return STATUS_INVALID_IMAGE_NE_FORMAT;
}
switch (nt.opt.hdr32.Magic)

View File

@ -5480,6 +5480,7 @@ static const struct
{ "INVALID_IMAGE_NE_FORMAT", STATUS_INVALID_IMAGE_NE_FORMAT },
{ "INVALID_IMAGE_NOT_MZ", STATUS_INVALID_IMAGE_NOT_MZ },
{ "INVALID_IMAGE_PROTECT", STATUS_INVALID_IMAGE_PROTECT },
{ "INVALID_IMAGE_WIN_16", STATUS_INVALID_IMAGE_WIN_16 },
{ "INVALID_IMAGE_WIN_64", STATUS_INVALID_IMAGE_WIN_64 },
{ "INVALID_LOCK_SEQUENCE", STATUS_INVALID_LOCK_SEQUENCE },
{ "INVALID_OWNER", STATUS_INVALID_OWNER },