diff options
author | Zeex <zeex@rocketmail.com> | 2013-12-14 13:24:47 +0700 |
---|---|---|
committer | Zeex <zeex@rocketmail.com> | 2013-12-14 13:30:08 +0700 |
commit | a5c482dd21925b38e912dded26ea33418b757c97 (patch) | |
tree | df9e199ca22e7a2f175cfd8ebb83260a81b16b51 /subhook_x86.c | |
parent | fc6f1b7fc18a492fe88aaf36eb597c6eb529a759 (diff) | |
download | subhook-a5c482dd21925b38e912dded26ea33418b757c97.zip subhook-a5c482dd21925b38e912dded26ea33418b757c97.tar.gz subhook-a5c482dd21925b38e912dded26ea33418b757c97.tar.bz2 |
Minor cleanup
Diffstat (limited to 'subhook_x86.c')
-rw-r--r-- | subhook_x86.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/subhook_x86.c b/subhook_x86.c index 42975bb..721e408 100644 --- a/subhook_x86.c +++ b/subhook_x86.c @@ -100,16 +100,15 @@ SUBHOOK_EXPORT int SUBHOOK_API subhook_remove(subhook_t hook) { SUBHOOK_EXPORT void *SUBHOOK_API subhook_read_dst(void *src) { unsigned char opcode; - intptr_t src_addr = (intptr_t)src; - intptr_t dst_addr; intptr_t *target; memcpy(&opcode, src, sizeof(opcode)); + if (opcode != jmp_opcode) return NULL; - memcpy(&target, (void *)(src_addr + sizeof(jmp_opcode)), sizeof(*target)); - dst_addr = *target + src_addr + sizeof(jmp_instr); - - return (void *)dst_addr; + memcpy(&target, (void *)((intptr_t)src + sizeof(jmp_opcode)), + sizeof(*target)); + + return (void *)(*target + (intptr_t)src + sizeof(jmp_instr)); } |