MCPcopy Create free account
hub / github.com/ELMERIKH/PyinMemoryPE / parse_data_directories

Method parse_data_directories

pythonmemorymodule/pefile.py:3512–3608  ·  view source on GitHub ↗

Parse and process the PE file's data directories. If the optional argument 'directories' is given, only the directories at the specified indexes will be parsed. Such functionality allows parsing of areas of interest without the burden of having to parse all others.

(
        self, directories=None, forwarded_exports_only=False, import_dllnames_only=False
    )

Source from the content-addressed store, hash-verified

3510 return offset
3511
3512 def parse_data_directories(
3513 self, directories=None, forwarded_exports_only=False, import_dllnames_only=False
3514 ):
3515 """Parse and process the PE file's data directories.
3516
3517 If the optional argument 'directories' is given, only
3518 the directories at the specified indexes will be parsed.
3519 Such functionality allows parsing of areas of interest
3520 without the burden of having to parse all others.
3521 The directories can then be specified as:
3522
3523 For export / import only:
3524
3525 directories = [ 0, 1 ]
3526
3527 or (more verbosely):
3528
3529 directories = [ DIRECTORY_ENTRY['IMAGE_DIRECTORY_ENTRY_IMPORT'],
3530 DIRECTORY_ENTRY['IMAGE_DIRECTORY_ENTRY_EXPORT'] ]
3531
3532 If 'directories' is a list, the ones that are processed will be removed,
3533 leaving only the ones that are not present in the image.
3534
3535 If `forwarded_exports_only` is True, the IMAGE_DIRECTORY_ENTRY_EXPORT
3536 attribute will only contain exports that are forwarded to another DLL.
3537
3538 If `import_dllnames_only` is True, symbols will not be parsed from
3539 the import table and the entries in the IMAGE_DIRECTORY_ENTRY_IMPORT
3540 attribute will not have a `symbols` attribute.
3541 """
3542
3543 directory_parsing = (
3544 ("IMAGE_DIRECTORY_ENTRY_IMPORT", self.parse_import_directory),
3545 ("IMAGE_DIRECTORY_ENTRY_EXPORT", self.parse_export_directory),
3546 ("IMAGE_DIRECTORY_ENTRY_RESOURCE", self.parse_resources_directory),
3547 ("IMAGE_DIRECTORY_ENTRY_DEBUG", self.parse_debug_directory),
3548 ("IMAGE_DIRECTORY_ENTRY_BASERELOC", self.parse_relocations_directory),
3549 ("IMAGE_DIRECTORY_ENTRY_TLS", self.parse_directory_tls),
3550 ("IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG", self.parse_directory_load_config),
3551 ("IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT", self.parse_delay_import_directory),
3552 ("IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT", self.parse_directory_bound_imports),
3553 ("IMAGE_DIRECTORY_ENTRY_EXCEPTION", self.parse_exceptions_directory),
3554 )
3555
3556 if directories is not None:
3557 if not isinstance(directories, (tuple, list)):
3558 directories = [directories]
3559
3560 for entry in directory_parsing:
3561 # OC Patch:
3562 #
3563 try:
3564 directory_index = DIRECTORY_ENTRY[entry[0]]
3565 dir_entry = self.OPTIONAL_HEADER.DATA_DIRECTORY[directory_index]
3566 except IndexError:
3567 break
3568
3569 # Only process all the directories if no individual ones have

Callers 3

full_loadMethod · 0.95
relocate_imageMethod · 0.95
is_driverMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected