} // end _GuestModeMainWrapper() private static int _GuestModeCleanup() { if (null == sm_altMainThread) { // Nothing to do. (I guess we were never started.) Util.Fail("currently not possible, therefore not tested"); } else { // We already have an alternate main thread, which is "paused" (blocked), // waiting to resume. Before we unblock it, we'll set this bit to let it // know that it should actually exit. DbgProvider.GuestModeTimeToExitAllTheWay = true; DbgProvider.GuestModeResume(); LogManager.Trace("Waiting for the DbgShell main thread."); sm_altMainThread.Join(); LogManager.Trace("_AltMainThread finished."); // Calling GuestModeFinalCleanup works even though we don't fire up the // DbgEngThread because the current thread has already been marked as the // thread that DbgEngThread's pump runs on, so it just runs synchronously. DbgProvider.GuestModeFinalCleanup(); } return(sm_exitCode); } // end _GuestModeCleanup()