It is an executable signature. It is a simple and naive way to check if the executable is in a given format. If everything is right works, but it can be something forged or coincident, it is unlikely, but it can happen, and of course it has other validations, but this is the first that is made, if you do not find it already know that this format is not.
According to the Wikipedia is short for Mark Zbikowski, the guy he created participated in the creation.
The bytes you see below are more significant and begin to inform the composition of this specific executable. In this type of format there is a very complex treatment to initialize and prepare the memory, only a very old format that can go straight to the memory without specific treatment.
The case of being an MZ, ie an old DOS executable has little specific information following, other formats (PE) are much richer.
The newer executables still contain the "MZ" for compatibility reasons so there is no error if you call a modern executable in an old system, it will give a more specific error that the executable itself provides. This is interesting because older systems do not understand new formats and would give a generic error.
- One listing of how it can be composed.
- The Osdev has a well simplified form.
- And there’s a Wikibook with a slightly larger summary of how is the format of the modern PE that I find more interesting.
- Microsoft documentation.
- And a code if you want to write an executable in hand.
Anyway it seems quite broad try to describe everything here.
See the diagram of Wikipedia:
Long way to answer all this, you would have to study Microsoft’s PE format. About MZ, it’s the initials of Mark Zbikowski, a developer of MS-DOS, and he’s only on EXE as a 16-bit subsystem compatibility indicator (if you try to run a modern executable on MS-DOS you will receive the message that the application cannot be run on DOS, and this warning is the only "functionality" of the "DOS part" of the executable) - MZ differentiates . exe do . com on 16 bit systems.
– Bacco