Holds relocation information. type: Type of relocation The type string can be obtained by RELOCATION_TYPE[type] rva: RVA of the relocation
| 1722 | |
| 1723 | |
| 1724 | class RelocationData(DataContainer): |
| 1725 | """Holds relocation information. |
| 1726 | |
| 1727 | type: Type of relocation |
| 1728 | The type string can be obtained by |
| 1729 | RELOCATION_TYPE[type] |
| 1730 | rva: RVA of the relocation |
| 1731 | """ |
| 1732 | |
| 1733 | def __setattr__(self, name, val): |
| 1734 | |
| 1735 | # If the instance doesn't yet have a struct attribute |
| 1736 | # it's not fully initialized so can't do any of the |
| 1737 | # following |
| 1738 | # |
| 1739 | if hasattr(self, "struct"): |
| 1740 | # Get the word containing the type and data |
| 1741 | # |
| 1742 | word = self.struct.Data |
| 1743 | |
| 1744 | if name == "type": |
| 1745 | word = (val << 12) | (word & 0xFFF) |
| 1746 | elif name == "rva": |
| 1747 | offset = max(val - self.base_rva, 0) |
| 1748 | word = (word & 0xF000) | (offset & 0xFFF) |
| 1749 | |
| 1750 | # Store the modified data |
| 1751 | # |
| 1752 | self.struct.Data = word |
| 1753 | |
| 1754 | self.__dict__[name] = val |
| 1755 | |
| 1756 | |
| 1757 | class TlsData(DataContainer): |