Skip to content

Commit

Permalink
Remove "OC Patch" comments
Browse files Browse the repository at this point in the history
This information is available from git blame
  • Loading branch information
j-t-1 authored Jun 9, 2024
1 parent 80535f5 commit 15a538f
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions pefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,6 @@ def __unpack__(self, data):
if len(data) > self.__format_length__:
data = data[: self.__format_length__]

# OC Patch:
# Some malware have incorrect header lengths.
# Fail gracefully if this occurs
# Buggy malware: a29b0118af8b7408444df81701ad5a7f
Expand Down Expand Up @@ -3078,7 +3077,6 @@ def __parse__(self, fname, data, fast_load):
if not self.DOS_HEADER or self.DOS_HEADER.e_magic != IMAGE_DOS_SIGNATURE:
raise PEFormatError("DOS Header magic not found.")

# OC Patch:
# Check for sane value in e_lfanew
#
if self.DOS_HEADER.e_lfanew > len(self.__data__):
Expand All @@ -3094,7 +3092,6 @@ def __parse__(self, fname, data, fast_load):

# We better check the signature right here, before the file screws
# around with sections:
# OC Patch:
# Some malware will cause the Signature value to not exist at all
if not self.NT_HEADERS or not self.NT_HEADERS.Signature:
raise PEFormatError("NT Headers not found.")
Expand Down Expand Up @@ -3216,7 +3213,6 @@ def __parse__(self, fname, data, fast_load):
if not self.FILE_HEADER:
raise PEFormatError("File Header missing")

# OC Patch:
# Die gracefully if there is no OPTIONAL_HEADER field
# 975440f5ad5e2e4a92c4d9a5f22f75c1
if self.OPTIONAL_HEADER is None:
Expand Down Expand Up @@ -3312,7 +3308,6 @@ def __parse__(self, fname, data, fast_load):

offset = self.parse_sections(sections_offset)

# OC Patch:
# There could be a problem if there are no raw data sections
# greater than 0
# fc91013eb72529da005110a3403541b6 example
Expand Down Expand Up @@ -3727,8 +3722,6 @@ def parse_data_directories(
directories = [directories]

for entry in directory_parsing:
# OC Patch:
#
try:
directory_index = DIRECTORY_ENTRY[entry[0]]
dir_entry = self.OPTIONAL_HEADER.DATA_DIRECTORY[directory_index]
Expand Down Expand Up @@ -3936,7 +3929,7 @@ def parse_directory_bound_imports(self, rva, size):
self.__data__[rva : rva + bnd_descr_size],
file_offset=rva,
)
# OC Patch:

if not bnd_frwd_ref:
raise PEFormatError("IMAGE_BOUND_FORWARDER_REF cannot be read")
rva += bnd_frwd_ref.sizeof()
Expand Down Expand Up @@ -4265,7 +4258,6 @@ def parse_image_base_relocation_list(self, rva, size, fmt=None):

relocations = []
while rva < end:
# OC Patch:
# Malware that has bad RVA entries will cause an error.
# Just continue on after an exception
#
Expand Down Expand Up @@ -4594,7 +4586,6 @@ def parse_resources_directory(self, rva, size=0, base_rva=None, level=0, dirs=No
are available as its attributes.
"""

# OC Patch:
if dirs is None:
dirs = [rva]

Expand Down Expand Up @@ -4741,8 +4732,6 @@ def parse_resources_directory(self, rva, size=0, base_rva=None, level=0, dirs=No
)

if res.DataIsDirectory:
# OC Patch:
#
# One trick malware can do is to recursively reference
# the next directory. This causes hilarity to ensue when
# trying to parse everything correctly.
Expand Down Expand Up @@ -5971,7 +5960,6 @@ def parse_imports(
# bound.
iat = self.get_import_table(first_thunk, max_length, contains_addresses)

# OC Patch:
# Would crash if IAT or ILT had None type
if (not iat or len(iat) == 0) and (not ilt or len(ilt) == 0):
self.__warnings.append(
Expand Down Expand Up @@ -7228,7 +7216,6 @@ def dump_dict(self):

return dump_dict

# OC Patch
def get_physical_by_rva(self, rva):
"""Gets the physical address in the PE file from an RVA value."""
try:
Expand Down

0 comments on commit 15a538f

Please sign in to comment.