Handle Ctrl events (CTRL_C_EVENT, CTRL_BREAK_EVENT, CTRL_CLOSE_EVENT, CTRL_LOGOFF_EVENT, CTRL_SHUTDOWN_EVENT) by redirecting the termination into a WM_QUIT message so that the shutdown code is still executed.
| 151 | // CTRL_LOGOFF_EVENT, CTRL_SHUTDOWN_EVENT) by redirecting the termination into |
| 152 | // a WM_QUIT message so that the shutdown code is still executed. |
| 153 | static BOOL CALLBACK HandleCtrlEvent(DWORD ctrlType) |
| 154 | { |
| 155 | (void) ctrlType; |
| 156 | if (IsRecording()) { |
| 157 | StopRecording(); |
| 158 | } |
| 159 | ExitMainThread(); |
| 160 | |
| 161 | // The other threads are now shutting down but if we return the system may |
| 162 | // terminate the process before they complete, which may leave the trace |
| 163 | // session open. We could wait for shutdown confirmation, but this |
| 164 | // function is run in a separate thread so we just put it to sleep |
| 165 | // indefinately and let the application shut itself down. |
| 166 | Sleep(INFINITE); |
| 167 | return TRUE; // The signal was handled, don't call any other handlers |
| 168 | } |
| 169 | |
| 170 | // Handle window messages to toggle recording on/off |
| 171 | static LRESULT CALLBACK HandleWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
nothing calls this directly
no test coverage detected