genpeimg: fix mistaken section header size. According to Microsoft docs and observation of real images, section headers are 40 bytes, not 36. Signed-off-by: Jeremy Drake <jeremyd2019@users.sourceforge.net> Signed-off-by: Martin Storsjö <martin@martin.st>
diff --git a/mingw-w64-tools/genpeimg/src/img.h b/mingw-w64-tools/genpeimg/src/img.h index 4a927c8..6e969a1 100644 --- a/mingw-w64-tools/genpeimg/src/img.h +++ b/mingw-w64-tools/genpeimg/src/img.h
@@ -66,7 +66,7 @@ } pe_filehdr; size_t optional_hdr_pos; size_t section_list; - size_t section_list_sz; /* Each section entry has 36 bytes size. */ + size_t section_list_sz; /* Each section entry has 40 bytes size. */ int is_64bit : 1; int is_bigendian : 1; } pe_image;
diff --git a/mingw-w64-tools/genpeimg/src/img_pe.c b/mingw-w64-tools/genpeimg/src/img_pe.c index 71794ab..91aef95 100644 --- a/mingw-w64-tools/genpeimg/src/img_pe.c +++ b/mingw-w64-tools/genpeimg/src/img_pe.c
@@ -133,7 +133,7 @@ return 0; } pe->section_list = pe->optional_hdr_pos + pe->pe_filehdr.szOptHdr; - pe->section_list_sz = ((size_t) pe->pe_filehdr.numsecs) * (4 * 9); + pe->section_list_sz = ((size_t) pe->pe_filehdr.numsecs) * 40; return 1; }