Skip to content

Commit

Permalink
Remove some arguments in an internal function
Browse files Browse the repository at this point in the history
  • Loading branch information
kubo committed Oct 2, 2022
1 parent a3dd7a7 commit 3911da0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/funchook.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ static int funchook_prepare_internal(funchook_t *funchook, void **target_func, v
memcpy(entry->trampoline, trampoline, TRAMPOLINE_BYTE_SIZE);
memcpy(entry->old_code, func, JUMP32_BYTE_SIZE);

funchook_fix_code(funchook, entry, &disp, func, hook_func);
funchook_fix_code(funchook, entry, &disp);
funchook_log_trampoline(funchook, entry->trampoline, trampoline_size);
#ifdef CPU_ARM64
int i;
Expand Down
6 changes: 3 additions & 3 deletions src/funchook_arm64.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,11 +358,11 @@ int funchook_make_trampoline(funchook_t *funchook, ip_displacement_t *disp, cons
return rv;
}

int funchook_fix_code(funchook_t *funchook, funchook_entry_t *entry, const ip_displacement_t *disp, const void *func, const void *hook_func)
int funchook_fix_code(funchook_t *funchook, funchook_entry_t *entry, const ip_displacement_t *disp)
{
/* func -> transit */
funchook_write_jump32(funchook, func, entry->transit, entry->new_code);
funchook_write_jump32(funchook, entry->target_func, entry->transit, entry->new_code);
/* transit -> hook_func */
funchook_write_jump64(funchook, entry->transit, hook_func, FUNCHOOK_ARM64_REG_X9);
funchook_write_jump64(funchook, entry->transit, entry->hook_func, FUNCHOOK_ARM64_REG_X9);
return 0;
}
2 changes: 1 addition & 1 deletion src/funchook_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void *funchook_resolve_func(funchook_t *funchook, void *func);

/* Functions in funchook_{CPU_NAME}.c */
int funchook_make_trampoline(funchook_t *funchook, ip_displacement_t *disp, const insn_t *func, insn_t *trampoline, size_t *trampoline_size);
int funchook_fix_code(funchook_t *funchook, funchook_entry_t *entry, const ip_displacement_t *disp, const void *func, const void *hook_func);
int funchook_fix_code(funchook_t *funchook, funchook_entry_t *entry, const ip_displacement_t *disp);
#ifdef CPU_X86_64
int funchook_page_avail(funchook_t *funchook, funchook_page_t *page, int idx, uint8_t *addr, ip_displacement_t *disp);
#else
Expand Down
12 changes: 6 additions & 6 deletions src/funchook_x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,21 +327,21 @@ static int handle_rip_relative(make_trampoline_context_t *ctx, const rip_relativ
return 0;
}

int funchook_fix_code(funchook_t *funchook, funchook_entry_t *entry, const ip_displacement_t *disp, const void *func, const void *hook_func)
int funchook_fix_code(funchook_t *funchook, funchook_entry_t *entry, const ip_displacement_t *disp)
{
insn_t *src_addr;
uint32_t *offset_addr;

#ifdef CPU_X86_64
if (funchook_jump32_avail(func, hook_func)) {
funchook_write_jump32(funchook, func, hook_func, entry->new_code);
if (funchook_jump32_avail(entry->target_func, entry->hook_func)) {
funchook_write_jump32(funchook, entry->target_func, entry->hook_func, entry->new_code);
entry->transit[0] = 0;
} else {
funchook_write_jump32(funchook, func, entry->transit, entry->new_code);
funchook_write_jump64(funchook, entry->transit, hook_func);
funchook_write_jump32(funchook, entry->target_func, entry->transit, entry->new_code);
funchook_write_jump64(funchook, entry->transit, entry->hook_func);
}
#else
funchook_write_jump32(funchook, func, hook_func, entry->new_code);
funchook_write_jump32(funchook, entry->target_func, entry->hook_func, entry->new_code);
#endif
/* fix rip-relative offsets */
src_addr = entry->trampoline + disp->disp[0].src_addr_offset;
Expand Down

0 comments on commit 3911da0

Please sign in to comment.