diff --git a/CMakeLists.txt b/CMakeLists.txt index 4eacae216ea5b..a196dbba5ce67 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,13 +21,8 @@ set(BIN_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") include(${CMAKE_SOURCE_DIR}/NEXTCLOUD.cmake) -set ( NCCONTEXTMENU_SHELLEXT_WINDOW_CLASS_NAME "${APPLICATION_SHORTNAME}_Shxt_CntMenuHndlr_WndClass" ) -set ( NCOVERLAYS_SHELLEXT_WINDOW_CLASS_NAME "${APPLICATION_SHORTNAME}_Shxt_Ovs_WndClass" ) - # CfAPI Shell Extensions set( CFAPI_SHELL_EXTENSIONS_LIB_NAME CfApiShellExtensions ) - -set ( CFAPI_SHELLEXT_WINDOW_CLASS_NAME "${APPLICATION_SHORTNAME}_${CFAPI_SHELL_EXTENSIONS_LIB_NAME}_WndClass" ) set( CFAPI_SHELLEXT_APPID_REG "{E314A650-DCA4-416E-974E-18EA37C213EA}") set( CFAPI_SHELLEXT_APPID_DISPLAY_NAME "${APPLICATION_NAME} CfApi Shell Extensions" ) diff --git a/admin/win/msi/Nextcloud.wxs b/admin/win/msi/Nextcloud.wxs index 98dc0e29db73d..c4c26de2d8260 100644 --- a/admin/win/msi/Nextcloud.wxs +++ b/admin/win/msi/Nextcloud.wxs @@ -61,10 +61,6 @@ - - - - - - - - - - + @@ -140,12 +131,6 @@ ]]> - - - - - - NSIS_UNINSTALLEXE AND NOT Installed @@ -154,8 +139,9 @@ (NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL") - - (SCHEDULE_REBOOT=1) OR ((NOT (UILevel=2)) AND (NOT IS_PREV_VERSION_SHELL_EXT_CLOSE_SUPPORTED)) + + + (SCHEDULE_REBOOT=1) OR NOT (UILevel=2) @@ -268,11 +254,6 @@ - - - - - @@ -302,7 +283,6 @@ - diff --git a/admin/win/msi/OEM.wxi.in b/admin/win/msi/OEM.wxi.in index dbc847a5c762b..aa88631468df8 100644 --- a/admin/win/msi/OEM.wxi.in +++ b/admin/win/msi/OEM.wxi.in @@ -32,10 +32,6 @@ - - - - diff --git a/admin/win/tools/NCMsiHelper/CustomAction.cpp b/admin/win/tools/NCMsiHelper/CustomAction.cpp index ce1c2eb51bc4d..db82ba6a7386d 100644 --- a/admin/win/tools/NCMsiHelper/CustomAction.cpp +++ b/admin/win/tools/NCMsiHelper/CustomAction.cpp @@ -20,8 +20,6 @@ */ #include "NCMsiHelper.h" -#include -#include /** * Sets up logging for MSIs and then calls the appropriate custom action with argc/argv parameters. @@ -96,71 +94,6 @@ UINT __stdcall RemoveNavigationPaneEntries(MSIHANDLE hInstall) return CustomActionArgcArgv(hInstall, DoRemoveNavigationPaneEntries, "RemoveNavigationPaneEntries"); } -UINT LogMsiInfoMessage(MSIHANDLE hInstall, const TCHAR *format, ...) -{ - TCHAR szFormatted[MAX_PATH]; - - va_list args; - va_start(args, format); - vswprintf(szFormatted, MAX_PATH, format, args); - va_end(args); - - PMSIHANDLE hRecord = ::MsiCreateRecord(1); - ::MsiRecordSetString(hRecord, 0, szFormatted); - - // we are always logging a message as info, as error will bring a popup that we don't want, just logs - return MsiProcessMessage(hInstall, INSTALLMESSAGE_INFO, hRecord); -} - -UINT __stdcall CloseWindowByClassName(MSIHANDLE hInstall) -{ - const auto windowClassPropertyName = _T("WNDCLASSNAMETOCLOSE"); - DWORD windowClassNameSize = 0; - if (MsiGetProperty(hInstall, windowClassPropertyName, _T(""), &windowClassNameSize) != ERROR_MORE_DATA) { - LogMsiInfoMessage(hInstall, - _T("ERROR: Custom action CloseWindowByClassName. MsiGetProperty failed for windowClassPropertyName: %s"), - windowClassPropertyName); - return ERROR_BAD_ARGUMENTS; - } - - if (windowClassNameSize <= 0) { - LogMsiInfoMessage(hInstall, _T("ERROR: Custom action CloseWindowByClassName. classNameSize is <= 0!")); - return ERROR_BAD_ARGUMENTS; - } - - ++windowClassNameSize; - - std::vector windowClassNameValue(windowClassNameSize, 0); - std::vector vec; - const auto getPropertyRes = MsiGetProperty(hInstall, windowClassPropertyName, windowClassNameValue.data(), &windowClassNameSize); - if (getPropertyRes != ERROR_SUCCESS) { - LogMsiInfoMessage(hInstall, _T("ERROR: Custom action CloseWindowByClassName. MsiGetProperty failed for windowClassPropertyName: %s with code: %d"), - windowClassNameValue.data(), - getPropertyRes); - return getPropertyRes; - } - - if (windowClassNameSize <= 0) { - LogMsiInfoMessage(hInstall, _T("ERROR: Custom action CloseWindowByClassName. Final classNameSize is <= 0!")); - return ERROR_BAD_ARGUMENTS; - } - - LogMsiInfoMessage(hInstall, _T("Custom action CloseWindowByClassName is running for windowClassNameValue: %s"), windowClassNameValue.data()); - - const auto windowToCloseHandle = FindWindow(windowClassNameValue.data(), NULL); - if (windowToCloseHandle == NULL) { - LogMsiInfoMessage(hInstall, _T("WARNING: Custom action CloseWindowByClassName. windowToCloseHandle is NULL.")); - // FindWindow will return NULL if the window is not currently running, so not an error - return ERROR_SUCCESS; - } - - LogMsiInfoMessage(hInstall, _T("Custom action CloseWindowByClassName. Sending WM_CLOSE message to windowClassNameValue: %s"), windowClassNameValue.data()); - - SendMessage(windowToCloseHandle, WM_CLOSE, 0, 0); - - return ERROR_SUCCESS; -} - /** * DllMain - Initialize and cleanup WiX custom action utils. */ diff --git a/admin/win/tools/NCMsiHelper/CustomAction.def b/admin/win/tools/NCMsiHelper/CustomAction.def index d1b20c3956e3a..dc15a63d1a11d 100644 --- a/admin/win/tools/NCMsiHelper/CustomAction.def +++ b/admin/win/tools/NCMsiHelper/CustomAction.def @@ -1,4 +1,3 @@ EXPORTS -CloseWindowByClassName ExecNsisUninstaller RemoveNavigationPaneEntries diff --git a/admin/win/tools/NCMsiHelper/NCMsiHelper.wxs b/admin/win/tools/NCMsiHelper/NCMsiHelper.wxs index c0fecbe435e14..181a55a0ca0dd 100644 --- a/admin/win/tools/NCMsiHelper/NCMsiHelper.wxs +++ b/admin/win/tools/NCMsiHelper/NCMsiHelper.wxs @@ -39,24 +39,5 @@ Execute="deferred" Impersonate="yes" /> - - - - diff --git a/config.h.in b/config.h.in index 39d2f178a4c3c..ca9907c52f294 100644 --- a/config.h.in +++ b/config.h.in @@ -48,10 +48,6 @@ #cmakedefine BUILD_UPDATER "@BUILD_UPDATER@" -#cmakedefine CFAPI_SHELLEXT_WINDOW_CLASS_NAME "@CFAPI_SHELLEXT_WINDOW_CLASS_NAME@" -#cmakedefine NCCONTEXTMENU_SHELLEXT_WINDOW_CLASS_NAME "@NCCONTEXTMENU_SHELLEXT_WINDOW_CLASS_NAME@" -#cmakedefine NCOVERLAYS_SHELLEXT_WINDOW_CLASS_NAME "@NCOVERLAYS_SHELLEXT_WINDOW_CLASS_NAME@" - #cmakedefine CFAPI_SHELLEXT_APPID_REG "@CFAPI_SHELLEXT_APPID_REG@" #cmakedefine CFAPI_SHELLEXT_APPID_DISPLAY_NAME "@CFAPI_SHELLEXT_APPID_DISPLAY_NAME@" diff --git a/shell_integration/windows/NCContextMenu/dllmain.cpp b/shell_integration/windows/NCContextMenu/dllmain.cpp index 4681a3cc19ace..4229b321a116c 100644 --- a/shell_integration/windows/NCContextMenu/dllmain.cpp +++ b/shell_integration/windows/NCContextMenu/dllmain.cpp @@ -21,11 +21,6 @@ HINSTANCE g_hInst = nullptr; long g_cDllRef = 0; -HWND hHiddenWnd = nullptr; -DWORD WINAPI MessageLoopThread(LPVOID lpParameter); -LRESULT CALLBACK HiddenWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); -void CreateHiddenWindowAndLaunchMessageLoop(); - BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved) { switch (dwReason) @@ -35,7 +30,6 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved) // path of the DLL to register the component. g_hInst = hModule; DisableThreadLibraryCalls(hModule); - CreateHiddenWindowAndLaunchMessageLoop(); break; case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: @@ -128,63 +122,3 @@ STDAPI DllUnregisterServer(void) return hr; } - -void CreateHiddenWindowAndLaunchMessageLoop() -{ - const WNDCLASSEX hiddenWindowClass{sizeof(WNDCLASSEX), - CS_CLASSDC, - HiddenWndProc, - 0L, - 0L, - GetModuleHandle(NULL), - NULL, - NULL, - NULL, - NULL, - NCCONTEXTMENU_SHELLEXT_WINDOW_CLASS_NAME, - NULL}; - - RegisterClassEx(&hiddenWindowClass); - - hHiddenWnd = CreateWindow(hiddenWindowClass.lpszClassName, - L"", - WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, - CW_USEDEFAULT, - CW_USEDEFAULT, - CW_USEDEFAULT, - NULL, - NULL, - hiddenWindowClass.hInstance, - NULL); - - ShowWindow(hHiddenWnd, SW_HIDE); - UpdateWindow(hHiddenWnd); - - const auto hMessageLoopThread = CreateThread(NULL, 0, MessageLoopThread, NULL, 0, NULL); - if (hMessageLoopThread) { - CloseHandle(hMessageLoopThread); - } -} - -DWORD WINAPI MessageLoopThread(LPVOID lpParameter) -{ - MSG msg; - while (GetMessage(&msg, NULL, 0, 0)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - return 0; -} - -LRESULT CALLBACK HiddenWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch (msg) { - case WM_CLOSE: - FreeLibrary(g_hInst); - break; - default: - return DefWindowProc(hwnd, msg, wParam, lParam); - } - return 0; -} diff --git a/shell_integration/windows/NCOverlays/DllMain.cpp b/shell_integration/windows/NCOverlays/DllMain.cpp index 5ea1971c1e970..ee54caa472403 100644 --- a/shell_integration/windows/NCOverlays/DllMain.cpp +++ b/shell_integration/windows/NCOverlays/DllMain.cpp @@ -20,11 +20,6 @@ HINSTANCE instanceHandle = nullptr; long dllReferenceCount = 0; -HWND hHiddenWnd = nullptr; -DWORD WINAPI MessageLoopThread(LPVOID lpParameter); -LRESULT CALLBACK HiddenWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); -void CreateHiddenWindowAndLaunchMessageLoop(); - BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved) { switch (dwReason) @@ -32,7 +27,6 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved) case DLL_PROCESS_ATTACH: instanceHandle = hModule; DisableThreadLibraryCalls(hModule); - CreateHiddenWindowAndLaunchMessageLoop(); break; case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: @@ -181,63 +175,3 @@ STDAPI DllUnregisterServer(void) return hResult; } - -void CreateHiddenWindowAndLaunchMessageLoop() -{ - const WNDCLASSEX hiddenWindowClass{sizeof(WNDCLASSEX), - CS_CLASSDC, - HiddenWndProc, - 0L, - 0L, - GetModuleHandle(NULL), - NULL, - NULL, - NULL, - NULL, - NCOVERLAYS_SHELLEXT_WINDOW_CLASS_NAME, - NULL}; - - RegisterClassEx(&hiddenWindowClass); - - hHiddenWnd = CreateWindow(hiddenWindowClass.lpszClassName, - L"", - WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, - CW_USEDEFAULT, - CW_USEDEFAULT, - CW_USEDEFAULT, - NULL, - NULL, - hiddenWindowClass.hInstance, - NULL); - - ShowWindow(hHiddenWnd, SW_HIDE); - UpdateWindow(hHiddenWnd); - - const auto hMessageLoopThread = CreateThread(NULL, 0, MessageLoopThread, NULL, 0, NULL); - if (hMessageLoopThread) { - CloseHandle(hMessageLoopThread); - } -} - -DWORD WINAPI MessageLoopThread(LPVOID lpParameter) -{ - MSG msg; - while (GetMessage(&msg, NULL, 0, 0)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - return 0; -} - -LRESULT CALLBACK HiddenWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch (msg) { - case WM_CLOSE: - FreeLibrary(instanceHandle); - break; - default: - return DefWindowProc(hwnd, msg, wParam, lParam); - } - return 0; -} diff --git a/shell_integration/windows/WinShellExtConstants.h.in b/shell_integration/windows/WinShellExtConstants.h.in index 0c9e56f164a5e..97014ea1f2552 100644 --- a/shell_integration/windows/WinShellExtConstants.h.in +++ b/shell_integration/windows/WinShellExtConstants.h.in @@ -29,9 +29,6 @@ #define OVERLAY_GUID_SYNC L"@WIN_SHELLEXT_OVERLAY_GUID_SYNC@" #define OVERLAY_GUID_WARNING L"@WIN_SHELLEXT_OVERLAY_GUID_WARNING@" -#cmakedefine NCCONTEXTMENU_SHELLEXT_WINDOW_CLASS_NAME L"@NCCONTEXTMENU_SHELLEXT_WINDOW_CLASS_NAME@" -#cmakedefine NCOVERLAYS_SHELLEXT_WINDOW_CLASS_NAME L"@NCOVERLAYS_SHELLEXT_WINDOW_CLASS_NAME@" - // // Preceding spaces are intended, two spaces to put us ahead of the competition :/ // diff --git a/src/libsync/vfs/cfapi/shellext/dllmain.cpp b/src/libsync/vfs/cfapi/shellext/dllmain.cpp index 801294ae01998..f0e469f49fbae 100644 --- a/src/libsync/vfs/cfapi/shellext/dllmain.cpp +++ b/src/libsync/vfs/cfapi/shellext/dllmain.cpp @@ -16,7 +16,6 @@ #include "customstateprovider.h" #include "thumbnailprovider.h" #include -#include long dllReferenceCount = 0; long dllObjectsCount = 0; @@ -26,11 +25,6 @@ HINSTANCE instanceHandle = nullptr; HRESULT CustomStateProvider_CreateInstance(REFIID riid, void **ppv); HRESULT ThumbnailProvider_CreateInstance(REFIID riid, void **ppv); -HWND hHiddenWnd = nullptr; -DWORD WINAPI MessageLoopThread(LPVOID lpParameter); -LRESULT CALLBACK HiddenWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); -void CreateHiddenWindowAndLaunchMessageLoop(); - const VfsShellExtensions::ClassObjectInit listClassesSupported[] = { {&__uuidof(winrt::CfApiShellExtensions::implementation::CustomStateProvider), CustomStateProvider_CreateInstance}, {&__uuidof(VfsShellExtensions::ThumbnailProvider), ThumbnailProvider_CreateInstance} @@ -44,8 +38,6 @@ STDAPI_(BOOL) DllMain(HINSTANCE hInstance, DWORD dwReason, void *) ::GetModuleFileName(instanceHandle, dllFilePath, _MAX_PATH); winrt::CfApiShellExtensions::implementation::CustomStateProvider::setDllFilePath(dllFilePath); DisableThreadLibraryCalls(hInstance); - - CreateHiddenWindowAndLaunchMessageLoop(); } return TRUE; @@ -81,66 +73,3 @@ HRESULT ThumbnailProvider_CreateInstance(REFIID riid, void **ppv) thumbnailProvider->Release(); return hresult; } - -void CreateHiddenWindowAndLaunchMessageLoop() -{ - const WNDCLASSEX hiddenWindowClass { - sizeof(WNDCLASSEX), - CS_CLASSDC, - HiddenWndProc, - 0L, - 0L, - GetModuleHandle(NULL), - NULL, - NULL, - NULL, - NULL, - _T(CFAPI_SHELLEXT_WINDOW_CLASS_NAME), - NULL - }; - - RegisterClassEx(&hiddenWindowClass); - - hHiddenWnd = CreateWindow( - hiddenWindowClass.lpszClassName, - _T(""), - WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, - CW_USEDEFAULT, - CW_USEDEFAULT, - CW_USEDEFAULT, - NULL, - NULL, - hiddenWindowClass.hInstance, - NULL); - - ShowWindow(hHiddenWnd, SW_HIDE); - UpdateWindow(hHiddenWnd); - - const auto hMessageLoopThread = CreateThread(NULL, 0, MessageLoopThread, NULL, 0, NULL); - if (hMessageLoopThread) { - CloseHandle(hMessageLoopThread); - } -} - -DWORD WINAPI MessageLoopThread(LPVOID lpParameter) -{ - MSG msg; - while (GetMessage(&msg, NULL, 0, 0)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - return 0; -} - -LRESULT CALLBACK HiddenWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch (msg) { - case WM_CLOSE: - FreeLibrary(instanceHandle); - break; - default: - return DefWindowProc(hwnd, msg, wParam, lParam); - } - return 0; -}