From 9fcb622f2ed7bd4a2ac9ed96140fd4c9e69c3a77 Mon Sep 17 00:00:00 2001 From: Acidfire Date: Thu, 8 Dec 2011 14:58:19 +0100 Subject: [PATCH 1/7] Added aboutbox to recovery menu and added stubs for explorer --- litestep/RecoveryMenu.cpp | 18 ++++++++++++++++++ litestep/litestep.rc | 2 ++ litestep/resource.h | 2 ++ 3 files changed, 22 insertions(+) diff --git a/litestep/RecoveryMenu.cpp b/litestep/RecoveryMenu.cpp index 81c511b..11084d6 100644 --- a/litestep/RecoveryMenu.cpp +++ b/litestep/RecoveryMenu.cpp @@ -37,6 +37,8 @@ #define ID_TERMINATE 3 #define ID_RUN 4 #define ID_SHUTDOWN 5 +#define ID_EXPLORER 6 +#define ID_ABOUT 7 const TCHAR szRecoveryMenuWndClass[] = _T("RecoveryMenuWndClass"); @@ -56,8 +58,10 @@ rgMenuCommands[] = \ { IDS_LITESTEP_RECYCLELS, ID_RECYCLE, "Re&cycle LiteStep" } ,{ IDS_LITESTEP_QUITLS, ID_QUIT, "&Quit LiteStep" } ,{ IDS_LITESTEP_TERMINATELS, ID_TERMINATE, "Forcibly &Terminate LiteStep" } + ,{ IDS_LITESTEP_ABOUTLS, ID_ABOUT, "&About LiteStep" } ,{ 0, -1, "" } ,{ IDS_LITESTEP_RUN, ID_RUN, "&Run..." } + ,{ IDS_LITESTEP_EXPLORER, ID_EXPLORER, "&Start Explorer as shell" } ,{ 0, -1, "" } ,{ IDS_LITESTEP_SHUTDOWNWIN, ID_SHUTDOWN, "Sh&utdown Windows..." } }; @@ -344,6 +348,14 @@ void RecoveryMenu::HandleMenuCommand(int nCommand) const PostMessage(GetLitestepWnd(), LM_RECYCLE, LR_QUIT, 0); } break; + + case ID_ABOUT: + { + // ditto + LMBANGCOMMAND cds = {sizeof(LMBANGCOMMAND), NULL, "!about", NULL}; + PostMessage(GetLitestepWnd(), LM_BANGCOMMAND, 0, (LPARAM)&cds); + } + break; case ID_TERMINATE: { @@ -362,6 +374,12 @@ void RecoveryMenu::HandleMenuCommand(int nCommand) const fnRunDlg(NULL, NULL, NULL, NULL, NULL, 0); } break; + + case ID_EXPLORER: + { + // todo + } + break; case ID_SHUTDOWN: { diff --git a/litestep/litestep.rc b/litestep/litestep.rc index 4eb04e3..4ad9f82 100644 --- a/litestep/litestep.rc +++ b/litestep/litestep.rc @@ -210,6 +210,8 @@ BEGIN IDS_LITESTEP_RUN "&Run..." IDS_LITESTEP_SHUTDOWNWIN "Sh&utdown Windows..." IDS_MODULEQUIT_ERROR "Exception while quitting module." + IDS_LITESTEP_ABOUTLS "&About LiteStep" + IDS_LITESTEP_EXPLORER "&Start Explorer as shell" END STRINGTABLE diff --git a/litestep/resource.h b/litestep/resource.h index 91daa8b..523017b 100644 --- a/litestep/resource.h +++ b/litestep/resource.h @@ -29,6 +29,8 @@ #define IDS_MATHEXCEPTION 25 #define IDS_LSAPI_INIT_ERROR 26 #define IDS_LITESTEP_INIT_ERROR 27 +#define IDS_LITESTEP_ABOUTLS 28 +#define IDS_LITESTEP_EXPLORER 29 #define IDI_LS 101 #define IDB_LS 102 #define IDD_ABOUTBOX 103 From 5e3a8ce526181a3baf91b6ee5735527b241a4388 Mon Sep 17 00:00:00 2001 From: Acidfire Date: Wed, 21 Dec 2011 23:06:14 +0100 Subject: [PATCH 2/7] Added Explorer exit path --- litestep/RecoveryMenu.cpp | 13 +++--- litestep/WinMain.cpp | 91 +++++++++++++++++++++++---------------- litestep/litestep.cpp | 6 +++ lsapi/lsapidefines.h | 1 + 4 files changed, 67 insertions(+), 44 deletions(-) diff --git a/litestep/RecoveryMenu.cpp b/litestep/RecoveryMenu.cpp index 11084d6..78137ee 100644 --- a/litestep/RecoveryMenu.cpp +++ b/litestep/RecoveryMenu.cpp @@ -356,6 +356,13 @@ void RecoveryMenu::HandleMenuCommand(int nCommand) const PostMessage(GetLitestepWnd(), LM_BANGCOMMAND, 0, (LPARAM)&cds); } break; + + case ID_EXPLORER: + { + // ditto + PostMessage(GetLitestepWnd(), LM_RECYCLE, LR_EXPLORER, 0); + } + break; case ID_TERMINATE: { @@ -374,12 +381,6 @@ void RecoveryMenu::HandleMenuCommand(int nCommand) const fnRunDlg(NULL, NULL, NULL, NULL, NULL, 0); } break; - - case ID_EXPLORER: - { - // todo - } - break; case ID_SHUTDOWN: { diff --git a/litestep/WinMain.cpp b/litestep/WinMain.cpp index 0b30971..583335f 100644 --- a/litestep/WinMain.cpp +++ b/litestep/WinMain.cpp @@ -276,58 +276,73 @@ int WINAPI _tWinMain(HINSTANCE hInst, HINSTANCE, LPTSTR lpCmdLine, int) wStartFlags |= LSF_RUN_EXPLORER; wStartFlags &= ~LSF_RUN_STARTUPAPPS; } - - if (wStartFlags & LSF_RUN_EXPLORER) - { - // - // Mode 2: (Try to) start Explorer - // - if (StartExplorerShell(EXPLORER_WAIT_TIMEOUT)) - { - // Explorer started as shell, no need try LiteStep as well - wStartFlags &= ~LSF_RUN_LITESTEP; - } - else - { - wStartFlags &= ~LSF_RUN_EXPLORER; - } - } - - if (wStartFlags & LSF_RUN_LITESTEP) + + bool bLoop = true; + while (bLoop) { - HANDLE hMutex = NULL; - - if (IsOtherInstanceRunning(&hMutex)) + // Loop back here if explorer is requested as the shell + // while LiteStep is already running + bLoop = false; + + if (wStartFlags & LSF_RUN_EXPLORER) { // - // Mode 3a: Other LiteStep instance already running + // Mode 2: (Try to) start Explorer // - RESOURCE_STR(hInst, IDS_LITESTEP_ERROR1, - "A previous instance of LiteStep was detected.\n" - "Are you sure you want to continue?"); - - // Can show a MessageBox here since the other instance - // should have closed the welcome screen already - INT idConfirm = RESOURCE_MSGBOX_F( - "LiteStep", MB_ICONINFORMATION | MB_YESNO | MB_DEFBUTTON2); - - if (idConfirm == IDNO) + if (StartExplorerShell(EXPLORER_WAIT_TIMEOUT)) { + // Explorer started as shell, no need try LiteStep as well wStartFlags &= ~LSF_RUN_LITESTEP; } + else + { + wStartFlags &= ~LSF_RUN_EXPLORER; + } } if (wStartFlags & LSF_RUN_LITESTEP) { - // - // Mode 3b: Start the shell! - // - nReturn = StartLitestep(hInst, wStartFlags, szAltConfigFile); + HANDLE hMutex = NULL; + + if (IsOtherInstanceRunning(&hMutex)) + { + // + // Mode 3a: Other LiteStep instance already running + // + RESOURCE_STR(hInst, IDS_LITESTEP_ERROR1, + "A previous instance of LiteStep was detected.\n" + "Are you sure you want to continue?"); + + // Can show a MessageBox here since the other instance + // should have closed the welcome screen already + INT idConfirm = RESOURCE_MSGBOX_F( + "LiteStep", MB_ICONINFORMATION | MB_YESNO | MB_DEFBUTTON2); + + if (idConfirm == IDNO) + { + wStartFlags &= ~LSF_RUN_LITESTEP; + } + } + + if (wStartFlags & LSF_RUN_LITESTEP) + { + // + // Mode 3b: Start the shell! + // + nReturn = StartLitestep(hInst, wStartFlags, szAltConfigFile); + } + + if (hMutex) + { + CloseHandle(hMutex); + } } - if (hMutex) + if ((nReturn == 4) && !(wStartFlags & LSF_RUN_EXPLORER)) { - CloseHandle(hMutex); + // User wants Explorer as the shell anyway + wStartFlags |= LSF_RUN_EXPLORER; + bLoop = true; } } } diff --git a/litestep/litestep.cpp b/litestep/litestep.cpp index 78870ed..f90f62c 100644 --- a/litestep/litestep.cpp +++ b/litestep/litestep.cpp @@ -906,6 +906,12 @@ LRESULT CLiteStep::InternalWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l PostQuitMessage(0); } break; + + case LR_EXPLORER: + { + PostQuitMessage(4); + } + break; default: // wParam == LR_MSSHUTDOWN { diff --git a/lsapi/lsapidefines.h b/lsapi/lsapidefines.h index db77329..7c6eb95 100644 --- a/lsapi/lsapidefines.h +++ b/lsapi/lsapidefines.h @@ -233,6 +233,7 @@ typedef struct LSDESKTOPINFO #define LR_LOGOFF 1 #define LR_QUIT 2 #define LR_MSSHUTDOWN 3 +#define LR_EXPLORER 4 //----------------------------------------------------------------------------- From f4e54b52e0dad6a63fc4cce3c1fcdad1d42ac32a Mon Sep 17 00:00:00 2001 From: Acidfire Date: Thu, 22 Dec 2011 16:38:56 +0100 Subject: [PATCH 3/7] Whitespace and varname cleanup --- litestep/RecoveryMenu.cpp | 30 +++++++++++++++--------------- litestep/litestep.rc | 4 ++-- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/litestep/RecoveryMenu.cpp b/litestep/RecoveryMenu.cpp index 78137ee..2bfbeed 100644 --- a/litestep/RecoveryMenu.cpp +++ b/litestep/RecoveryMenu.cpp @@ -58,10 +58,10 @@ rgMenuCommands[] = \ { IDS_LITESTEP_RECYCLELS, ID_RECYCLE, "Re&cycle LiteStep" } ,{ IDS_LITESTEP_QUITLS, ID_QUIT, "&Quit LiteStep" } ,{ IDS_LITESTEP_TERMINATELS, ID_TERMINATE, "Forcibly &Terminate LiteStep" } - ,{ IDS_LITESTEP_ABOUTLS, ID_ABOUT, "&About LiteStep" } + ,{ IDS_LITESTEP_ABOUTLS, ID_ABOUT, "&About LiteStep" } ,{ 0, -1, "" } ,{ IDS_LITESTEP_RUN, ID_RUN, "&Run..." } - ,{ IDS_LITESTEP_EXPLORER, ID_EXPLORER, "&Start Explorer as shell" } + ,{ IDS_LITESTEP_EXPLORER, ID_EXPLORER, "&Start Explorer as shell" } ,{ 0, -1, "" } ,{ IDS_LITESTEP_SHUTDOWNWIN, ID_SHUTDOWN, "Sh&utdown Windows..." } }; @@ -349,20 +349,20 @@ void RecoveryMenu::HandleMenuCommand(int nCommand) const } break; - case ID_ABOUT: - { - // ditto - LMBANGCOMMAND cds = {sizeof(LMBANGCOMMAND), NULL, "!about", NULL}; - PostMessage(GetLitestepWnd(), LM_BANGCOMMAND, 0, (LPARAM)&cds); - } - break; - - case ID_EXPLORER: - { - // ditto + case ID_ABOUT: + { + // ditto + LMBANGCOMMAND lmbc = {sizeof(LMBANGCOMMAND), NULL, "!about", NULL}; + PostMessage(GetLitestepWnd(), LM_BANGCOMMAND, 0, (LPARAM)&lmbc); + } + break; + + case ID_EXPLORER: + { + // ditto PostMessage(GetLitestepWnd(), LM_RECYCLE, LR_EXPLORER, 0); - } - break; + } + break; case ID_TERMINATE: { diff --git a/litestep/litestep.rc b/litestep/litestep.rc index 4ad9f82..853bf3c 100644 --- a/litestep/litestep.rc +++ b/litestep/litestep.rc @@ -210,8 +210,8 @@ BEGIN IDS_LITESTEP_RUN "&Run..." IDS_LITESTEP_SHUTDOWNWIN "Sh&utdown Windows..." IDS_MODULEQUIT_ERROR "Exception while quitting module." - IDS_LITESTEP_ABOUTLS "&About LiteStep" - IDS_LITESTEP_EXPLORER "&Start Explorer as shell" + IDS_LITESTEP_ABOUTLS "&About LiteStep" + IDS_LITESTEP_EXPLORER "&Start Explorer as shell" END STRINGTABLE From 111a5db1a198e507ba2ce0aa68818368989ab5a6 Mon Sep 17 00:00:00 2001 From: Acidfire Date: Fri, 23 Dec 2011 09:59:16 +0100 Subject: [PATCH 4/7] Fixed more whitespace issues --- litestep/RecoveryMenu.cpp | 6 +++--- litestep/WinMain.cpp | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/litestep/RecoveryMenu.cpp b/litestep/RecoveryMenu.cpp index 2bfbeed..9fa36e1 100644 --- a/litestep/RecoveryMenu.cpp +++ b/litestep/RecoveryMenu.cpp @@ -351,9 +351,9 @@ void RecoveryMenu::HandleMenuCommand(int nCommand) const case ID_ABOUT: { - // ditto - LMBANGCOMMAND lmbc = {sizeof(LMBANGCOMMAND), NULL, "!about", NULL}; - PostMessage(GetLitestepWnd(), LM_BANGCOMMAND, 0, (LPARAM)&lmbc); + // ditto + LMBANGCOMMAND lmbc = {sizeof(LMBANGCOMMAND), NULL, "!about", NULL}; + PostMessage(GetLitestepWnd(), LM_BANGCOMMAND, 0, (LPARAM)&lmbc); } break; diff --git a/litestep/WinMain.cpp b/litestep/WinMain.cpp index 583335f..831b24e 100644 --- a/litestep/WinMain.cpp +++ b/litestep/WinMain.cpp @@ -312,18 +312,18 @@ int WINAPI _tWinMain(HINSTANCE hInst, HINSTANCE, LPTSTR lpCmdLine, int) RESOURCE_STR(hInst, IDS_LITESTEP_ERROR1, "A previous instance of LiteStep was detected.\n" "Are you sure you want to continue?"); - + // Can show a MessageBox here since the other instance // should have closed the welcome screen already INT idConfirm = RESOURCE_MSGBOX_F( "LiteStep", MB_ICONINFORMATION | MB_YESNO | MB_DEFBUTTON2); - + if (idConfirm == IDNO) { wStartFlags &= ~LSF_RUN_LITESTEP; } } - + if (wStartFlags & LSF_RUN_LITESTEP) { // @@ -331,7 +331,7 @@ int WINAPI _tWinMain(HINSTANCE hInst, HINSTANCE, LPTSTR lpCmdLine, int) // nReturn = StartLitestep(hInst, wStartFlags, szAltConfigFile); } - + if (hMutex) { CloseHandle(hMutex); From 46869a9d22a5c03db79b0f22c80d7ff0cde13cfd Mon Sep 17 00:00:00 2001 From: Acidfire Date: Fri, 23 Dec 2011 11:09:03 +0100 Subject: [PATCH 5/7] Defined exit codes and more cleanup --- litestep/WinMain.cpp | 16 +++++++++------- litestep/litestep.cpp | 6 +++--- utility/shellhlp.cpp | 2 +- utility/shellhlp.h | 11 +++++++++++ 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/litestep/WinMain.cpp b/litestep/WinMain.cpp index 831b24e..13a1e28 100644 --- a/litestep/WinMain.cpp +++ b/litestep/WinMain.cpp @@ -276,14 +276,13 @@ int WINAPI _tWinMain(HINSTANCE hInst, HINSTANCE, LPTSTR lpCmdLine, int) wStartFlags |= LSF_RUN_EXPLORER; wStartFlags &= ~LSF_RUN_STARTUPAPPS; } - - bool bLoop = true; - while (bLoop) + + bool bLoop; + do { // Loop back here if explorer is requested as the shell // while LiteStep is already running - bLoop = false; - + if (wStartFlags & LSF_RUN_EXPLORER) { // @@ -303,7 +302,7 @@ int WINAPI _tWinMain(HINSTANCE hInst, HINSTANCE, LPTSTR lpCmdLine, int) if (wStartFlags & LSF_RUN_LITESTEP) { HANDLE hMutex = NULL; - + if (IsOtherInstanceRunning(&hMutex)) { // @@ -338,13 +337,16 @@ int WINAPI _tWinMain(HINSTANCE hInst, HINSTANCE, LPTSTR lpCmdLine, int) } } - if ((nReturn == 4) && !(wStartFlags & LSF_RUN_EXPLORER)) + bLoop = false; + + if ((nReturn == LRV_EXPLORER_START) && !(wStartFlags & LSF_RUN_EXPLORER)) { // User wants Explorer as the shell anyway wStartFlags |= LSF_RUN_EXPLORER; bLoop = true; } } + while (bLoop); } return nReturn; diff --git a/litestep/litestep.cpp b/litestep/litestep.cpp index f90f62c..b5965a5 100644 --- a/litestep/litestep.cpp +++ b/litestep/litestep.cpp @@ -147,7 +147,7 @@ int StartLitestep(HINSTANCE hInst, WORD wStartFlags, LPCTSTR pszAltConfigFile) if (FAILED(GetAppPath(szAppPath, COUNTOF(szAppPath)))) { // something really crappy is going on. - return -1; + return LRV_NO_APP_PATH; } if (wStartFlags & LSF_ALTERNATE_CONFIG) @@ -195,7 +195,7 @@ int StartLitestep(HINSTANCE hInst, WORD wStartFlags, LPCTSTR pszAltConfigFile) RESOURCE_MSGBOX_F("LiteStep", MB_ICONERROR); - return 2; + return LRV_NO_STEP; } // Initialize the LSAPI. Note: The LSAPI controls the bang and settings @@ -205,7 +205,7 @@ int StartLitestep(HINSTANCE hInst, WORD wStartFlags, LPCTSTR pszAltConfigFile) RESOURCE_MSGBOX(hInst, IDS_LSAPI_INIT_ERROR, "Failed to initialize the LiteStep API.", "LiteStep"); - return 3; + return LRV_LSAPI_FAIL; } // All child processes get this variable diff --git a/utility/shellhlp.cpp b/utility/shellhlp.cpp index 0c919cd..9585aab 100644 --- a/utility/shellhlp.cpp +++ b/utility/shellhlp.cpp @@ -405,7 +405,7 @@ void LSShutdownDialog(HWND hWnd) (GetAsyncKeyState(VK_CONTROL) & 0x8000) && (GetAsyncKeyState(VK_MENU) & 0x8000)) { - PostQuitMessage(1); + PostQuitMessage(LRV_SHUTDOWN_DLG); } } } diff --git a/utility/shellhlp.h b/utility/shellhlp.h index 0284f49..13da5f8 100644 --- a/utility/shellhlp.h +++ b/utility/shellhlp.h @@ -68,6 +68,17 @@ HANDLE LSActivateActCtxForDll(LPCTSTR pszDll, PULONG_PTR pulCookie); HANDLE LSActivateActCtxForClsid(REFCLSID rclsid, PULONG_PTR pulCookie); void LSDeactivateActCtx(HANDLE hActCtx, ULONG_PTR* pulCookie); +//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +// +// Litestep Return Values (LRV) +// +#define LRV_NO_APP_PATH -1 +#define LRV_OK 0 // is also S_OK from WinError +#define LRV_SHUTDOWN_DLG 1 +#define LRV_NO_STEP 2 +#define LRV_LSAPI_FAIL 3 +#define LRV_EXPLORER_START 4 + //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // From 9353acd81d305c70f9fddf39a2b028a0b8d55128 Mon Sep 17 00:00:00 2001 From: Acidfire Date: Sat, 24 Dec 2011 04:43:33 +0100 Subject: [PATCH 6/7] Minor logic change --- litestep/WinMain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/litestep/WinMain.cpp b/litestep/WinMain.cpp index 13a1e28..9dcd4aa 100644 --- a/litestep/WinMain.cpp +++ b/litestep/WinMain.cpp @@ -339,7 +339,7 @@ int WINAPI _tWinMain(HINSTANCE hInst, HINSTANCE, LPTSTR lpCmdLine, int) bLoop = false; - if ((nReturn == LRV_EXPLORER_START) && !(wStartFlags & LSF_RUN_EXPLORER)) + if ((nReturn == LRV_EXPLORER_START) && (wStartFlags & LSF_RUN_LITESTEP)) { // User wants Explorer as the shell anyway wStartFlags |= LSF_RUN_EXPLORER; From fd902652867e728bf0de888876e51bdc04ff7eb0 Mon Sep 17 00:00:00 2001 From: Acidfire Date: Fri, 30 Dec 2011 18:13:00 +0100 Subject: [PATCH 7/7] added note about launching explorer from recovery --- docs/manual.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/manual.txt b/docs/manual.txt index aab52bb..5f1cbe2 100644 --- a/docs/manual.txt +++ b/docs/manual.txt @@ -280,7 +280,8 @@ Contents: key combination: CTRL+ALT+F1 that is, press and hold the CTRL key and the ALT key then depress the F1 key and release all three. A popup menu will appear at your mouse cursor location. This menu can be used recover from a broken - configuration. + configuration. Note that launching Explorer might not always work if there is + already an Explorer file manager window open. A) LiteStep Structure ---------------------