terminal/src
Michael Niksa 41ade2c57e
Pass inbound handoff message via heap so it cannot race out of scope by the time it reaches the ConsoleIoThread (#10751)
Pass inbound handoff message via heap so it cannot race out of scope by the time it reaches the ConsoleIoThread

## PR Checklist
* [x] Closes #10251
* [x] I work here.
* [x] Manually verified somewhat

## Detailed Description of the Pull Request / Additional comments
- `OpenConsole.exe` is started in response to the OS `conhost.exe` request for a handoff and prepares an Out Of Proc Multithreaded COM server.
- A COM thread from the pool inside `OpenConsole.exe` picks up the inbound message and allocates some stack space for the `CONSOLE_API_MSG` coming in
- That COM thread calls down to set up the I/O thread that will pump the console driver handle and passes a pointer to the stack-allocated `CONSOLE_API_MSG` as the `LPVOID` parameter for starting the thread.

Now one of two things happen:
1. The I/O thread is scheduled pretty much immediately (or soon enough that the COM thread hasn't messed with the stack space), picks up the pointer to the COM thread's stack with `CONSOLE_API_MSG`, and processes the initial message correctly.
2. The COM thread continues and finalizes the handoff message to `conhost.exe` declaring success. It then pops stack and "frees" the memory space. If it doesn't manage to overwrite it, we're still good. If it does, then things go crazy.

This fix changes it so that the `CONSOLE_API_MSG` is sent into the heap before being passed to the other thread so it's in a known location that won't be freed or overwritten unexpectedly.

## Validation Steps Performed
- [x] - Confirmed that many handoffs from the run box seem to work alright on my system after this change.
- [x] - Confirmed that many tab creations/splits seem to work alright on my system after this change.
- [x] - Would prefer if @ianjoneill could try to F5 this branch to build/deploy it, set it as default, and see if it makes it go away completely... but I'm pretty confident it is this based on the dumps provided either way.
2021-07-22 12:51:30 +00:00
..
api-ms-win-core-synch-l1-2-0 Introduce a api-ms-win-core-synch-l1-2-0 shim for Windows 7 (#10559) 2021-07-07 16:48:28 +00:00
buffer Fix building with v143 toolchain (#10727) 2021-07-20 19:00:49 +02:00
cascadia Don't auto-generate the hidden field when creating profile stubs (#10714) 2021-07-21 22:41:11 +00:00
dep
host Pass inbound handoff message via heap so it cannot race out of scope by the time it reaches the ConsoleIoThread (#10751) 2021-07-22 12:51:30 +00:00
inc Release unneeded memory more eagerly from conhost (#10738) 2021-07-21 05:59:57 +00:00
interactivity Fix building with v143 toolchain (#10727) 2021-07-20 19:00:49 +02:00
internal Implement Default Terminal (#7489) 2021-03-26 17:09:49 -05:00
propsheet Merged PR 6176782: [Git2Git] Get rid of dead build macros/#defines FE_IME, W32_SB, etc. 2021-06-21 10:50:52 -07:00
propslib Merged PR 6176782: [Git2Git] Get rid of dead build macros/#defines FE_IME, W32_SB, etc. 2021-06-21 10:50:52 -07:00
renderer Fix building with v143 toolchain (#10727) 2021-07-20 19:00:49 +02:00
server Release unneeded memory more eagerly from conhost (#10738) 2021-07-21 05:59:57 +00:00
staging Merged PR 6147892: Make til::feature build in the OS 2021-06-11 17:57:36 +00:00
terminal Don't override success value when resetting mouse mode in hard reset (#10661) 2021-07-14 16:46:34 +00:00
testlist Reflect testlist change from OS 2021-03-29 15:24:43 -05:00
til Introduce vk() and sc() key chord specifiers (#10666) 2021-07-20 22:34:51 +00:00
tools Upgrade Windows SDK to 19041 (#10118) 2021-05-20 16:04:25 +00:00
tsf Merged PR 6176782: [Git2Git] Get rid of dead build macros/#defines FE_IME, W32_SB, etc. 2021-06-21 10:50:52 -07:00
types Expose Text Attributes to UI Automation (#10336) 2021-07-09 23:21:35 +00:00
winconpty [Defapp] Use real HPCON for PTY management; Have Monarch always listen for connections (#10170) 2021-05-24 21:56:46 +00:00
common.build.post.props Add support for branch- and branding-based feature flagging (#10361) 2021-06-10 23:09:52 +00:00
common.build.pre.props Enable incremental linking for debug builds (#10342) 2021-06-04 23:52:49 +00:00
common.build.tests.props Enable /Zc:preprocessor (#10593) 2021-07-13 23:00:11 +00:00
common.pgo.compile.props Implement PGO in pipelines for AMD64 architecture; supply training test scenarios (#10071) 2021-05-13 21:12:30 +00:00
common.pgo.runtime.props Implement PGO in pipelines for AMD64 architecture; supply training test scenarios (#10071) 2021-05-13 21:12:30 +00:00
ConsolePerf.regions.xml
ConsolePerf.wprp Set keyword flags on all tracelog events (#10098) 2021-05-14 23:14:26 +00:00
cppwinrt.build.post.props Update C++/WinRT to 2.0.210309.3 (#9437) 2021-03-10 16:04:59 -06:00
cppwinrt.build.pre.props Enable /Zc:preprocessor (#10593) 2021-07-13 23:00:11 +00:00
dirs Merged PR 6147892: Make til::feature build in the OS 2021-06-11 17:57:36 +00:00
features.xml Allow creating and editing unfocused appearances in the SUI (#10317) 2021-07-13 23:33:22 +00:00
project.inc Merged PR 6147892: Make til::feature build in the OS 2021-06-11 17:57:36 +00:00
project.unittest.inc Merged PR 4915530: Reflect OS Build fixes on top of 58f5d7c7 2020-07-13 23:00:53 +00:00
StaticAnalysis.ruleset Fix SA for Visual Studio 16.8 (#8551) 2020-12-11 05:04:30 +00:00
Terminal.wprp Set keyword flags on all tracelog events (#10098) 2021-05-14 23:14:26 +00:00
unit.tests.x64.runsettings
unit.tests.x86.runsettings
wap-common.build.post.props
wap-common.build.pre.props Fix compilation with VS16.10 and later (#10208) 2021-05-26 20:11:38 +00:00