'Python pefile analysis lief and pefile giving different values for e_lfanew

I am using lief and pefile modules to analyse PE32 files in python. When getting the dos header data, everything seems to be the same between the two modules except for the e_lfanew field which should be the offset to the PE file header.

liefpe = lief.PE.Binary("python-3.9.10.exe", lief.PE.PE_TYPE.PE32)
pefilepe = pefile.PE("python-3.9.10.exe")

print(liefpe.dos_header.addressof_new_exeheader)
print(pefilepe.DOS_HEADER.e_lfanew)

output:

240
272

Why is there a difference by 32? I tried with other files and have found similar differences.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source