Skip to content

Module

Script automatically generated by Emscripten during compilation of zombs_wasm.wasm. It serves as a JavaScript entry module instantiating and interacting with the WASM instance in BinCodec methods.

Module

INFO

Due to the script being automatically generated and later obfuscated during bundling, only relevant properties and methods are mentioned.

Properties

NameTypeDescription
asmWebAssembly.Instance.prototype.exportsRaw exports of the instantiated zombs_wasm.wasm instance. The core export function is j, which is then wrapped as _MakeBlendField.
HEAP8Int8ArraySigned 8-bit view over the WASM linear memory.
HEAP32Int32ArraySigned 32-bit view over the WASM linear memory.
HEAPU8Uint8ArrayUnsigned 8-bit view over the WASM linear memory.

Methods

_main()

ts
function _main(argc?: number, argv?: number): number

Generated wrapper for program entrypoint representing C/C++ main() function. The generated wrapper calls it after __wasm_call_ctors() has run. Calls imported function _emscripten_run_script_int() to set a random seed for the Mersenne Twister PRNG used during the PoW process.

_MakeBlendField()

ts
function _MakeBlendField(opcode: MBF_COMMAND, value: number): number

Runs the obfuscated MBF entrypoint. Despite the name, this function is not only a pure "make blend field" function; it behaves like a compact command dispatcher. The first argument selects an operation and the second argument provides that operation's parameter. Calls imported functions _emscripten_run_script_string() or _emscripten_run_script_int() depending on return value type to perform environment checks via evaluation of strings with eval() during specific calls. May call _emscripten_resize_heap() to grow and update memory views during _MakeBlendField(172, 36).

Every call used by BinCodec, their respective usage and strings evaluated during runtime is shown as follows:

CallUsageEvaluated Strings
_MakeBlendField(255, 140)Prepares the module before decoding the first PACKET_PRE_ENTER_WORLD challenge by setting chall_count to 0.-
_MakeBlendField(24, 132)Resets the decoder state before the input bytes are copied.-
_MakeBlendField(228, buffer.remaining())Returns a pointer to writable WASM memory where BinCodec copies the incoming challenge bytes. buffer.remaining() is usually 132; this call also stores the pointer and length for the later solve step.-
_MakeBlendField(172, 36)Solves the copied challenge and prepares the 64-byte PoW response. May call _emscripten_resize_heap() when challenge signals a memory grow.typeof window === "undefined" ? 1 : 0;
typeof process !== 'undefined' ? 1 : 0;
Game.currentGame.network.connected ? 1 : 0
Game.currentGame.network.connectionOptions.ipAddress
Game.currentGame.world.myUid === null ? 0 : Game.currentGame.world.myUid;
_MakeBlendField(4, 152)Returns a pointer to the 64-byte PoW response used by PACKET_ENTER_WORLD or PACKET_BLEND.document.getElementById("hud").children.length;
_MakeBlendField(187, 22)Returns a pointer to the 16-byte PACKET_ENTER_WORLD2 payload.-

WARNING

The numeric command values are taken from the bundled client and are not self-describing API constants. Treat them as version-specific WASM protocol details.

WASM Imports / Exports

INFO

The short names (a, b, c and g, h, i, etc.) are minified Emscripten import/export names. They are stable only for the analyzed generated file, not for every possible rebuild of zombs_wasm.wasm, as name shuffling has already happened more than once.

Imports

wasmImports is the JavaScript import object passed into the WASM instance. The generated wrapper places it under module namespace a:

ts
const info = {
    a: wasmImports
};

That means a WASM import written as (import "a" "d" ...) resolves to wasmImports.d in JavaScript. These imports let the compiled C++ code call back into JavaScript for browser/runtime services.

ImportJavaScript FunctionTypeDescription
a_abort_js() => voidAborts the Emscripten runtime.
b_emscripten_run_script_string(ptr: number) => numberRuns JavaScript from a UTF-8 string in WASM memory and returns a pointer to the string result.
c_emscripten_run_script_int(ptr: number) => numberRuns JavaScript from a UTF-8 string in WASM memory and returns the numeric result.
d_emscripten_get_now() => numberReturns performance.now(). Called by _main() to obtain seed for random number generation.
e_emscripten_resize_heap(requestedSize: number) => booleanAttempts to grow WASM linear memory and refreshes the heap views.
f__emscripten_memcpy_js(dest: number, src: number, num: number) => Uint8ArrayImplements memory copying through HEAPU8.copyWithin().

Exports

The generated script maps short WASM export names into readable Module properties:

WASM ExportModule WrapperTypeNotes
g-WebAssembly.MemoryLinear memory. updateMemoryViews() rebuilds all HEAP* views from this buffer.
h__wasm_call_ctors() => voidC/C++ static constructor hook registered by the generated wrapper.
i_main() => numberProgram entrypoint representing C/C++ main() function.
j_MakeBlendField(opcode: number, value: number) => numberMBF command dispatcher.
k-WebAssembly.TableFunction table used internally by the WASM instance.
l_malloc(size: number) => numberMemory allocator wrapper used by Emscripten helpers.
mstackSave() => numberSaves the stack pointer for temporary conversions.
nstackRestore(ptr: number) => voidRestores the stack pointer.
ostackAlloc(size: number) => numberAllocates temporary stack memory.

DANGER

Generated Emscripten helper paths can expect a wrapper representing the C/C++ free() function when replacing allocated memory, but the stock zombs_wasm.wasm used by the client does not provide a usable _free() export. See the reconnection bug described in _MakeBlendField/overview.

Data Interfaces

These interfaces are inferred from their usage by BinCodec.

MBF_COMMAND

ts
type MBF_COMMAND = 4 | 24 | 172 | 187 | 228 | 255;

_MakeBlendField accepts plain numbers, but only the command values above are visible in the client-side network path.

MBF_CHALLENGE

ts
interface MBF_CHALLENGE {
    opcode: 5 | 10,
    challenge: Uint8Array
}

Represents the 132-byte payload received from PACKET_PRE_ENTER_WORLD or PACKET_BLEND before it is copied into HEAPU8.

MBF_RESULT

ts
interface MBF_RESULT {
    extra: ArrayBuffer
}

Returned from BinCodec.decodePreEnterWorldResponse() and BinCodec.decodeBlend(). The extra buffer is 64 bytes long and is later sent back through PACKET_ENTER_WORLD or PACKET_BLEND.

ENTER_WORLD2_PAYLOAD

ts
type ENTER_WORLD2_PAYLOAD = Uint8Array;

The first 16 bytes at the pointer returned by _MakeBlendField(187, 22). BinCodec.encodeEnterWorld2() writes these bytes directly into a PACKET_ENTER_WORLD2 packet.