diff options
author | segfault <segfault@secmail.pro> | 2019-03-25 02:37:35 +0100 |
---|---|---|
committer | segfault <segfault@secmail.pro> | 2019-03-25 02:37:35 +0100 |
commit | 4e56c8ee1723dd01fd1e3385a7d696ec36416fed (patch) | |
tree | 69e23f9aec7af4aeb4670c4d9d40a0a3b0676db1 | |
parent | 02aef8902a4a48c32f1156c6f888ad2d4050a71a (diff) |
cosmetics
Signed-off-by: segfault <segfault@secmail.pro>
-rw-r--r-- | injector.c | 18 |
1 files changed, 5 insertions, 13 deletions
@@ -246,18 +246,10 @@ static int prepare_last_section(pe_buffer *pe, uint8_t **ptrToShellcode) } static uint8_t * -RvaToPtr(uint8_t *buf, off_t rva) +RvaToPtr(pe_buffer *pe, off_t rva) { - PIMAGE_DOS_HEADER dosHdr = (PIMAGE_DOS_HEADER) buf; - PIMAGE_FILE_HEADER fileHdr = - (PIMAGE_FILE_HEADER)(buf + - dosHdr->e_lfanew + - sizeof(DWORD)); - PIMAGE_SECTION_HEADER sections = - (PIMAGE_SECTION_HEADER)(buf + - dosHdr->e_lfanew + - sizeof(IMAGE_NT_HEADERS)); - size_t nSections = fileHdr->NumberOfSections; + PIMAGE_SECTION_HEADER sections = pe->secHdr; + size_t nSections = pe->fileHdr->NumberOfSections; off_t pos = 0; for (SIZE_T i = 0; i < nSections; ++i) { @@ -267,7 +259,7 @@ RvaToPtr(uint8_t *buf, off_t rva) } if (rva < pos) { rva -= sections[i].VirtualAddress; - return buf + rva + sections[i].PointerToRawData; + return pe->buf + rva + sections[i].PointerToRawData; } } return NULL; @@ -313,7 +305,7 @@ static int search_patch_near_entry(pe_buffer *pe, patch_ctx *pa) { const size_t maxbytes = 30; size_t i; - uint8_t *insts8 = RvaToPtr(pe->buf, + uint8_t *insts8 = RvaToPtr(pe, pe->optHdr->AddressOfEntryPoint); uint16_t *insts16; uint32_t relAddr; |