Check for MZ header before trying to decipher the PE header.

This commit is contained in:
Uwe Bonnes 2000-01-23 02:27:16 +00:00 committed by Alexandre Julliard
parent 9c55e6dc9d
commit c8c800c851

View file

@ -498,13 +498,18 @@ HMODULE PE_LoadImage( HANDLE hFile, LPCSTR filename, WORD *version )
WARN("MapViewOfFile error %ld\n", GetLastError() ); WARN("MapViewOfFile error %ld\n", GetLastError() );
return 0; return 0;
} }
if ( *(WORD*)hModule !=IMAGE_DOS_SIGNATURE)
{
WARN("%s image doesn't have DOS signature, but 0x%04x\n", filename,*(WORD*)hModule);
goto error;
}
nt = PE_HEADER( hModule ); nt = PE_HEADER( hModule );
/* Check signature */ /* Check signature */
if ( nt->Signature != IMAGE_NT_SIGNATURE ) if ( nt->Signature != IMAGE_NT_SIGNATURE )
{ {
WARN("image doesn't have PE signature, but 0x%08lx\n", WARN("%s image doesn't have PE signature, but 0x%08lx\n", nt->Signature );
nt->Signature );
goto error; goto error;
} }