Changes all stack buffers using hardcoded sizes for CONTEXT to instead use heap-allocated buffers sized to match the kernel's actual CONTEXT size for the given flags.
Adds a mechanism to query the CONTEXT64 size from 32-bit DR using switch_modes_and_call().
The one place where we can't easily use heap is thread_set_self_mcontext() because it doesn't return and we thus do not have a simple way to free the buffer. There, we use a large 4096-byte stack buffer, and we check the size needed: if it's larger than that, we use a lost heap allocation and issue a debug build warning which should alert someone. If we end up needing more space there in the future we may want to store a pointer in the dcontext and have a special check to free it or something.
Fixes #2666 (closed)