| 2732 | ) |
| 2733 | |
| 2734 | def __init__( |
| 2735 | self, |
| 2736 | name=None, |
| 2737 | data=None, |
| 2738 | fast_load=None, |
| 2739 | max_symbol_exports=MAX_SYMBOL_EXPORT_COUNT, |
| 2740 | max_repeated_symbol=120, |
| 2741 | ): |
| 2742 | |
| 2743 | self.max_symbol_exports = max_symbol_exports |
| 2744 | self.max_repeated_symbol = max_repeated_symbol |
| 2745 | |
| 2746 | self._get_section_by_rva_last_used = None |
| 2747 | |
| 2748 | self.sections = [] |
| 2749 | |
| 2750 | self.__warnings = [] |
| 2751 | |
| 2752 | self.PE_TYPE = None |
| 2753 | |
| 2754 | if name is None and data is None: |
| 2755 | raise ValueError("Must supply either name or data") |
| 2756 | |
| 2757 | # This list will keep track of all the structures created. |
| 2758 | # That will allow for an easy iteration through the list |
| 2759 | # in order to save the modifications made |
| 2760 | self.__structures__ = [] |
| 2761 | self.__from_file = None |
| 2762 | |
| 2763 | # We only want to print these warnings once |
| 2764 | self.FileAlignment_Warning = False |
| 2765 | self.SectionAlignment_Warning = False |
| 2766 | |
| 2767 | # Count of total resource entries across nested tables |
| 2768 | self.__total_resource_entries_count = 0 |
| 2769 | # Sum of the size of all resource entries parsed, which should not |
| 2770 | # exceed the file size. |
| 2771 | self.__total_resource_bytes = 0 |
| 2772 | # The number of imports parsed in this file |
| 2773 | self.__total_import_symbols = 0 |
| 2774 | |
| 2775 | fast_load = fast_load if fast_load is not None else globals()["fast_load"] |
| 2776 | try: |
| 2777 | self.__parse__(name, data, fast_load) |
| 2778 | except: |
| 2779 | self.close() |
| 2780 | raise |
| 2781 | |
| 2782 | def __enter__(self): |
| 2783 | return self |