[docs]classDllImport(PEReloc):""" There's nothing special to be done for DLL imports but this class provides a unique name to the relocation type. """pass
@propertydefvalue(self):""" In all the other cases, we can ignore the relocation difference part of the calculation because we simply use to_mva() to get our rebased address. In this case, however, we have to adjust the un-rebased address first. """org_bytes=self.owner.memory.load(self.relative_addr,2)org_value=struct.unpack("<I",org_bytes)[0]adjusted_value=(org_value<<16)+self.next_rvaadjusted_value=(AT.from_lva(adjusted_value,self.owner)&0xFFFF0000)>>16adjusted_bytes=struct.pack("<I",adjusted_value)returnadjusted_bytes
[docs]classIMAGE_REL_BASED_DIR64(PEReloc):@propertydefvalue(self):org_bytes=self.owner.memory.load(self.relative_addr,8)org_value=struct.unpack("<Q",org_bytes)[0]rebased_value=AT.from_lva(org_value,self.owner).to_mva()ifrebased_value<0orrebased_value>=0x10000000000000000:log.error("Incorrect rebased address %x found at %s. Maybe the relocation table is broken.",rebased_value,self.owner,)returnNonerebased_bytes=struct.pack("<Q",rebased_value)returnrebased_bytes