Fix Insert the CN passport URL as a new DEX string so any domain works

This commit is contained in:
Tenshi committed 2026-11-01 10:06:45 +01:00
1 parent 737780597b
commit daece35d94
4 files changed
+926 -39

No files matched your search

+17 -14
View File
@@ -53,18 +53,21 @@ 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:
The patch inserts the origin as a new string at its sorted position in
`string_ids` (`format::dex::insert_string`) and repoints the
`const-string` that loaded the official login URL
(`https://passport-api.mihoyo.com`) to it, so login goes to the server.
Any origin is accepted, not only ones that sort next to a reusable slot.
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.
Insertion shifts every string index at or after the new one, so
`insert_string` renumbers all references — the fixed-width id tables,
`const-string`/`const-string/jumbo` operands, and the ULEB128 string
indices in debug info and annotations — and relocates every file offset
(itself and the string data grow 4-aligned). A DEX with more than 65536
strings can hold a 16-bit `const-string` whose operand would overflow
when renumbered; `format::dex::promote` rewrites those to
`const-string/jumbo` first, rebuilding the affected method (branch and
switch targets fixed, the code item re-padded to 4-byte alignment). If
the origin is already present (for example the stock `http://127.0.0.1`
when the server runs on the device), the login is repointed to the
existing id with no insertion. Checksums are recomputed.