Skip to content

v2.3.6-beta

Choose a tag to compare

@uesleibros uesleibros released this 10 May 02:25
· 118 commits to main since this release
01fa84a

Wasabi v2.3.6

This release brings a significant internal restructuring alongside a handful of meaningful behavioral changes. The public API surface stays largely compatible with v2.3.5, with the exception of two renamed functions. Most of what changed lives under the hood: a cleaner code layout, stronger cryptographic primitives, better documentation of internal structures, and a more stable foundation for the async system introduced in the previous cycle.

Breaking Changes

WebSocketSend renamed to WebSocketSendText
WebSocketReceive renamed to WebSocketReceiveText

The old names are no longer present. This rename was made to align with the binary counterparts (WebSocketSendBinary, WebSocketReceiveBinary) and make the intent of each function unambiguous at a glance. A global find-and-replace in any workbook that calls these functions is all that's needed.

Security

Replaced RtlGenRandom with BCryptGenRandom

The internal random byte generation used for WebSocket frame masking keys previously called RtlGenRandom (exported from advapi32.dll under the undocumented alias SystemFunction036). This worked fine in practice, but relying on an undocumented export is not something to depend on long-term. The call now goes through BCryptGenRandom from bcrypt.dll with the BCRYPT_USE_SYSTEM_PREFERRED_RNG flag, which is the documented, supported path for cryptographically strong random bytes on Windows Vista and later. The behavior is identical from the outside; this is purely an internal correctness improvement.

Async Event-Driven Model (Experimental)

This feature is experimental. The underlying mechanism involves native Win32 window subclassing via a machine-code thunk, which comes with some hard constraints you need to be aware of before using it in production.

The async model introduced in the previous release is now better documented and stabilized, but the subclassing mechanism still has sharp edges:

Do not edit code in the VBE while an async connection is active. Doing so will crash the host application. The thunk holds a pointer into the VBA runtime, and the VBE's project reset path does not give Wasabi a chance to clean up before tearing down the runtime.

Do not use the Pause button (yellow square) in the VBE while async is running. This also triggers a project reset and will cause a crash for the same reason.

The correct way to stop an async session is either:

  • Calling WebSocketDisconnect or WebSocketDisconnectAll from your code, which properly unregisters the socket from WSAAsyncSelect, restores the original window procedure, destroys the hidden window, and releases the thunk memory.
  • Clicking the Reset button (blue square) in the VBE, but only after calling one of the disconnect functions first. Clicking Reset without disconnecting first is unsafe.

The thunk contains a guard that attempts to detect whether the VBA runtime is still alive before dispatching, but explicit cleanup is the only reliable approach. Treat this the same way you would treat any unmanaged resource.

Everything else about the async model works as described in the API reference. The handler object must be stored at module or workbook level, the five callback methods must be implemented, and the connection must already be established before calling WasabiUseAsync.

Code Organization

The module was reorganized into a numbered section layout to make navigation easier in the VBE, which does not have a file outline view:

1.  API Declarations
2.  Constants
3.  Types & Structs
4.  Enums
5.  Global Variables
6.  Low-Level Memory & Thunks
7.  Windows Messaging & Async Core
8.  Time & Buffer Utilities
9.  Connection Pool Management
10. Network Infrastructure (MTU, Proxy, TCP, Certificates)
11. WebSocket Protocol Core
12. TCP/Buffering Core
13. MQTT Protocol Core
14. Middleware & Queueing
15. Public APIs (TCP, WebSocket, MQTT, Compression)

This is a pure organizational change. No logic was moved or modified as part of the restructure; the diff between sections only reflects repositioned declarations and renamed groupings.

All constants, enums, and type definitions were also moved into their respective sections rather than being scattered. WasabiError, MqttPacketType, and WasabiConnectionMode now live in section 4 alongside the other enums. Constants like BUFFER_SIZE, MSG_QUEUE_SIZE, and the socket/TLS/crypto constants are now grouped under section 2 with comments indicating which subsystem they belong to.

Internal Documentation

All private types, structs, and key functions now carry JSDoc-style block comments describing their purpose and fields. This is primarily useful if you ever need to read or modify the internals, and it also makes it easier to follow the data flow between the TLS, WebSocket, and MQTT layers when something goes wrong and you need to trace it.

The license header was also updated to JSDoc block format for consistency with the rest of the file.

Fixes and Minor Improvements

INVALID_SOCKET is now declared once per compilation target (64-bit or 32-bit) at the top of the global variables section, removing the redundant #If VBA7 block that previously re-declared it mid-file.

The HOSTENT64 type declaration was moved to the types section alongside HOSTENT32, where it belongs. Previously it was declared much later in the file, away from the other network structs.

The BCRYPT_USE_SYSTEM_PREFERRED_RNG constant is now explicitly declared rather than inlined as a magic number, consistent with how every other Win32 constant is handled in the module.

Notes on Upgrading from v2.3.5

The only change that will break existing code is the rename of WebSocketSend and WebSocketReceive. Everything else is either internal or additive. If your code does not call either of those two functions directly, upgrading is a drop-in replacement.