📄 relocationhandler.asm
字号:
; Author: Brandon LaCombe
; Date: February 3, 2006
; License: Public Domain
.386
.model flat, stdcall
option casemap:none
include windows.inc
include LoaderStructs.inc
.code
ExportRelocationHandler proc pdwRelocationHandlerSize:dword
mov eax, pdwRelocationHandlerSize
.if eax
mov dword ptr[eax], relocation_handler_end - relocation_handler_start
.endif
mov eax, relocation_handler_start
ret
ExportRelocationHandler endp
relocation_handler_start:
mov ecx, (LOADER_STRUCT ptr[ebx]).dwImageDelta ; ecx = image delta
.if ecx ; only process if relocated
mov edi, (LOADER_STRUCT ptr[ebx]).pRelocations ; edi = reloc tbl ptr
jmp enter_relocation_procedure ; enter reloc proc
relocation_loop:
xor eax, eax ; zero high word
lodsw ; load reloc entry
.if eax ; only process valid entries
and ah, 00Fh ; remove reloc type specifier
add eax, (LOADER_STRUCT ptr[ebx]).dwImageBase ; eax = address of reloc
add [eax + edx], ecx ; add delta to reloc
.endif
enter_relocation_loop:
cmp esi, edi ; loop while we have reloc data
jne relocation_loop ; process next reloc entry
enter_relocation_procedure:
mov edx, (IMAGE_BASE_RELOCATION ptr[edi]).VirtualAddress ; edx = reloc sec start rva
lea esi, [edi + IMAGE_SIZEOF_BASE_RELOCATION] ; esi = reloc data ptr
add edi, (IMAGE_BASE_RELOCATION ptr[edi]).SizeOfBlock ; edi = next reloc tbl
test edx, edx ; only process if we have an rva
jnz enter_relocation_loop ; start processing reloc tbl
.endif
relocation_handler_end:
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -