mirror of
https://git.ely.my.id/Tenshi/Hi3-Patcher
synced 2026-11-04 21:46:48 +01:00
71 lines
3.0 KiB
Markdown
71 lines
3.0 KiB
Markdown
# 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`)
|
|
|
|
- `dispatch` replaces the `"DispatchUrls": [...]` list with
|
|
`"<origin>/query_dispatch"` entries inside its original byte range,
|
|
space-padding the rest.
|
|
- `sdk` rewrites the URLs of the production `bh3_*` records in
|
|
`server_pc` (`env` `0` for `bh3_cn`, else `2`), padding each record to
|
|
its original length.
|
|
- `android_urls` rewrites `http(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 an `x…@` userinfo prefix; `ws`/`wss` follow 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:
|
|
|
|
1. Appends a `string_data_item` for the chosen origin
|
|
(`format::dex::append_string`) and points the loopback string id at
|
|
it.
|
|
2. Points the `const-string` that loaded the official login URL
|
|
(`https://passport-api.mihoyo.com`) at that id, so login goes to the
|
|
server.
|
|
3. Moves the original loopback `const-string` to the neighboring id to
|
|
keep `string_ids` sorted.
|
|
|
|
The origin must sort between those neighbors; other addresses are
|
|
rejected. Checksums are recomputed.
|