| 2700 | { |
| 2701 | public: |
| 2702 | virtual bool ApplyRelocation(Ref<BinaryView> view, Ref<Architecture> arch, Ref<Relocation> reloc, uint8_t* dest, size_t len) override |
| 2703 | { |
| 2704 | // Note: info.base contains preferred base address and the base where the image is actually loaded |
| 2705 | (void)view; |
| 2706 | (void)arch; |
| 2707 | (void)len; |
| 2708 | uint64_t* data64 = (uint64_t*)dest; |
| 2709 | uint32_t* data32 = (uint32_t*)dest; |
| 2710 | uint16_t* data16 = (uint16_t*)dest; |
| 2711 | auto info = reloc->GetInfo(); |
| 2712 | if (info.size == 8) |
| 2713 | { |
| 2714 | data64[0] += info.base; |
| 2715 | } |
| 2716 | else if (info.size == 4) |
| 2717 | { |
| 2718 | data32[0] += (uint32_t)info.base; |
| 2719 | } |
| 2720 | else if (info.size == 2) |
| 2721 | { |
| 2722 | if (info.nativeType == PE_IMAGE_REL_BASED_HIGH) |
| 2723 | { |
| 2724 | data16[0] = data16[0] + (uint16_t)(info.base >> 16); |
| 2725 | } |
| 2726 | else if (info.nativeType == PE_IMAGE_REL_BASED_LOW) |
| 2727 | { |
| 2728 | data16[0] = data16[0] + (uint16_t)(info.base & 0xffff); |
| 2729 | } |
| 2730 | } |
| 2731 | return true; |
| 2732 | } |
| 2733 | |
| 2734 | virtual bool GetRelocationInfo(Ref<BinaryView> view, Ref<Architecture> arch, vector<BNRelocationInfo>& result) override |
| 2735 | { |