From 671abb988c30034cd33c4485c4e6fba02604686e Mon Sep 17 00:00:00 2001 From: j-t-1 <120829237+j-t-1@users.noreply.github.com> Date: Sun, 8 Sep 2024 19:46:03 +0100 Subject: [PATCH] Slightly simplify is_exe and is_dll EXE_flag and DLL_flag are powers of two, meaning the equality check after the bitwise And is unnecessary. --- pefile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pefile.py b/pefile.py index f804678..6191742 100644 --- a/pefile.py +++ b/pefile.py @@ -7820,7 +7820,7 @@ def is_exe(self): if ( (not self.is_dll()) and (not self.is_driver()) - and (EXE_flag & self.FILE_HEADER.Characteristics) == EXE_flag + and (EXE_flag & self.FILE_HEADER.Characteristics) ): return True @@ -7834,7 +7834,7 @@ def is_dll(self): DLL_flag = IMAGE_CHARACTERISTICS["IMAGE_FILE_DLL"] - if (DLL_flag & self.FILE_HEADER.Characteristics) == DLL_flag: + if DLL_flag & self.FILE_HEADER.Characteristics: return True return False