summaryrefslogtreecommitdiffstats
path: root/src/file_exe.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2009-07-03 07:37:09 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2009-07-03 07:37:09 +0200
commit6c32033a49fb849c4e0706d24e1e4e8af2fcf109 (patch)
tree8fa05892ccb9e7f984402ccaf36835c47fbb60be /src/file_exe.c
parent7b9693d6eaa8fb130e17e512603eb12dfed8af13 (diff)
PhotoRec: recover 16 bits (MZ NE) windows executable
Diffstat (limited to 'src/file_exe.c')
-rw-r--r--src/file_exe.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/file_exe.c b/src/file_exe.c
index 0a7a078..8405460 100644
--- a/src/file_exe.c
+++ b/src/file_exe.c
@@ -68,6 +68,15 @@ static int header_check_exe(const unsigned char *buffer, const unsigned int buff
{
const struct pe_image_file_hdr *pe_hdr;
pe_hdr=(const struct pe_image_file_hdr *)(buffer+le32(dos_hdr->e_lfanew));
+ if(le32(dos_hdr->e_lfanew)>0 &&
+ le32(dos_hdr->e_lfanew) <= buffer_size-sizeof(struct pe_image_file_hdr) &&
+ (le32(pe_hdr->Magic) & 0xffff) == IMAGE_WIN16_SIGNATURE)
+ {
+ /* NE Win16 */
+ reset_file_recovery(file_recovery_new);
+ file_recovery_new->extension=file_hint_exe.extension;
+ return 1;
+ }
if(le32(dos_hdr->e_lfanew)==0 ||
le32(dos_hdr->e_lfanew) > buffer_size-sizeof(struct pe_image_file_hdr) ||
le32(pe_hdr->Magic) != IMAGE_NT_SIGNATURE)
@@ -104,6 +113,7 @@ static int header_check_exe(const unsigned char *buffer, const unsigned int buff
#endif
return 0;
}
+ /* PE */
if(le16(pe_hdr->Characteristics) & 0x2000)
{
/* Dynamic Link Library */