wto_ws.dll no longer scans aces.exe or carries structure offsets of a game build. It reads the values the patcher resolved (wto_ws.cfg native.* lines) into g_lmp through one table that names, per module, which value fills which field (local_mp_values.c), and installs each module whose values are all present, in dependency order, instead of giving up on the whole bridge when one subsystem is missing. When the settings were resolved for another executable (PE time stamp and image size differ), the bridge stays off. local_mp_offsets.h keeps the existing names so the module code reads as before; only Dagor library layouts (dag::Vector, DataBlock), protocol enums, the reflection buffer size and the two change request members with no reader in the client remain constants. A few fields are derived where the client has no instruction of its own for them (local_mp_values.c derive_values). The signatures moved to patches/native, and the header-based check-offsets command is gone: record-game-version and the launcher's patch check resolve the native modules now. Shared sites moved to local_mp_core (mission customBots, the player's unit eid) so modules do not depend on each other for them. Checked: DLL build (no warnings outside MinHook); root and launcher type checks; check-patches on 2.61.0.37; version records for 2.61.0.37 and 2.61.0.43 (10 native modules each); a lab run of the 2.61.0.37 copy logs 239 native values and "9 of 9 LocalMP modules installed". Battles were not played in this run. BREAKING CHANGE: Rebuild game copies to generate the new native values in wto_ws.cfg. Use record-game-version.ts or the launcher patch check in place of wtotools check-offsets.
204 lines
13 KiB
C
204 lines
13 KiB
C
/*
|
|
* Which wto_ws.cfg value fills which field of g_lmp, per LocalMP module (local_mp_values.h). The
|
|
* names are `<site>` and `<site>.<capture>` of patches/native/<module>.jsonc.
|
|
*
|
|
* A few fields are derived from captured ones where the client has no instruction of its own for
|
|
* them; each derivation is described in derive_values().
|
|
*/
|
|
#include "local_mp_values.h"
|
|
#include "hook_config.h"
|
|
|
|
#include <windows.h>
|
|
#include <string.h>
|
|
|
|
LmpValues g_lmp;
|
|
|
|
typedef enum LmpValueKind {
|
|
LMP_ADDRESS, /* an RVA: stored as the address in this process */
|
|
LMP_OFFSET, /* a structure offset or size */
|
|
LMP_SIGNED, /* a signed displacement */
|
|
} LmpValueKind;
|
|
|
|
typedef struct LmpValueSpec {
|
|
const char *module;
|
|
const char *name;
|
|
LmpValueKind kind;
|
|
size_t field;
|
|
} LmpValueSpec;
|
|
|
|
#define A(module, name, field) { module, name, LMP_ADDRESS, offsetof(LmpValues, field) }
|
|
#define O(module, name, field) { module, name, LMP_OFFSET, offsetof(LmpValues, field) }
|
|
#define S(module, name, field) { module, name, LMP_SIGNED, offsetof(LmpValues, field) }
|
|
#define CORE "local_mp_core"
|
|
#define PLAYERS "local_mp_players"
|
|
#define LOADOUT "local_mp_loadout"
|
|
#define ACTIONS "local_mp_actions"
|
|
#define AWARDS "local_mp_awards"
|
|
#define SCORES "local_mp_scores"
|
|
#define KILLS "local_mp_kills"
|
|
#define EVENTS "local_mp_events"
|
|
#define NUKE "local_mp_nuke"
|
|
#define SUPPORT "local_mp_support"
|
|
|
|
static const LmpValueSpec SPECS[] = {
|
|
A(CORE, "do_respawn_player", do_respawn_player), O(CORE, "do_respawn_player.app_score_rules", app_score_rules),
|
|
A(CORE, "do_respawn_player.hero", hero),
|
|
A(CORE, "disabled_slots_mask.multiplayer", multiplayer), A(CORE, "disabled_slots_mask.app", app),
|
|
A(CORE, "disabled_slots_mask.local_mplayer", local_mplayer), O(CORE, "disabled_slots_mask.mplayer_broken_slots", mp_broken_slots),
|
|
A(CORE, "get_player_country", get_player_country), O(CORE, "get_player_country.mp_is_local_mp", mp_is_local_mp),
|
|
A(CORE, "get_player_country.player_count", player_count), A(CORE, "get_player_country.player_table", player_table),
|
|
A(CORE, "sq_local_country.mission_settings", mission_settings),
|
|
A(CORE, "refl_dtor", refl_dtor), A(CORE, "refl_stdmem.stdmem", stdmem),
|
|
A(CORE, "aircraft_change_result", aircraft_change_result), O(CORE, "aircraft_change_result.econ_change_req", econ_change_req),
|
|
A(CORE, "set_player_gui_state", set_player_gui_state), A(CORE, "get_unit_by_eid", get_unit_by_eid),
|
|
A(CORE, "set_owning_mplayer", set_owning_mplayer), O(CORE, "set_owning_mplayer.mp_pid", mp_pid),
|
|
A(CORE, "iground_on_dead", iground_on_dead), A(CORE, "datablock_get_str", datablock_get_str),
|
|
A(CORE, "datablock_set_from", datablock_set_from), A(CORE, "datablock_set_from.dagmem_alloc", dagmem_alloc),
|
|
A(CORE, "mp_construct_local", mp_construct_local), O(CORE, "mp_construct_local.mp_chat_host", mp_chat_host),
|
|
O(CORE, "mp_construct_local.mp_is_host", mp_is_host),
|
|
A(CORE, "gui_state_update", gui_state_update),
|
|
O(CORE, "app_econ_state.econ_holder", app_econ_holder), O(CORE, "app_econ_state.econ_state", econ_state),
|
|
O(CORE, "mplayer_matching.match_team", match_team), O(CORE, "mplayer_matching.mp_team", mp_team),
|
|
O(CORE, "mplayer_matching.mp_user_id", mp_user_id),
|
|
A(CORE, "unit_change_aircraft", unit_change_aircraft), O(CORE, "unit_type.unit_type", unit_type),
|
|
O(CORE, "unit_info_name.unit_info", unit_info), O(CORE, "unit_info_name.info_name", unit_info_name),
|
|
O(CORE, "unit_mplayer.unit_mplayer", unit_mplayer), O(CORE, "mission_custom_bots.custom_bots", mis_custom_bots),
|
|
O(CORE, "mplayer_unit_eid.unit_eid", mp_unit_eid),
|
|
|
|
A(PLAYERS, "mplayer_init_matching", mplayer_init_matching), A(PLAYERS, "is_slot_ready_at_host", is_slot_ready_at_host),
|
|
O(PLAYERS, "mplayer_gui_state.gui_state", mp_gui_state), O(PLAYERS, "mplayer_used_spares.used_spares", mp_used_spares),
|
|
O(PLAYERS, "mission_allies_country.allies_country", mis_allies_country),
|
|
O(PLAYERS, "mission_axis_country.axis_country", mis_axis_country),
|
|
O(PLAYERS, "mission_arcade_country.arcade_country", mis_arcade_country),
|
|
|
|
A(LOADOUT, "sem_change_aircraft_send", sem_change_aircraft_send), A(LOADOUT, "refl_ctor", refl_ctor),
|
|
A(LOADOUT, "datablock_dtor", datablock_dtor), A(LOADOUT, "bullet_vec_assign", bullet_vec_assign),
|
|
A(LOADOUT, "get_decals_blk", get_decals_blk), A(LOADOUT, "get_attachables_blk", get_attachables_blk),
|
|
A(LOADOUT, "str_hash_fnv1", str_hash_fnv1), A(LOADOUT, "namemap_add_name_id", namemap_add_name_id),
|
|
A(LOADOUT, "crew_skills_init", crew_skills_init),
|
|
O(LOADOUT, "refl_objects.bullets", refl_bullets), O(LOADOUT, "refl_objects.disabled_mods", refl_disabled_mods),
|
|
O(LOADOUT, "refl_objects.enabled_mods", refl_enabled_mods), O(LOADOUT, "refl_objects.custom_preset", refl_custom_preset),
|
|
O(LOADOUT, "refl_objects.attachables", refl_attachables), O(LOADOUT, "refl_objects.decals", refl_decals),
|
|
O(LOADOUT, "refl_names.custom_skin", refl_custom_skin), O(LOADOUT, "refl_names.skin", refl_skin),
|
|
O(LOADOUT, "refl_names.weapon", refl_weapon), O(LOADOUT, "refl_names.unit", refl_unit),
|
|
O(LOADOUT, "refl_flags.flags", refl_flags), O(LOADOUT, "refl_targeting.gun_convergence", refl_gun_convergence),
|
|
O(LOADOUT, "refl_vertical_targeting.vertical_targeting", refl_vertical_targeting),
|
|
O(LOADOUT, "refl_bomb_fuse.bomb_fuse", refl_bomb_fuse),
|
|
O(LOADOUT, "respawn_spawn.resp_base_id", mp_resp_base_id), O(LOADOUT, "respawn_spawn.spawn_delay_a", mp_spawn_delay_a),
|
|
O(LOADOUT, "unit_spawn_state.spawn_delay_b", mp_spawn_delay_b), O(LOADOUT, "respawn_spawn.spawn_pos_x", mp_spawn_pos_x),
|
|
O(LOADOUT, "respawn_spawn.spawn_pos_y", mp_spawn_pos_y), O(LOADOUT, "respawn_spawn.spawn_pos_z", mp_spawn_pos_z),
|
|
O(LOADOUT, "change_req_slot.slot_id", econ_req_slot_id),
|
|
O(LOADOUT, "change_req_bullets.bullets_begin", econ_req_bullets_begin),
|
|
O(LOADOUT, "change_req_bullets.bullets_end", econ_req_bullets_end),
|
|
O(LOADOUT, "unit_crew_skills.crew_skills", unit_crew_skills),
|
|
|
|
A(ACTIONS, "mp_init_chat", mp_init_chat), O(ACTIONS, "mp_chat.mp_chat", mp_chat),
|
|
O(ACTIONS, "mp_team_countries.team1_countries", mp_team1_countries),
|
|
O(ACTIONS, "mp_team_countries.team2_countries", mp_team2_countries),
|
|
|
|
A(AWARDS, "score_msg_blk_ctor.call", blk_ctor), A(AWARDS, "score_msg_blk_set_str.call", blk_set_str),
|
|
A(AWARDS, "score_msg_blk_to_owned.call", blk_to_owned), A(AWARDS, "score_msg_blk_set_int.call", blk_set_int),
|
|
O(AWARDS, "score_msg_hud_queue.queue", gsd_hud_queue), A(AWARDS, "score_msg_hud_queue.call", hud_notify_script),
|
|
A(AWARDS, "score_msg_blk_dtor.call", blk_dtor), O(AWARDS, "score_msg_exp_class.exp_class", unit_info_exp_class),
|
|
A(AWARDS, "game_save_data.game_save_data", game_save_data),
|
|
|
|
A(SCORES, "datablock_get_real", datablock_get_real),
|
|
O(SCORES, "mission_score_params.custom_score_params", mis_custom_score_params),
|
|
|
|
A(KILLS, "mplayer_add_score", mplayer_add_score), O(KILLS, "mplayer_score.score", mp_score),
|
|
O(KILLS, "mplayer_stat_sync.dirty", mp_stat_dirty), O(KILLS, "mplayer_stat_sync.payload", mp_stat_payload),
|
|
A(KILLS, "net_mark_dirty", net_mark_dirty),
|
|
A(KILLS, "on_unit_dead_once", on_unit_dead_once), O(KILLS, "on_unit_dead_once.skip_kill", unit_skip_kill),
|
|
O(KILLS, "unit_severe.severe_idx", unit_severe_idx), O(KILLS, "unit_severe.severe_uid", unit_severe_uid),
|
|
O(KILLS, "unit_severe.severe_pid", unit_severe_pid),
|
|
O(KILLS, "ground_death_flags.already_dead", igm_already_dead), O(KILLS, "ground_death_flags.dead_silent", igm_dead_silent),
|
|
O(KILLS, "ground_bailout.bailout_dead", igm_bailout_dead),
|
|
O(KILLS, "ground_offenders.offenders_count", igm_offenders_count), O(KILLS, "ground_offenders.offenders", igm_offenders),
|
|
O(KILLS, "ground_offenders.offender_size", offender_size), O(KILLS, "ground_offenders.killer", igm_killer),
|
|
O(KILLS, "ground_offenders.killer_uid", igm_killer_uid), O(KILLS, "ground_offenders.killer_pid", igm_killer_pid),
|
|
A(KILLS, "iground_award_assists", iground_award_assists),
|
|
O(KILLS, "iground_award_assists.choose_offender", unit_vtf_choose_offender),
|
|
O(KILLS, "offender_fields.unit_army", unit_army), O(KILLS, "offender_fields.army", offender_army),
|
|
O(KILLS, "offender_fields.uid", offender_uid), O(KILLS, "offender_fields.pid", offender_pid),
|
|
O(KILLS, "stat_kills.field", mp_kills), O(KILLS, "stat_ground_kills.field", mp_ground_kills),
|
|
O(KILLS, "stat_human_kills.field", mp_human_kills), O(KILLS, "stat_naval_kills.field", mp_naval_kills),
|
|
O(KILLS, "stat_team_kills.field", mp_team_kills), O(KILLS, "stat_ai_kills.field", mp_ai_kills),
|
|
O(KILLS, "stat_ai_ground_kills.field", mp_ai_ground_kills), O(KILLS, "stat_ai_naval_kills.field", mp_ai_naval_kills),
|
|
O(KILLS, "stat_assists.field", mp_assists), O(KILLS, "stat_deaths.field", mp_deaths),
|
|
O(KILLS, "stat_capture_zone.field", mp_capture_zone), O(KILLS, "stat_score.fallback", mp_fallback_score),
|
|
O(KILLS, "stat_award_damage.field", mp_award_damage), O(KILLS, "stat_air_severe.field", mp_air_severe_dmg),
|
|
O(KILLS, "stat_ship_severe.field", mp_ship_severe_dmg),
|
|
|
|
A(EVENTS, "dispatch_assist", dispatch_assist), A(EVENTS, "caller_capture_zone.call", dispatch_capture_zone),
|
|
A(EVENTS, "caller_hit_crit.call", dispatch_hit_crit), A(EVENTS, "caller_severe_damage.call", dispatch_severe_damage),
|
|
A(EVENTS, "caller_naval_damage.call", dispatch_naval_damage), O(EVENTS, "offender_assist.assist_sent", offender_assist_sent),
|
|
|
|
A(NUKE, "shell_launch", shell_launch), A(NUKE, "shell_explode", shell_explode), A(NUKE, "cta_logic_action", cta_logic_action),
|
|
O(NUKE, "shell_instant_win.record", shell_launch_record), O(NUKE, "shell_instant_win.instant_win", shell_rec_instant_win),
|
|
O(NUKE, "mission_vars_data.data", mission_vars_data), O(NUKE, "mission_vars_walk.count", mission_vars_count),
|
|
S(NUKE, "mission_vars_walk.entry_bias", mission_var_bias), S(NUKE, "mission_vars_step.name", mission_var_name_disp),
|
|
O(NUKE, "mission_vars_step.stride", mission_var_stride), S(NUKE, "mission_vars_value.value", mission_var_value_disp),
|
|
|
|
A(SUPPORT, "set_controlled_unit", set_controlled_unit), O(SUPPORT, "mplayer_support_unit.eid", mp_support_unit_eid),
|
|
O(SUPPORT, "mplayer_support_unit.unit", mp_support_unit_ptr),
|
|
};
|
|
|
|
static void store(const LmpValueSpec *spec, int64_t value, uint8_t *base)
|
|
{
|
|
uint8_t *field = (uint8_t *)&g_lmp + spec->field;
|
|
if (spec->kind == LMP_ADDRESS) {
|
|
uint8_t *address = base + value;
|
|
memcpy(field, &address, sizeof(address));
|
|
} else if (spec->kind == LMP_SIGNED) {
|
|
ptrdiff_t signed_value = (ptrdiff_t)value;
|
|
memcpy(field, &signed_value, sizeof(signed_value));
|
|
} else {
|
|
size_t offset = (size_t)value;
|
|
memcpy(field, &offset, sizeof(offset));
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Fields the client reads nowhere at a fixed displacement of its own:
|
|
* - the change request members are captured as offsets in the economic state, which is how the
|
|
* client addresses them, and used relative to the request;
|
|
* - the reflection fuel is the float before the gun convergence in the block the reflection
|
|
* constructor initialises as one (+0xd0..+0xdf on 2.61.0.37); no client code reads it;
|
|
* - the ground model's killer army is the army member of the killer record embedded in it;
|
|
* - a mission variable's name and value are where the walk's displacements point from the
|
|
* pointer it keeps `entry_bias` bytes into each entry.
|
|
*/
|
|
static void derive_values(const char *module)
|
|
{
|
|
if (strcmp(module, LOADOUT) == 0) {
|
|
g_lmp.req_slot_id = g_lmp.econ_req_slot_id - g_lmp.econ_change_req;
|
|
g_lmp.req_bullets_begin = g_lmp.econ_req_bullets_begin - g_lmp.econ_change_req;
|
|
g_lmp.req_bullets_end = g_lmp.econ_req_bullets_end - g_lmp.econ_change_req;
|
|
g_lmp.refl_fuel = g_lmp.refl_gun_convergence - sizeof(float);
|
|
} else if (strcmp(module, KILLS) == 0) {
|
|
g_lmp.igm_killer_army = g_lmp.igm_killer + g_lmp.offender_army;
|
|
} else if (strcmp(module, NUKE) == 0) {
|
|
g_lmp.mission_var_name = (size_t)(g_lmp.mission_var_bias + g_lmp.mission_var_name_disp);
|
|
g_lmp.mission_var_value = (size_t)(g_lmp.mission_var_bias + g_lmp.mission_var_value_disp);
|
|
}
|
|
}
|
|
|
|
int lmp_values_load(const char *module)
|
|
{
|
|
uint8_t *base = (uint8_t *)GetModuleHandleW(NULL);
|
|
size_t i;
|
|
|
|
for (i = 0; i < sizeof(SPECS) / sizeof(SPECS[0]); i++) {
|
|
int64_t value;
|
|
if (strcmp(SPECS[i].module, module) != 0)
|
|
continue;
|
|
if (!config_native_value(SPECS[i].name, &value)) {
|
|
log_line("local_mp: %s unavailable: no value %s in wto_ws.cfg", module, SPECS[i].name);
|
|
return 0;
|
|
}
|
|
store(&SPECS[i], value, base);
|
|
}
|
|
derive_values(module);
|
|
return 1;
|
|
}
|