From c8c800c8519354f941670081964fa094fe209598 Mon Sep 17 00:00:00 2001 From: Uwe Bonnes Date: Sun, 23 Jan 2000 02:27:16 +0000 Subject: [PATCH] Check for MZ header before trying to decipher the PE header. --- loader/pe_image.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/loader/pe_image.c b/loader/pe_image.c index 5324ee8b999..7c0128cd07c 100644 --- a/loader/pe_image.c +++ b/loader/pe_image.c @@ -498,13 +498,18 @@ HMODULE PE_LoadImage( HANDLE hFile, LPCSTR filename, WORD *version ) WARN("MapViewOfFile error %ld\n", GetLastError() ); 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 ); /* Check signature */ if ( nt->Signature != IMAGE_NT_SIGNATURE ) { - WARN("image doesn't have PE signature, but 0x%08lx\n", - nt->Signature ); + WARN("%s image doesn't have PE signature, but 0x%08lx\n", nt->Signature ); goto error; }