refactor(native): batch MinHook enable calls and log status codes

Switch ws2_32 and LocalMP hook installers to MH_QueueEnableHook with two MH_ApplyQueued passes (mandatory network hooks first, then all LocalMP modules), reducing DllMain thread-freeze cycles from 26 to 2. Roll back partial module hooks on error and log MH_StatusToString diagnostics to wto_ws.log.

Checked: native/wto-net/build.ps1 compiles cleanly with zero warnings in project sources, and PE inspection confirms WS2_32/KERNEL32 imports and 49 exports. In-game verification pending.
This commit is contained in:
N0VAN0M4LY committed 2026-12-02 07:24:27 +08:00
1 parent 90bd5a315d
commit 96077153c6
11 files changed
+120 -105

No files matched your search

+5 -10
View File
@@ -192,18 +192,13 @@ static void __fastcall hook_on_unit_dead_once(uint8_t *victim)
int install_local_mp_kill_hooks(void)
{
uint8_t *p_ground_dead = g_lmp.iground_on_dead;
uint8_t *p_dead = g_lmp.on_unit_dead_once;
const LocalMpHookSpec hooks[] = {
{ "iground_on_dead", g_lmp.iground_on_dead, (void *)&hook_iground_on_became_dead, (void **)&orig_iground_on_dead },
{ "on_unit_dead_once", g_lmp.on_unit_dead_once, (void *)&hook_on_unit_dead_once, (void **)&orig_on_unit_dead_once },
};
fn_mplayer_add_score = (MPlayerAddScoreFn)g_lmp.mplayer_add_score;
fn_net_mark_dirty = (NetMarkDirtyFn)g_lmp.net_mark_dirty;
if (MH_CreateHook(p_ground_dead, (void *)&hook_iground_on_became_dead, (void **)&orig_iground_on_dead) != MH_OK ||
MH_EnableHook(p_ground_dead) != MH_OK ||
MH_CreateHook(p_dead, (void *)&hook_on_unit_dead_once, (void **)&orig_on_unit_dead_once) != MH_OK ||
MH_EnableHook(p_dead) != MH_OK) {
log_line("local_mp: failed to install unit-death scoring hooks");
return 0;
}
return 1;
return local_mp_queue_hooks("local_mp_kills", hooks, sizeof(hooks) / sizeof(hooks[0]));
}