(self, name, val)
| 1555 | """ |
| 1556 | |
| 1557 | def __setattr__(self, name, val): |
| 1558 | |
| 1559 | # If the instance doesn't yet have an ordinal attribute |
| 1560 | # it's not fully initialized so can't do any of the |
| 1561 | # following |
| 1562 | # |
| 1563 | if ( |
| 1564 | hasattr(self, "ordinal") |
| 1565 | and hasattr(self, "bound") |
| 1566 | and hasattr(self, "name") |
| 1567 | ): |
| 1568 | |
| 1569 | if name == "ordinal": |
| 1570 | |
| 1571 | if self.pe.PE_TYPE == OPTIONAL_HEADER_MAGIC_PE: |
| 1572 | ordinal_flag = IMAGE_ORDINAL_FLAG |
| 1573 | elif self.pe.PE_TYPE == OPTIONAL_HEADER_MAGIC_PE_PLUS: |
| 1574 | ordinal_flag = IMAGE_ORDINAL_FLAG64 |
| 1575 | |
| 1576 | # Set the ordinal and flag the entry as importing by ordinal |
| 1577 | self.struct_table.Ordinal = ordinal_flag | (val & 0xFFFF) |
| 1578 | self.struct_table.AddressOfData = self.struct_table.Ordinal |
| 1579 | self.struct_table.Function = self.struct_table.Ordinal |
| 1580 | self.struct_table.ForwarderString = self.struct_table.Ordinal |
| 1581 | elif name == "bound": |
| 1582 | if self.struct_iat is not None: |
| 1583 | self.struct_iat.AddressOfData = val |
| 1584 | self.struct_iat.AddressOfData = self.struct_iat.AddressOfData |
| 1585 | self.struct_iat.Function = self.struct_iat.AddressOfData |
| 1586 | self.struct_iat.ForwarderString = self.struct_iat.AddressOfData |
| 1587 | elif name == "address": |
| 1588 | self.struct_table.AddressOfData = val |
| 1589 | self.struct_table.Ordinal = self.struct_table.AddressOfData |
| 1590 | self.struct_table.Function = self.struct_table.AddressOfData |
| 1591 | self.struct_table.ForwarderString = self.struct_table.AddressOfData |
| 1592 | elif name == "name": |
| 1593 | # Make sure we reset the entry in case the import had been set to |
| 1594 | # import by ordinal |
| 1595 | if self.name_offset: |
| 1596 | |
| 1597 | name_rva = self.pe.get_rva_from_offset(self.name_offset) |
| 1598 | self.pe.set_dword_at_offset( |
| 1599 | self.ordinal_offset, (0 << 31) | name_rva |
| 1600 | ) |
| 1601 | |
| 1602 | # Complain if the length of the new name is longer than the |
| 1603 | # existing one |
| 1604 | if len(val) > len(self.name): |
| 1605 | raise PEFormatError( |
| 1606 | "The export name provided is longer than the existing one." |
| 1607 | ) |
| 1608 | pass |
| 1609 | self.pe.set_bytes_at_offset(self.name_offset, val) |
| 1610 | |
| 1611 | self.__dict__[name] = val |
| 1612 | |
| 1613 | |
| 1614 | class ExportDirData(DataContainer): |
nothing calls this directly
no test coverage detected