I was thinking something like that:
if (flags & FLAG_1) size = max(size, FIELDOFFSET(..) + ...); if (flags & FLAG_2) size = max(size, ...); if (cbSize < size) { SetLastError(...); return; }
To make it easier to read you can use just FIELDOFFSET() of the next field.
Thanks for the suggestion. It seems that it won't significantly improve readability or simplify the code, so I'd prefer to stick with my solution.
I think it's fine to duplicate that for A and W functions, and avoid changing Rtl* one at all, as long as we don't provide compatible interface for it, nothing is going to call it successfully anyway.
RtlCreateActivationContext() already performs the checks for the flags and structure field contents, so discussing where the checks belong is out of the scope of this MR. If you have justified reasons to doubt about current implementation feel free to add appropriate tests.