diff options
author | Haru <haru@dotalux.com> | 2016-03-14 01:26:28 +0100 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2016-07-12 20:58:43 +0200 |
commit | b0a4a441f582810c91aeec458fdbe7cc6cc78db9 (patch) | |
tree | 5ff3c893d02984f5797b03c40b466970bce35a5b /src | |
parent | c4a3a3f59e5720b300077c3d34aa7f4ecdd76400 (diff) | |
download | hercules-b0a4a441f582810c91aeec458fdbe7cc6cc78db9.tar.gz hercules-b0a4a441f582810c91aeec458fdbe7cc6cc78db9.tar.bz2 hercules-b0a4a441f582810c91aeec458fdbe7cc6cc78db9.tar.xz hercules-b0a4a441f582810c91aeec458fdbe7cc6cc78db9.zip |
HPM Hooks Update
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/common/HPMDataCheck.h | 7 | ||||
-rw-r--r-- | src/common/HPMSymbols.inc.h | 6 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking.Defs.inc | 24 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_char.HPMHooksCore.inc | 45 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_char.HookingPoints.inc | 12 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_char.Hooks.inc | 293 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_char.sources.inc | 1 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc | 45 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc | 12 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_login.Hooks.inc | 293 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_login.sources.inc | 1 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc | 45 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc | 12 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_map.Hooks.inc | 293 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_map.sources.inc | 1 |
15 files changed, 1089 insertions, 1 deletions
diff --git a/src/common/HPMDataCheck.h b/src/common/HPMDataCheck.h index 8045b745f..55ea1e1b9 100644 --- a/src/common/HPMDataCheck.h +++ b/src/common/HPMDataCheck.h @@ -246,7 +246,7 @@ HPExport const struct s_HPMDataCheck HPMDataCheck[] = { #define COMMON_SOCKET_H #endif // COMMON_SOCKET_H #ifdef COMMON_SPINLOCK_H - { "SPIN_LOCK", sizeof(struct SPIN_LOCK), SERVER_TYPE_ALL }, + { "spin_lock", sizeof(struct spin_lock), SERVER_TYPE_ALL }, #else #define COMMON_SPINLOCK_H #endif // COMMON_SPINLOCK_H @@ -269,6 +269,11 @@ HPExport const struct s_HPMDataCheck HPMDataCheck[] = { #else #define COMMON_SYSINFO_H #endif // COMMON_SYSINFO_H + #ifdef COMMON_THREAD_H + { "thread_interface", sizeof(struct thread_interface), SERVER_TYPE_ALL }, + #else + #define COMMON_THREAD_H + #endif // COMMON_THREAD_H #ifdef COMMON_TIMER_H { "TimerData", sizeof(struct TimerData), SERVER_TYPE_ALL }, { "timer_interface", sizeof(struct timer_interface), SERVER_TYPE_ALL }, diff --git a/src/common/HPMSymbols.inc.h b/src/common/HPMSymbols.inc.h index 379c04b14..0a2e64cb4 100644 --- a/src/common/HPMSymbols.inc.h +++ b/src/common/HPMSymbols.inc.h @@ -254,6 +254,9 @@ struct sv_interface *sv; #ifdef COMMON_SYSINFO_H /* sysinfo */ struct sysinfo_interface *sysinfo; #endif // COMMON_SYSINFO_H +#ifdef COMMON_THREAD_H /* thread */ +struct thread_interface *thread; +#endif // COMMON_THREAD_H #ifdef COMMON_TIMER_H /* timer */ struct timer_interface *timer; #endif // COMMON_TIMER_H @@ -498,6 +501,9 @@ if ((server_type&(SERVER_TYPE_ALL)) && !HPM_SYMBOL("sv", sv)) return "sv"; #ifdef COMMON_SYSINFO_H /* sysinfo */ if ((server_type&(SERVER_TYPE_ALL)) && !HPM_SYMBOL("sysinfo", sysinfo)) return "sysinfo"; #endif // COMMON_SYSINFO_H +#ifdef COMMON_THREAD_H /* thread */ +if ((server_type&(SERVER_TYPE_ALL)) && !HPM_SYMBOL("thread", thread)) return "thread"; +#endif // COMMON_THREAD_H #ifdef COMMON_TIMER_H /* timer */ if ((server_type&(SERVER_TYPE_ALL)) && !HPM_SYMBOL("timer", timer)) return "timer"; #endif // COMMON_TIMER_H diff --git a/src/plugins/HPMHooking/HPMHooking.Defs.inc b/src/plugins/HPMHooking/HPMHooking.Defs.inc index cbf15fa7e..2ac33f6f7 100644 --- a/src/plugins/HPMHooking/HPMHooking.Defs.inc +++ b/src/plugins/HPMHooking/HPMHooking.Defs.inc @@ -7063,6 +7063,30 @@ typedef void (*HPMHOOK_post_sysinfo_init) (void); typedef void (*HPMHOOK_pre_sysinfo_final) (void); typedef void (*HPMHOOK_post_sysinfo_final) (void); #endif // COMMON_SYSINFO_H +#ifdef COMMON_THREAD_H /* thread */ +typedef void (*HPMHOOK_pre_thread_init) (void); +typedef void (*HPMHOOK_post_thread_init) (void); +typedef void (*HPMHOOK_pre_thread_final) (void); +typedef void (*HPMHOOK_post_thread_final) (void); +typedef struct thread_handle* (*HPMHOOK_pre_thread_create) (threadFunc *entry_point, void **param); +typedef struct thread_handle* (*HPMHOOK_post_thread_create) (struct thread_handle* retVal___, threadFunc entry_point, void *param); +typedef struct thread_handle* (*HPMHOOK_pre_thread_create_opt) (threadFunc *entry_point, void **param, size_t *stack_size, enum thread_priority *prio); +typedef struct thread_handle* (*HPMHOOK_post_thread_create_opt) (struct thread_handle* retVal___, threadFunc entry_point, void *param, size_t stack_size, enum thread_priority prio); +typedef void (*HPMHOOK_pre_thread_destroy) (struct thread_handle **handle); +typedef void (*HPMHOOK_post_thread_destroy) (struct thread_handle *handle); +typedef struct thread_handle* (*HPMHOOK_pre_thread_self) (void); +typedef struct thread_handle* (*HPMHOOK_post_thread_self) (struct thread_handle* retVal___); +typedef int (*HPMHOOK_pre_thread_get_tid) (void); +typedef int (*HPMHOOK_post_thread_get_tid) (int retVal___); +typedef bool (*HPMHOOK_pre_thread_wait) (struct thread_handle **handle, void ***out_exit_code); +typedef bool (*HPMHOOK_post_thread_wait) (bool retVal___, struct thread_handle *handle, void **out_exit_code); +typedef void (*HPMHOOK_pre_thread_prio_set) (struct thread_handle **handle, enum thread_priority *prio); +typedef void (*HPMHOOK_post_thread_prio_set) (struct thread_handle *handle, enum thread_priority prio); +typedef enum thread_priority (*HPMHOOK_pre_thread_prio_get) (struct thread_handle **handle); +typedef enum thread_priority (*HPMHOOK_post_thread_prio_get) (enum thread_priority retVal___, struct thread_handle *handle); +typedef void (*HPMHOOK_pre_thread_yield) (void); +typedef void (*HPMHOOK_post_thread_yield) (void); +#endif // COMMON_THREAD_H #ifdef COMMON_TIMER_H /* timer */ typedef int64 (*HPMHOOK_pre_timer_gettick) (void); typedef int64 (*HPMHOOK_post_timer_gettick) (int64 retVal___); diff --git a/src/plugins/HPMHooking/HPMHooking_char.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_char.HPMHooksCore.inc index 2162fad57..f51ddcffc 100644 --- a/src/plugins/HPMHooking/HPMHooking_char.HPMHooksCore.inc +++ b/src/plugins/HPMHooking/HPMHooking_char.HPMHooksCore.inc @@ -1448,6 +1448,28 @@ struct { struct HPMHookPoint *HP_sysinfo_init_post; struct HPMHookPoint *HP_sysinfo_final_pre; struct HPMHookPoint *HP_sysinfo_final_post; + struct HPMHookPoint *HP_thread_init_pre; + struct HPMHookPoint *HP_thread_init_post; + struct HPMHookPoint *HP_thread_final_pre; + struct HPMHookPoint *HP_thread_final_post; + struct HPMHookPoint *HP_thread_create_pre; + struct HPMHookPoint *HP_thread_create_post; + struct HPMHookPoint *HP_thread_create_opt_pre; + struct HPMHookPoint *HP_thread_create_opt_post; + struct HPMHookPoint *HP_thread_destroy_pre; + struct HPMHookPoint *HP_thread_destroy_post; + struct HPMHookPoint *HP_thread_self_pre; + struct HPMHookPoint *HP_thread_self_post; + struct HPMHookPoint *HP_thread_get_tid_pre; + struct HPMHookPoint *HP_thread_get_tid_post; + struct HPMHookPoint *HP_thread_wait_pre; + struct HPMHookPoint *HP_thread_wait_post; + struct HPMHookPoint *HP_thread_prio_set_pre; + struct HPMHookPoint *HP_thread_prio_set_post; + struct HPMHookPoint *HP_thread_prio_get_pre; + struct HPMHookPoint *HP_thread_prio_get_post; + struct HPMHookPoint *HP_thread_yield_pre; + struct HPMHookPoint *HP_thread_yield_post; struct HPMHookPoint *HP_timer_gettick_pre; struct HPMHookPoint *HP_timer_gettick_post; struct HPMHookPoint *HP_timer_gettick_nocache_pre; @@ -2899,6 +2921,28 @@ struct { int HP_sysinfo_init_post; int HP_sysinfo_final_pre; int HP_sysinfo_final_post; + int HP_thread_init_pre; + int HP_thread_init_post; + int HP_thread_final_pre; + int HP_thread_final_post; + int HP_thread_create_pre; + int HP_thread_create_post; + int HP_thread_create_opt_pre; + int HP_thread_create_opt_post; + int HP_thread_destroy_pre; + int HP_thread_destroy_post; + int HP_thread_self_pre; + int HP_thread_self_post; + int HP_thread_get_tid_pre; + int HP_thread_get_tid_post; + int HP_thread_wait_pre; + int HP_thread_wait_post; + int HP_thread_prio_set_pre; + int HP_thread_prio_set_post; + int HP_thread_prio_get_pre; + int HP_thread_prio_get_post; + int HP_thread_yield_pre; + int HP_thread_yield_post; int HP_timer_gettick_pre; int HP_timer_gettick_post; int HP_timer_gettick_nocache_pre; @@ -2964,5 +3008,6 @@ struct { struct strlib_interface strlib; struct sv_interface sv; struct sysinfo_interface sysinfo; + struct thread_interface thread; struct timer_interface timer; } source; diff --git a/src/plugins/HPMHooking/HPMHooking_char.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_char.HookingPoints.inc index d9021e906..4371cf81a 100644 --- a/src/plugins/HPMHooking/HPMHooking_char.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking_char.HookingPoints.inc @@ -773,6 +773,18 @@ struct HookingPointData HookingPoints[] = { { HP_POP(sysinfo->is_superuser, HP_sysinfo_is_superuser) }, { HP_POP(sysinfo->init, HP_sysinfo_init) }, { HP_POP(sysinfo->final, HP_sysinfo_final) }, +/* thread_interface */ + { HP_POP(thread->init, HP_thread_init) }, + { HP_POP(thread->final, HP_thread_final) }, + { HP_POP(thread->create, HP_thread_create) }, + { HP_POP(thread->create_opt, HP_thread_create_opt) }, + { HP_POP(thread->destroy, HP_thread_destroy) }, + { HP_POP(thread->self, HP_thread_self) }, + { HP_POP(thread->get_tid, HP_thread_get_tid) }, + { HP_POP(thread->wait, HP_thread_wait) }, + { HP_POP(thread->prio_set, HP_thread_prio_set) }, + { HP_POP(thread->prio_get, HP_thread_prio_get) }, + { HP_POP(thread->yield, HP_thread_yield) }, /* timer_interface */ { HP_POP(timer->gettick, HP_timer_gettick) }, { HP_POP(timer->gettick_nocache, HP_timer_gettick_nocache) }, diff --git a/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc index 958724065..aecffbecd 100644 --- a/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc @@ -19050,6 +19050,299 @@ void HP_sysinfo_final(void) { } return; } +/* thread_interface */ +void HP_thread_init(void) { + int hIndex = 0; + if( HPMHooks.count.HP_thread_init_pre ) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_init_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_init_pre[hIndex].func; + preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.thread.init(); + } + if( HPMHooks.count.HP_thread_init_post ) { + void (*postHookFunc) (void); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_init_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_init_post[hIndex].func; + postHookFunc(); + } + } + return; +} +void HP_thread_final(void) { + int hIndex = 0; + if( HPMHooks.count.HP_thread_final_pre ) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_final_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_final_pre[hIndex].func; + preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.thread.final(); + } + if( HPMHooks.count.HP_thread_final_post ) { + void (*postHookFunc) (void); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_final_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_final_post[hIndex].func; + postHookFunc(); + } + } + return; +} +struct thread_handle* HP_thread_create(threadFunc entry_point, void *param) { + int hIndex = 0; + struct thread_handle* retVal___ = NULL; + if( HPMHooks.count.HP_thread_create_pre ) { + struct thread_handle* (*preHookFunc) (threadFunc *entry_point, void **param); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_create_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_create_pre[hIndex].func; + retVal___ = preHookFunc(&entry_point, ¶m); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.thread.create(entry_point, param); + } + if( HPMHooks.count.HP_thread_create_post ) { + struct thread_handle* (*postHookFunc) (struct thread_handle* retVal___, threadFunc entry_point, void *param); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_create_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_create_post[hIndex].func; + retVal___ = postHookFunc(retVal___, entry_point, param); + } + } + return retVal___; +} +struct thread_handle* HP_thread_create_opt(threadFunc entry_point, void *param, size_t stack_size, enum thread_priority prio) { + int hIndex = 0; + struct thread_handle* retVal___ = NULL; + if( HPMHooks.count.HP_thread_create_opt_pre ) { + struct thread_handle* (*preHookFunc) (threadFunc *entry_point, void **param, size_t *stack_size, enum thread_priority *prio); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_create_opt_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_create_opt_pre[hIndex].func; + retVal___ = preHookFunc(&entry_point, ¶m, &stack_size, &prio); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.thread.create_opt(entry_point, param, stack_size, prio); + } + if( HPMHooks.count.HP_thread_create_opt_post ) { + struct thread_handle* (*postHookFunc) (struct thread_handle* retVal___, threadFunc entry_point, void *param, size_t stack_size, enum thread_priority prio); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_create_opt_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_create_opt_post[hIndex].func; + retVal___ = postHookFunc(retVal___, entry_point, param, stack_size, prio); + } + } + return retVal___; +} +void HP_thread_destroy(struct thread_handle *handle) { + int hIndex = 0; + if( HPMHooks.count.HP_thread_destroy_pre ) { + void (*preHookFunc) (struct thread_handle **handle); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_destroy_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_destroy_pre[hIndex].func; + preHookFunc(&handle); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.thread.destroy(handle); + } + if( HPMHooks.count.HP_thread_destroy_post ) { + void (*postHookFunc) (struct thread_handle *handle); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_destroy_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_destroy_post[hIndex].func; + postHookFunc(handle); + } + } + return; +} +struct thread_handle* HP_thread_self(void) { + int hIndex = 0; + struct thread_handle* retVal___ = NULL; + if( HPMHooks.count.HP_thread_self_pre ) { + struct thread_handle* (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_self_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_self_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.thread.self(); + } + if( HPMHooks.count.HP_thread_self_post ) { + struct thread_handle* (*postHookFunc) (struct thread_handle* retVal___); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_self_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_self_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} +int HP_thread_get_tid(void) { + int hIndex = 0; + int retVal___ = 0; + if( HPMHooks.count.HP_thread_get_tid_pre ) { + int (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_get_tid_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_get_tid_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.thread.get_tid(); + } + if( HPMHooks.count.HP_thread_get_tid_post ) { + int (*postHookFunc) (int retVal___); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_get_tid_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_get_tid_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} +bool HP_thread_wait(struct thread_handle *handle, void **out_exit_code) { + int hIndex = 0; + bool retVal___ = false; + if( HPMHooks.count.HP_thread_wait_pre ) { + bool (*preHookFunc) (struct thread_handle **handle, void ***out_exit_code); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_wait_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_wait_pre[hIndex].func; + retVal___ = preHookFunc(&handle, &out_exit_code); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.thread.wait(handle, out_exit_code); + } + if( HPMHooks.count.HP_thread_wait_post ) { + bool (*postHookFunc) (bool retVal___, struct thread_handle *handle, void **out_exit_code); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_wait_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_wait_post[hIndex].func; + retVal___ = postHookFunc(retVal___, handle, out_exit_code); + } + } + return retVal___; +} +void HP_thread_prio_set(struct thread_handle *handle, enum thread_priority prio) { + int hIndex = 0; + if( HPMHooks.count.HP_thread_prio_set_pre ) { + void (*preHookFunc) (struct thread_handle **handle, enum thread_priority *prio); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_prio_set_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_prio_set_pre[hIndex].func; + preHookFunc(&handle, &prio); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.thread.prio_set(handle, prio); + } + if( HPMHooks.count.HP_thread_prio_set_post ) { + void (*postHookFunc) (struct thread_handle *handle, enum thread_priority prio); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_prio_set_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_prio_set_post[hIndex].func; + postHookFunc(handle, prio); + } + } + return; +} +enum thread_priority HP_thread_prio_get(struct thread_handle *handle) { + int hIndex = 0; + enum thread_priority retVal___ = THREADPRIO_NORMAL; + if( HPMHooks.count.HP_thread_prio_get_pre ) { + enum thread_priority (*preHookFunc) (struct thread_handle **handle); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_prio_get_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_prio_get_pre[hIndex].func; + retVal___ = preHookFunc(&handle); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.thread.prio_get(handle); + } + if( HPMHooks.count.HP_thread_prio_get_post ) { + enum thread_priority (*postHookFunc) (enum thread_priority retVal___, struct thread_handle *handle); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_prio_get_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_prio_get_post[hIndex].func; + retVal___ = postHookFunc(retVal___, handle); + } + } + return retVal___; +} +void HP_thread_yield(void) { + int hIndex = 0; + if( HPMHooks.count.HP_thread_yield_pre ) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_yield_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_yield_pre[hIndex].func; + preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.thread.yield(); + } + if( HPMHooks.count.HP_thread_yield_post ) { + void (*postHookFunc) (void); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_yield_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_yield_post[hIndex].func; + postHookFunc(); + } + } + return; +} /* timer_interface */ int64 HP_timer_gettick(void) { int hIndex = 0; diff --git a/src/plugins/HPMHooking/HPMHooking_char.sources.inc b/src/plugins/HPMHooking/HPMHooking_char.sources.inc index f1180dea8..54ae8f030 100644 --- a/src/plugins/HPMHooking/HPMHooking_char.sources.inc +++ b/src/plugins/HPMHooking/HPMHooking_char.sources.inc @@ -61,4 +61,5 @@ memcpy(&HPMHooks.source.StrBuf, StrBuf, sizeof(struct stringbuf_interface)); memcpy(&HPMHooks.source.strlib, strlib, sizeof(struct strlib_interface)); memcpy(&HPMHooks.source.sv, sv, sizeof(struct sv_interface)); memcpy(&HPMHooks.source.sysinfo, sysinfo, sizeof(struct sysinfo_interface)); +memcpy(&HPMHooks.source.thread, thread, sizeof(struct thread_interface)); memcpy(&HPMHooks.source.timer, timer, sizeof(struct timer_interface)); diff --git a/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc index 91d2304d8..b97b6ea7f 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc @@ -676,6 +676,28 @@ struct { struct HPMHookPoint *HP_sysinfo_init_post; struct HPMHookPoint *HP_sysinfo_final_pre; struct HPMHookPoint *HP_sysinfo_final_post; + struct HPMHookPoint *HP_thread_init_pre; + struct HPMHookPoint *HP_thread_init_post; + struct HPMHookPoint *HP_thread_final_pre; + struct HPMHookPoint *HP_thread_final_post; + struct HPMHookPoint *HP_thread_create_pre; + struct HPMHookPoint *HP_thread_create_post; + struct HPMHookPoint *HP_thread_create_opt_pre; + struct HPMHookPoint *HP_thread_create_opt_post; + struct HPMHookPoint *HP_thread_destroy_pre; + struct HPMHookPoint *HP_thread_destroy_post; + struct HPMHookPoint *HP_thread_self_pre; + struct HPMHookPoint *HP_thread_self_post; + struct HPMHookPoint *HP_thread_get_tid_pre; + struct HPMHookPoint *HP_thread_get_tid_post; + struct HPMHookPoint *HP_thread_wait_pre; + struct HPMHookPoint *HP_thread_wait_post; + struct HPMHookPoint *HP_thread_prio_set_pre; + struct HPMHookPoint *HP_thread_prio_set_post; + struct HPMHookPoint *HP_thread_prio_get_pre; + struct HPMHookPoint *HP_thread_prio_get_post; + struct HPMHookPoint *HP_thread_yield_pre; + struct HPMHookPoint *HP_thread_yield_post; struct HPMHookPoint *HP_timer_gettick_pre; struct HPMHookPoint *HP_timer_gettick_post; struct HPMHookPoint *HP_timer_gettick_nocache_pre; @@ -1355,6 +1377,28 @@ struct { int HP_sysinfo_init_post; int HP_sysinfo_final_pre; int HP_sysinfo_final_post; + int HP_thread_init_pre; + int HP_thread_init_post; + int HP_thread_final_pre; + int HP_thread_final_post; + int HP_thread_create_pre; + int HP_thread_create_post; + int HP_thread_create_opt_pre; + int HP_thread_create_opt_post; + int HP_thread_destroy_pre; + int HP_thread_destroy_post; + int HP_thread_self_pre; + int HP_thread_self_post; + int HP_thread_get_tid_pre; + int HP_thread_get_tid_post; + int HP_thread_wait_pre; + int HP_thread_wait_post; + int HP_thread_prio_set_pre; + int HP_thread_prio_set_post; + int HP_thread_prio_get_pre; + int HP_thread_prio_get_post; + int HP_thread_yield_pre; + int HP_thread_yield_post; int HP_timer_gettick_pre; int HP_timer_gettick_post; int HP_timer_gettick_nocache_pre; @@ -1406,5 +1450,6 @@ struct { struct strlib_interface strlib; struct sv_interface sv; struct sysinfo_interface sysinfo; + struct thread_interface thread; struct timer_interface timer; } source; diff --git a/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc index 48e376287..2d3e37bc3 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc @@ -373,6 +373,18 @@ struct HookingPointData HookingPoints[] = { { HP_POP(sysinfo->is_superuser, HP_sysinfo_is_superuser) }, { HP_POP(sysinfo->init, HP_sysinfo_init) }, { HP_POP(sysinfo->final, HP_sysinfo_final) }, +/* thread_interface */ + { HP_POP(thread->init, HP_thread_init) }, + { HP_POP(thread->final, HP_thread_final) }, + { HP_POP(thread->create, HP_thread_create) }, + { HP_POP(thread->create_opt, HP_thread_create_opt) }, + { HP_POP(thread->destroy, HP_thread_destroy) }, + { HP_POP(thread->self, HP_thread_self) }, + { HP_POP(thread->get_tid, HP_thread_get_tid) }, + { HP_POP(thread->wait, HP_thread_wait) }, + { HP_POP(thread->prio_set, HP_thread_prio_set) }, + { HP_POP(thread->prio_get, HP_thread_prio_get) }, + { HP_POP(thread->yield, HP_thread_yield) }, /* timer_interface */ { HP_POP(timer->gettick, HP_timer_gettick) }, { HP_POP(timer->gettick_nocache, HP_timer_gettick_nocache) }, diff --git a/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc index e176c8488..013a56104 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc @@ -8756,6 +8756,299 @@ void HP_sysinfo_final(void) { } return; } +/* thread_interface */ +void HP_thread_init(void) { + int hIndex = 0; + if( HPMHooks.count.HP_thread_init_pre ) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_init_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_init_pre[hIndex].func; + preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.thread.init(); + } + if( HPMHooks.count.HP_thread_init_post ) { + void (*postHookFunc) (void); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_init_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_init_post[hIndex].func; + postHookFunc(); + } + } + return; +} +void HP_thread_final(void) { + int hIndex = 0; + if( HPMHooks.count.HP_thread_final_pre ) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_final_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_final_pre[hIndex].func; + preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.thread.final(); + } + if( HPMHooks.count.HP_thread_final_post ) { + void (*postHookFunc) (void); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_final_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_final_post[hIndex].func; + postHookFunc(); + } + } + return; +} +struct thread_handle* HP_thread_create(threadFunc entry_point, void *param) { + int hIndex = 0; + struct thread_handle* retVal___ = NULL; + if( HPMHooks.count.HP_thread_create_pre ) { + struct thread_handle* (*preHookFunc) (threadFunc *entry_point, void **param); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_create_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_create_pre[hIndex].func; + retVal___ = preHookFunc(&entry_point, ¶m); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.thread.create(entry_point, param); + } + if( HPMHooks.count.HP_thread_create_post ) { + struct thread_handle* (*postHookFunc) (struct thread_handle* retVal___, threadFunc entry_point, void *param); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_create_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_create_post[hIndex].func; + retVal___ = postHookFunc(retVal___, entry_point, param); + } + } + return retVal___; +} +struct thread_handle* HP_thread_create_opt(threadFunc entry_point, void *param, size_t stack_size, enum thread_priority prio) { + int hIndex = 0; + struct thread_handle* retVal___ = NULL; + if( HPMHooks.count.HP_thread_create_opt_pre ) { + struct thread_handle* (*preHookFunc) (threadFunc *entry_point, void **param, size_t *stack_size, enum thread_priority *prio); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_create_opt_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_create_opt_pre[hIndex].func; + retVal___ = preHookFunc(&entry_point, ¶m, &stack_size, &prio); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.thread.create_opt(entry_point, param, stack_size, prio); + } + if( HPMHooks.count.HP_thread_create_opt_post ) { + struct thread_handle* (*postHookFunc) (struct thread_handle* retVal___, threadFunc entry_point, void *param, size_t stack_size, enum thread_priority prio); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_create_opt_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_create_opt_post[hIndex].func; + retVal___ = postHookFunc(retVal___, entry_point, param, stack_size, prio); + } + } + return retVal___; +} +void HP_thread_destroy(struct thread_handle *handle) { + int hIndex = 0; + if( HPMHooks.count.HP_thread_destroy_pre ) { + void (*preHookFunc) (struct thread_handle **handle); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_destroy_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_destroy_pre[hIndex].func; + preHookFunc(&handle); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.thread.destroy(handle); + } + if( HPMHooks.count.HP_thread_destroy_post ) { + void (*postHookFunc) (struct thread_handle *handle); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_destroy_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_destroy_post[hIndex].func; + postHookFunc(handle); + } + } + return; +} +struct thread_handle* HP_thread_self(void) { + int hIndex = 0; + struct thread_handle* retVal___ = NULL; + if( HPMHooks.count.HP_thread_self_pre ) { + struct thread_handle* (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_self_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_self_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.thread.self(); + } + if( HPMHooks.count.HP_thread_self_post ) { + struct thread_handle* (*postHookFunc) (struct thread_handle* retVal___); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_self_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_self_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} +int HP_thread_get_tid(void) { + int hIndex = 0; + int retVal___ = 0; + if( HPMHooks.count.HP_thread_get_tid_pre ) { + int (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_get_tid_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_get_tid_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.thread.get_tid(); + } + if( HPMHooks.count.HP_thread_get_tid_post ) { + int (*postHookFunc) (int retVal___); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_get_tid_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_get_tid_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} +bool HP_thread_wait(struct thread_handle *handle, void **out_exit_code) { + int hIndex = 0; + bool retVal___ = false; + if( HPMHooks.count.HP_thread_wait_pre ) { + bool (*preHookFunc) (struct thread_handle **handle, void ***out_exit_code); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_wait_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_wait_pre[hIndex].func; + retVal___ = preHookFunc(&handle, &out_exit_code); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.thread.wait(handle, out_exit_code); + } + if( HPMHooks.count.HP_thread_wait_post ) { + bool (*postHookFunc) (bool retVal___, struct thread_handle *handle, void **out_exit_code); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_wait_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_wait_post[hIndex].func; + retVal___ = postHookFunc(retVal___, handle, out_exit_code); + } + } + return retVal___; +} +void HP_thread_prio_set(struct thread_handle *handle, enum thread_priority prio) { + int hIndex = 0; + if( HPMHooks.count.HP_thread_prio_set_pre ) { + void (*preHookFunc) (struct thread_handle **handle, enum thread_priority *prio); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_prio_set_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_prio_set_pre[hIndex].func; + preHookFunc(&handle, &prio); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.thread.prio_set(handle, prio); + } + if( HPMHooks.count.HP_thread_prio_set_post ) { + void (*postHookFunc) (struct thread_handle *handle, enum thread_priority prio); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_prio_set_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_prio_set_post[hIndex].func; + postHookFunc(handle, prio); + } + } + return; +} +enum thread_priority HP_thread_prio_get(struct thread_handle *handle) { + int hIndex = 0; + enum thread_priority retVal___ = THREADPRIO_NORMAL; + if( HPMHooks.count.HP_thread_prio_get_pre ) { + enum thread_priority (*preHookFunc) (struct thread_handle **handle); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_prio_get_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_prio_get_pre[hIndex].func; + retVal___ = preHookFunc(&handle); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.thread.prio_get(handle); + } + if( HPMHooks.count.HP_thread_prio_get_post ) { + enum thread_priority (*postHookFunc) (enum thread_priority retVal___, struct thread_handle *handle); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_prio_get_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_prio_get_post[hIndex].func; + retVal___ = postHookFunc(retVal___, handle); + } + } + return retVal___; +} +void HP_thread_yield(void) { + int hIndex = 0; + if( HPMHooks.count.HP_thread_yield_pre ) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_yield_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_yield_pre[hIndex].func; + preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.thread.yield(); + } + if( HPMHooks.count.HP_thread_yield_post ) { + void (*postHookFunc) (void); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_yield_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_yield_post[hIndex].func; + postHookFunc(); + } + } + return; +} /* timer_interface */ int64 HP_timer_gettick(void) { int hIndex = 0; diff --git a/src/plugins/HPMHooking/HPMHooking_login.sources.inc b/src/plugins/HPMHooking/HPMHooking_login.sources.inc index ddd1206ca..6677a0c55 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.sources.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.sources.inc @@ -47,4 +47,5 @@ memcpy(&HPMHooks.source.StrBuf, StrBuf, sizeof(struct stringbuf_interface)); memcpy(&HPMHooks.source.strlib, strlib, sizeof(struct strlib_interface)); memcpy(&HPMHooks.source.sv, sv, sizeof(struct sv_interface)); memcpy(&HPMHooks.source.sysinfo, sysinfo, sizeof(struct sysinfo_interface)); +memcpy(&HPMHooks.source.thread, thread, sizeof(struct thread_interface)); memcpy(&HPMHooks.source.timer, timer, sizeof(struct timer_interface)); diff --git a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc index e3276fdf6..1f46a1c0f 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc @@ -5868,6 +5868,28 @@ struct { struct HPMHookPoint *HP_sysinfo_init_post; struct HPMHookPoint *HP_sysinfo_final_pre; struct HPMHookPoint *HP_sysinfo_final_post; + struct HPMHookPoint *HP_thread_init_pre; + struct HPMHookPoint *HP_thread_init_post; + struct HPMHookPoint *HP_thread_final_pre; + struct HPMHookPoint *HP_thread_final_post; + struct HPMHookPoint *HP_thread_create_pre; + struct HPMHookPoint *HP_thread_create_post; + struct HPMHookPoint *HP_thread_create_opt_pre; + struct HPMHookPoint *HP_thread_create_opt_post; + struct HPMHookPoint *HP_thread_destroy_pre; + struct HPMHookPoint *HP_thread_destroy_post; + struct HPMHookPoint *HP_thread_self_pre; + struct HPMHookPoint *HP_thread_self_post; + struct HPMHookPoint *HP_thread_get_tid_pre; + struct HPMHookPoint *HP_thread_get_tid_post; + struct HPMHookPoint *HP_thread_wait_pre; + struct HPMHookPoint *HP_thread_wait_post; + struct HPMHookPoint *HP_thread_prio_set_pre; + struct HPMHookPoint *HP_thread_prio_set_post; + struct HPMHookPoint *HP_thread_prio_get_pre; + struct HPMHookPoint *HP_thread_prio_get_post; + struct HPMHookPoint *HP_thread_yield_pre; + struct HPMHookPoint *HP_thread_yield_post; struct HPMHookPoint *HP_timer_gettick_pre; struct HPMHookPoint *HP_timer_gettick_post; struct HPMHookPoint *HP_timer_gettick_nocache_pre; @@ -11871,6 +11893,28 @@ struct { int HP_sysinfo_init_post; int HP_sysinfo_final_pre; int HP_sysinfo_final_post; + int HP_thread_init_pre; + int HP_thread_init_post; + int HP_thread_final_pre; + int HP_thread_final_post; + int HP_thread_create_pre; + int HP_thread_create_post; + int HP_thread_create_opt_pre; + int HP_thread_create_opt_post; + int HP_thread_destroy_pre; + int HP_thread_destroy_post; + int HP_thread_self_pre; + int HP_thread_self_post; + int HP_thread_get_tid_pre; + int HP_thread_get_tid_post; + int HP_thread_wait_pre; + int HP_thread_wait_post; + int HP_thread_prio_set_pre; + int HP_thread_prio_set_post; + int HP_thread_prio_get_pre; + int HP_thread_prio_get_post; + int HP_thread_yield_pre; + int HP_thread_yield_post; int HP_timer_gettick_pre; int HP_timer_gettick_post; int HP_timer_gettick_nocache_pre; @@ -12090,6 +12134,7 @@ struct { struct strlib_interface strlib; struct sv_interface sv; struct sysinfo_interface sysinfo; + struct thread_interface thread; struct timer_interface timer; struct trade_interface trade; struct unit_interface unit; diff --git a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc index 4f103df81..6d7b62cff 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc @@ -3005,6 +3005,18 @@ struct HookingPointData HookingPoints[] = { { HP_POP(sysinfo->is_superuser, HP_sysinfo_is_superuser) }, { HP_POP(sysinfo->init, HP_sysinfo_init) }, { HP_POP(sysinfo->final, HP_sysinfo_final) }, +/* thread_interface */ + { HP_POP(thread->init, HP_thread_init) }, + { HP_POP(thread->final, HP_thread_final) }, + { HP_POP(thread->create, HP_thread_create) }, + { HP_POP(thread->create_opt, HP_thread_create_opt) }, + { HP_POP(thread->destroy, HP_thread_destroy) }, + { HP_POP(thread->self, HP_thread_self) }, + { HP_POP(thread->get_tid, HP_thread_get_tid) }, + { HP_POP(thread->wait, HP_thread_wait) }, + { HP_POP(thread->prio_set, HP_thread_prio_set) }, + { HP_POP(thread->prio_get, HP_thread_prio_get) }, + { HP_POP(thread->yield, HP_thread_yield) }, /* timer_interface */ { HP_POP(timer->gettick, HP_timer_gettick) }, { HP_POP(timer->gettick_nocache, HP_timer_gettick_nocache) }, diff --git a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc index 949928058..ae813a9cb 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc @@ -78627,6 +78627,299 @@ void HP_sysinfo_final(void) { } return; } +/* thread_interface */ +void HP_thread_init(void) { + int hIndex = 0; + if( HPMHooks.count.HP_thread_init_pre ) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_init_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_init_pre[hIndex].func; + preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.thread.init(); + } + if( HPMHooks.count.HP_thread_init_post ) { + void (*postHookFunc) (void); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_init_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_init_post[hIndex].func; + postHookFunc(); + } + } + return; +} +void HP_thread_final(void) { + int hIndex = 0; + if( HPMHooks.count.HP_thread_final_pre ) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_final_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_final_pre[hIndex].func; + preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.thread.final(); + } + if( HPMHooks.count.HP_thread_final_post ) { + void (*postHookFunc) (void); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_final_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_final_post[hIndex].func; + postHookFunc(); + } + } + return; +} +struct thread_handle* HP_thread_create(threadFunc entry_point, void *param) { + int hIndex = 0; + struct thread_handle* retVal___ = NULL; + if( HPMHooks.count.HP_thread_create_pre ) { + struct thread_handle* (*preHookFunc) (threadFunc *entry_point, void **param); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_create_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_create_pre[hIndex].func; + retVal___ = preHookFunc(&entry_point, ¶m); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.thread.create(entry_point, param); + } + if( HPMHooks.count.HP_thread_create_post ) { + struct thread_handle* (*postHookFunc) (struct thread_handle* retVal___, threadFunc entry_point, void *param); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_create_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_create_post[hIndex].func; + retVal___ = postHookFunc(retVal___, entry_point, param); + } + } + return retVal___; +} +struct thread_handle* HP_thread_create_opt(threadFunc entry_point, void *param, size_t stack_size, enum thread_priority prio) { + int hIndex = 0; + struct thread_handle* retVal___ = NULL; + if( HPMHooks.count.HP_thread_create_opt_pre ) { + struct thread_handle* (*preHookFunc) (threadFunc *entry_point, void **param, size_t *stack_size, enum thread_priority *prio); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_create_opt_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_create_opt_pre[hIndex].func; + retVal___ = preHookFunc(&entry_point, ¶m, &stack_size, &prio); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.thread.create_opt(entry_point, param, stack_size, prio); + } + if( HPMHooks.count.HP_thread_create_opt_post ) { + struct thread_handle* (*postHookFunc) (struct thread_handle* retVal___, threadFunc entry_point, void *param, size_t stack_size, enum thread_priority prio); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_create_opt_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_create_opt_post[hIndex].func; + retVal___ = postHookFunc(retVal___, entry_point, param, stack_size, prio); + } + } + return retVal___; +} +void HP_thread_destroy(struct thread_handle *handle) { + int hIndex = 0; + if( HPMHooks.count.HP_thread_destroy_pre ) { + void (*preHookFunc) (struct thread_handle **handle); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_destroy_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_destroy_pre[hIndex].func; + preHookFunc(&handle); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.thread.destroy(handle); + } + if( HPMHooks.count.HP_thread_destroy_post ) { + void (*postHookFunc) (struct thread_handle *handle); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_destroy_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_destroy_post[hIndex].func; + postHookFunc(handle); + } + } + return; +} +struct thread_handle* HP_thread_self(void) { + int hIndex = 0; + struct thread_handle* retVal___ = NULL; + if( HPMHooks.count.HP_thread_self_pre ) { + struct thread_handle* (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_self_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_self_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.thread.self(); + } + if( HPMHooks.count.HP_thread_self_post ) { + struct thread_handle* (*postHookFunc) (struct thread_handle* retVal___); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_self_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_self_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} +int HP_thread_get_tid(void) { + int hIndex = 0; + int retVal___ = 0; + if( HPMHooks.count.HP_thread_get_tid_pre ) { + int (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_get_tid_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_get_tid_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.thread.get_tid(); + } + if( HPMHooks.count.HP_thread_get_tid_post ) { + int (*postHookFunc) (int retVal___); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_get_tid_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_get_tid_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} +bool HP_thread_wait(struct thread_handle *handle, void **out_exit_code) { + int hIndex = 0; + bool retVal___ = false; + if( HPMHooks.count.HP_thread_wait_pre ) { + bool (*preHookFunc) (struct thread_handle **handle, void ***out_exit_code); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_wait_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_wait_pre[hIndex].func; + retVal___ = preHookFunc(&handle, &out_exit_code); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.thread.wait(handle, out_exit_code); + } + if( HPMHooks.count.HP_thread_wait_post ) { + bool (*postHookFunc) (bool retVal___, struct thread_handle *handle, void **out_exit_code); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_wait_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_wait_post[hIndex].func; + retVal___ = postHookFunc(retVal___, handle, out_exit_code); + } + } + return retVal___; +} +void HP_thread_prio_set(struct thread_handle *handle, enum thread_priority prio) { + int hIndex = 0; + if( HPMHooks.count.HP_thread_prio_set_pre ) { + void (*preHookFunc) (struct thread_handle **handle, enum thread_priority *prio); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_prio_set_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_prio_set_pre[hIndex].func; + preHookFunc(&handle, &prio); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.thread.prio_set(handle, prio); + } + if( HPMHooks.count.HP_thread_prio_set_post ) { + void (*postHookFunc) (struct thread_handle *handle, enum thread_priority prio); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_prio_set_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_prio_set_post[hIndex].func; + postHookFunc(handle, prio); + } + } + return; +} +enum thread_priority HP_thread_prio_get(struct thread_handle *handle) { + int hIndex = 0; + enum thread_priority retVal___ = THREADPRIO_NORMAL; + if( HPMHooks.count.HP_thread_prio_get_pre ) { + enum thread_priority (*preHookFunc) (struct thread_handle **handle); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_prio_get_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_prio_get_pre[hIndex].func; + retVal___ = preHookFunc(&handle); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.thread.prio_get(handle); + } + if( HPMHooks.count.HP_thread_prio_get_post ) { + enum thread_priority (*postHookFunc) (enum thread_priority retVal___, struct thread_handle *handle); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_prio_get_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_prio_get_post[hIndex].func; + retVal___ = postHookFunc(retVal___, handle); + } + } + return retVal___; +} +void HP_thread_yield(void) { + int hIndex = 0; + if( HPMHooks.count.HP_thread_yield_pre ) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_yield_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_yield_pre[hIndex].func; + preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.thread.yield(); + } + if( HPMHooks.count.HP_thread_yield_post ) { + void (*postHookFunc) (void); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_yield_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_yield_post[hIndex].func; + postHookFunc(); + } + } + return; +} /* timer_interface */ int64 HP_timer_gettick(void) { int hIndex = 0; diff --git a/src/plugins/HPMHooking/HPMHooking_map.sources.inc b/src/plugins/HPMHooking/HPMHooking_map.sources.inc index 87cf0c3ed..0df5aee53 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.sources.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.sources.inc @@ -83,6 +83,7 @@ memcpy(&HPMHooks.source.StrBuf, StrBuf, sizeof(struct stringbuf_interface)); memcpy(&HPMHooks.source.strlib, strlib, sizeof(struct strlib_interface)); memcpy(&HPMHooks.source.sv, sv, sizeof(struct sv_interface)); memcpy(&HPMHooks.source.sysinfo, sysinfo, sizeof(struct sysinfo_interface)); +memcpy(&HPMHooks.source.thread, thread, sizeof(struct thread_interface)); memcpy(&HPMHooks.source.timer, timer, sizeof(struct timer_interface)); memcpy(&HPMHooks.source.trade, trade, sizeof(struct trade_interface)); memcpy(&HPMHooks.source.unit, unit, sizeof(struct unit_interface)); |