Skip to content

Commit

Permalink
Update comment and readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
cimadai committed Jan 3, 2018
1 parent 813af03 commit ec563fa
Show file tree
Hide file tree
Showing 4 changed files with 402 additions and 26 deletions.
2 changes: 1 addition & 1 deletion app/src/main/cpp/hooker.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ int unhook_rand() {
*/
int hook_entry(char *so_file_path) {
LOGD("Hook success, pid = %d\n", getpid());
LOGD("Hello %s\n", so_file_path);
LOGD("Injecting %s\n", so_file_path);
void *hooker = dlopen(so_file_path, RTLD_NOW);
uint32_t new_rand_pointer = (uint32_t) dlsym(hooker, "new_rand");
uint32_t *old_rand_pointer = (uint32_t *) dlsym(hooker, "old_rand");
Expand Down
3 changes: 0 additions & 3 deletions app/src/main/cpp/inline_hook.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,6 @@ static void doInlineHook(struct inlineHookItem *item)
}

if (TEST_BIT0(item->target_addr)) {
LOGD("TEST_BIT0 -> 1\n");
int i;

i = 0;
Expand All @@ -363,13 +362,11 @@ static void doInlineHook(struct inlineHookItem *item)
((uint16_t *) CLEAR_BIT0(item->target_addr))[i++] = item->new_addr >> 16;
}
else {
LOGD("TEST_BIT0 -> 2\n");
((uint32_t *) (item->target_addr))[0] = 0xe51ff004; // LDR PC, [PC, #-4]
((uint32_t *) (item->target_addr))[1] = item->new_addr;
}

int m_ret = mprotect((void *) PAGE_START(CLEAR_BIT0(item->target_addr)), PAGE_SIZE * 2, PROT_READ | PROT_EXEC);
LOGD("mprotect result = %d\n", m_ret);

item->status = HOOKED;

Expand Down
3 changes: 2 additions & 1 deletion app/src/main/cpp/process_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ void *get_remote_func_address(pid_t target_pid, const char *lib_name, void *loca
// 対象プロセスにおける対象ライブラリの開始アドレス
remote_module_base = get_library_address(target_pid, lib_name);

/*目标进程函数地址= 目标进程lib库地址 + (本进程函数地址 -本进程lib库地址)*/
LOGD("Remote base = %x, Local base = %x, Local func addr = %x\n", remote_module_base, local_module_base, local_func_address);

// 対象プロセスにおける対象関数のアドレス =
// 対象プロセスにおける対象ライブラリの開始アドレス + (自プロセスにおける対象関数のアドレス - 自プロセスにおける対象ライブラリの開始アドレス)
void *target_address = (void *) ((uint32_t) remote_module_base +
Expand Down
Loading

0 comments on commit ec563fa

Please sign in to comment.