terminal/src/host
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
..
exe Persist inbox conhost; delegate control activities to it via a pipe (#10415) 2021-06-16 19:23:37 +00:00
ft_fuzzer Add a Fuzzing configuration and a version of conhost that can be fuzzed (#9604) 2021-03-29 14:23:30 +00:00
ft_host Merged PR 6140256: Migrate OSS up to 94d39b758 2021-06-09 23:03:04 +00:00
ft_integrity Fix a bunch of spelling errors across the project (#4295) 2020-02-10 20:40:01 +00:00
ft_uia Enable /Zc:preprocessor (#10593) 2021-07-13 23:00:11 +00:00
lib Implement Default Terminal (#7489) 2021-03-26 17:09:49 -05:00
proxy Persist inbox conhost; delegate control activities to it via a pipe (#10415) 2021-06-16 19:23:37 +00:00
ut_host Make sure we terminate the expected title string (#10711) 2021-07-20 14:04:53 +00:00
ut_lib Unify and clean up the common build properties (#3429) 2019-11-05 14:29:11 -08:00
_output.cpp Skip accessibility notifier and all event calculations when we're in PTY mode (#10569) 2021-07-09 18:45:44 +00:00
_output.h Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
_stream.cpp Skip accessibility notifier and all event calculations when we're in PTY mode (#10569) 2021-07-09 18:45:44 +00:00
_stream.h WriteCharsLegacy: Add some notes in comments and rename WC_ECHO (#9605) 2021-03-24 16:26:50 -05:00
alias.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
alias.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
ApiRoutines.h Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
cmdline.cpp WriteCharsLegacy: Add some notes in comments and rename WC_ECHO (#9605) 2021-03-24 16:26:50 -05:00
cmdline.h WriteCharsLegacy: Add some notes in comments and rename WC_ECHO (#9605) 2021-03-24 16:26:50 -05:00
CommandListPopup.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
CommandListPopup.hpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
CommandNumberPopup.cpp WriteCharsLegacy: Add some notes in comments and rename WC_ECHO (#9605) 2021-03-24 16:26:50 -05:00
CommandNumberPopup.hpp Add explicit identifier to some constructors (#5652) 2020-04-29 16:50:47 -07:00
conapi.h Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
conareainfo.cpp Replace basic_string_view<T> with span<const T> (#6921) 2020-07-15 16:40:42 +00:00
conareainfo.h Improve the legacy color conversions (#6358) 2020-06-08 19:05:06 +00:00
conattrs.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
conddkrefs.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
conhost.rcv Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
conhostv2_traceviewpp.tvpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
conimeinfo.cpp Skip accessibility notifier and all event calculations when we're in PTY mode (#10569) 2021-07-09 18:45:44 +00:00
conimeinfo.h Replace basic_string_view<T> with span<const T> (#6921) 2020-07-15 16:40:42 +00:00
conserv.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
ConsoleArguments.cpp Fix startup race of resizing ConPTY (#10449) 2021-06-22 19:23:16 +00:00
ConsoleArguments.hpp Fix startup race of resizing ConPTY (#10449) 2021-06-22 19:23:16 +00:00
consoleInformation.cpp Eliminate more transient allocations: Titles and invalid rectangles and bitmap runs and utf8 conversions (#8621) 2021-02-16 20:52:33 +00:00
conv.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
convarea.cpp Make sure we don't hide the cursor until the IME starts (#7673) 2020-09-18 19:25:39 +00:00
conwinuserrefs.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
CopyFromCharPopup.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
CopyFromCharPopup.hpp Add explicit identifier to some constructors (#5652) 2020-04-29 16:50:47 -07:00
CopyToCharPopup.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
CopyToCharPopup.hpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
CursorBlinker.cpp Skip accessibility notifier and all event calculations when we're in PTY mode (#10569) 2021-07-09 18:45:44 +00:00
CursorBlinker.hpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
dbcs.cpp Replace gsl::at with a new til::at(span) for pre-checked bounds (#6925) 2020-07-15 10:29:36 -07:00
dbcs.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
directio.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
directio.h Switch all DSR responses to appending instead of prepending (#7583) 2020-09-09 23:55:22 +00:00
dirs Merged PR 5677497: [Git2Git] Merged PR 5655213: Allow conhost to handoff to registered default app handler 2021-02-11 21:07:50 +00:00
getset.cpp Skip accessibility notifier and all event calculations when we're in PTY mode (#10569) 2021-07-09 18:45:44 +00:00
getset.h OSC 8 support for conhost and terminal (#7251) 2020-09-03 13:52:39 -04:00
globals.cpp Implement a pair of shims for cls, Clear-Host in conpty mode (#5627) 2020-04-30 21:53:31 +00:00
globals.h Persist inbox conhost; delegate control activities to it via a pipe (#10415) 2021-06-16 19:23:37 +00:00
handle.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
handle.h Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
history.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
history.h Replace macros with constexpr part 2 (#3416) 2019-11-04 07:37:47 -06:00
host-common.vcxitems Implement Default Terminal (#7489) 2021-03-26 17:09:49 -05:00
IIoProvider.hpp Fix a bunch of spelling errors across the project (#4295) 2020-02-10 20:40:01 +00:00
init.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
init.hpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
input.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
input.h Replace macros with constexpr part 2 (#3416) 2019-11-04 07:37:47 -06:00
inputBuffer.cpp [Conpty] Pass through request for mouse mode to the Terminal (#9970) 2021-05-07 02:46:11 +00:00
inputBuffer.hpp [Conpty] Pass through request for mouse mode to the Terminal (#9970) 2021-05-07 02:46:11 +00:00
inputKeyInfo.cpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
inputReadHandleData.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
inputReadHandleData.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
misc.cpp #10497: Do not force the font on output codepage change (#10591) 2021-07-08 21:10:35 +00:00
misc.h WriteCharsLegacy: Add some notes in comments and rename WC_ECHO (#9605) 2021-03-24 16:26:50 -05:00
ntprivapi.cpp Change NULL to nullptr since they are pointers (#4960) 2020-03-20 20:35:12 +00:00
ntprivapi.hpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
output.cpp Add support for double-width/double-height lines in conhost (#8664) 2021-02-18 05:44:50 +00:00
output.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
outputStream.cpp Fix the cursor blink VT sequence being ignored (#10589) 2021-07-09 18:45:16 +00:00
outputStream.hpp Revert "Prevent the virtual viewport bottom being moved up unintentionally (#9770)" 2021-04-28 12:45:09 -05:00
popup.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
popup.h Improve the legacy color conversions (#6358) 2020-06-08 19:05:06 +00:00
precomp.cpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
precomp.h Reduce Transient Allocations during Bulk Text Output (#8617) 2021-01-05 18:06:06 +00:00
PtySignalInputThread.cpp Fix startup race of resizing ConPTY (#10449) 2021-06-22 19:23:16 +00:00
PtySignalInputThread.hpp Fix startup race of resizing ConPTY (#10449) 2021-06-22 19:23:16 +00:00
readData.cpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
readData.hpp Merged PR 6034984: Fix a crash caused by improper buffer management w/ multiple clients 2021-05-11 16:56:43 +00:00
readDataCooked.cpp Merged PR 6142815: OS build fixes on top of 94d39b758 2021-06-10 15:52:14 +00:00
readDataCooked.hpp Merged PR 6034984: Fix a crash caused by improper buffer management w/ multiple clients 2021-05-11 16:56:43 +00:00
readDataDirect.cpp Merged PR 6034984: Fix a crash caused by improper buffer management w/ multiple clients 2021-05-11 16:56:43 +00:00
readDataDirect.hpp Merged PR 6034984: Fix a crash caused by improper buffer management w/ multiple clients 2021-05-11 16:56:43 +00:00
readDataRaw.cpp Merged PR 6034984: Fix a crash caused by improper buffer management w/ multiple clients 2021-05-11 16:56:43 +00:00
readDataRaw.hpp Merged PR 6034984: Fix a crash caused by improper buffer management w/ multiple clients 2021-05-11 16:56:43 +00:00
registry.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
registry.hpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
renderData.cpp Eliminate more transient allocations: Titles and invalid rectangles and bitmap runs and utf8 conversions (#8621) 2021-02-16 20:52:33 +00:00
renderData.hpp Expose Text Attributes to UI Automation (#10336) 2021-07-09 23:21:35 +00:00
renderFontDefaults.cpp Allow FontInfo{,Base,Desired} to store a font name > 32 wch (#3107) 2019-10-14 21:23:45 -07:00
renderFontDefaults.hpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
res.rc Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
resource.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
runft.bat Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
runtests.bat Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
runut.bat Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
ScreenBufferRenderTarget.cpp Fix TerminalControl crash on exit (#10031) 2021-05-04 21:17:37 +00:00
ScreenBufferRenderTarget.hpp Fix TerminalControl crash on exit (#10031) 2021-05-04 21:17:37 +00:00
screenInfo.cpp Skip accessibility notifier and all event calculations when we're in PTY mode (#10569) 2021-07-09 18:45:44 +00:00
screenInfo.hpp Skip accessibility notifier and all event calculations when we're in PTY mode (#10569) 2021-07-09 18:45:44 +00:00
scrolling.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
scrolling.hpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
selection.cpp Skip accessibility notifier and all event calculations when we're in PTY mode (#10569) 2021-07-09 18:45:44 +00:00
selection.hpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
selectionInput.cpp Fix color selection operations in conhost (#8577) 2020-12-14 19:45:49 +00:00
selectionState.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
server.h Eliminate more transient allocations: Titles and invalid rectangles and bitmap runs and utf8 conversions (#8621) 2021-02-16 20:52:33 +00:00
settings.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
settings.hpp Add support for the "blink" graphic rendition attribute (#7490) 2020-09-21 23:21:33 +00:00
sources.inc Merged PR 6176782: [Git2Git] Get rid of dead build macros/#defines FE_IME, W32_SB, etc. 2021-06-21 10:50:52 -07:00
sources.test.inc Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
srvinit.cpp 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
srvinit.h Persist inbox conhost; delegate control activities to it via a pipe (#10415) 2021-06-16 19:23:37 +00:00
stream.cpp Fix building with v143 toolchain (#10727) 2021-07-20 19:00:49 +02:00
stream.h Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
telemetry.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
telemetry.hpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
tracing.cpp Reflect recent OS build changes, incl. a version of GH-10166 2021-06-09 22:57:38 +00:00
tracing.hpp Reflect recent OS build changes, incl. a version of GH-10166 2021-06-09 22:57:38 +00:00
utf8ToWideCharParser.cpp Fix a bunch of spelling errors across the project (#4295) 2020-02-10 20:40:01 +00:00
utf8ToWideCharParser.hpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
utils.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
utils.hpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
VtInputThread.cpp Add names to threads to make debugging a slight bit easier (#9801) 2021-04-14 10:56:52 +00:00
VtInputThread.hpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
VtIo.cpp [Conpty] Pass through request for mouse mode to the Terminal (#9970) 2021-05-07 02:46:11 +00:00
VtIo.hpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
writeData.cpp Merged PR 6034984: Fix a crash caused by improper buffer management w/ multiple clients 2021-05-11 16:56:43 +00:00
writeData.hpp Merged PR 6034984: Fix a crash caused by improper buffer management w/ multiple clients 2021-05-11 16:56:43 +00:00