Repository navigation
Tooling
Python 3, standard library only, run from the repository root. The tests drive the mock; none starts the game.
ThreadingHTTPServer speaking haxe.remoting (__x in, hxr + serialized out), logging each request raw and decoded.
export GUL_BIND=0.0.0.0
export GUL_BASE=http://127.0.0.1:8096
export GUL_DSUR_B_OPS=startSession
export GUL_DSUR_HX=1
export GUL_DSUR_HX_PURPOSE=game
export GUL_DSUR_HX_TEMPLATE=1
export GUL_DSUR_HX_TAIL=0
export GUL_HS_MODE=resultdsur
export GUL_CTX_PROVIDER_ENUM=1
export GUL_CTX_PROVIDER_IDX=2
export GUL_USER_POLL_DELAY=10
export GUL_TRACK_DELAY=0
export GUL_M_DRM=3
export GUL_IID_TEMPLATE=player
export GUL_IID_TEMPLATE_BLOB=player
export GUL_URL_ACTION=join
export GUL_TRACK_STYLE=result
export GUL_NOCL=0
python3 mock_appserver.py 8096
On Windows use set GUL_...=... for the same names. The branch-B reply is required: without it startSession answers branch A with no entity or
template (726 bytes against 1053) and the client cannot seed its datastore. Binds 127.0.0.1 by
default; GUL_BIND overrides. GUL_BASE is the address the client uses.
Structure:
-
HANDSHAKE— thedoHandshakeconfig, includingm_drmas anHxEnum. -
SESSION_CTX— the session context and account record (pluspgsToken); merged fromGUL_CTX_EXTRA, reduced byGUL_CTX_MINIMAL, fields dropped byGUL_CTX_DROP. -
PGS_PARTY— the generic party blob. -
OP_REPLIES— 18 named ops. Anything else receiveshandshake_result_dsur(None), a generic success. -
_dsur(payload)— branch A by default, branch B whenGUL_DSUR_Bis set or the current op is inGUL_DSUR_B_OPS. -
do_POST— routes/remoting/<conn>/<op>, the JSON legs, and the{}catch-all.
Knobs:
| group | variables |
|---|---|
| transport |
GUL_BASE, GUL_BIND, GUL_COMPRESS (none/zlib/raw/raw4), GUL_LOG_REQ
|
| handshake |
GUL_M_DRM, GUL_M_DRM_ARG, GUL_SERVER_ENV, GUL_COOLDOWN
|
| session |
GUL_CTX_MINIMAL, GUL_CTX_EXTRA, GUL_CTX_DROP, GUL_CTX_PROVIDER_ENUM, GUL_CTX_PROVIDER_IDX, GUL_RCONF
|
| branch B |
GUL_DSUR_B, GUL_DSUR_B_OPS, GUL_DSUR_DIRECT, GUL_DSUR_DIRECT_OPS, GUL_DSUR_DIRECT_VALUE
|
| entities |
GUL_DSUR_ENTITIES, GUL_DSUR_ENTITIES_STR, GUL_DSUR_ENTITIES_RAW, GUL_IID, GUL_IID_TEMPLATE, GUL_DSUR_BLOB_JSON, GUL_DSUR_BLOB_RAW, GUL_DSUR_BLOB_INTMAP
|
| PGS |
GUL_HEARTBEAT_SEC, GUL_USER_WATCH_STAMP, GUL_USER_WATCH_HOLD, GUL_PGS_ACCOUNTS
|
| replay |
GUL_TRACK_PUSH_PLAYER, GUL_TRACK_DELAY
|
The _RAW knobs take wire text, not JSON. Passing ["x"] emits literal brackets, rejected by the client with Invalid char [ at position 140.
Wire-format serializer/deserializer and builders.
- Tokens:
n t f z i d k m p y R o g a h u r x b h. -
Serializer.value(): dict → anonymous object or StringMap; list → array withu<n>null runs;str→y<len>:;HxEnum→w…;HxClass/HxInstance→ declarations +T<idx>:. -
RawFragmentsplices verbatim wire text. It is astrsubclass, so its check precedes the String branch. -
handshake_response(config)—[V decl][Result.Success(T0 instance)]. -
handshake_result_dsur(config)—[n][Result.Success(DSUR)], the universal accepted form. -
dsur_branch_b(config, entities, blob, extra_classes)—[n][Result.Success(DSUR)]with non-emptyupdatedEntities; emits the enum prefix first so the string table cannot shift. -
result_success(value)—[n][Result.Success(value)]without a DSUR wrapper.
Limitations: Unserializer does not implement w; r object references are not emitted.
The hxInflate writer (Deflater.hx grammar) and a host-side reader mirroring Inflater.hx, validated by tests/test_hxinflate.py. Decl describes a class (name, base, version, custom, fields); Raw injects verbatim text. A payload is valid when it decodes to its declared length, the check behind the account template's 36-byte extent and the player template's 4,296-byte extent.
tools/pakdump.py — UE4 v3 pak reader: index listing and extraction.
python3 tools/pakdump.py <pak> info
python3 tools/pakdump.py <pak> list [--filter TEXT]
python3 tools/pakdump.py <pak> extract <path> --out <dir>
tools/pak_patch_url.py — same-length in-place URL patcher. Layout:
footer 44 B at EOF-44: magic 0x5A6F12E1, version, index_offset, index_size, sha1
index: FString mount, u32 count, then per entry
FString path, u64 offset, u64 size, u64 csize, u16 method, u16 flags, sha1, 5 zero bytes
on-disk per-file header 53 B at entry.offset: same fields
compression none (v3), no encryption
Replaces every OLD with NEW (equal length); refreshes affected entries' sha1 in the index and on-disk header, and the footer index sha1. Reversible by swapping the arguments.
python3 tools/pak_patch_url.py ".../hns-WindowsNoEditor.pak" \
'https://api.playstreamline.com' 'http://127.0.0.1:8096/////////'
Trailing slashes pad to the original length; the client's URL join supplies the rest.
| tool | purpose |
|---|---|
tools/fix_pe_checksum.py |
MS checksum: zero PE+0x58, 16-bit LE sum with carry fold, add file length once. --check prints stored/computed/delta and exits non-zero on mismatch; without it the field is rewritten |
tools/u16scan.py |
UTF-16LE printable-run extraction, filtered by endpoint/keyword patterns |
tools/unwind.py, tools/stackscan.py, tools/throwscan.py
|
unwind metadata, stack-frame scanning, throw-site scanning over the shipped binary or a minidump |
VA ↔ file offset: .text −0xC00, .rdata −0xE00 (PatchIndex). A 32-bit address in a listing is an RVA; image base 0x140000000.
python3 tests/run_all.py
No pytest or game files; discovers unittest classes and module-level test_* functions, drives mock_appserver.py on ephemeral ports, and reports one total: 53 checks (38 unittest + 15 module-level), 0 failed.
| test | covers |
|---|---|
test_haxe_ser_decode |
captured request bodies, token coverage |
test_hxinflate |
writer/reader symmetry, header, IntMap, null runs |
test_mock_branch_b |
branch A/B envelopes, entity-only contract, template negative control |
test_tpl_entity_payload |
the player template entity body |
test_login_gate_contract |
session context, playerIID, seven-value body (eight-value trailer tolerated) |
test_tracking_reply |
the postTrackingInfo reply shape |
test_unknown_op |
generic-success fallback |
test_process_url |
the processUrl reply literal and UrlAction variant |
test_user_watch_pacing |
user-watch long poll and stamp behaviour |
The mock allocates one identity per login (Player1, Player2, …), keyed by the client's session id
or cookie rather than its address, and keeps it stable across that session's operations. GUL_IID and
GUL_NAME pin a fixed value for single-client tests; GUL_NAME_PREFIX changes the auto prefix.