Skip to content

Commit

Permalink
[efi] Work around broken 32-bit PE executable parsing in ImageHlp.dll
Browse files Browse the repository at this point in the history
The Microsoft PE/COFF specification defines the MajorLinkerVersion and
MinorLinkerVersion fields as "The linker major version number" and
"The linker minor version number" respectively, and has nothing more
to say on the matter.  These fields have no significance: they do not
affect the interpretation of the remainder of the file, but merely
provide diagnostic information for interested humans to read.

Apparently, versions 2.4 and earlier of the Microsoft linker produced
binaries so incorrigibly cursed that even to attempt to parse such a
binary would risk summoning a plague of enraged spiders.  To protect
users from unwanted arachnids, ImageHlp.dll's MapAndLoad() function
will helpfully fail to map and/or load a 32-bit binary unless the
linker version field indicates version 2.5 or later.  (64-bit binaries
are exempt from such helpfulness.)

Work around the broken Microsoft ImageHlp.dll library by providing a
linker version number that will satisfy the arbitrary whims of the
MapAndLoad() function.

Debugged-by: James Murray <jmurray@microsoft.com>
Debugged-by: Michael Brown <mbrown@fensystems.co.uk>
Signed-off-by: Michael Brown <mbrown@fensystems.co.uk>
  • Loading branch information
mcb30 committed Sep 22, 2015
1 parent be72dfd commit 670c7e2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/prefix.S
Expand Up @@ -99,8 +99,8 @@ pe_header:
.size pe_header, . - pe_header
opt_header:
.word opt_magic /* Magic */
.byte 0 /* MajorLinkerVersion */
.byte 0 /* MinorLinkerVersion */
.byte 42 /* MajorLinkerVersion */
.byte 42 /* MinorLinkerVersion */
.long _text_total_len /* SizeOfCode */
.long _data_total_len /* SizeOfInitializedData */
.long _bss_total_len /* SizeOfUninitializedData */
Expand Down

0 comments on commit 670c7e2

Please sign in to comment.