diff --git a/qemu/include/tcg/tcg.h b/qemu/include/tcg/tcg.h index e4fab1a0..85eec860 100644 --- a/qemu/include/tcg/tcg.h +++ b/qemu/include/tcg/tcg.h @@ -692,6 +692,7 @@ struct TCGContext { TCGOp *icount_start_insn; /* qemu/tcg/tcg.c */ GHashTable *helper_table; + GHashTable *custom_helper_infos; // To support inline hooks. TCGv_ptr cpu_env; struct tcg_region_state region; GTree *tree; diff --git a/qemu/tcg/tcg.c b/qemu/tcg/tcg.c index 76d6eb61..9d7b9b17 100644 --- a/qemu/tcg/tcg.c +++ b/qemu/tcg/tcg.c @@ -692,6 +692,7 @@ void uc_add_inline_hook(uc_engine *uc, struct hook *hk, void** args, int args_le info->sizemask = sizemask; g_hash_table_insert(helper_table, (gpointer)info->func, (gpointer)info); + g_hash_table_insert(uc->tcg_ctx->custom_helper_infos, (gpointer)info->func, (gpointer)info); tcg_gen_callN(tcg_ctx, info->func, NULL, args_len, (TCGTemp**)args); } @@ -752,6 +753,9 @@ void tcg_context_init(TCGContext *s) helper_table = g_hash_table_new(NULL, NULL); s->helper_table = helper_table; + // Unicorn: Store our custom inline hooks infomation + s->custom_helper_infos = g_hash_table_new_full(NULL, NULL, NULL, g_free); + for (i = 0; i < ARRAY_SIZE(all_helpers); ++i) { g_hash_table_insert(helper_table, (gpointer)all_helpers[i].func, (gpointer)&all_helpers[i]); diff --git a/qemu/unicorn_common.h b/qemu/unicorn_common.h index 5176430e..3e06ccac 100644 --- a/qemu/unicorn_common.h +++ b/qemu/unicorn_common.h @@ -49,6 +49,7 @@ static void release_common(void *t) } tcg_pool_reset(s); g_hash_table_destroy(s->helper_table); + g_hash_table_destroy(s->custom_helper_infos); g_free(s->indirect_reg_alloc_order); /* qemu/tcg/tcg/c:4018: img = g_malloc(img_size); */ g_free((void *)(s->one_entry->symfile_addr));