The attached patch changes the screen depth request/advertisement sent by the client according to Microsoft protocol documentation MS-RDPBCGR.pdf pg. 32-37. Without the patch connecting to a 24bpp capable server with 32bpp will fallback to 8bpp (because highColorDepth has an invalid value of 32). WIth the patch we correctly set highColorDepth to 24bpp for fallback and signal 32bpp connection via earlyCapabilityFlags.
I am also falling back to 32bpp if 24bpp was requersted and the server only support 32bpp but not 24bpp (which should be the case if it's 32bpp capable). It could be arqued that falling back would mean 16bpp, but I find this behaviour closer to what the user expects.
I also fixed some fields that seemed to be wrongly setup when comparing with the M$ spec. Some stuff seemed wrongly positioned or byteswapped.
There also was an output of out_uint32_le(s, 1) that I removed - was that supposed to be the digital product id? It seemed out of place so I just kept that zeroed out.