There are only two options: only pass the number of bytes requested or return an error for unreasonable sizes. What is Terminal Server doing?
It's returning an error.
And what is the error? If you know the error code returned, Ill add it to the code so we can end this discussion.
waveOutGetDevCapsW lets the driver do the copy (just like old versions of windows). The driver should be checking the size and only copying that much. If it doesn't, then it broken.
Any references for this claim?
Read the code.
You are saying that the driver "should only copy that much", but *what* should it copy? In other words: If the size doesn't match the size of any known structure (WAVEOUTCAPSA/WAVEOUTCAPSW/WAVEOUTCAPS2A/WAVEOUTCAPS2W), should the driver then just *assume* some structure? Which one? As far as I know, there's no guarantee that, for example, the first sizeof(WAVEOUTCAPSW) bytes of WAVEOUTCAPSW are the same as WAVEOUTCAPS2W.
Again, read the code. WAVEOUTCAPS2 is a superset of WAVEOUTCAPS so it doesn't matter when the length is shorter than WAVEOUTCAPS. The drivers only support W so mixing A and W is not an issue.