3.0 KiB
Dispatch & SDK patch
Rewrites client URLs to a chosen HTTP or HTTPS server. The server is a host or IP with an optional port, without scheme or path.
URL rules (dispatch/mod.rs)
dispatchreplaces the"DispatchUrls": [...]list with"<origin>/query_dispatch"entries inside its original byte range, space-padding the rest.sdkrewrites the URLs of the productionbh3_*records inserver_pc(env0forbh3_cn, else2), padding each record to its original length.android_urlsrewriteshttp(s)/ws(s)URLs and bare hosts on the official domains (bh3.com,honkaiimpact3.com,mihoyo.com,hoyoverse.com, plus one known IP). Shorter replacements keep the original length with anx…@userinfo prefix;ws/wssfollow the chosen scheme.
If a replacement is longer than the original, dispatch_grow, sdk_grow
or android_urls_grow writes it at full length and the asset is
enlarged: unity::replace_script rewrites the serialized object table and
header size, and Bundle::replace_node re-chunks a UnityFS node and
fixes its directory. The tool then prints a warning that assets were
enlarged.
Windows (dispatch/windows.rs)
Writes three files together and rolls back on failure:
| File | Content patched |
|---|---|
BH3_Data/sharedassets0.assets |
ChannelConfig dispatch URLs; also identifies the region |
BH3_Data/resources.assets |
server_pc SDK URLs |
BH3_Data/StreamingAssets/MiHoYoSDKRes/PC/mihoyo_sdk_res |
the server_pc copy inside the SDK bundle |
Both server_pc copies must be byte-equal before patching.
Android (dispatch/android.rs)
Patches serialized files, UnityFS bundle nodes and plain text among the
candidate assets/ entries (assets/bin/data/* and known text
extensions, except package_config.json, share_config.json, .wmv
and .bak). .splitN parts are joined for patching and re-split at the
original chunk size; enlarging can add parts. DEX, native libraries and
.wmv are copied unchanged, except for the CN passport URL below. At
least one ChannelConfig and one SDK/resource URL are required, otherwise
no APK is written. The result is repacked and signed by android::sign.
CN passport URL (dispatch/cn_android.rs)
The CN passport login URL is a plaintext string in the DEX that declares
…account.sdk.utils.RSAUtils; only that DEX is edited. The server must
use HTTP — HTTPS is rejected.
The stock DEX has exactly one loopback string, http://127.0.0.1 (an SDK
default), between known neighbors in the sorted string_ids table. The
patch:
- Appends a
string_data_itemfor the chosen origin (format::dex::append_string) and points the loopback string id at it. - Points the
const-stringthat loaded the official login URL (https://passport-api.mihoyo.com) at that id, so login goes to the server. - Moves the original loopback
const-stringto the neighboring id to keepstring_idssorted.
The origin must sort between those neighbors; other addresses are rejected. Checksums are recomputed.