refactor(native)!: load LocalMP values from the build configuration
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.
This commit is contained in:
1 parent
dde852e2b1
commit
fdac56a036
23 files changed
+721
-805
No files matched your search
@@ -23,7 +23,7 @@ WTOffline 是《战争雷霆》(War Thunder)Windows 客户端的单机离线
|
||||
| 游戏副本构建 | 可用。命令行脚本与启动器共用同一套构建代码 |
|
||||
| 启动器 | 安装向导(选择原版目录、补丁兼容性检查、复制、备份)可用;从启动器启动服务器和游戏仍在开发 |
|
||||
|
||||
其他客户端版本没有验证过。补丁使用特征码定位,小版本更新后可能仍然命中,但不保证功能正确。
|
||||
其他客户端版本没有验证过。补丁和 native 模块按特征码、字符串引用和从代码中读出的值定位,小版本更新后通常仍能命中,但没有核对记录(`patches/versions/`)的版本不保证功能正确。
|
||||
|
||||
## 功能
|
||||
|
||||
@@ -102,7 +102,7 @@ AI 的驾驶、寻路和战术使用游戏自带的 AI,目前仍有明显不
|
||||
|
||||
1. 本地服务器的匹配服务在排队后下发开局通知,内容是完整的任务配置,包括地图、AI 阵容和出生规则。
|
||||
2. 界面脚本补丁收到通知后,在游戏进程内以 LocalMP 主机身份开局。
|
||||
3. `native/wto-net` 中的 `local_mp_*` 模块补上被裁掉的服务端处理,包括选车与出生、击杀归属、计分、奖励事件、聊天主机和核弹胜负判定。这些函数在 `.text` 段中按特征码定位,某个特征失配时只跳过对应功能并写日志。
|
||||
3. `native/wto-net` 中的 `local_mp_*` 模块补上被裁掉的服务端处理,包括选车与出生、击杀归属、计分、奖励事件、聊天主机和核弹胜负判定。它们需要的函数、全局变量和结构体偏移定义在 `patches/native/`,由构建按当前客户端解析后写入 `wto_ws.cfg`;某个模块无法解析时,安装器列出受影响的功能,DLL 只跳过该模块并写日志。
|
||||
4. 对局中的战斗事件实时上报本地服务器,用于判定嘉奖;对局结束后由服务器按游戏数据和配置结算收益,结算页显示服务器的结果。
|
||||
|
||||
### 与正版隔离
|
||||
@@ -214,10 +214,11 @@ npm run build --workspace "@wto/launcher"
|
||||
```powershell
|
||||
python -m pip install -e ./tools
|
||||
wtotools check-patches --exe "<原版目录>\win64\aces.exe" # 定位并核对全部 exe 补丁
|
||||
wtotools check-offsets --exe "<原版目录>\win64\aces.exe" # 核对 local_mp 模块的特征码
|
||||
wtotools check-gui --gui "<原版目录>\gui.vromfs.bin" --sq "<sq.exe 路径>" # 应用界面补丁并用 Quirrel 编译器编译
|
||||
```
|
||||
|
||||
检查全部补丁和 native 模块并写入该客户端版本的核对记录:`node scripts/record-game-version.ts --game "<原版目录>"`。
|
||||
|
||||
## 目录结构
|
||||
|
||||
```text
|
||||
@@ -280,7 +281,7 @@ The repository contains source code and patch definitions only. It does not cont
|
||||
| Game copy build | Working. The command-line script and the launcher share the same build code |
|
||||
| Launcher | The install wizard (select the original folder, check patch compatibility, copy, back up) works. Starting the server and the game from the launcher is in development |
|
||||
|
||||
Other client versions have not been verified. Patches are located by signature scanning, so they may still match after a minor update, but correct behavior is not guaranteed.
|
||||
Other client versions have not been verified. Patches and native modules are located by signatures, string references and values read from the code, so they usually still match after a minor update, but correct behavior is not guaranteed for a version without a check record (`patches/versions/`).
|
||||
|
||||
## Features
|
||||
|
||||
@@ -359,7 +360,7 @@ When queueing, the client only ever connects to a remote battle server as a clie
|
||||
|
||||
1. After the player queues, the local matching service sends a battle start notification carrying the full mission configuration, including the map, AI lineups, and spawn rules.
|
||||
2. A UI script patch receives the notification and starts the battle in the game process as a LocalMP host.
|
||||
3. The `local_mp_*` modules in `native/wto-net` restore the stripped server-side handlers: vehicle selection and spawning, kill attribution, scoring, award events, the chat host, and nuke victory. These functions are located in the `.text` section by signature. If a signature does not match, only that feature is skipped and a log entry is written.
|
||||
3. The `local_mp_*` modules in `native/wto-net` restore the stripped server-side handlers: vehicle selection and spawning, kill attribution, scoring, award events, the chat host, and nuke victory. The functions, globals and structure offsets they need are defined in `patches/native/`; the build resolves them against the client and writes them into `wto_ws.cfg`. If a module cannot be resolved, the installer lists the affected features and the DLL skips only that module and writes a log entry.
|
||||
4. Combat events are reported to the local server during the battle to decide awards. When the battle ends, the server settles rewards from the game data and tuning, and the debriefing shows the server's results.
|
||||
|
||||
### Isolation from the online game
|
||||
@@ -471,10 +472,11 @@ npm run build --workspace "@wto/launcher"
|
||||
```powershell
|
||||
python -m pip install -e ./tools
|
||||
wtotools check-patches --exe "<stock folder>\win64\aces.exe" # locate and verify every exe patch
|
||||
wtotools check-offsets --exe "<stock folder>\win64\aces.exe" # verify the local_mp module signatures
|
||||
wtotools check-gui --gui "<stock folder>\gui.vromfs.bin" --sq "<path to sq.exe>" # apply UI patches and compile them with the Quirrel compiler
|
||||
```
|
||||
|
||||
To check every patch and native module and write the check record of that client version: `node scripts/record-game-version.ts --game "<stock folder>"`.
|
||||
|
||||
## Repository layout
|
||||
|
||||
```text
|
||||
|
||||
@@ -22,7 +22,7 @@ New-Item -ItemType Directory -Force $obj | Out-Null
|
||||
|
||||
$sources = @(
|
||||
"$src\dll_main.c", "$src\hook_config.c", "$src\redirect_rules.c", "$src\resolver_hooks.c", "$src\connection_hooks.c",
|
||||
"$src\local_mp_core.c", "$src\local_mp_players.c", "$src\local_mp_loadout.c", "$src\local_mp_actions.c", "$src\local_mp_awards.c", "$src\local_mp_kills.c", "$src\local_mp_events.c", "$src\local_mp_scores.c", "$src\local_mp_nuke.c", "$src\local_mp_support.c",
|
||||
"$src\local_mp_core.c", "$src\local_mp_values.c", "$src\local_mp_players.c", "$src\local_mp_loadout.c", "$src\local_mp_actions.c", "$src\local_mp_awards.c", "$src\local_mp_kills.c", "$src\local_mp_events.c", "$src\local_mp_scores.c", "$src\local_mp_nuke.c", "$src\local_mp_support.c",
|
||||
"$mh\src\hook.c", "$mh\src\buffer.c", "$mh\src\trampoline.c", "$mh\src\hde\hde64.c"
|
||||
) | ForEach-Object { '"' + (Resolve-Path $_) + '"' }
|
||||
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
/*
|
||||
* Settings and log next to the DLL.
|
||||
*
|
||||
* wto_ws.cfg, written by the build into the game copy: one line "port=<local server port>".
|
||||
* Without a valid port the hooks still answer every host name locally but refuse every
|
||||
* connection that would leave the machine.
|
||||
* wto_ws.cfg, written by the build into the game copy (@wto/patcher network-hook.ts):
|
||||
* port=<local server port> without a valid port the hooks still answer every host name
|
||||
* locally but refuse every connection that would leave the machine
|
||||
* exe.time_date_stamp=0x... the executable the native values were resolved for
|
||||
* exe.size_of_image=0x...
|
||||
* native.<name>=<value> what the LocalMP modules need from the executable: RVAs of
|
||||
* functions and globals, structure offsets (local_mp_values.c)
|
||||
*
|
||||
* wto_ws.log: which host names were answered locally and which connections were redirected or
|
||||
* refused, so a run shows every address the game tried (the audit handover 6.2 asks for).
|
||||
@@ -17,9 +21,22 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define NATIVE_PREFIX "native."
|
||||
#define NATIVE_NAME_MAX 80
|
||||
#define NATIVE_VALUES_MAX 512
|
||||
|
||||
typedef struct NativeValue {
|
||||
char name[NATIVE_NAME_MAX];
|
||||
int64_t value;
|
||||
} NativeValue;
|
||||
|
||||
static wchar_t g_folder[MAX_PATH];
|
||||
static CRITICAL_SECTION g_log_lock;
|
||||
static FILE *g_log;
|
||||
static NativeValue g_native[NATIVE_VALUES_MAX];
|
||||
static size_t g_native_count;
|
||||
static int64_t g_exe_time_date_stamp = -1;
|
||||
static int64_t g_exe_size_of_image = -1;
|
||||
|
||||
static void find_folder(HMODULE self)
|
||||
{
|
||||
@@ -33,36 +50,100 @@ static void find_folder(HMODULE self)
|
||||
slash[1] = L'\0';
|
||||
}
|
||||
|
||||
static void read_port(void)
|
||||
static void read_port(const char *text)
|
||||
{
|
||||
char *end;
|
||||
unsigned long port = strtoul(text, &end, 10);
|
||||
if (end != text && port > 0 && port < 65536)
|
||||
g_service_port = (unsigned short)port;
|
||||
}
|
||||
|
||||
/* "<value>" as written by the build: hexadecimal 0x..., negative as -0x... */
|
||||
static int parse_value(const char *text, int64_t *value)
|
||||
{
|
||||
char *end;
|
||||
long long parsed = strtoll(text, &end, 0);
|
||||
if (end == text)
|
||||
return 0;
|
||||
*value = (int64_t)parsed;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void read_native_value(const char *line)
|
||||
{
|
||||
const char *name = line + sizeof(NATIVE_PREFIX) - 1;
|
||||
const char *equals = strchr(name, '=');
|
||||
size_t length = equals ? (size_t)(equals - name) : 0;
|
||||
NativeValue *slot;
|
||||
|
||||
if (length == 0 || length >= NATIVE_NAME_MAX || g_native_count >= NATIVE_VALUES_MAX)
|
||||
return;
|
||||
slot = &g_native[g_native_count];
|
||||
memcpy(slot->name, name, length);
|
||||
slot->name[length] = '\0';
|
||||
if (parse_value(equals + 1, &slot->value))
|
||||
g_native_count++;
|
||||
}
|
||||
|
||||
static void read_settings(void)
|
||||
{
|
||||
wchar_t path[MAX_PATH];
|
||||
char line[128];
|
||||
char line[160];
|
||||
FILE *file;
|
||||
if (_snwprintf_s(path, MAX_PATH, _TRUNCATE, L"%swto_ws.cfg", g_folder) < 0)
|
||||
return;
|
||||
if (_wfopen_s(&file, path, L"r") != 0 || file == NULL)
|
||||
return;
|
||||
while (fgets(line, sizeof(line), file)) {
|
||||
unsigned long port;
|
||||
char *end;
|
||||
if (strncmp(line, "port=", 5) != 0)
|
||||
continue;
|
||||
port = strtoul(line + 5, &end, 10);
|
||||
if (end != line + 5 && port > 0 && port < 65536)
|
||||
g_service_port = (unsigned short)port;
|
||||
line[strcspn(line, "\r\n")] = '\0';
|
||||
if (strncmp(line, "port=", 5) == 0)
|
||||
read_port(line + 5);
|
||||
else if (strncmp(line, "exe.time_date_stamp=", 20) == 0)
|
||||
parse_value(line + 20, &g_exe_time_date_stamp);
|
||||
else if (strncmp(line, "exe.size_of_image=", 18) == 0)
|
||||
parse_value(line + 18, &g_exe_size_of_image);
|
||||
else if (strncmp(line, NATIVE_PREFIX, sizeof(NATIVE_PREFIX) - 1) == 0)
|
||||
read_native_value(line);
|
||||
}
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
int config_native_value(const char *name, int64_t *value)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < g_native_count; i++) {
|
||||
if (strcmp(g_native[i].name, name) == 0) {
|
||||
*value = g_native[i].value;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int config_native_matches_executable(void)
|
||||
{
|
||||
const uint8_t *module = (const uint8_t *)GetModuleHandleW(NULL);
|
||||
const IMAGE_DOS_HEADER *dos = (const IMAGE_DOS_HEADER *)module;
|
||||
const IMAGE_NT_HEADERS64 *nt;
|
||||
|
||||
if (module == NULL || dos->e_magic != IMAGE_DOS_SIGNATURE)
|
||||
return 0;
|
||||
nt = (const IMAGE_NT_HEADERS64 *)(module + dos->e_lfanew);
|
||||
return nt->Signature == IMAGE_NT_SIGNATURE &&
|
||||
(int64_t)nt->FileHeader.TimeDateStamp == g_exe_time_date_stamp &&
|
||||
(int64_t)nt->OptionalHeader.SizeOfImage == g_exe_size_of_image;
|
||||
}
|
||||
|
||||
void config_load(HMODULE self)
|
||||
{
|
||||
wchar_t path[MAX_PATH];
|
||||
InitializeCriticalSection(&g_log_lock);
|
||||
find_folder(self);
|
||||
read_port();
|
||||
read_settings();
|
||||
if (_snwprintf_s(path, MAX_PATH, _TRUNCATE, L"%swto_ws.log", g_folder) >= 0)
|
||||
g_log = _wfsopen(path, L"w", _SH_DENYWR);
|
||||
log_line("wto_ws: local server port %u%s", g_service_port, g_service_port ? "" : " (none: outside connections are refused)");
|
||||
log_line("wto_ws: %u native value(s) for the LocalMP modules", (unsigned)g_native_count);
|
||||
}
|
||||
|
||||
void log_line(const char *format, ...)
|
||||
|
||||
@@ -3,7 +3,13 @@
|
||||
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <stdint.h>
|
||||
|
||||
void config_load(HMODULE self);
|
||||
void log_line(const char *format, ...);
|
||||
void describe_address(const struct sockaddr *name, int length, char *text, size_t size);
|
||||
|
||||
/* A value the build resolved from the executable (wto_ws.cfg "native.<name>="); 0 when absent. */
|
||||
int config_native_value(const char *name, int64_t *value);
|
||||
/* Whether the settings were resolved for the executable this process runs (PE time stamp and size). */
|
||||
int config_native_matches_executable(void);
|
||||
@@ -123,16 +123,12 @@ static uint8_t __fastcall hook_mp_construct_local(uint8_t *mp, void *mis, void *
|
||||
return ok;
|
||||
}
|
||||
|
||||
int install_local_mp_action_hooks(const uint8_t *text, size_t text_size)
|
||||
int install_local_mp_action_hooks(void)
|
||||
{
|
||||
uint8_t *p_construct = local_mp_scan_unique(text, text_size, "Multiplayer::constructLocalMP", LMP_SIG_MP_CONSTRUCT_LOCAL);
|
||||
uint8_t *p_init_chat = local_mp_scan_unique(text, text_size, "Multiplayer::initMPChat", LMP_SIG_MP_INIT_CHAT);
|
||||
uint8_t *p_set_from = local_mp_scan_unique(text, text_size, "DataBlock::setFrom", LMP_SIG_DATABLOCK_SET_FROM);
|
||||
uint8_t *p_construct = g_lmp.mp_construct_local;
|
||||
|
||||
if (!p_construct || !p_init_chat || !p_set_from)
|
||||
return 0;
|
||||
fn_mp_init_chat = (MpInitChatFn)p_init_chat;
|
||||
fn_dagmem_alloc = (DagmemAllocFn)local_mp_resolve_rip(p_set_from + 0x25, 1, 5);
|
||||
fn_mp_init_chat = (MpInitChatFn)g_lmp.mp_init_chat;
|
||||
fn_dagmem_alloc = (DagmemAllocFn)g_lmp.dagmem_alloc;
|
||||
|
||||
if (MH_CreateHook(p_construct, (void *)&hook_mp_construct_local, (void **)&orig_mp_construct_local) != MH_OK ||
|
||||
MH_EnableHook(p_construct) != MH_OK) {
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
*
|
||||
* The event is queued with the same call addScoreMessage uses, but without its
|
||||
* "hudShowAwardMessages" option gate, so the record does not depend on a HUD setting.
|
||||
* Every engine helper below is resolved from a call site inside addScoreMessage
|
||||
* (LMP_SIG_HUD_ADD_SCORE_MSG); see local_mp_offsets.h for the 2.61.0.37 addresses.
|
||||
* Every engine helper below, and the queue's offset in GameSaveData, is captured from a call site
|
||||
* inside addScoreMessage (patches/native/local_mp_awards.jsonc).
|
||||
*/
|
||||
#include "hooks.h"
|
||||
#include "hook_config.h"
|
||||
@@ -29,7 +29,6 @@ typedef void (__fastcall *BlkSetIntFn)(void *blk, const char *name, const int32_
|
||||
typedef void (__fastcall *HudNotifyScriptFn)(void *queue, const char *event_name, const void *blk);
|
||||
|
||||
static uint8_t **g_game_save_data;
|
||||
static uint32_t g_hud_queue_off;
|
||||
static BlkCtorFn fn_blk_ctor;
|
||||
static BlkDtorFn fn_blk_dtor;
|
||||
static BlkToOwnedFn fn_blk_to_owned;
|
||||
@@ -77,7 +76,7 @@ void local_mp_report_award_event(const LocalMpAwardEvent *ev)
|
||||
blk_set_int(blk, "victimIsPlayer", ev->victim_is_player ? 1 : 0);
|
||||
blk_set_int(blk, "friendly", ev->friendly ? 1 : 0);
|
||||
blk_set_int(blk, "damage", ev->damage);
|
||||
fn_hud_notify_script(gsd + g_hud_queue_off, LMP_AWARD_EVENT_NAME, blk);
|
||||
fn_hud_notify_script(gsd + LMP_GSD_OFF_HUD_QUEUE, LMP_AWARD_EVENT_NAME, blk);
|
||||
fn_blk_dtor(blk);
|
||||
}
|
||||
|
||||
@@ -92,44 +91,18 @@ void local_mp_report_nuclear_strike(void)
|
||||
return;
|
||||
memset(blk, 0, sizeof(blk));
|
||||
fn_blk_ctor(blk);
|
||||
fn_hud_notify_script(gsd + g_hud_queue_off, LMP_NUCLEAR_STRIKE_EVENT_NAME, blk);
|
||||
fn_hud_notify_script(gsd + LMP_GSD_OFF_HUD_QUEUE, LMP_NUCLEAR_STRIKE_EVENT_NAME, blk);
|
||||
fn_blk_dtor(blk);
|
||||
}
|
||||
|
||||
static void *call_target(uint8_t *score_msg, size_t call_off)
|
||||
int install_local_mp_award_hooks(void)
|
||||
{
|
||||
return local_mp_resolve_rip(score_msg + call_off, 1, 5);
|
||||
}
|
||||
|
||||
int install_local_mp_award_hooks(const uint8_t *text, size_t text_size, uint8_t *p_ground_dead)
|
||||
{
|
||||
uint8_t *p_score_msg = local_mp_scan_unique(text, text_size, "GameSaveData::addScoreMessage", LMP_SIG_HUD_ADD_SCORE_MSG);
|
||||
static const size_t call_offs[] = {
|
||||
LMP_SCORE_MSG_CALL_BLK_CTOR, LMP_SCORE_MSG_CALL_BLK_SET_STR, LMP_SCORE_MSG_CALL_BLK_TO_OWNED,
|
||||
LMP_SCORE_MSG_CALL_BLK_SET_INT, LMP_SCORE_MSG_CALL_HUD_NOTIFY, LMP_SCORE_MSG_CALL_BLK_DTOR,
|
||||
};
|
||||
size_t i;
|
||||
|
||||
if (!p_ground_dead || !p_score_msg)
|
||||
return 0;
|
||||
if (p_ground_dead[0xa19] != 0x48 || p_ground_dead[0xa1a] != 0x8b || p_ground_dead[0xa1b] != 0x0d)
|
||||
return 0;
|
||||
for (i = 0; i < sizeof(call_offs) / sizeof(call_offs[0]); i++) {
|
||||
if (p_score_msg[call_offs[i]] != 0xe8)
|
||||
return 0;
|
||||
}
|
||||
if (p_score_msg[LMP_SCORE_MSG_ADD_HUD_QUEUE] != 0x48 ||
|
||||
p_score_msg[LMP_SCORE_MSG_ADD_HUD_QUEUE + 1] != 0x81 ||
|
||||
p_score_msg[LMP_SCORE_MSG_ADD_HUD_QUEUE + 2] != 0xc1)
|
||||
return 0;
|
||||
|
||||
g_game_save_data = (uint8_t **)local_mp_resolve_rip(p_ground_dead + 0xa19, 3, 7);
|
||||
memcpy(&g_hud_queue_off, p_score_msg + LMP_SCORE_MSG_ADD_HUD_QUEUE + 3, sizeof(g_hud_queue_off));
|
||||
fn_blk_ctor = (BlkCtorFn)call_target(p_score_msg, LMP_SCORE_MSG_CALL_BLK_CTOR);
|
||||
fn_blk_set_str = (BlkSetStrFn)call_target(p_score_msg, LMP_SCORE_MSG_CALL_BLK_SET_STR);
|
||||
fn_blk_to_owned = (BlkToOwnedFn)call_target(p_score_msg, LMP_SCORE_MSG_CALL_BLK_TO_OWNED);
|
||||
fn_blk_set_int = (BlkSetIntFn)call_target(p_score_msg, LMP_SCORE_MSG_CALL_BLK_SET_INT);
|
||||
fn_hud_notify_script = (HudNotifyScriptFn)call_target(p_score_msg, LMP_SCORE_MSG_CALL_HUD_NOTIFY);
|
||||
fn_blk_dtor = (BlkDtorFn)call_target(p_score_msg, LMP_SCORE_MSG_CALL_BLK_DTOR);
|
||||
g_game_save_data = (uint8_t **)g_lmp.game_save_data;
|
||||
fn_blk_ctor = (BlkCtorFn)g_lmp.blk_ctor;
|
||||
fn_blk_set_str = (BlkSetStrFn)g_lmp.blk_set_str;
|
||||
fn_blk_to_owned = (BlkToOwnedFn)g_lmp.blk_to_owned;
|
||||
fn_blk_set_int = (BlkSetIntFn)g_lmp.blk_set_int;
|
||||
fn_hud_notify_script = (HudNotifyScriptFn)g_lmp.hud_notify_script;
|
||||
fn_blk_dtor = (BlkDtorFn)g_lmp.blk_dtor;
|
||||
return 1;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Core signature scanner, RIP-relative address resolver, Dagor allocator helpers,
|
||||
* and engine global discovery for the LocalMP in-process host bridge.
|
||||
* Engine globals, Dagor allocator helpers and module installation of the LocalMP in-process host
|
||||
* bridge. Addresses and offsets come from wto_ws.cfg (local_mp_values.c).
|
||||
*/
|
||||
#include "hooks.h"
|
||||
#include "hook_config.h"
|
||||
@@ -28,76 +28,6 @@ LmpGetUnitByEidFn g_lmp_get_unit_by_eid;
|
||||
LmpSetOwningMPlayerFn g_lmp_set_owning_mplayer;
|
||||
LmpDataBlockGetStrFn g_lmp_datablock_get_str;
|
||||
|
||||
static int hex_nibble(char c)
|
||||
{
|
||||
if (c >= '0' && c <= '9') return c - '0';
|
||||
if (c >= 'a' && c <= 'f') return c - 'a' + 10;
|
||||
if (c >= 'A' && c <= 'F') return c - 'A' + 10;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static size_t parse_pattern(const char *spec, uint8_t *bytes, uint8_t *mask, size_t cap)
|
||||
{
|
||||
size_t n = 0;
|
||||
const char *p = spec;
|
||||
while (*p != '\0') {
|
||||
while (*p == ' ') p++;
|
||||
if (*p == '\0') break;
|
||||
if (n >= cap) return 0;
|
||||
if (p[0] == '?' && p[1] == '?') {
|
||||
bytes[n] = 0;
|
||||
mask[n] = 0;
|
||||
p += 2;
|
||||
} else {
|
||||
int hi = hex_nibble(p[0]);
|
||||
int lo = hex_nibble(p[1]);
|
||||
if (hi < 0 || lo < 0) return 0;
|
||||
bytes[n] = (uint8_t)((hi << 4) | lo);
|
||||
mask[n] = 1;
|
||||
p += 2;
|
||||
}
|
||||
n++;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
uint8_t *local_mp_scan_unique(const uint8_t *base, size_t size, const char *name, const char *spec)
|
||||
{
|
||||
uint8_t pat[192];
|
||||
uint8_t mask[192];
|
||||
size_t len = parse_pattern(spec, pat, mask, sizeof(pat));
|
||||
uint8_t *hit = NULL;
|
||||
size_t i, j;
|
||||
|
||||
if (len == 0 || size < len) {
|
||||
log_line("local_mp: invalid pattern for %s", name);
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0; i <= size - len; i++) {
|
||||
for (j = 0; j < len; j++) {
|
||||
if (mask[j] && base[i + j] != pat[j])
|
||||
break;
|
||||
}
|
||||
if (j == len) {
|
||||
if (hit != NULL) {
|
||||
log_line("local_mp: ambiguous signature for %s", name);
|
||||
return NULL;
|
||||
}
|
||||
hit = (uint8_t *)(base + i);
|
||||
}
|
||||
}
|
||||
if (hit == NULL)
|
||||
log_line("local_mp: signature not found for %s", name);
|
||||
return hit;
|
||||
}
|
||||
|
||||
void *local_mp_resolve_rip(const uint8_t *insn, size_t disp_off, size_t insn_len)
|
||||
{
|
||||
int32_t disp = 0;
|
||||
memcpy(&disp, insn + disp_off, sizeof(disp));
|
||||
return (void *)(insn + insn_len + (intptr_t)disp);
|
||||
}
|
||||
|
||||
int local_mp_is_host(void)
|
||||
{
|
||||
uint8_t *mp = g_local_mp_multiplayer ? *g_local_mp_multiplayer : NULL;
|
||||
@@ -194,100 +124,64 @@ const char *local_mp_unit_name(const uint8_t *unit)
|
||||
return (name != NULL && name[0] != '\0') ? name : NULL;
|
||||
}
|
||||
|
||||
static int find_exe_text_section(const uint8_t **out_base, size_t *out_size)
|
||||
{
|
||||
const uint8_t *mod = (const uint8_t *)GetModuleHandleW(NULL);
|
||||
const IMAGE_DOS_HEADER *dos;
|
||||
const IMAGE_NT_HEADERS64 *nt;
|
||||
const IMAGE_SECTION_HEADER *sec;
|
||||
WORD i;
|
||||
/* Module installers in dependency order: a module only calls into the ones before it. */
|
||||
typedef struct LocalMpModule {
|
||||
const char *name;
|
||||
int (*install)(void);
|
||||
} LocalMpModule;
|
||||
|
||||
if (mod == NULL) return 0;
|
||||
dos = (const IMAGE_DOS_HEADER *)mod;
|
||||
if (dos->e_magic != IMAGE_DOS_SIGNATURE) return 0;
|
||||
nt = (const IMAGE_NT_HEADERS64 *)(mod + dos->e_lfanew);
|
||||
if (nt->Signature != IMAGE_NT_SIGNATURE) return 0;
|
||||
sec = IMAGE_FIRST_SECTION(nt);
|
||||
for (i = 0; i < nt->FileHeader.NumberOfSections; i++, sec++) {
|
||||
if (memcmp(sec->Name, ".text\0\0\0", 8) == 0) {
|
||||
*out_base = mod + sec->VirtualAddress;
|
||||
*out_size = sec->Misc.VirtualSize;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
static const LocalMpModule MODULES[] = {
|
||||
{ "local_mp_players", install_local_mp_player_hooks },
|
||||
{ "local_mp_loadout", install_local_mp_loadout_hooks },
|
||||
{ "local_mp_actions", install_local_mp_action_hooks },
|
||||
{ "local_mp_awards", install_local_mp_award_hooks },
|
||||
{ "local_mp_scores", install_local_mp_score_reader },
|
||||
{ "local_mp_kills", install_local_mp_kill_hooks },
|
||||
{ "local_mp_events", install_local_mp_event_hooks },
|
||||
{ "local_mp_nuke", install_local_mp_nuke_hooks },
|
||||
{ "local_mp_support", install_local_mp_support_hooks },
|
||||
};
|
||||
|
||||
static int verify_core_rip_opcodes(
|
||||
const uint8_t *p_refl_dtor,
|
||||
const uint8_t *p_sq_country,
|
||||
const uint8_t *p_get_country
|
||||
)
|
||||
static void use_core_values(void)
|
||||
{
|
||||
return p_refl_dtor[0x8b] == 0x48 && p_refl_dtor[0x8c] == 0x8b && p_refl_dtor[0x8d] == 0x0d &&
|
||||
p_sq_country[0x1c] == 0x48 && p_sq_country[0x1d] == 0x8d && p_sq_country[0x1e] == 0x0d &&
|
||||
p_get_country[0x2e] == 0x44 && p_get_country[0x2f] == 0x3b && p_get_country[0x30] == 0x15 &&
|
||||
p_get_country[0x37] == 0x4c && p_get_country[0x38] == 0x8b && p_get_country[0x39] == 0x1d;
|
||||
g_local_mp_multiplayer = (uint8_t **)g_lmp.multiplayer;
|
||||
g_local_mp_app = (uint8_t **)g_lmp.app;
|
||||
g_local_mp_mplayer = (uint8_t **)g_lmp.local_mplayer;
|
||||
g_local_mp_hero = (uint8_t **)g_lmp.hero;
|
||||
g_local_mp_mission_settings = g_lmp.mission_settings;
|
||||
g_local_mp_stdmem = (void ***)g_lmp.stdmem;
|
||||
g_local_mp_player_count = (uint32_t *)g_lmp.player_count;
|
||||
g_local_mp_player_table = (uint8_t ***)g_lmp.player_table;
|
||||
|
||||
g_lmp_get_player_country = (LmpGetPlayerCountryFn)g_lmp.get_player_country;
|
||||
g_lmp_set_player_gui_state = (LmpSetPlayerGuiStateFn)g_lmp.set_player_gui_state;
|
||||
g_lmp_aircraft_change_result = (LmpAircraftChangeResultFn)g_lmp.aircraft_change_result;
|
||||
g_lmp_get_unit_by_eid = (LmpGetUnitByEidFn)g_lmp.get_unit_by_eid;
|
||||
g_lmp_set_owning_mplayer = (LmpSetOwningMPlayerFn)g_lmp.set_owning_mplayer;
|
||||
g_lmp_datablock_get_str = (LmpDataBlockGetStrFn)g_lmp.datablock_get_str;
|
||||
}
|
||||
|
||||
void install_local_mp_hooks(void)
|
||||
{
|
||||
const uint8_t *text = NULL;
|
||||
size_t text_size = 0;
|
||||
uint8_t *p_disabled_mask, *p_do_respawn, *p_get_country, *p_sq_country, *p_blk_str;
|
||||
uint8_t *p_refl_dtor, *p_change_res, *p_set_gui, *p_unit_eid, *p_set_owner, *p_ground_dead;
|
||||
size_t i;
|
||||
unsigned installed = 0;
|
||||
|
||||
if (!find_exe_text_section(&text, &text_size)) {
|
||||
log_line("local_mp: executable .text section not found, skipping");
|
||||
if (!config_native_matches_executable()) {
|
||||
log_line("local_mp: wto_ws.cfg was built for another aces.exe, LocalMP bridge disabled");
|
||||
return;
|
||||
}
|
||||
|
||||
p_disabled_mask = local_mp_scan_unique(text, text_size, "getDisabledSlotsMask", LMP_SIG_DISABLED_SLOTS_MASK);
|
||||
p_do_respawn = local_mp_scan_unique(text, text_size, "doRespawnPlayer", LMP_SIG_DO_RESPAWN_PLAYER);
|
||||
p_get_country = local_mp_scan_unique(text, text_size, "MissionSettings::getPlayerCountry", LMP_SIG_GET_PLAYER_COUNTRY);
|
||||
p_sq_country = local_mp_scan_unique(text, text_size, "sq_get_local_player_country", LMP_SIG_SQ_LOCAL_COUNTRY);
|
||||
p_refl_dtor = local_mp_scan_unique(text, text_size, "ChangeUnitReflection::dtor", LMP_SIG_REFL_DTOR);
|
||||
p_change_res = local_mp_scan_unique(text, text_size, "aircraftChangeResultFromHost", LMP_SIG_AIRCRAFT_CHANGE_RESULT);
|
||||
p_set_gui = local_mp_scan_unique(text, text_size, "setPlayerGuiState", LMP_SIG_SET_PLAYER_GUI_STATE);
|
||||
p_unit_eid = local_mp_scan_unique(text, text_size, "getUnitByEid", LMP_SIG_GET_UNIT_BY_EID);
|
||||
p_set_owner = local_mp_scan_unique(text, text_size, "Unit::setOwningMPlayer", LMP_SIG_SET_OWNING_MPLAYER);
|
||||
p_ground_dead = local_mp_scan_unique(text, text_size, "IGroundModel::onBecameDead", LMP_SIG_IGROUND_ON_DEAD);
|
||||
p_blk_str = local_mp_scan_unique(text, text_size, "DataBlock::getStr", LMP_SIG_DATABLOCK_GET_STR);
|
||||
|
||||
if (!p_disabled_mask || !p_do_respawn || !p_get_country || !p_sq_country || !p_refl_dtor ||
|
||||
!p_change_res || !p_set_gui || !p_unit_eid || !p_set_owner || !p_ground_dead || !p_blk_str ||
|
||||
!verify_core_rip_opcodes(p_refl_dtor, p_sq_country, p_get_country)) {
|
||||
log_line("local_mp: core signatures or RIP layout unavailable, LocalMP bridge disabled");
|
||||
if (!lmp_values_load("local_mp_core")) {
|
||||
log_line("local_mp: core values unavailable, LocalMP bridge disabled");
|
||||
return;
|
||||
}
|
||||
|
||||
g_local_mp_multiplayer = (uint8_t **)local_mp_resolve_rip(p_disabled_mask + 0x02, 3, 8);
|
||||
g_local_mp_app = (uint8_t **)local_mp_resolve_rip(p_disabled_mask + 0x0c, 3, 7);
|
||||
g_local_mp_mplayer = (uint8_t **)local_mp_resolve_rip(p_disabled_mask + 0x1f, 3, 7);
|
||||
g_local_mp_hero = (uint8_t **)local_mp_resolve_rip(p_do_respawn + 0x7d, 3, 7);
|
||||
g_local_mp_mission_settings = (uint8_t *)local_mp_resolve_rip(p_sq_country + 0x1c, 3, 7);
|
||||
g_local_mp_stdmem = (void ***)local_mp_resolve_rip(p_refl_dtor + 0x8b, 3, 7);
|
||||
g_local_mp_player_count = (uint32_t *)local_mp_resolve_rip(p_get_country + 0x2e, 3, 7);
|
||||
g_local_mp_player_table = (uint8_t ***)local_mp_resolve_rip(p_get_country + 0x37, 3, 7);
|
||||
|
||||
g_lmp_get_player_country = (LmpGetPlayerCountryFn)p_get_country;
|
||||
g_lmp_set_player_gui_state = (LmpSetPlayerGuiStateFn)p_set_gui;
|
||||
g_lmp_aircraft_change_result = (LmpAircraftChangeResultFn)p_change_res;
|
||||
g_lmp_get_unit_by_eid = (LmpGetUnitByEidFn)p_unit_eid;
|
||||
g_lmp_set_owning_mplayer = (LmpSetOwningMPlayerFn)p_set_owner;
|
||||
g_lmp_datablock_get_str = (LmpDataBlockGetStrFn)p_blk_str;
|
||||
|
||||
if (!install_local_mp_player_hooks(text, text_size, p_do_respawn) ||
|
||||
!install_local_mp_loadout_hooks(text, text_size) ||
|
||||
!install_local_mp_action_hooks(text, text_size) ||
|
||||
!install_local_mp_award_hooks(text, text_size, p_ground_dead) ||
|
||||
!install_local_mp_kill_hooks(text, text_size, p_ground_dead) ||
|
||||
!install_local_mp_event_hooks(text, text_size) ||
|
||||
!install_local_mp_score_reader(text, text_size) ||
|
||||
!install_local_mp_nuke_hooks(text, text_size) ||
|
||||
!install_local_mp_support_hooks(text, text_size)) {
|
||||
log_line("local_mp: one or more LocalMP subsystem hooks failed to initialize");
|
||||
return;
|
||||
use_core_values();
|
||||
for (i = 0; i < sizeof(MODULES) / sizeof(MODULES[0]); i++) {
|
||||
if (!lmp_values_load(MODULES[i].name))
|
||||
continue;
|
||||
if (MODULES[i].install())
|
||||
installed++;
|
||||
else
|
||||
log_line("local_mp: %s failed to install its hooks", MODULES[i].name);
|
||||
}
|
||||
log_line("local_mp: all LocalMP host subsystems installed");
|
||||
log_line("local_mp: %u of %u LocalMP modules installed", installed, (unsigned)(sizeof(MODULES) / sizeof(MODULES[0])));
|
||||
}
|
||||
@@ -224,25 +224,14 @@ static void __fastcall hook_dispatch_naval_damage(int64_t uid, uint8_t *victim,
|
||||
orig_dispatch_naval_damage(uid, victim, offender, award_dmg);
|
||||
}
|
||||
|
||||
int install_local_mp_event_hooks(const uint8_t *text, size_t text_size)
|
||||
int install_local_mp_event_hooks(void)
|
||||
{
|
||||
uint8_t *p_igm_ass = local_mp_scan_unique(text, text_size, "IGroundModel::awardAssists", LMP_SIG_IGROUND_AWARD_ASSISTS);
|
||||
uint8_t *p_assist = local_mp_scan_unique(text, text_size, "dispatchAssist", LMP_SIG_DISPATCH_ASSIST);
|
||||
uint8_t *p_cap_c = local_mp_scan_unique(text, text_size, "caller_captureZone", LMP_SIG_CALLER_CAPTURE_ZONE);
|
||||
uint8_t *p_hit_c = local_mp_scan_unique(text, text_size, "caller_hitCrit", LMP_SIG_CALLER_HIT_CRIT);
|
||||
uint8_t *p_sev_c = local_mp_scan_unique(text, text_size, "caller_severeDmg", LMP_SIG_CALLER_SEVERE_DMG);
|
||||
uint8_t *p_nav_c = local_mp_scan_unique(text, text_size, "caller_navalDmg", LMP_SIG_CALLER_NAVAL_DMG);
|
||||
uint8_t *p_cap, *p_hit, *p_sev, *p_nav;
|
||||
|
||||
if (!p_igm_ass || !p_assist || !p_cap_c || !p_hit_c || !p_sev_c || !p_nav_c)
|
||||
return 0;
|
||||
if (p_cap_c[0x6b] != 0xe8 || p_hit_c[0x59] != 0xe8 || p_sev_c[0x2f] != 0xe8 || p_nav_c[0x67] != 0xe8)
|
||||
return 0;
|
||||
|
||||
p_cap = (uint8_t *)local_mp_resolve_rip(p_cap_c + 0x6b, 1, 5);
|
||||
p_hit = (uint8_t *)local_mp_resolve_rip(p_hit_c + 0x59, 1, 5);
|
||||
p_sev = (uint8_t *)local_mp_resolve_rip(p_sev_c + 0x2f, 1, 5);
|
||||
p_nav = (uint8_t *)local_mp_resolve_rip(p_nav_c + 0x67, 1, 5);
|
||||
uint8_t *p_igm_ass = g_lmp.iground_award_assists;
|
||||
uint8_t *p_assist = g_lmp.dispatch_assist;
|
||||
uint8_t *p_cap = g_lmp.dispatch_capture_zone;
|
||||
uint8_t *p_hit = g_lmp.dispatch_hit_crit;
|
||||
uint8_t *p_sev = g_lmp.dispatch_severe_damage;
|
||||
uint8_t *p_nav = g_lmp.dispatch_naval_damage;
|
||||
|
||||
if (MH_CreateHook(p_igm_ass, (void *)&hook_iground_award_assists, (void **)&orig_iground_award_assists) != MH_OK ||
|
||||
MH_EnableHook(p_igm_ass) != MH_OK ||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
* Shared internal state, resolved engine pointers, and subsystem interfaces
|
||||
* for the LocalMP in-process host bridge.
|
||||
*
|
||||
* All addresses are resolved dynamically from masked .text signatures in
|
||||
* local_mp_offsets.h and every detour is gated on local_mp_is_host().
|
||||
* Addresses and structure offsets come from the build (local_mp_values.h); every detour is gated
|
||||
* on local_mp_is_host().
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
@@ -48,8 +48,6 @@ extern LmpGetUnitByEidFn g_lmp_get_unit_by_eid;
|
||||
extern LmpSetOwningMPlayerFn g_lmp_set_owning_mplayer;
|
||||
extern LmpDataBlockGetStrFn g_lmp_datablock_get_str;
|
||||
|
||||
uint8_t *local_mp_scan_unique(const uint8_t *base, size_t size, const char *name, const char *spec);
|
||||
void *local_mp_resolve_rip(const uint8_t *insn, size_t disp_off, size_t insn_len);
|
||||
int local_mp_is_host(void);
|
||||
int local_mp_is_local_mplayer(const uint8_t *mp);
|
||||
uint8_t *local_mp_econ_state(void);
|
||||
@@ -84,13 +82,13 @@ void local_mp_add_mplayer_score(uint8_t *mp, float delta, uint32_t event_id);
|
||||
void local_mp_mark_mplayer_dirty(uint8_t *mp);
|
||||
void local_mp_inc_mplayer_stat(uint8_t *mp, size_t off);
|
||||
|
||||
/* Subsystem hook installers invoked once from install_local_mp_hooks(). */
|
||||
int install_local_mp_player_hooks(const uint8_t *text, size_t text_size, uint8_t *p_do_respawn);
|
||||
int install_local_mp_loadout_hooks(const uint8_t *text, size_t text_size);
|
||||
int install_local_mp_action_hooks(const uint8_t *text, size_t text_size);
|
||||
int install_local_mp_award_hooks(const uint8_t *text, size_t text_size, uint8_t *p_ground_dead);
|
||||
int install_local_mp_kill_hooks(const uint8_t *text, size_t text_size, uint8_t *p_ground_dead);
|
||||
int install_local_mp_event_hooks(const uint8_t *text, size_t text_size);
|
||||
int install_local_mp_score_reader(const uint8_t *text, size_t text_size);
|
||||
int install_local_mp_nuke_hooks(const uint8_t *text, size_t text_size);
|
||||
int install_local_mp_support_hooks(const uint8_t *text, size_t text_size);
|
||||
/* Module hook installers, called by install_local_mp_hooks() once the module's values are loaded. */
|
||||
int install_local_mp_player_hooks(void);
|
||||
int install_local_mp_loadout_hooks(void);
|
||||
int install_local_mp_action_hooks(void);
|
||||
int install_local_mp_award_hooks(void);
|
||||
int install_local_mp_kill_hooks(void);
|
||||
int install_local_mp_event_hooks(void);
|
||||
int install_local_mp_score_reader(void);
|
||||
int install_local_mp_nuke_hooks(void);
|
||||
int install_local_mp_support_hooks(void);
|
||||
@@ -190,17 +190,13 @@ static void __fastcall hook_on_unit_dead_once(uint8_t *victim)
|
||||
orig_on_unit_dead_once(victim);
|
||||
}
|
||||
|
||||
int install_local_mp_kill_hooks(const uint8_t *text, size_t text_size, uint8_t *p_ground_dead)
|
||||
int install_local_mp_kill_hooks(void)
|
||||
{
|
||||
uint8_t *p_add = local_mp_scan_unique(text, text_size, "MPlayer::addScore", LMP_SIG_MPLAYER_ADD_SCORE);
|
||||
uint8_t *p_dirty = local_mp_scan_unique(text, text_size, "net_mark_dirty", LMP_SIG_NET_MARK_DIRTY);
|
||||
uint8_t *p_dead = local_mp_scan_unique(text, text_size, "onUnitDeadOnce", LMP_SIG_ON_UNIT_DEAD_ONCE);
|
||||
uint8_t *p_ground_dead = g_lmp.iground_on_dead;
|
||||
uint8_t *p_dead = g_lmp.on_unit_dead_once;
|
||||
|
||||
if (!p_ground_dead || !p_add || !p_dirty || !p_dead)
|
||||
return 0;
|
||||
|
||||
fn_mplayer_add_score = (MPlayerAddScoreFn)p_add;
|
||||
fn_net_mark_dirty = (NetMarkDirtyFn)p_dirty;
|
||||
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 ||
|
||||
|
||||
@@ -200,36 +200,27 @@ static void __fastcall hook_sem_change_aircraft_send(
|
||||
unit_name ? unit_name : "", weapon_name ? weapon_name : "", (int)req_slot_id, is_silent);
|
||||
}
|
||||
|
||||
int install_local_mp_loadout_hooks(const uint8_t *text, size_t text_size)
|
||||
int install_local_mp_loadout_hooks(void)
|
||||
{
|
||||
uint8_t *p_sem_send = local_mp_scan_unique(text, text_size, "SemChangeAircraftRequest::send", LMP_SIG_SEM_CHANGE_AIRCRAFT_SEND);
|
||||
uint8_t *p_refl_ctor = local_mp_scan_unique(text, text_size, "ChangeUnitReflection::ctor", LMP_SIG_REFL_CTOR);
|
||||
uint8_t *p_refl_dtor = local_mp_scan_unique(text, text_size, "ChangeUnitReflection::dtor", LMP_SIG_REFL_DTOR);
|
||||
uint8_t *p_change_air = local_mp_scan_unique(text, text_size, "Unit::changeAircraft", LMP_SIG_UNIT_CHANGE_AIRCRAFT);
|
||||
uint8_t *p_blk_set = local_mp_scan_unique(text, text_size, "DataBlock::setFrom", LMP_SIG_DATABLOCK_SET_FROM);
|
||||
uint8_t *p_blk_dtor = local_mp_scan_unique(text, text_size, "DataBlock::~DataBlock", LMP_SIG_DATABLOCK_DTOR);
|
||||
uint8_t *p_bullets = local_mp_scan_unique(text, text_size, "BulletSetVec::assign", LMP_SIG_BULLET_VEC_ASSIGN);
|
||||
uint8_t *p_decals = local_mp_scan_unique(text, text_size, "GameSaveData::getDecalsBlk", LMP_SIG_GET_DECALS_BLK);
|
||||
uint8_t *p_attach = local_mp_scan_unique(text, text_size, "GameSaveData::getAttachablesBlk", LMP_SIG_GET_ATTACHABLES_BLK);
|
||||
uint8_t *p_hash = local_mp_scan_unique(text, text_size, "str_hash_fnv1", LMP_SIG_STR_HASH_FNV1);
|
||||
uint8_t *p_nm_add = local_mp_scan_unique(text, text_size, "OAHashNameMap::addNameId", LMP_SIG_NAMEMAP_ADD_NAME_ID);
|
||||
uint8_t *p_crew = local_mp_scan_unique(text, text_size, "UnitCrewSkills::initFromSave", LMP_SIG_CREW_SKILLS_INIT);
|
||||
uint8_t *p_sem_send = g_lmp.sem_change_aircraft_send;
|
||||
|
||||
if (!p_sem_send || !p_refl_ctor || !p_refl_dtor || !p_change_air || !p_blk_set || !p_blk_dtor ||
|
||||
!p_bullets || !p_decals || !p_attach || !p_hash || !p_nm_add || !p_crew)
|
||||
/* 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) {
|
||||
log_line("local_mp: ChangeUnitReflection members reach +0x%zx, past the 0x%x-byte buffer",
|
||||
LMP_REFL_OFF_BULLETS_VEC + 0x20u, LMP_REFL_SIZE);
|
||||
return 0;
|
||||
|
||||
fn_refl_ctor = (ReflCtorFn)p_refl_ctor;
|
||||
fn_refl_dtor = (ReflDtorFn)p_refl_dtor;
|
||||
fn_unit_change_aircraft = (UnitChangeAircraftFn)p_change_air;
|
||||
fn_datablock_set_from = (DataBlockSetFromFn)p_blk_set;
|
||||
fn_datablock_dtor = (DataBlockDtorFn)p_blk_dtor;
|
||||
fn_bullet_vec_assign = (BulletSetVecAssignFn)p_bullets;
|
||||
fn_get_decals_blk = (GetDecalsBlkFn)p_decals;
|
||||
fn_get_attachables_blk = (GetAttachablesBlkFn)p_attach;
|
||||
fn_str_hash = (StrHashFnv1Fn)p_hash;
|
||||
fn_namemap_add = (NameMapAddNameIdFn)p_nm_add;
|
||||
fn_crew_skills_init = (CrewSkillsInitFn)p_crew;
|
||||
}
|
||||
fn_refl_ctor = (ReflCtorFn)g_lmp.refl_ctor;
|
||||
fn_refl_dtor = (ReflDtorFn)g_lmp.refl_dtor;
|
||||
fn_unit_change_aircraft = (UnitChangeAircraftFn)g_lmp.unit_change_aircraft;
|
||||
fn_datablock_set_from = (DataBlockSetFromFn)g_lmp.datablock_set_from;
|
||||
fn_datablock_dtor = (DataBlockDtorFn)g_lmp.datablock_dtor;
|
||||
fn_bullet_vec_assign = (BulletSetVecAssignFn)g_lmp.bullet_vec_assign;
|
||||
fn_get_decals_blk = (GetDecalsBlkFn)g_lmp.get_decals_blk;
|
||||
fn_get_attachables_blk = (GetAttachablesBlkFn)g_lmp.get_attachables_blk;
|
||||
fn_str_hash = (StrHashFnv1Fn)g_lmp.str_hash_fnv1;
|
||||
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) {
|
||||
|
||||
@@ -61,7 +61,7 @@ static void __fastcall hook_shell_launch(void **launch, void *a2, uint8_t *owner
|
||||
orig_shell_launch(launch, a2, owner, a4, a5, a6);
|
||||
if (launch == NULL || !local_mp_is_host())
|
||||
return;
|
||||
record = (const uint8_t *)launch[LMP_SHELL_LAUNCH_IDX_RECORD];
|
||||
record = *(const uint8_t *const *)((const uint8_t *)launch + LMP_SHELL_LAUNCH_OFF_RECORD);
|
||||
if (record == NULL || record[LMP_SHELL_REC_OFF_INSTANT_WIN] != 1)
|
||||
return;
|
||||
mp = owner_mplayer(owner);
|
||||
@@ -127,14 +127,11 @@ static uint64_t __fastcall hook_cta_logic(uint8_t *ctx, void *a2, void *a3, void
|
||||
return orig_cta_logic(ctx, a2, a3, a4);
|
||||
}
|
||||
|
||||
int install_local_mp_nuke_hooks(const uint8_t *text, size_t text_size)
|
||||
int install_local_mp_nuke_hooks(void)
|
||||
{
|
||||
uint8_t *p_launch = local_mp_scan_unique(text, text_size, "shell launch (instant-win flag)", LMP_SIG_SHELL_LAUNCH);
|
||||
uint8_t *p_explode = local_mp_scan_unique(text, text_size, "shell explosion", LMP_SIG_SHELL_EXPLODE);
|
||||
uint8_t *p_cta = local_mp_scan_unique(text, text_size, "cta_logic_action", LMP_SIG_CTA_LOGIC_ACTION);
|
||||
|
||||
if (!p_launch || !p_explode || !p_cta)
|
||||
return 0;
|
||||
uint8_t *p_launch = g_lmp.shell_launch;
|
||||
uint8_t *p_explode = g_lmp.shell_explode;
|
||||
uint8_t *p_cta = g_lmp.cta_logic_action;
|
||||
if (MH_CreateHook(p_launch, (void *)&hook_shell_launch, (void **)&orig_shell_launch) != MH_OK ||
|
||||
MH_CreateHook(p_explode, (void *)&hook_shell_explode, (void **)&orig_shell_explode) != MH_OK ||
|
||||
MH_CreateHook(p_cta, (void *)&hook_cta_logic, (void **)&orig_cta_logic) != MH_OK ||
|
||||
|
||||
@@ -1,20 +1,24 @@
|
||||
/*
|
||||
* Centralized struct offsets, RIP-relative displacements, and .text signatures
|
||||
* for the War Thunder 2.61.0.37 LocalMP in-process host bridge.
|
||||
* Structure offsets of the LocalMP host bridge.
|
||||
*
|
||||
* The game's own structures are what the build captured from the code of the executable at hand
|
||||
* (local_mp_values.h); the names below keep the modules readable. Constants remain only for what
|
||||
* a game build does not decide:
|
||||
* - Dagor engine library layouts (DagorEngine, BSD-3): dag::Vector (data pointer, allocator,
|
||||
* count, capacity) and the 0x20-byte DataBlock object;
|
||||
* - enums of the game protocol (GUI states, EXP_EVENT_* of globalScripts/expEventConsts.nut,
|
||||
* unit types);
|
||||
* - two members of the change request with no reader in the client (respawn base, spare type);
|
||||
* - the size of the ChangeUnitReflection buffer the loadout module builds on its stack.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "local_mp_values.h"
|
||||
|
||||
#define LMP_GUI_STATE_PILOT_CONTROL 2
|
||||
#define LMP_GUI_STATE_CA_SELECT 6
|
||||
#define LMP_GUI_STATE_CA_READY 8
|
||||
|
||||
#define LMP_MISSION_STATUS_RUNNING 1
|
||||
#define LMP_MISSION_STATUS_SUCCESS 2
|
||||
#define LMP_MISSION_STATUS_FAIL 3
|
||||
#define LMP_STATS_RESULT_IN_PROGRESS 0
|
||||
#define LMP_STATS_RESULT_SUCCESS 1
|
||||
#define LMP_STATS_RESULT_FAIL 2
|
||||
|
||||
#define LMP_EXP_EVENT_CAPTURE_ZONE 2u
|
||||
#define LMP_EXP_EVENT_KILL 5u
|
||||
#define LMP_EXP_EVENT_KILL_GROUND 6u
|
||||
@@ -26,283 +30,143 @@
|
||||
#define LMP_EXP_EVENT_KILL_HUMAN 39u
|
||||
#define LMP_EXP_EVENT_COUNT 45u
|
||||
|
||||
/*
|
||||
* @anchor "localMP"
|
||||
* @anchor "get_local_player_country"
|
||||
* @anchor "mpDom1"
|
||||
* @anchor "mpHadAlivePlayers"
|
||||
* @anchor "guiscriptutils::is_crew_slot_was_ready_at_host"
|
||||
* @anchor "customBots"
|
||||
* @anchor "botDeviationLimits"
|
||||
* @anchor "Reflection: invalid object 0x%p"
|
||||
*/
|
||||
#define LMP_MP_MGR_OFF_IS_HOST 0x0060u
|
||||
#define LMP_MP_MGR_OFF_IS_LOCAL_MP 0x0061u
|
||||
#define LMP_MP_MGR_OFF_TEAM1_COUNTRIES 0x0150u
|
||||
#define LMP_MP_MGR_OFF_TEAM2_COUNTRIES 0x0170u
|
||||
#define LMP_MP_MGR_OFF_MP_CHAT 0x01f0u
|
||||
#define LMP_MP_MGR_OFF_CHAT_HOST 0x01f8u
|
||||
#define LMP_TAB_OFF_DATA 0x0000u
|
||||
#define LMP_TAB_OFF_ALLOC 0x0008u
|
||||
#define LMP_TAB_OFF_COUNT 0x0010u
|
||||
#define LMP_TAB_OFF_CAPACITY 0x0014u
|
||||
#define LMP_APP_OFF_SCORE_RULES 0x03e0u
|
||||
#define LMP_SCORE_RULES_OFF_MSTATUS 0x00f0u
|
||||
#define LMP_APP_OFF_ECON_HOLDER 0x03f0u
|
||||
#define LMP_ECON_HOLDER_OFF_STATE 0x09a8u
|
||||
#define LMP_MIS_OFF_AXIS_COUNTRY 0x00c8u
|
||||
#define LMP_MIS_OFF_ALLIES_COUNTRY 0x00d0u
|
||||
#define LMP_MIS_OFF_ARCADE_COUNTRY 0x01d0u
|
||||
#define LMP_MIS_OFF_CUSTOM_BOTS 0x0718u
|
||||
/* MissionSettings copy of the mission block customScoreParams (2.61.0.37 loader 0x12657a0 copies it at
|
||||
* 0x126d762); the client never reads it, local_mp_scores.c reads the local server's score table there. */
|
||||
#define LMP_MIS_OFF_CUSTOM_SCORE_PARAMS 0x06d8u
|
||||
#define LMP_MATCH_INFO_OFF_TEAM 0x0004u
|
||||
|
||||
/*
|
||||
* @anchor "set_aircraft_accepted_cb"
|
||||
*/
|
||||
#define LMP_ECON_OFF_CHANGE_REQ 0xf578u
|
||||
#define LMP_REQ_OFF_BULLETS_BEGIN 0x0090u
|
||||
#define LMP_REQ_OFF_BULLETS_END 0x0098u
|
||||
#define LMP_REQ_OFF_RESP_BASE_ID 0x00b8u
|
||||
#define LMP_REQ_OFF_SPARE_TYPE 0x00c0u
|
||||
#define LMP_REQ_OFF_SLOT_ID 0x00e4u
|
||||
|
||||
/*
|
||||
* @anchor "get_mplayers_list"
|
||||
* @anchor "kills"
|
||||
* @anchor "teamKills"
|
||||
* @anchor "deaths"
|
||||
* @anchor "groundKills"
|
||||
* @anchor "humanKills"
|
||||
* @anchor "navalKills"
|
||||
* @anchor "aiKills"
|
||||
* @anchor "aiGroundKills"
|
||||
* @anchor "aiNavalKills"
|
||||
* @anchor "assists"
|
||||
* @anchor "captureZone"
|
||||
* @anchor "awardDamage"
|
||||
* @anchor "airSevereDamage"
|
||||
* @anchor "shipSevereDamage"
|
||||
*/
|
||||
#define LMP_MP_OFF_PID 0x0008u
|
||||
#define LMP_MP_OFF_USER_ID 0x00b8u
|
||||
#define LMP_MP_OFF_FLAGS 0x01d8u
|
||||
#define LMP_MP_OFF_TEAM 0x0228u
|
||||
#define LMP_MP_OFF_FALLBACK_SCORE 0x02d8u
|
||||
#define LMP_MP_OFF_BROKEN_SLOTS_MASK 0x04d0u
|
||||
#define LMP_MP_OFF_USED_SPARES_MASK 0x0520u
|
||||
#define LMP_MP_OFF_GUI_STATE 0x0640u
|
||||
#define LMP_MP_OFF_UNIT_EID 0x0850u
|
||||
#define LMP_MP_OFF_SCORE 0x08f8u
|
||||
#define LMP_MP_OFF_KILLS 0x09d8u
|
||||
#define LMP_MP_OFF_TEAM_KILLS 0x09dau
|
||||
#define LMP_MP_OFF_DEATHS 0x09dcu
|
||||
#define LMP_MP_OFF_GROUND_KILLS 0x09deu
|
||||
#define LMP_MP_OFF_HUMAN_KILLS 0x09e0u
|
||||
#define LMP_MP_OFF_NAVAL_KILLS 0x09e2u
|
||||
#define LMP_MP_OFF_AI_KILLS 0x09e4u
|
||||
#define LMP_MP_OFF_AI_GROUND_KILLS 0x09e6u
|
||||
#define LMP_MP_OFF_AI_NAVAL_KILLS 0x09e8u
|
||||
#define LMP_MP_OFF_ASSISTS 0x09ecu
|
||||
#define LMP_MP_OFF_CAPTURE_ZONE 0x09eeu
|
||||
#define LMP_MP_OFF_AWARD_DAMAGE 0x0a00u
|
||||
#define LMP_MP_OFF_AIR_SEVERE_DMG 0x0a06u
|
||||
#define LMP_MP_OFF_SHIP_SEVERE_DMG 0x0a08u
|
||||
#define LMP_MP_OFF_STAT_DIRTY 0x0a10u
|
||||
#define LMP_MP_OFF_STAT_PAYLOAD 0x0a30u
|
||||
/* missionSupportUnitRef: cached unit pointer and entity id (set 0x59da3c..0x59da47, ctor 0x5ad57b). */
|
||||
#define LMP_MP_OFF_SUPPORT_UNIT_PTR 0x0b50u
|
||||
#define LMP_MP_OFF_SUPPORT_UNIT_EID 0x0b58u
|
||||
#define LMP_MP_OFF_RESP_BASE_ID 0x0bd8u
|
||||
#define LMP_MP_OFF_SPAWN_DELAY_A 0x0bf4u
|
||||
#define LMP_MP_OFF_SPAWN_DELAY_B 0x0bf8u
|
||||
#define LMP_MP_OFF_SPAWN_POS_X 0x0bfcu
|
||||
#define LMP_MP_OFF_SPAWN_POS_Y 0x0c00u
|
||||
#define LMP_MP_OFF_SPAWN_POS_Z 0x0c04u
|
||||
|
||||
/*
|
||||
* @anchor "unit__playerId"
|
||||
* @anchor "setMyPlayer uid:%i eid:%08x ptr:%p pid:%d (saved pid:%d)"
|
||||
* @anchor "IGroundModel__onBecameDead"
|
||||
*/
|
||||
#define LMP_UNIT_OFF_TYPE 0x008cu
|
||||
#define LMP_UNIT_OFF_SEVERE_IDX 0x06b0u
|
||||
#define LMP_UNIT_OFF_SEVERE_PID 0x06d0u
|
||||
#define LMP_UNIT_OFF_SEVERE_UID 0x0708u
|
||||
#define LMP_UNIT_OFF_MPLAYER 0x0f98u
|
||||
/* Unit type at +0x8c (the stock scoreboard counters split kills by it, see local_mp_kills.c). */
|
||||
/* Unit type at LMP_UNIT_OFF_TYPE (the stock scoreboard counters split kills by it). */
|
||||
#define LMP_UNIT_TYPE_AIRCRAFT 0x0000u
|
||||
#define LMP_UNIT_TYPE_SHIP 0x0005u
|
||||
#define LMP_UNIT_TYPE_HELICOPTER 0x000du
|
||||
#define LMP_UNIT_TYPE_HUMAN 0x000eu
|
||||
#define LMP_UNIT_OFF_ARMY 0x1010u
|
||||
#define LMP_UNIT_OFF_PID 0x1018u
|
||||
#define LMP_UNIT_OFF_INFO 0x1020u
|
||||
#define LMP_UNIT_INFO_OFF_NAME 0x0010u
|
||||
/* Unit info expClass string; addScoreMessage reads it for the "expClass" field (2.61.0.37 0x189bb20). */
|
||||
#define LMP_UNIT_INFO_OFF_EXP_CLASS 0x0038u
|
||||
#define LMP_UNIT_OFF_CREW_SKILLS 0x10a8u
|
||||
#define LMP_UNIT_VTF_CHOOSE_OFFENDER 0x0498u
|
||||
#define LMP_UNIT_OFF_SKIP_KILL 0x3058u
|
||||
#define LMP_IGM_OFF_OFFENDERS_PTR 0x17c0u
|
||||
#define LMP_IGM_OFF_OFFENDERS_CNT 0x17d0u
|
||||
#define LMP_IGM_OFF_KILLER_PID 0x1a08u
|
||||
#define LMP_IGM_OFF_KILLER_ARMY 0x1a04u
|
||||
#define LMP_IGM_OFF_KILLER_UID 0x1a40u
|
||||
#define LMP_IGM_OFF_DEAD_SILENT 0x1c19u
|
||||
#define LMP_IGM_OFF_ALREADY_DEAD 0x2101u
|
||||
#define LMP_IGM_OFF_BAILOUT_DEAD 0x3888u
|
||||
#define LMP_OFFENDER_STRIDE 0x0160u
|
||||
#define LMP_OFFENDER_OFF_ARMY 0x001cu
|
||||
#define LMP_OFFENDER_OFF_PID 0x0020u
|
||||
#define LMP_OFFENDER_OFF_UID 0x0058u
|
||||
#define LMP_OFFENDER_OFF_ASSIST_SENT 0x0148u
|
||||
|
||||
/*
|
||||
* @anchor "defaultDecals"
|
||||
* @anchor "slaveAttachables"
|
||||
* @anchor "bulletsWeapon%i"
|
||||
*/
|
||||
#define LMP_REFL_SIZE 0x0200u
|
||||
#define LMP_REFL_OFF_UNIT_NAME 0x0050u
|
||||
#define LMP_REFL_OFF_WEAPON_NAME 0x0058u
|
||||
#define LMP_REFL_OFF_SKIN_NAME 0x0060u
|
||||
#define LMP_REFL_OFF_CUSTOM_SKIN 0x0068u
|
||||
#define LMP_REFL_OFF_DECALS_BLK 0x0070u
|
||||
#define LMP_REFL_OFF_ATTACHABLES_BLK 0x0090u
|
||||
#define LMP_REFL_OFF_CUSTOM_PRESET_BLK 0x00b0u
|
||||
#define LMP_REFL_OFF_FLAGS 0x00d0u
|
||||
#define LMP_REFL_OFF_FUEL 0x00d8u
|
||||
#define LMP_REFL_OFF_GUN_CONVERGENCE 0x00dcu
|
||||
#define LMP_REFL_OFF_VERT_TARGETING 0x00e0u
|
||||
#define LMP_REFL_OFF_BOMB_FUSE 0x00e4u
|
||||
#define LMP_REFL_OFF_ENABLED_MODS 0x00f0u
|
||||
#define LMP_REFL_OFF_DISABLED_MODS 0x0140u
|
||||
#define LMP_REFL_OFF_BULLETS_VEC 0x0190u
|
||||
/* dag::Vector */
|
||||
#define LMP_TAB_OFF_DATA 0x0000u
|
||||
#define LMP_TAB_OFF_ALLOC 0x0008u
|
||||
#define LMP_TAB_OFF_COUNT 0x0010u
|
||||
#define LMP_TAB_OFF_CAPACITY 0x0014u
|
||||
|
||||
/*
|
||||
* GameSaveData::addScoreMessage (2.61.0.37 0x189a8e0, LMP_SIG_HUD_ADD_SCORE_MSG) builds the
|
||||
* "InBattleReward" HUD script event. local_mp_awards.c resolves the DataBlock helpers and the
|
||||
* HUD event queue from these call sites in it instead of scanning each helper separately
|
||||
* (DataBlock::setStr and the queue function have byte-identical twins elsewhere in .text).
|
||||
* +0x10bc call DataBlock::DataBlock (0x3093000)
|
||||
* +0x1154 call DataBlock set string (0x3094950, name, const char *)
|
||||
* +0x116f call DataBlock make-owned (0x30998c0), called while +0x14 != -1
|
||||
* +0x1188 call DataBlock set int (0x3095130, name, const int *)
|
||||
* +0x155b add rcx, imm32 (GameSaveData HUD event queue offset, 0xae8)
|
||||
* +0x1571 call HUD script event queue (0x1804900, queue, event name, const DataBlock *)
|
||||
* +0x15b0 call DataBlock::~DataBlock (0x3093a60)
|
||||
* The DataBlock object is 0x20 bytes (constructor 0x3093000 writes +0x00..+0x1f).
|
||||
*
|
||||
* @anchor "GameSaveData::addScoreMessage - bad messageType received %d"
|
||||
* @anchor "InBattleReward"
|
||||
*/
|
||||
#define LMP_SCORE_MSG_CALL_BLK_CTOR 0x10bcu
|
||||
#define LMP_SCORE_MSG_CALL_BLK_SET_STR 0x1154u
|
||||
#define LMP_SCORE_MSG_CALL_BLK_TO_OWNED 0x116fu
|
||||
#define LMP_SCORE_MSG_CALL_BLK_SET_INT 0x1188u
|
||||
#define LMP_SCORE_MSG_ADD_HUD_QUEUE 0x155bu
|
||||
#define LMP_SCORE_MSG_CALL_HUD_NOTIFY 0x1571u
|
||||
#define LMP_SCORE_MSG_CALL_BLK_DTOR 0x15b0u
|
||||
/* DataBlock object, and the member that is -1 while the block does not own its data. */
|
||||
#define LMP_BLK_SIZE 0x0020u
|
||||
#define LMP_BLK_OFF_OWNED_STATE 0x0014u
|
||||
|
||||
/* @rip_check LMP_SIG_DISABLED_SLOTS_MASK + 0x02 : 48 83 3d */
|
||||
/* @rip_check LMP_SIG_DISABLED_SLOTS_MASK + 0x0c : 48 8b 0d */
|
||||
/* @rip_check LMP_SIG_DISABLED_SLOTS_MASK + 0x1f : 48 8b 0d */
|
||||
/* @rip_check LMP_SIG_DO_RESPAWN_PLAYER + 0x7d : 48 8b 15 */
|
||||
/* @rip_check LMP_SIG_SQ_LOCAL_COUNTRY + 0x1c : 48 8d 0d */
|
||||
/* @rip_check LMP_SIG_REFL_DTOR + 0x8b : 48 8b 0d */
|
||||
/* @rip_check LMP_SIG_GET_PLAYER_COUNTRY + 0x2e : 44 3b 15 */
|
||||
/* @rip_check LMP_SIG_GET_PLAYER_COUNTRY + 0x37 : 4c 8b 1d */
|
||||
/* @rip_check LMP_SIG_IGROUND_ON_DEAD + 0xa19 : 48 8b 0d */
|
||||
/* @rip_check LMP_SIG_DATABLOCK_SET_FROM + 0x25 : e8 */
|
||||
/* @rip_check LMP_SIG_CALLER_CAPTURE_ZONE + 0x6b : e8 */
|
||||
/* @rip_check LMP_SIG_CALLER_HIT_CRIT + 0x59 : e8 */
|
||||
/* @rip_check LMP_SIG_CALLER_SEVERE_DMG + 0x2f : e8 */
|
||||
/* @rip_check LMP_SIG_CALLER_NAVAL_DMG + 0x67 : e8 */
|
||||
/* @rip_check LMP_SIG_HUD_ADD_SCORE_MSG + 0x10bc : e8 */
|
||||
/* @rip_check LMP_SIG_HUD_ADD_SCORE_MSG + 0x1154 : e8 */
|
||||
/* @rip_check LMP_SIG_HUD_ADD_SCORE_MSG + 0x116f : e8 */
|
||||
/* @rip_check LMP_SIG_HUD_ADD_SCORE_MSG + 0x1188 : e8 */
|
||||
/* @rip_check LMP_SIG_HUD_ADD_SCORE_MSG + 0x155b : 48 81 c1 */
|
||||
/* @rip_check LMP_SIG_HUD_ADD_SCORE_MSG + 0x1571 : e8 */
|
||||
/* @rip_check LMP_SIG_HUD_ADD_SCORE_MSG + 0x15b0 : e8 */
|
||||
/* ChangeUnitReflection is built on the stack; the highest member the client touches is +0x1ec on
|
||||
* 2.61.0.37 (Unit::changeAircraft), and the loadout module refuses captures that do not fit. */
|
||||
#define LMP_REFL_SIZE 0x0400u
|
||||
|
||||
#define LMP_SIG_DISABLED_SLOTS_MASK "31 c0 48 83 3d ?? ?? ?? ?? 00 74 ?? 48 8b 0d ?? ?? ?? ?? 0f b6 89 f3 00 00 00 f6 c1 01 74 ?? 48 8b 0d ?? ?? ?? ?? 48 85 c9 74 ?? 8b 81 a0 04 00 00 0b 81 d0 04 00 00 c3"
|
||||
#define LMP_SIG_DO_RESPAWN_PLAYER "56 57 53 48 81 ec 40 01 00 00 44 0f 29 84 24 30 01 00 00 0f 29 bc 24 20 01 00 00 0f 29 b4 24 10 01 00 00 48 8b 91 e0 03 00 00 48 c7 c0 ff ff ff ff 48 85 d2 0f 84 ?? ?? ?? ?? 8b 92 f0 00 00 00 83 fa 01 0f 85 ?? ?? ?? ?? f3 0f 10 81 e4 06 00 00 0f 57 c9 0f 2e c1 0f 83 ?? ?? ?? ?? 4c 8b 05 ?? ?? ?? ?? 40 b6 01 4d 85 c0 0f 84 ?? ?? ?? ?? f6 05 ?? ?? ?? ?? 04 0f 84 ?? ?? ?? ?? 48 8b 15 ?? ?? ?? ?? 48 85 d2 0f 84 ?? ?? ?? ??"
|
||||
#define LMP_SIG_SEM_CHANGE_AIRCRAFT_SEND "41 57 41 56 41 55 41 54 56 57 55 53 48 81 ec f8 01 00 00 44 0f 29 84 24 e0 01 00 00 0f 29 bc 24 d0 01 00 00 0f 29 b4 24 c0 01 00 00 4c 89 cf 4c 89 c3 49 89 d7 48 89 ce 8b 05 ?? ?? ?? ?? 65 48 8b 0c 25 58 00 00 00"
|
||||
#define LMP_SIG_GUI_STATE_UPDATE "56 57 48 83 ec 48 48 89 ce f3 0f 10 41 08 f3 0f 58 c1 f3 0f 11 41 08 f3 0f 10 51 10 0f 57 c0 0f 2e c2 73 ?? f3 0f 5c d1 f3 0f 11 56 10 48 8b 0d ?? ?? ?? ?? b0 01 0f 2e 81 e4 06 00 00 76 ??"
|
||||
#define LMP_SIG_MPLAYER_INIT_MATCHING "41 56 56 57 55 53 48 81 ec e0 00 00 00 48 89 d7 48 89 ce 48 89 91 90 0c 00 00 48 8d 8c 24 88 00 00 00 0f 57 c0 0f 11 84 24 b8 00 00 00 0f 11 84 24 a8 00 00 00 0f 11 84 24 98 00 00 00"
|
||||
#define LMP_SIG_GET_PLAYER_COUNTRY "56 48 83 ec 40 4c 89 c0 4c 8b 05 ?? ?? ?? ?? 4d 85 c0 0f 84 ?? ?? ?? ?? 45 31 d2 41 80 78 61 00 44 0f 44 d2 81 fa fa 00 00 00 44 0f 45 d2 44 3b 15 ?? ?? ?? ?? 73 ?? 4c 8b 1d ?? ?? ?? ??"
|
||||
#define LMP_SIG_SQ_LOCAL_COUNTRY "41 56 56 57 53 48 83 ec 68 48 89 ce 48 8b 05 ?? ?? ?? ?? 48 85 c0 74 ?? 0f b6 50 08 48 8d 0d ?? ?? ?? ?? 4c 8d 44 24 20 41 b9 40 00 00 00 e8 ?? ?? ?? ?? 48 89 c7"
|
||||
#define LMP_SIG_REFL_CTOR "56 48 83 ec 50 0f 29 74 24 40 48 89 ce 66 c7 41 08 ff ff c7 41 0c ff ff ff ff 0f 57 f6 0f 11 71 10 c7 41 20 44 4e 45 54 0f 11 71 28 0f 11 71 38"
|
||||
#define LMP_SIG_REFL_DTOR "56 57 53 48 83 ec 40 48 89 ce 48 8d 05 ?? ?? ?? ?? 48 89 01 48 8b 89 b0 01 00 00 48 85 c9 74 ?? e8 ?? ?? ?? ?? 48 8b be 90 01 00 00 48 8b 9e 98 01 00 00 48 39 df"
|
||||
#define LMP_SIG_UNIT_CHANGE_AIRCRAFT "41 57 41 56 56 57 55 53 48 81 ec 88 00 00 00 48 89 ce 8b 81 90 00 00 00 a8 10 75 ?? 80 be 1a 0f 00 00 00 75 ?? 48 8b 05 ?? ?? ?? ?? 0f b6 80 f3 00 00 00 0f b6 0d ?? ?? ?? ?? 08 c8 a8 01 74 ??"
|
||||
#define LMP_SIG_AIRCRAFT_CHANGE_RESULT "41 57 41 56 56 57 53 48 83 ec 50 41 89 d0 48 89 ce 48 81 c1 78 f5 00 00 48 89 f2 e8 ?? ?? ?? ?? 84 c0 0f 84 ?? ?? ?? ?? 48 8b 9e 78 f5 00 00 48 85 db 48 8d 3d ?? ?? ?? ?? 48 0f 44 df"
|
||||
#define LMP_SIG_DATABLOCK_SET_FROM "41 57 41 56 41 55 41 54 56 57 55 53 48 83 ec 48 48 89 d7 48 89 ce 66 2e 0f 1f 84 00 00 00 00 00 b9 90 00 00 00 e8 ?? ?? ?? ?? 48 85 c0 75 ?? 48 8b 05 ?? ?? ?? ??"
|
||||
#define LMP_SIG_DATABLOCK_DTOR "41 57 41 56 41 54 56 57 53 48 83 ec 38 0f 29 74 24 20 48 8b 41 18"
|
||||
#define LMP_SIG_DATABLOCK_GET_STR "48 83 ec 28 4c 89 44 24 20 4c 8d 44 24 20 e8 ?? ?? ?? ?? 90 48 83 c4 28 c3 cc cc cc cc cc cc cc 41 57"
|
||||
/* float getReal(const DataBlock *, const char *name, float def): 2.61.0.37 wrapper 0x5445270 around
|
||||
* DataBlock::getReal 0x30961a0 (the call MPlayer::addScore 0x59f2d0 uses for spawnScoreMultiplier). */
|
||||
#define LMP_SIG_DATABLOCK_GET_REAL "48 83 ec 28 f3 0f 11 54 24 24 4c 8d 44 24 24 e8 ?? ?? ?? ?? 90 48 83 c4 28 c3 cc cc cc cc cc cc 56 57 53 48 83 ec 30 48 89 d7 48 89 ce 48 8d 15"
|
||||
#define LMP_SIG_MP_CONSTRUCT_LOCAL "56 57 53 48 83 ec 60 48 89 ce 48 81 c1 f8 00 00 00 e8 ?? ?? ?? ?? 66 c7 46 60 01 01"
|
||||
#define LMP_SIG_MP_INIT_CHAT "41 57 41 56 41 54 56 57 53 48 83 ec 48 48 89 d7 48 89 ce 48 8b 05 ?? ?? ?? ?? 48 85 c0 74 ?? c6 00 01 48 8b 9e 00 02 00 00"
|
||||
#define LMP_SIG_IGROUND_AWARD_ASSISTS "41 57 41 56 41 55 41 54 56 57 55 53 48 81 ec a8 01 00 00 44 0f 29 94 24 90 01 00 00 44 0f 29 8c 24 80 01 00 00 44 0f 29 84 24 70 01 00 00 0f 29 bc 24 60 01 00 00 0f 29 b4 24 50 01 00 00 48 89 ce 48 8b 01 48 8d 54 24 28 41 b0 01 ff 90 98 04 00 00"
|
||||
#define LMP_SIG_BULLET_VEC_ASSIGN "41 57 41 56 41 55 41 54 56 57 55 53 48 83 ec 58 4c 89 c5 49 89 d7 48 89 ce 4c 89 c3 48 29 d3 4c 8b 01 48 8b 41 10 4c 29 c0 48 39 c3 0f 86 ?? ?? ?? ?? 48 89 d9"
|
||||
#define LMP_SIG_SET_PLAYER_GUI_STATE "41 57 41 56 41 54 56 57 55 53 48 83 ec 40 89 d6 48 8b 15 ?? ?? ?? ?? 48 85 d2 74 ?? 80 7a 60 00 0f 84 ?? ?? ?? ?? 85 c9 78 ?? 31 c0 80 7a 61 00 0f 44 c1 81 f9 fa 00 00 00 0f 45 c1 eb ?? 89 c8"
|
||||
#define LMP_SIG_GET_UNIT_BY_EID "39 0d ?? ?? ?? ?? 74 2f 89 ca c1 ea 0a 3b 15 ?? ?? ?? ??"
|
||||
#define LMP_SIG_SET_OWNING_MPLAYER "41 57 41 56 41 55 41 54 56 57 55 53 48 81 ec 98 00 00 00 44 89 c3 48 89 d7 48 89 ce 48 85 d2"
|
||||
#define LMP_SIG_GET_DECALS_BLK "41 57 41 56 41 55 41 54 56 57 55 53 48 81 ec 88 00 00 00 44 0f 29 44 24 70 0f 29 7c 24 60 0f 29 74 24 50 4d 89 cf"
|
||||
#define LMP_SIG_GET_ATTACHABLES_BLK "41 57 41 56 41 55 41 54 56 57 55 53 48 83 ec 38 48 89 d7 4d 85 c0"
|
||||
#define LMP_SIG_STR_HASH_FNV1 "41 56 56 57 53 49 89 d0 49 ba db 28 b4 a0 d1 7e 03 e7 48 83 fa 10 77 76"
|
||||
#define LMP_SIG_NAMEMAP_ADD_NAME_ID "41 57 41 56 41 55 41 54 56 57 55 53 48 83 ec 38 44 89 cf 48 89 ce 80 79 4b 00"
|
||||
#define LMP_SIG_CREW_SKILLS_INIT "41 56 56 57 55 53 48 81 ec 90 00 00 00 0f 29 b4 24 80 00 00 00 0f 28 f3"
|
||||
#define LMP_SIG_IGROUND_ON_DEAD "41 57 41 56 41 55 41 54 56 57 55 53 48 81 ec a8 01 00 00 44 0f 29 8c 24 90 01 00 00 44 0f 29 84 24 80 01 00 00 0f 29 bc 24 70 01 00 00 0f 29 b4 24 60 01 00 00 89 d3"
|
||||
#define LMP_SIG_ON_UNIT_DEAD_ONCE "41 57 41 56 41 55 41 54 56 57 55 53 48 81 ec 98 01 00 00 44 0f 29 84 24 80 01 00 00 0f 29 bc 24 70 01 00 00 0f 29 b4 24 60 01 00 00 80 b9 58 30 00 00 00 0f 85 ?? ?? ?? ?? 48 89 ce 48 8d 54 24 38 e8 ?? ?? ?? ?? 66 83 7c 24 38 ff"
|
||||
#define LMP_SIG_MPLAYER_ADD_SCORE "41 57 41 56 56 57 55 53 48 81 ec 88 00 00 00 0f 29 7c 24 70 0f 29 74 24 60 48 89 ce 44 89 c0 f3 0f 2a 84 81 fc 08 00 00 0f 28 f9 f3 0f 58 c1 f3 0f 2c c8 89 8c 86 fc 08 00 00"
|
||||
#define LMP_SIG_NET_MARK_DIRTY "56 57 53 48 83 ec 40 81 7a 20 44 4e 45 54 0f 85 ?? ?? ?? ?? 48 89 ce 0f b7 41 02 a8 02 75 ?? f6 42 48 02 75 ?? a8 01 75 ?? 4c 89 c7 83 c8 01 66 89 46 02"
|
||||
#define LMP_SIG_HUD_ADD_SCORE_MSG "41 57 41 56 41 55 41 54 56 57 55 53 48 81 ec 38 01 00 00 45 89 c5 41 8d 45 fd"
|
||||
#define LMP_SIG_DISPATCH_ASSIST "41 57 41 56 41 55 41 54 56 57 55 53 48 83 ec 78 0f 29 7c 24 60 0f 29 74 24 50 0f 28 f3 4c 89 c6 48 89 d7 48 89 cb 48 8b 05 ?? ?? ?? ?? 48 85 c9 7e ?? 48 85 c0"
|
||||
#define LMP_SIG_CALLER_CAPTURE_ZONE "41 57 41 56 41 55 41 54 56 57 55 53 48 83 ec 38 44 0f b7 72 02 44 8b 7a 04 4c 8b 62 08 4c 8b 6a 18 49 8d 85 88 06 00 00 48 89 44 24 30 49 8d 85 50 06 00 00 48 89 44 24 28 eb ?? 48 8b 90 08 0e 00 00 89 d1 83 e1 01 0b 0d ?? ?? ?? ?? 3b 88 14 0e 00 00 0f 85 ?? ?? ?? ?? 48 83 e2 fe 48 8b 82 98 0f 00 00 48 8b 88 b8 00 00 00 e8 ?? ?? ?? ??"
|
||||
#define LMP_SIG_CALLER_HIT_CRIT "8b 0d ?? ?? ?? ?? f7 c1 00 00 08 00 75 ?? f7 c1 00 00 00 01 75 ?? 0f b6 8f 10 10 00 00 39 4e 1c 74 ?? 41 20 c0 0f b6 86 49 01 00 00 0f 57 db f3 0f 5f 9e 30 01 00 00 48 8b 4e 58 85 ed f3 0f 5d 1d ?? ?? ?? ?? 88 44 24 30 0f 9f 44 24 28 44 88 44 24 20 48 89 fa 49 89 f0 e8 ?? ?? ?? ??"
|
||||
#define LMP_SIG_CALLER_SEVERE_DMG "66 83 be b0 06 00 00 ff 0f 85 ?? ?? ?? ?? 48 89 f1 e8 ?? ?? ?? ?? 84 c0 0f 84 ?? ?? ?? ?? 48 8d 9e b0 06 00 00 48 8b 4f 58 48 89 f2 49 89 f8 e8 ?? ?? ?? ?? 48 89 f1 48 89 fa e8 ?? ?? ?? ?? 0f b6 ae d4 06 00 00"
|
||||
#define LMP_SIG_CALLER_NAVAL_DMG "66 83 b9 90 0f 00 00 01 77 ?? 66 83 ff ff 74 ?? 0f b7 c7 0f 57 d2 f3 0f 2a d0 f3 0f 59 15 ?? ?? ?? ?? eb ?? f3 0f 10 15 ?? ?? ?? ?? 48 8b 94 24 c0 03 00 00 0f b6 7c 24 5b 41 89 f9 e8 ?? ?? ?? ?? 0f 57 c0 0f 2e f0 0f 96 c0 40 08 f8 a8 01 75 ?? 48 8b 96 e8 0a 00 00 4c 8b 84 24 c0 03 00 00 49 8b 48 58 0f 28 de e8 ?? ?? ?? ??"
|
||||
/*
|
||||
* Nuclear instant win (local_mp_nuke.c, 2.61.0.37):
|
||||
* bomb launch 0x1431c10: launch[3] is the launch record, record+0x70 its instant-win flag
|
||||
* (set at 0x143330d / 0x143337d from the bomb property isInstantWinOnExplode);
|
||||
* shell explosion 0xbe7c00: 8th argument = the launch record's instant-win flag (passed from
|
||||
* record+0x70 at 0x2fd778 / 0x2fd7c3);
|
||||
* cta_logic_action 0x11bc400: its context holds the mission variables at +0x40 (data) and
|
||||
* +0x50 (count), 0x20 bytes each, name pointer at +0 and int value at +0x10 (0x11bd164 walks
|
||||
* r15 = entry+8, compares [r15-8] and takes the value at r15+8, 0x11bd1a6).
|
||||
*
|
||||
* @anchor "isInstantWinOnExplode"
|
||||
* @anchor "onBombMiss"
|
||||
* @anchor "cta_logic_action"
|
||||
* @anchor "mpTi1"
|
||||
*/
|
||||
#define LMP_SHELL_LAUNCH_IDX_RECORD 3u
|
||||
#define LMP_SHELL_REC_OFF_INSTANT_WIN 0x0070u
|
||||
#define LMP_MISSION_VARS_OFF_DATA 0x0040u
|
||||
#define LMP_MISSION_VARS_OFF_COUNT 0x0050u
|
||||
#define LMP_MISSION_VAR_STRIDE 0x0020u
|
||||
#define LMP_MISSION_VAR_OFF_NAME 0x0000u
|
||||
#define LMP_MISSION_VAR_OFF_VALUE 0x0010u
|
||||
#define LMP_SIG_SHELL_LAUNCH "41 57 41 56 41 54 56 57 55 53 48 81 ec 30 02 00 00 44 0f 29 bc 24 20 02 00 00"
|
||||
#define LMP_SIG_SHELL_EXPLODE "41 57 41 56 41 55 41 54 56 57 55 53 48 81 ec a8 02 00 00 44 0f 29 bc 24 90 02 00 00 44 0f 29 b4 24 80 02 00 00 44 0f 29 ac 24 70 02 00 00 44 0f 29 a4 24 60 02 00 00 44 0f 29 9c 24 50 02 00 00 44 0f 29 94 24 40 02 00 00 44 0f 29 8c 24 30 02 00 00 44 0f 29 84 24 20 02 00 00 0f 29 bc 24 10 02 00 00 0f 29 b4 24 00 02 00 00 41 89 d3"
|
||||
#define LMP_SIG_CTA_LOGIC_ACTION "41 57 41 56 41 55 41 54 56 57 55 53 48 81 ec a8 02 00 00 44 0f 29 bc 24 90 02 00 00 44 0f 29 b4 24 80 02 00 00 44 0f 29 ac 24 70 02 00 00 44 0f 29 a4 24 60 02 00 00 44 0f 29 9c 24 50 02 00 00 44 0f 29 94 24 40 02 00 00 44 0f 29 8c 24 30 02 00 00 44 0f 29 84 24 20 02 00 00 0f 29 bc 24 10 02 00 00 0f 29 b4 24 00 02 00 00 48 89 cf"
|
||||
/* Change request members the client never addresses at a fixed displacement (the request is filled
|
||||
* and freed member by member through its reflection table), relative to LMP_ECON_OFF_CHANGE_REQ. */
|
||||
#define LMP_REQ_OFF_RESP_BASE_ID 0x00b8u
|
||||
#define LMP_REQ_OFF_SPARE_TYPE 0x00c0u
|
||||
|
||||
/*
|
||||
* Mission support unit reference (local_mp_support.c), 2.61.0.37:
|
||||
* setControlledUnit 0x598a70 (MPlayer *mp, uint32 eid), log "setControlledUnit() called with
|
||||
* eid:%08x"; the unit update gives a player back the vehicle with eid 0 when the player's
|
||||
* support unit is gone (0xfd1450, 0xfd25c3).
|
||||
*
|
||||
* @anchor "setControlledUnit() called with eid:%08x"
|
||||
*/
|
||||
#define LMP_SIG_SET_CONTROLLED_UNIT "56 57 53 48 83 ec 40 89 d7 48 89 ce 89 d0 48 89 44 24 28 c7 44 24 20 03 00 00 00"
|
||||
#define LMP_SIG_IS_SLOT_READY_AT_HOST "41 56 56 57 55 53 48 81 ec a0 00 00 00 0f 29 b4 24 90 00 00 00 44 89 c3 48 89 d6 48 83 3d"
|
||||
/* Multiplayer */
|
||||
#define LMP_MP_MGR_OFF_IS_HOST (g_lmp.mp_is_host)
|
||||
#define LMP_MP_MGR_OFF_IS_LOCAL_MP (g_lmp.mp_is_local_mp)
|
||||
#define LMP_MP_MGR_OFF_TEAM1_COUNTRIES (g_lmp.mp_team1_countries)
|
||||
#define LMP_MP_MGR_OFF_TEAM2_COUNTRIES (g_lmp.mp_team2_countries)
|
||||
#define LMP_MP_MGR_OFF_MP_CHAT (g_lmp.mp_chat)
|
||||
#define LMP_MP_MGR_OFF_CHAT_HOST (g_lmp.mp_chat_host)
|
||||
|
||||
/* App and the economic state */
|
||||
#define LMP_APP_OFF_SCORE_RULES (g_lmp.app_score_rules)
|
||||
#define LMP_APP_OFF_ECON_HOLDER (g_lmp.app_econ_holder)
|
||||
#define LMP_ECON_HOLDER_OFF_STATE (g_lmp.econ_state)
|
||||
#define LMP_ECON_OFF_CHANGE_REQ (g_lmp.econ_change_req)
|
||||
#define LMP_REQ_OFF_BULLETS_BEGIN (g_lmp.req_bullets_begin)
|
||||
#define LMP_REQ_OFF_BULLETS_END (g_lmp.req_bullets_end)
|
||||
#define LMP_REQ_OFF_SLOT_ID (g_lmp.req_slot_id)
|
||||
|
||||
/* MissionSettings and the matching info */
|
||||
#define LMP_MIS_OFF_AXIS_COUNTRY (g_lmp.mis_axis_country)
|
||||
#define LMP_MIS_OFF_ALLIES_COUNTRY (g_lmp.mis_allies_country)
|
||||
#define LMP_MIS_OFF_ARCADE_COUNTRY (g_lmp.mis_arcade_country)
|
||||
#define LMP_MIS_OFF_CUSTOM_BOTS (g_lmp.mis_custom_bots)
|
||||
#define LMP_MIS_OFF_CUSTOM_SCORE_PARAMS (g_lmp.mis_custom_score_params)
|
||||
#define LMP_MATCH_INFO_OFF_TEAM (g_lmp.match_team)
|
||||
|
||||
/* MPlayer */
|
||||
#define LMP_MP_OFF_PID (g_lmp.mp_pid)
|
||||
#define LMP_MP_OFF_USER_ID (g_lmp.mp_user_id)
|
||||
#define LMP_MP_OFF_TEAM (g_lmp.mp_team)
|
||||
#define LMP_MP_OFF_FALLBACK_SCORE (g_lmp.mp_fallback_score)
|
||||
#define LMP_MP_OFF_BROKEN_SLOTS_MASK (g_lmp.mp_broken_slots)
|
||||
#define LMP_MP_OFF_USED_SPARES_MASK (g_lmp.mp_used_spares)
|
||||
#define LMP_MP_OFF_GUI_STATE (g_lmp.mp_gui_state)
|
||||
#define LMP_MP_OFF_UNIT_EID (g_lmp.mp_unit_eid)
|
||||
#define LMP_MP_OFF_SCORE (g_lmp.mp_score)
|
||||
#define LMP_MP_OFF_KILLS (g_lmp.mp_kills)
|
||||
#define LMP_MP_OFF_TEAM_KILLS (g_lmp.mp_team_kills)
|
||||
#define LMP_MP_OFF_DEATHS (g_lmp.mp_deaths)
|
||||
#define LMP_MP_OFF_GROUND_KILLS (g_lmp.mp_ground_kills)
|
||||
#define LMP_MP_OFF_HUMAN_KILLS (g_lmp.mp_human_kills)
|
||||
#define LMP_MP_OFF_NAVAL_KILLS (g_lmp.mp_naval_kills)
|
||||
#define LMP_MP_OFF_AI_KILLS (g_lmp.mp_ai_kills)
|
||||
#define LMP_MP_OFF_AI_GROUND_KILLS (g_lmp.mp_ai_ground_kills)
|
||||
#define LMP_MP_OFF_AI_NAVAL_KILLS (g_lmp.mp_ai_naval_kills)
|
||||
#define LMP_MP_OFF_ASSISTS (g_lmp.mp_assists)
|
||||
#define LMP_MP_OFF_CAPTURE_ZONE (g_lmp.mp_capture_zone)
|
||||
#define LMP_MP_OFF_AWARD_DAMAGE (g_lmp.mp_award_damage)
|
||||
#define LMP_MP_OFF_AIR_SEVERE_DMG (g_lmp.mp_air_severe_dmg)
|
||||
#define LMP_MP_OFF_SHIP_SEVERE_DMG (g_lmp.mp_ship_severe_dmg)
|
||||
#define LMP_MP_OFF_STAT_DIRTY (g_lmp.mp_stat_dirty)
|
||||
#define LMP_MP_OFF_STAT_PAYLOAD (g_lmp.mp_stat_payload)
|
||||
#define LMP_MP_OFF_SUPPORT_UNIT_PTR (g_lmp.mp_support_unit_ptr)
|
||||
#define LMP_MP_OFF_SUPPORT_UNIT_EID (g_lmp.mp_support_unit_eid)
|
||||
#define LMP_MP_OFF_RESP_BASE_ID (g_lmp.mp_resp_base_id)
|
||||
#define LMP_MP_OFF_SPAWN_DELAY_A (g_lmp.mp_spawn_delay_a)
|
||||
#define LMP_MP_OFF_SPAWN_DELAY_B (g_lmp.mp_spawn_delay_b)
|
||||
#define LMP_MP_OFF_SPAWN_POS_X (g_lmp.mp_spawn_pos_x)
|
||||
#define LMP_MP_OFF_SPAWN_POS_Y (g_lmp.mp_spawn_pos_y)
|
||||
#define LMP_MP_OFF_SPAWN_POS_Z (g_lmp.mp_spawn_pos_z)
|
||||
|
||||
/* Unit, its unit info, and the ground model */
|
||||
#define LMP_UNIT_OFF_TYPE (g_lmp.unit_type)
|
||||
#define LMP_UNIT_OFF_SEVERE_IDX (g_lmp.unit_severe_idx)
|
||||
#define LMP_UNIT_OFF_SEVERE_PID (g_lmp.unit_severe_pid)
|
||||
#define LMP_UNIT_OFF_SEVERE_UID (g_lmp.unit_severe_uid)
|
||||
#define LMP_UNIT_OFF_MPLAYER (g_lmp.unit_mplayer)
|
||||
#define LMP_UNIT_OFF_ARMY (g_lmp.unit_army)
|
||||
#define LMP_UNIT_OFF_INFO (g_lmp.unit_info)
|
||||
#define LMP_UNIT_INFO_OFF_NAME (g_lmp.unit_info_name)
|
||||
#define LMP_UNIT_INFO_OFF_EXP_CLASS (g_lmp.unit_info_exp_class)
|
||||
#define LMP_UNIT_OFF_CREW_SKILLS (g_lmp.unit_crew_skills)
|
||||
#define LMP_UNIT_VTF_CHOOSE_OFFENDER (g_lmp.unit_vtf_choose_offender)
|
||||
#define LMP_UNIT_OFF_SKIP_KILL (g_lmp.unit_skip_kill)
|
||||
#define LMP_IGM_OFF_OFFENDERS_PTR (g_lmp.igm_offenders)
|
||||
#define LMP_IGM_OFF_OFFENDERS_CNT (g_lmp.igm_offenders_count)
|
||||
#define LMP_IGM_OFF_KILLER_PID (g_lmp.igm_killer_pid)
|
||||
#define LMP_IGM_OFF_KILLER_ARMY (g_lmp.igm_killer_army)
|
||||
#define LMP_IGM_OFF_KILLER_UID (g_lmp.igm_killer_uid)
|
||||
#define LMP_IGM_OFF_DEAD_SILENT (g_lmp.igm_dead_silent)
|
||||
#define LMP_IGM_OFF_ALREADY_DEAD (g_lmp.igm_already_dead)
|
||||
#define LMP_IGM_OFF_BAILOUT_DEAD (g_lmp.igm_bailout_dead)
|
||||
#define LMP_OFFENDER_STRIDE (g_lmp.offender_size)
|
||||
#define LMP_OFFENDER_OFF_ARMY (g_lmp.offender_army)
|
||||
#define LMP_OFFENDER_OFF_PID (g_lmp.offender_pid)
|
||||
#define LMP_OFFENDER_OFF_UID (g_lmp.offender_uid)
|
||||
#define LMP_OFFENDER_OFF_ASSIST_SENT (g_lmp.offender_assist_sent)
|
||||
|
||||
/* ChangeUnitReflection */
|
||||
#define LMP_REFL_OFF_UNIT_NAME (g_lmp.refl_unit)
|
||||
#define LMP_REFL_OFF_WEAPON_NAME (g_lmp.refl_weapon)
|
||||
#define LMP_REFL_OFF_SKIN_NAME (g_lmp.refl_skin)
|
||||
#define LMP_REFL_OFF_CUSTOM_SKIN (g_lmp.refl_custom_skin)
|
||||
#define LMP_REFL_OFF_DECALS_BLK (g_lmp.refl_decals)
|
||||
#define LMP_REFL_OFF_ATTACHABLES_BLK (g_lmp.refl_attachables)
|
||||
#define LMP_REFL_OFF_CUSTOM_PRESET_BLK (g_lmp.refl_custom_preset)
|
||||
#define LMP_REFL_OFF_FLAGS (g_lmp.refl_flags)
|
||||
#define LMP_REFL_OFF_FUEL (g_lmp.refl_fuel)
|
||||
#define LMP_REFL_OFF_GUN_CONVERGENCE (g_lmp.refl_gun_convergence)
|
||||
#define LMP_REFL_OFF_VERT_TARGETING (g_lmp.refl_vertical_targeting)
|
||||
#define LMP_REFL_OFF_BOMB_FUSE (g_lmp.refl_bomb_fuse)
|
||||
#define LMP_REFL_OFF_ENABLED_MODS (g_lmp.refl_enabled_mods)
|
||||
#define LMP_REFL_OFF_DISABLED_MODS (g_lmp.refl_disabled_mods)
|
||||
#define LMP_REFL_OFF_BULLETS_VEC (g_lmp.refl_bullets)
|
||||
|
||||
/* Nuclear instant win: the launch record, and the logic context's mission variables. */
|
||||
#define LMP_SHELL_LAUNCH_OFF_RECORD (g_lmp.shell_launch_record)
|
||||
#define LMP_SHELL_REC_OFF_INSTANT_WIN (g_lmp.shell_rec_instant_win)
|
||||
#define LMP_MISSION_VARS_OFF_DATA (g_lmp.mission_vars_data)
|
||||
#define LMP_MISSION_VARS_OFF_COUNT (g_lmp.mission_vars_count)
|
||||
#define LMP_MISSION_VAR_STRIDE (g_lmp.mission_var_stride)
|
||||
#define LMP_MISSION_VAR_OFF_NAME (g_lmp.mission_var_name)
|
||||
#define LMP_MISSION_VAR_OFF_VALUE (g_lmp.mission_var_value)
|
||||
|
||||
/* GameSaveData HUD script event queue */
|
||||
#define LMP_GSD_OFF_HUD_QUEUE (g_lmp.gsd_hud_queue)
|
||||
@@ -206,14 +206,12 @@ static uint8_t __fastcall hook_is_slot_ready_at_host(int32_t slot_id, const char
|
||||
return (*(uint32_t *)(mplayer + LMP_MP_OFF_BROKEN_SLOTS_MASK) & (1u << (uint32_t)slot_id)) == 0 ? 1 : 0;
|
||||
}
|
||||
|
||||
int install_local_mp_player_hooks(const uint8_t *text, size_t text_size, uint8_t *p_do_respawn)
|
||||
int install_local_mp_player_hooks(void)
|
||||
{
|
||||
uint8_t *p_gui_update = local_mp_scan_unique(text, text_size, "GuiState::update", LMP_SIG_GUI_STATE_UPDATE);
|
||||
uint8_t *p_mp_init = local_mp_scan_unique(text, text_size, "MPlayer::initFromMatching", LMP_SIG_MPLAYER_INIT_MATCHING);
|
||||
uint8_t *p_slot_ready = local_mp_scan_unique(text, text_size, "is_crew_slot_was_ready_at_host", LMP_SIG_IS_SLOT_READY_AT_HOST);
|
||||
|
||||
if (!p_gui_update || !p_mp_init || !p_do_respawn || !p_slot_ready)
|
||||
return 0;
|
||||
uint8_t *p_gui_update = g_lmp.gui_state_update;
|
||||
uint8_t *p_mp_init = g_lmp.mplayer_init_matching;
|
||||
uint8_t *p_do_respawn = g_lmp.do_respawn_player;
|
||||
uint8_t *p_slot_ready = g_lmp.is_slot_ready_at_host;
|
||||
|
||||
if (MH_CreateHook(p_gui_update, (void *)&hook_gui_state_update, (void **)&orig_gui_state_update) != MH_OK ||
|
||||
MH_EnableHook(p_gui_update) != MH_OK ||
|
||||
|
||||
@@ -55,9 +55,8 @@ float local_mp_event_score(const char *event, const uint8_t *unit, int victim_is
|
||||
return victim_is_player ? score : score * local_mp_score_param("wtoScore_aiMul");
|
||||
}
|
||||
|
||||
int install_local_mp_score_reader(const uint8_t *text, size_t text_size)
|
||||
int install_local_mp_score_reader(void)
|
||||
{
|
||||
fn_datablock_get_real = (DataBlockGetRealFn)local_mp_scan_unique(
|
||||
text, text_size, "DataBlock::getReal", LMP_SIG_DATABLOCK_GET_REAL);
|
||||
return fn_datablock_get_real != NULL;
|
||||
fn_datablock_get_real = (DataBlockGetRealFn)g_lmp.datablock_get_real;
|
||||
return 1;
|
||||
}
|
||||
@@ -98,12 +98,9 @@ static void __fastcall hook_set_controlled_unit(uint8_t *mp, uint32_t eid)
|
||||
}
|
||||
}
|
||||
|
||||
int install_local_mp_support_hooks(const uint8_t *text, size_t text_size)
|
||||
int install_local_mp_support_hooks(void)
|
||||
{
|
||||
uint8_t *p_set = local_mp_scan_unique(text, text_size, "setControlledUnit", LMP_SIG_SET_CONTROLLED_UNIT);
|
||||
|
||||
if (!p_set)
|
||||
return 0;
|
||||
uint8_t *p_set = g_lmp.set_controlled_unit;
|
||||
if (MH_CreateHook(p_set, (void *)&hook_set_controlled_unit, (void **)&orig_set_controlled_unit) != MH_OK ||
|
||||
MH_EnableHook(p_set) != MH_OK) {
|
||||
log_line("local_mp: failed to install the support unit hook");
|
||||
|
||||
@@ -0,0 +1,203 @@
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* What the LocalMP modules need from aces.exe, as resolved by the build (patches/native/*.jsonc,
|
||||
* @wto/patcher native-resolve.ts) and handed over in wto_ws.cfg. Nothing here is a constant of a
|
||||
* game build: functions and globals are absolute addresses in this process, structure offsets are
|
||||
* what the definitions captured from the code.
|
||||
*
|
||||
* lmp_values_load(module) fills the fields of one module (local_mp_values.c); a module whose values
|
||||
* are not all present is left off. The build only writes the values of modules that resolved
|
||||
* completely together with the modules they require.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct LmpValues {
|
||||
/* local_mp_core */
|
||||
uint8_t *do_respawn_player, *get_player_country, *refl_dtor, *aircraft_change_result, *set_player_gui_state;
|
||||
uint8_t *get_unit_by_eid, *set_owning_mplayer, *iground_on_dead, *datablock_get_str, *datablock_set_from;
|
||||
uint8_t *mp_construct_local, *gui_state_update, *unit_change_aircraft, *dagmem_alloc;
|
||||
uint8_t *multiplayer, *app, *local_mplayer, *hero, *mission_settings, *stdmem, *player_count, *player_table;
|
||||
size_t mp_is_host, mp_is_local_mp, mp_chat_host, mp_pid, mp_user_id, mp_team, mp_broken_slots, mp_unit_eid;
|
||||
size_t match_team, app_score_rules, app_econ_holder, econ_state, econ_change_req;
|
||||
size_t unit_type, unit_mplayer, unit_info, unit_info_name, mis_custom_bots;
|
||||
|
||||
/* local_mp_players */
|
||||
uint8_t *mplayer_init_matching, *is_slot_ready_at_host;
|
||||
size_t mp_gui_state, mp_used_spares, mis_allies_country, mis_axis_country, mis_arcade_country;
|
||||
|
||||
/* local_mp_loadout */
|
||||
uint8_t *sem_change_aircraft_send, *refl_ctor, *datablock_dtor, *bullet_vec_assign, *get_decals_blk;
|
||||
uint8_t *get_attachables_blk, *str_hash_fnv1, *namemap_add_name_id, *crew_skills_init;
|
||||
size_t refl_bullets, refl_disabled_mods, refl_enabled_mods, refl_custom_preset, refl_attachables, refl_decals;
|
||||
size_t refl_custom_skin, refl_skin, refl_weapon, refl_unit, refl_flags, refl_gun_convergence;
|
||||
size_t refl_vertical_targeting, refl_bomb_fuse, refl_fuel;
|
||||
size_t mp_resp_base_id, mp_spawn_delay_a, mp_spawn_delay_b, mp_spawn_pos_x, mp_spawn_pos_y, mp_spawn_pos_z;
|
||||
/* Change request members: captured as offsets in the economic state, used relative to the request. */
|
||||
size_t econ_req_slot_id, econ_req_bullets_begin, econ_req_bullets_end;
|
||||
size_t req_slot_id, req_bullets_begin, req_bullets_end;
|
||||
size_t unit_crew_skills;
|
||||
|
||||
/* local_mp_actions */
|
||||
uint8_t *mp_init_chat;
|
||||
size_t mp_chat, mp_team1_countries, mp_team2_countries;
|
||||
|
||||
/* local_mp_awards */
|
||||
uint8_t *blk_ctor, *blk_set_str, *blk_to_owned, *blk_set_int, *hud_notify_script, *blk_dtor, *game_save_data;
|
||||
size_t gsd_hud_queue, unit_info_exp_class;
|
||||
|
||||
/* local_mp_scores */
|
||||
uint8_t *datablock_get_real;
|
||||
size_t mis_custom_score_params;
|
||||
|
||||
/* local_mp_kills */
|
||||
uint8_t *mplayer_add_score, *net_mark_dirty, *on_unit_dead_once, *iground_award_assists;
|
||||
size_t mp_score, mp_stat_dirty, mp_stat_payload, unit_skip_kill, unit_severe_idx, unit_severe_uid, unit_severe_pid;
|
||||
size_t igm_already_dead, igm_dead_silent, igm_bailout_dead, igm_offenders_count, igm_offenders, offender_size;
|
||||
size_t igm_killer, igm_killer_uid, igm_killer_pid, igm_killer_army, unit_vtf_choose_offender;
|
||||
size_t unit_army, offender_army, offender_uid, offender_pid;
|
||||
size_t mp_kills, mp_ground_kills, mp_human_kills, mp_naval_kills, mp_team_kills, mp_ai_kills;
|
||||
size_t mp_ai_ground_kills, mp_ai_naval_kills, mp_assists, mp_deaths, mp_capture_zone, mp_fallback_score;
|
||||
size_t mp_award_damage, mp_air_severe_dmg, mp_ship_severe_dmg;
|
||||
|
||||
/* local_mp_events */
|
||||
uint8_t *dispatch_assist, *dispatch_capture_zone, *dispatch_hit_crit, *dispatch_severe_damage, *dispatch_naval_damage;
|
||||
size_t offender_assist_sent;
|
||||
|
||||
/* local_mp_nuke */
|
||||
uint8_t *shell_launch, *shell_explode, *cta_logic_action;
|
||||
size_t shell_launch_record, shell_rec_instant_win, mission_vars_data, mission_vars_count, mission_var_stride;
|
||||
ptrdiff_t mission_var_bias, mission_var_name_disp, mission_var_value_disp;
|
||||
size_t mission_var_name, mission_var_value;
|
||||
|
||||
/* local_mp_support */
|
||||
uint8_t *set_controlled_unit;
|
||||
size_t mp_support_unit_eid, mp_support_unit_ptr;
|
||||
} LmpValues;
|
||||
|
||||
extern LmpValues g_lmp;
|
||||
|
||||
/* Fill the values of `module` ("local_mp_core", ...); returns 0 and logs the first missing one. */
|
||||
int lmp_values_load(const char *module);
|
||||
@@ -429,6 +429,64 @@
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
// MissionSettings customBots.
|
||||
// 2.61.0.37: 0x126ef8d (lea rdi, [rsi + 0x718]; mov rcx, rdi; call 0x3093970)
|
||||
"mission_custom_bots": {
|
||||
"variants": [
|
||||
{
|
||||
"written_for": "2.61.0.37",
|
||||
"locate": {
|
||||
"method": "within",
|
||||
"in": "mission_settings_load",
|
||||
"pattern": "48 8d be ?? ?? ?? ?? 48 89 f9 e8 ?? ?? ?? ??",
|
||||
"captures": {
|
||||
"custom_bots": {
|
||||
"offset": 3,
|
||||
"type": "u32"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
// Scoreboard row writer (refers to "airSevereDamage").
|
||||
// 2.61.0.37: 0x12929f0
|
||||
"scoreboard_rows": {
|
||||
"variants": [
|
||||
{
|
||||
"written_for": "2.61.0.37",
|
||||
"locate": {
|
||||
"method": "string_ref",
|
||||
"string": "airSevereDamage",
|
||||
"target": "function"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
// The controlled unit eid, falling back to the player's own unit eid.
|
||||
// 2.61.0.37: 0x1292bfb (mov edx, dword ptr [rdi + 0x880]; lea r8, [rdi + 0x854]; test edx, edx; ...)
|
||||
"mplayer_unit_eid": {
|
||||
"variants": [
|
||||
{
|
||||
"written_for": "2.61.0.37",
|
||||
"locate": {
|
||||
"method": "within",
|
||||
"in": "scoreboard_rows",
|
||||
"pattern": "8b 97 ?? ?? ?? ?? 4c 8d 87 54 08 00 00 85 d2 4c 0f 45 c1 48 8d 8f 48 08 00 00 0f 44 97 ?? ?? ?? ??",
|
||||
"captures": {
|
||||
"controlled_eid": {
|
||||
"offset": 2,
|
||||
"type": "u32"
|
||||
},
|
||||
"unit_eid": {
|
||||
"offset": 29,
|
||||
"type": "u32"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -89,44 +89,6 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
// Scoreboard row writer (refers to "airSevereDamage").
|
||||
// 2.61.0.37: 0x12929f0
|
||||
"scoreboard_rows": {
|
||||
"variants": [
|
||||
{
|
||||
"written_for": "2.61.0.37",
|
||||
"locate": {
|
||||
"method": "string_ref",
|
||||
"string": "airSevereDamage",
|
||||
"target": "function"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
// The controlled unit eid, falling back to the player's own unit eid.
|
||||
// 2.61.0.37: 0x1292bfb (mov edx, dword ptr [rdi + 0x880]; lea r8, [rdi + 0x854]; test edx, edx; ...)
|
||||
"mplayer_unit_eid": {
|
||||
"variants": [
|
||||
{
|
||||
"written_for": "2.61.0.37",
|
||||
"locate": {
|
||||
"method": "within",
|
||||
"in": "scoreboard_rows",
|
||||
"pattern": "8b 97 ?? ?? ?? ?? 4c 8d 87 54 08 00 00 85 d2 4c 0f 45 c1 48 8d 8f 48 08 00 00 0f 44 97 ?? ?? ?? ??",
|
||||
"captures": {
|
||||
"controlled_eid": {
|
||||
"offset": 2,
|
||||
"type": "u32"
|
||||
},
|
||||
"unit_eid": {
|
||||
"offset": 29,
|
||||
"type": "u32"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
// MissionSettings allies country.
|
||||
// 2.61.0.37: 0x1277500 (mov rcx, qword ptr [rcx + 0xd0]; jmp 0x127751f; xor r10d, r10d)
|
||||
"mission_allies_country": {
|
||||
@@ -186,26 +148,6 @@
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
// MissionSettings customBots.
|
||||
// 2.61.0.37: 0x126ef8d (lea rdi, [rsi + 0x718]; mov rcx, rdi; call 0x3093970)
|
||||
"mission_custom_bots": {
|
||||
"variants": [
|
||||
{
|
||||
"written_for": "2.61.0.37",
|
||||
"locate": {
|
||||
"method": "within",
|
||||
"in": "mission_settings_load",
|
||||
"pattern": "48 8d be ?? ?? ?? ?? 48 89 f9 e8 ?? ?? ?? ??",
|
||||
"captures": {
|
||||
"custom_bots": {
|
||||
"offset": 3,
|
||||
"type": "u32"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -183,7 +183,10 @@
|
||||
"unit_info_name": "2.61.0.37",
|
||||
"unit_mplayer": "2.61.0.37",
|
||||
"refl_stdmem": "2.61.0.37",
|
||||
"mission_settings_load": "2.61.0.37"
|
||||
"mission_settings_load": "2.61.0.37",
|
||||
"mission_custom_bots": "2.61.0.37",
|
||||
"scoreboard_rows": "2.61.0.37",
|
||||
"mplayer_unit_eid": "2.61.0.37"
|
||||
},
|
||||
"local_mp_actions": {
|
||||
"mp_init_chat": "2.61.0.37",
|
||||
@@ -248,12 +251,9 @@
|
||||
"mplayer_gui_state": "2.61.0.37",
|
||||
"mplayer_clear_before_lobby": "2.61.0.37",
|
||||
"mplayer_used_spares": "2.61.0.37",
|
||||
"scoreboard_rows": "2.61.0.37",
|
||||
"mplayer_unit_eid": "2.61.0.37",
|
||||
"mission_allies_country": "2.61.0.37",
|
||||
"mission_axis_country": "2.61.0.37",
|
||||
"mission_arcade_country": "2.61.0.37",
|
||||
"mission_custom_bots": "2.61.0.37"
|
||||
"mission_arcade_country": "2.61.0.37"
|
||||
},
|
||||
"local_mp_loadout": {
|
||||
"sem_change_aircraft_send": "2.61.0.37",
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
"""Commands that work on the game executable.
|
||||
|
||||
wtotools check-patches --exe <aces.exe> [--patches patches/exe]
|
||||
wtotools check-offsets --exe <aces.exe> [--header native/wto-net/src/local_mp_offsets.h]
|
||||
wtotools patch-exe --exe <aces.exe> --out <aces.exe> [--patches patches/exe] [--force]
|
||||
|
||||
The input executable is only ever read. `patch-exe` refuses to write over its input and
|
||||
@@ -16,11 +15,9 @@ from pathlib import Path
|
||||
|
||||
from ..exepatch import apply_writes, changed_ranges, load_patches, plan_patches
|
||||
from ..exepatch.assemble import disagreement, needs_site
|
||||
from ..offset_check import parse_offset_header, verify_offsets
|
||||
from ..pe import PeImage
|
||||
|
||||
DEFAULT_PATCHES = Path("patches/exe")
|
||||
DEFAULT_OFFSET_HEADER = Path("native/wto-net/src/local_mp_offsets.h")
|
||||
|
||||
|
||||
def register(commands: argparse._SubParsersAction) -> None:
|
||||
@@ -28,11 +25,6 @@ def register(commands: argparse._SubParsersAction) -> None:
|
||||
_add_common(check)
|
||||
check.set_defaults(handler=_check_patches)
|
||||
|
||||
offsets = commands.add_parser("check-offsets", help="verify native LocalMP signatures and anchor strings")
|
||||
offsets.add_argument("--exe", type=Path, required=True, help="the game executable to read")
|
||||
offsets.add_argument("--header", type=Path, default=DEFAULT_OFFSET_HEADER, help="C header with LMP_SIG_* and @anchor tags")
|
||||
offsets.set_defaults(handler=_check_offsets)
|
||||
|
||||
patch = commands.add_parser("patch-exe", help="apply every patch to a copy of the executable")
|
||||
_add_common(patch)
|
||||
patch.add_argument("--out", type=Path, required=True, help="where to write the patched copy")
|
||||
@@ -75,14 +67,6 @@ def _source_problems(definitions, plan) -> list[str]:
|
||||
return problems
|
||||
|
||||
|
||||
def _check_offsets(args: argparse.Namespace) -> int:
|
||||
spec = parse_offset_header(args.header)
|
||||
ok, lines = verify_offsets(PeImage(args.exe.read_bytes()), spec)
|
||||
for line in lines:
|
||||
print(line)
|
||||
return 0 if ok else 1
|
||||
|
||||
|
||||
def _patch_exe(args: argparse.Namespace) -> int:
|
||||
if args.out.resolve() == args.exe.resolve():
|
||||
print("refusing to write over the input executable; choose a different --out", file=sys.stderr)
|
||||
|
||||
@@ -1,134 +0,0 @@
|
||||
"""Verify native LocalMP signatures, RIP opcodes, and English anchor strings against aces.exe.
|
||||
|
||||
Parses `native/wto-net/src/local_mp_offsets.h` directly as the single source of truth so
|
||||
C hook code and binary calibration checks can never drift apart across game updates.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
|
||||
from .pe import PeImage
|
||||
|
||||
_SIG_RE = re.compile(r'^#define\s+(LMP_SIG_\w+)\s+"([0-9a-fA-F? ]+)"', re.MULTILINE)
|
||||
_RIP_RE = re.compile(r"@rip_check\s+(LMP_SIG_\w+)\s*\+\s*0x([0-9a-fA-F]+)\s*:\s*([0-9a-fA-F ]+)")
|
||||
_ANCHOR_RE = re.compile(r'^\s*\*\s*@anchor\s+"([^"]+)"', re.MULTILINE)
|
||||
_LEA_RE = re.compile(rb"[\x48\x4c]\x8d[\x05\x0d\x15\x1d\x25\x2d\x35\x3d](....)", re.DOTALL)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class RipCheckSpec:
|
||||
sig_name: str
|
||||
offset: int
|
||||
expected_prefix: bytes
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class OffsetHeaderSpec:
|
||||
signatures: list[tuple[str, str]]
|
||||
rip_checks: list[RipCheckSpec]
|
||||
anchors: list[str]
|
||||
|
||||
|
||||
def parse_offset_header(header_path: Path) -> OffsetHeaderSpec:
|
||||
source = header_path.read_text(encoding="utf-8")
|
||||
signatures = _SIG_RE.findall(source)
|
||||
rip_checks = [
|
||||
RipCheckSpec(name, int(off_hex, 16), bytes.fromhex(prefix_hex))
|
||||
for name, off_hex, prefix_hex in _RIP_RE.findall(source)
|
||||
]
|
||||
anchors = list(dict.fromkeys(_ANCHOR_RE.findall(source)))
|
||||
return OffsetHeaderSpec(signatures=signatures, rip_checks=rip_checks, anchors=anchors)
|
||||
|
||||
|
||||
def _compile_signature(spec: str) -> re.Pattern[bytes]:
|
||||
parts: list[bytes] = []
|
||||
for token in spec.split():
|
||||
if token == "??":
|
||||
parts.append(b".")
|
||||
else:
|
||||
parts.append(re.escape(bytes([int(token, 16)])))
|
||||
return re.compile(b"".join(parts), re.DOTALL)
|
||||
|
||||
|
||||
def _index_rip_lea_targets(text_rva: int, text_bytes: bytes) -> dict[int, list[int]]:
|
||||
targets: dict[int, list[int]] = {}
|
||||
for match in _LEA_RE.finditer(text_bytes):
|
||||
insn_rva = text_rva + match.start()
|
||||
disp = int.from_bytes(match.group(1), "little", signed=True)
|
||||
target_rva = insn_rva + 7 + disp
|
||||
bucket = targets.get(target_rva)
|
||||
if bucket is None:
|
||||
targets[target_rva] = [insn_rva]
|
||||
elif len(bucket) < 4:
|
||||
bucket.append(insn_rva)
|
||||
return targets
|
||||
|
||||
|
||||
def _find_cstring_rvas(pe: PeImage, text: str) -> list[int]:
|
||||
needle = text.encode("ascii") + b"\x00"
|
||||
rvas: list[int] = []
|
||||
for sec in pe.sections:
|
||||
if sec.name == ".text" or sec.raw_size == 0:
|
||||
continue
|
||||
raw = pe.data[sec.raw_offset : sec.raw_offset + min(sec.virtual_size, sec.raw_size)]
|
||||
pos = 0
|
||||
while True:
|
||||
idx = raw.find(needle, pos)
|
||||
if idx < 0:
|
||||
break
|
||||
rvas.append(sec.rva + idx)
|
||||
pos = idx + len(needle)
|
||||
return rvas
|
||||
|
||||
|
||||
def verify_offsets(pe: PeImage, spec: OffsetHeaderSpec) -> tuple[bool, list[str]]:
|
||||
lines: list[str] = []
|
||||
failures = 0
|
||||
text_sec = pe.section(".text")
|
||||
text_bytes = pe.section_bytes(".text")
|
||||
resolved_sigs: dict[str, int] = {}
|
||||
|
||||
lines.append(f"Checking {len(spec.signatures)} .text signature(s):")
|
||||
for name, pattern in spec.signatures:
|
||||
hits = [text_sec.rva + m.start() for m in _compile_signature(pattern).finditer(text_bytes)]
|
||||
if len(hits) == 1:
|
||||
resolved_sigs[name] = hits[0]
|
||||
lines.append(f" [OK] {name:<34} -> {hits[0]:#09x}")
|
||||
else:
|
||||
failures += 1
|
||||
lines.append(f" [FAIL] {name:<34} -> {len(hits)} match(es)")
|
||||
|
||||
lines.append(f"Checking {len(spec.rip_checks)} RIP displacement anchor(s):")
|
||||
for chk in spec.rip_checks:
|
||||
base_rva = resolved_sigs.get(chk.sig_name)
|
||||
if base_rva is None:
|
||||
failures += 1
|
||||
lines.append(f" [FAIL] {chk.sig_name} + {chk.offset:#x}: base signature unresolved")
|
||||
continue
|
||||
actual = pe.read(base_rva + chk.offset, len(chk.expected_prefix))
|
||||
if actual == chk.expected_prefix:
|
||||
lines.append(f" [OK] {chk.sig_name} + {chk.offset:#x} == {actual.hex(' ')}")
|
||||
else:
|
||||
failures += 1
|
||||
lines.append(
|
||||
f" [FAIL] {chk.sig_name} + {chk.offset:#x}: expected {chk.expected_prefix.hex(' ')}, got {actual.hex(' ')}"
|
||||
)
|
||||
|
||||
lea_targets = _index_rip_lea_targets(text_sec.rva, text_bytes)
|
||||
lines.append(f"Checking {len(spec.anchors)} English anchor string(s):")
|
||||
for anchor in spec.anchors:
|
||||
str_rvas = _find_cstring_rvas(pe, anchor)
|
||||
xrefs = [xr for sr in str_rvas for xr in lea_targets.get(sr, ())]
|
||||
if str_rvas and xrefs:
|
||||
fn_range = pe.function_containing(xrefs[0])
|
||||
fn_str = f"{fn_range[0]:#x}" if fn_range else f"{xrefs[0]:#x}"
|
||||
lines.append(f" [OK] {anchor!r:<58} -> str {str_rvas[0]:#x}, fn {fn_str}")
|
||||
elif str_rvas:
|
||||
lines.append(f" [OK] {anchor!r:<58} -> str {str_rvas[0]:#x} (table/data ref)")
|
||||
else:
|
||||
failures += 1
|
||||
lines.append(f" [FAIL] {anchor!r}: string not found in image")
|
||||
|
||||
return failures == 0, lines
|
||||
Reference in new issue
Block a user