Skip to content

v2.3.3-beta

Choose a tag to compare

@uesleibros uesleibros released this 06 May 21:51
· 225 commits to main since this release
c379c41

Wasabi v2.3.3-beta

What's New

High-Performance Assembly Engine (Wasabi ASM)

This release introduces a paradigm shift in VBA networking performance. We have successfully offloaded critical byte-processing bottlenecks from the interpreted VBA runtime directly to the CPU via Machine Code Thunks. Wasabi now executes native x86 and x64 instructions for heavy lifting, achieving C-level throughput.

Integrated Low-Level Thunks
  • ws_mask (Assembly): A complete rewrite of the WebSocket XOR masking logic. By eliminating the high-overhead VBA For...Next loops, payloads ranging from kilobytes to several megabytes are now masked in microseconds.
  • mem_zero (Assembly): Implements hardware-level memory zeroing using the rep stosb instruction. This provides a lightning-fast way to clear internal buffers without the overhead of external DLL calls.
  • mem_find (Assembly): An ultra-optimized "Needle in a Haystack" search engine powered by the repe cmpsb instruction. It allows Wasabi to scan massive TCP streams for delimiters almost instantaneously.
Core Engine Otimizations
  • Native Entropy via RtlGenRandom: Replaced the legacy CryptGenRandom (which required complex CSP context management) with the SystemFunction036 (RtlGenRandom) API. This fetches cryptographically secure random bytes for WebSocket masking directly from the Windows Kernel with significantly lower latency.
  • ASM-Powered TcpReceiveUntil: The blocking read-until-delimiter logic has been refactored to use the mem_find thunk. Searching for patterns like \r\n or custom binary delimiters no longer blocks the Office UI thread during large data transfers.
  • Proactive Buffer Sanitization: Updated the CleanupHandle routine to utilize the new mem_zero engine. Upon connection teardown, all sensitive buffers (recvBuffer, DecryptBuffer, TcpRecvBuffer) are physically zeroed in RAM to prevent data leakage and improve security.

Internal Architecture & Bug Fixes

  • Discord Gateway Fix (Error 4002): Resolved a critical race condition/logic bug where payload data was being XORed in-place over uninitialized memory segments. Introduced a dedicated copy-buffer step before masking to ensure full compatibility with Discord's strict frame validation.
  • Zero-Footprint Encapsulation: All assembly-related infrastructure (LoadThunk, WasabiMemFind, m_ptr* pointers) is now strictly Private. The engine complexity is completely abstracted away, leaving a clean, high-level API for the end user.
  • Binary Lifecycle Management: Added InitWasabiThunks and ShutdownWasabiThunks procedures. These manage the safe allocation of executable memory via VirtualAlloc with PAGE_EXECUTE_READWRITE permissions and ensure all allocated pages are freed immediately upon WSACleanup.
  • Dead Code Elimination (JIT Cleanup): Stripped legacy bitwise math functions (U32Shl1, SHR32, ROTL32, ADD32) and unused thunks like swap_32. This reduces the module size and minimizes the memory footprint.
  • Hardened SafeArrayLen: Improved the pointer-based array length detection. By using VarPtrArray and CopyMemoryFromPtr instead of On Error traps, the module is now significantly more stable when handling uninitialized dynamic arrays.

Validated

Full test suite executed on Windows 10/11 (x86 & x64) across Excel 365, Word, and Access:

Test Case Status Details
Discord IDENTIFY Masking ✅ Passed Resolved 4002 error; handshake stable.
Throughput (10MB Payload) ✅ Passed Masking overhead is now sub-millisecond.
Secure Wipe on Close ✅ Passed Verified RAM zeroing via memory dump.
TcpReceiveUntil Scanner ✅ Passed ASM scan found \r\n in 1MB buffer instantly.
x64 FastCall Alignment ✅ Passed Registers (RCX, RDX, R8, R9) verified stable.
x86 Stack Integrity ✅ Passed Ret 16 cleanup verified; no stack corruption.
Kernel Entropy ✅ Passed RtlGenRandom successfully seeding mask keys.

Tip

Performance Impact: With the Wasabi ASM Engine, processing overhead for the networking layer is now effectively "free" in terms of CPU cycles. This allows your VBA project to dedicate 100% of its execution time to your bot's logic or data processing rather than handling protocol-level math.