Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. What field of PE Header tells that whether a valid PE file or not?

What field of PE Header tells that whether a valid PE file or not?

Scheduled Pinned Locked Moved C / C++ / MFC
javajavascripthtmlquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    glitteringsound
    wrote on last edited by
    #1

    Hello, I need to check that whether a given binary is a valid PE file (Perhaps might some one can rename java file/class file or .js/html files to .exe or .DLL ). In this case i suspect that e_magic field of FileHeader structure would tell this.. or any other field will let the user know about the validity of PE file? Regards Usman

    C L 2 Replies Last reply
    0
    • G glitteringsound

      Hello, I need to check that whether a given binary is a valid PE file (Perhaps might some one can rename java file/class file or .js/html files to .exe or .DLL ). In this case i suspect that e_magic field of FileHeader structure would tell this.. or any other field will let the user know about the validity of PE file? Regards Usman

      C Offline
      C Offline
      Code o mat
      wrote on last edited by
      #2

      Am not sure if this is what you are looking for or not but here[^] they say:

      Old MS-DOS .exe files and the newer Microsoft Windows PE (Portable Executable) .exe files start with the ASCII string "MZ" (4D 5A), the initials of the designer of the file format, Mark Zbikowski. The definition allows "ZM" (5A 4D) as well, but this is quite uncommon.

      > The problem with computers is that they do what you tell them to do and not what you want them to do. < > "It doesn't work, fix it" does not qualify as a bug report. < > Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <

      1 Reply Last reply
      0
      • G glitteringsound

        Hello, I need to check that whether a given binary is a valid PE file (Perhaps might some one can rename java file/class file or .js/html files to .exe or .DLL ). In this case i suspect that e_magic field of FileHeader structure would tell this.. or any other field will let the user know about the validity of PE file? Regards Usman

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        The PEF specification is a large set of rules that must be obeyed. Obeying some of them is insufficient to be a valid EXE file. So you could check a few of those rules to rule out the obvious violators, you would have to check everything to be absolutely sure it is a real EXE though. If all you want to do is discard some obvious non-EXE files, look at the first two bytes, and a couple of the header bytes such as the e_magic field. :)

        Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

        Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups