Skip to content

Commit

Permalink
Merge branch 'master' of ssh://github.com/erocarrera/pefile
Browse files Browse the repository at this point in the history
  • Loading branch information
erocarrera committed Aug 26, 2024
2 parents d05a038 + 853c6ab commit 37c75e5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
11 changes: 4 additions & 7 deletions pefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -7778,7 +7778,7 @@ def is_driver(self):
# Checking that the ImageBase field of the OptionalHeader is above or
# equal to 0x80000000 (that is, whether it lies in the upper 2GB of
# the address space, normally belonging to the kernel) is not a
# reliable enough indicator. For instance, PEs that play the invalid
# reliable enough indicator. For instance, PEs that play the invalid
# ImageBase trick to get relocated could be incorrectly assumed to be
# drivers.

Expand All @@ -7803,18 +7803,17 @@ def is_driver(self):
# self.DIRECTORY_ENTRY_IMPORT will now exist, although it may be empty.
# If it imports from "ntoskrnl.exe" or other kernel components it should
# be a driver
#
system_DLLs = {
b"ntoskrnl.exe", b"hal.dll", b"ndis.sys", b"bootvid.dll", b"kdcom.dll"
}
if system_DLLs.intersection(
[imp.dll.lower() for imp in self.DIRECTORY_ENTRY_IMPORT]
{imp.dll.lower() for imp in self.DIRECTORY_ENTRY_IMPORT}
):
return True

driver_like_section_names = {b"page", b"paged"}
if driver_like_section_names.intersection(
[section.Name.lower().rstrip(b"\x00") for section in self.sections]
{section.Name.lower().rstrip(b"\x00") for section in self.sections}
) and (
self.OPTIONAL_HEADER.Subsystem
in (
Expand All @@ -7835,9 +7834,7 @@ def get_overlay_data_start_offset(self):
def update_if_sum_is_larger_and_within_file(
offset_and_size, file_size=len(self.__data__)
):
if sum(offset_and_size) <= file_size and sum(offset_and_size) > sum(
largest_offset_and_size
):
if sum(largest_offset_and_size) < sum(offset_and_size) <= file_size:
return offset_and_size
return largest_offset_and_size

Expand Down
8 changes: 2 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@
import os
import re
import sys

try:
from setuptools import Command, setup
except ImportError as excp:
from distutils.core import setup, Command

from unittest import TestLoader, TextTestRunner

from setuptools import Command, setup


os.environ["COPY_EXTENDED_ATTRIBUTES_DISABLE"] = "true"
os.environ["COPYFILE_DISABLE"] = "true"
Expand Down

0 comments on commit 37c75e5

Please sign in to comment.