On Mon Aug 4 21:56:36 2025 +0000, Alfred Agrell wrote:
Could try something like
union hstring_wire { struct { ULONG context; } repr1; struct { ULONG context; ULONG size; WCHAR data[]; } repr2; struct { ULONG context; #ifdef _WIN64 ULONG pad; #endif HSTRING str; } repr3; };
and you can read context from any of the members; https://en.cppreference.com/w/c/language/union.html says it will be type-punned, which doesn't do a whole lot of anything when it's ULONG already. (Or you can simply omit the padding member completely, and the compiler will insert the padding if needed. Does winehq have any policy on whether padding members should be explicit?)
I think this will already produce expected padding on 64-bit.
``` struct { ULONG context; HSTRING str; }; ```
If it gets too ugly to have a single structure, I don't see a problem in having two separate types.