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

+4 -7
View File
@@ -202,7 +202,9 @@ static void __fastcall hook_sem_change_aircraft_send(
int install_local_mp_loadout_hooks(void)
{
uint8_t *p_sem_send = g_lmp.sem_change_aircraft_send;
const LocalMpHookSpec hooks[] = {
{ "sem_change_aircraft_send", g_lmp.sem_change_aircraft_send, (void *)&hook_sem_change_aircraft_send, (void **)&orig_sem_send },
};
/* The reflection is built in a fixed stack buffer; its bullet sets vector is its last member. */
if (LMP_REFL_OFF_BULLETS_VEC + 0x20u > LMP_REFL_SIZE) {
@@ -222,10 +224,5 @@ int install_local_mp_loadout_hooks(void)
fn_namemap_add = (NameMapAddNameIdFn)g_lmp.namemap_add_name_id;
fn_crew_skills_init = (CrewSkillsInitFn)g_lmp.crew_skills_init;
if (MH_CreateHook(p_sem_send, (void *)&hook_sem_change_aircraft_send, (void **)&orig_sem_send) != MH_OK ||
MH_EnableHook(p_sem_send) != MH_OK) {
log_line("local_mp: failed to install SemChangeAircraftRequest::send hook");
return 0;
}
return 1;
return local_mp_queue_hooks("local_mp_loadout", hooks, sizeof(hooks) / sizeof(hooks[0]));
}