Skip to content

Commit

Permalink
fixed jump
Browse files Browse the repository at this point in the history
  • Loading branch information
rdbo committed Apr 6, 2024
1 parent 0f2eac7 commit fadc1d7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tests/unit/hook.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <libmem/libmem.h>
#include <stdint.h>
#include "minunit.h"
#include "helpers.h"

Expand Down Expand Up @@ -44,7 +45,9 @@ char *test_LM_HookCode(struct hook_args *arg)
*/
LM_Disassemble((lm_address_t)target_function, &inst);
if (!strcmp(inst.mnemonic, "jmp")) {
hook_address += *(lm_address_t *)&inst.bytes[1] + inst.size; /* Calculate real address from 'jmp' offset */
hook_address += *(uint32_t *)&inst.bytes[1] + (uint32_t)inst.size; /* Calculate real address from 'jmp' offset */
printf("<RESOLVED JMP TO: %p> ", (void *)hook_address);
fflush(stdout);
}

arg->hksize = LM_HookCode(hook_address, (lm_address_t)hk_target_function, &arg->trampoline);
Expand Down

0 comments on commit fadc1d7

Please sign in to comment.