diff --git a/AppxManifest.xml.cmake b/AppxManifest.xml.cmake index 92ee2a07e..af9bd3765 100644 --- a/AppxManifest.xml.cmake +++ b/AppxManifest.xml.cmake @@ -1,10 +1,13 @@  + IgnorableNamespaces="com desktop desktop4 desktop5 rescap uap uap3"> @@ -54,6 +57,22 @@ + + + + + + + + + + + + + + + + diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 25addf337..52ffdfe97 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -272,6 +272,7 @@ elseif(WIN32) COMMAND ${CMAKE_COMMAND} -E make_directory appx COMMAND ${CMAKE_COMMAND} -E copy AppxManifest.xml appx COMMAND ${CMAKE_COMMAND} -E copy $ appx + COMMAND ${CMAKE_COMMAND} -E copy $ appx COMMAND ${CMAKE_COMMAND} -E copy ${LIBS_PATH}/libcrypto-3${OPENSSL_SUFFIX}.dll appx COMMAND ${CMAKE_COMMAND} -E copy ${LIBS_PATH}/libssl-3${OPENSSL_SUFFIX}.dll appx COMMAND ${CMAKE_COMMAND} -E copy ${LIBS_PATH}/zlib$<$:d>1.dll appx diff --git a/extensions/windows/CMakeLists.txt b/extensions/windows/CMakeLists.txt index 6eb096647..c4bb27403 100644 --- a/extensions/windows/CMakeLists.txt +++ b/extensions/windows/CMakeLists.txt @@ -1,9 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(EsteidShellExtension VERSION 3.13.9) add_library(${PROJECT_NAME} SHARED - dllmain.cpp EsteidShellExtension.def - EsteidShlExt.cpp + EsteidShellExtension.cpp EsteidShellExtension.rc ) target_compile_definitions(${PROJECT_NAME} PRIVATE @@ -19,7 +18,30 @@ set_target_properties(${PROJECT_NAME} PROPERTIES INTERPROCEDURAL_OPTIMIZATION YES COMPILE_OPTIONS "/guard:cf" LINK_OPTIONS "/guard:cf" - LINK_LIBRARIES "uxtheme;RuntimeObject" + LINK_LIBRARIES "uxtheme;RuntimeObject;Shlwapi" + SKIP_AUTOMOC ON +) + +add_library(${PROJECT_NAME}V2 SHARED + EsteidShellExtension.def + EsteidShellExtensionV2.cpp + EsteidShellExtension.rc +) +target_compile_definitions(${PROJECT_NAME}V2 PRIVATE + _UNICODE + UNICODE + _WINDLL + WIN32_LEAN_AND_MEAN + NO_ICON + VERSION=${PROJECT_VERSION_MAJOR},${PROJECT_VERSION_MINOR},${PROJECT_VERSION_PATCH},${BUILD_NUMBER} + VERSION_STR="${VERSION}" +) +set_target_properties(${PROJECT_NAME}V2 PROPERTIES + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" + INTERPROCEDURAL_OPTIMIZATION YES + COMPILE_OPTIONS "/guard:cf" + LINK_OPTIONS "/guard:cf" + LINK_LIBRARIES "uxtheme;RuntimeObject;Shlwapi" SKIP_AUTOMOC ON ) diff --git a/extensions/windows/EsteidShlExt.cpp b/extensions/windows/EsteidShellExtension.cpp similarity index 63% rename from extensions/windows/EsteidShlExt.cpp rename to extensions/windows/EsteidShellExtension.cpp index 20eb6b709..1891e13d7 100644 --- a/extensions/windows/EsteidShlExt.cpp +++ b/extensions/windows/EsteidShellExtension.cpp @@ -1,18 +1,39 @@ -// EsteidShlExt.cpp : Implementation of CEsteidShlExt -// http://msdn.microsoft.com/en-us/library/bb757020.aspx +/* + * EsteidShellExtension + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ -#include "EsteidShlExt.h" #include "resource.h" +#include +#include #include +#include #include #include -extern HINSTANCE instanceHandle; +#include +#include -typedef DWORD ARGB; +extern "C" IMAGE_DOS_HEADER __ImageBase; -bool HasAlpha(ARGB *pargb, const SIZE &sizeImage, int cxRow) +using ARGB = DWORD; + +static bool HasAlpha(ARGB *pargb, const SIZE &sizeImage, int cxRow) { ULONG cxDelta = cxRow - sizeImage.cx; for(ULONG y = sizeImage.cy; y; --y) @@ -27,18 +48,19 @@ bool HasAlpha(ARGB *pargb, const SIZE &sizeImage, int cxRow) return false; } -BITMAPINFO InitBitmapInfo(const SIZE &sizeImage) +static BITMAPINFO InitBitmapInfo(const SIZE &sizeImage) { - BITMAPINFO pbmi{{sizeof(BITMAPINFOHEADER)}}; - pbmi.bmiHeader.biPlanes = 1; - pbmi.bmiHeader.biCompression = BI_RGB; - pbmi.bmiHeader.biWidth = sizeImage.cx; - pbmi.bmiHeader.biHeight = sizeImage.cy; - pbmi.bmiHeader.biBitCount = 32; - return pbmi; + return {{ + .biSize = sizeof(BITMAPINFOHEADER), + .biWidth = sizeImage.cx, + .biHeight = sizeImage.cy, + .biPlanes = 1, + .biBitCount = 32, + .biCompression = BI_RGB, + }}; } -HRESULT ConvertToPARGB32(HDC hdc, ARGB *pargb, HBITMAP hbmp, const SIZE &sizeImage, int cxRow) +static HRESULT ConvertToPARGB32(HDC hdc, ARGB *pargb, HBITMAP hbmp, const SIZE &sizeImage, int cxRow) { BITMAPINFO bmi = InitBitmapInfo(sizeImage); HRESULT hr = E_OUTOFMEMORY; @@ -68,7 +90,7 @@ HRESULT ConvertToPARGB32(HDC hdc, ARGB *pargb, HBITMAP hbmp, const SIZE &sizeIma return hr; } -HRESULT ConvertBufferToPARGB32(HPAINTBUFFER hPaintBuffer, HDC hdc, HICON hicon, const SIZE &sizeIcon) +static HRESULT ConvertBufferToPARGB32(HPAINTBUFFER hPaintBuffer, HDC hdc, HICON hicon, const SIZE &sizeIcon) { RGBQUAD *prgbQuad; int cxRow = 0; @@ -91,10 +113,42 @@ HRESULT ConvertBufferToPARGB32(HPAINTBUFFER hPaintBuffer, HDC hdc, HICON hicon, return hr; } +struct +#ifdef _WIN64 + __declspec(uuid("5606A547-759D-43DA-AEEB-D3BF1D1E816D")) +#else + __declspec(uuid("310AAB39-76FE-401B-8A7F-0F578C5F6AB5")) +#endif + CEsteidShlExt : public winrt::implements +{ + CEsteidShlExt(); + ~CEsteidShlExt() override; + + // IShellExtInit + STDMETHODIMP Initialize(LPCITEMIDLIST pidlFolder, LPDATAOBJECT pdtobj, HKEY hkeyProgID) final; + + // IContextMenu + STDMETHODIMP QueryContextMenu(HMENU, UINT, UINT, UINT, UINT) final; + STDMETHODIMP InvokeCommand(LPCMINVOKECOMMANDINFO) final; + STDMETHODIMP GetCommandString(UINT_PTR, UINT, UINT *, LPSTR, UINT) final; + +private: + enum : uint8_t { + MENU_SIGN = 0, + MENU_ENCRYPT = 1, + }; + + static bool WINAPI FindRegistryInstallPath(std::wstring &path); + STDMETHODIMP ExecuteDigidocclient(LPCMINVOKECOMMANDINFO pCmdInfo, bool crypto = false); + + HBITMAP m_DigidocBmp = nullptr; + std::vector m_Files; +}; + CEsteidShlExt::CEsteidShlExt() { const SIZE sizeIcon { GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON) }; - if(HICON hIcon = (HICON)LoadImage(instanceHandle, MAKEINTRESOURCE(IDB_DIGIDOCICO), IMAGE_ICON, sizeIcon.cx, sizeIcon.cy, LR_DEFAULTCOLOR|LR_CREATEDIBSECTION)) + if(HICON hIcon = (HICON)LoadImage(reinterpret_cast(&__ImageBase), MAKEINTRESOURCE(IDB_DIGIDOCICO), IMAGE_ICON, sizeIcon.cx, sizeIcon.cy, LR_DEFAULTCOLOR|LR_CREATEDIBSECTION)) { if(HDC hdcDest = CreateCompatibleDC(nullptr)) { @@ -211,9 +265,17 @@ STDMETHODIMP CEsteidShlExt::GetCommandString( // supplied buffer. if (uFlags & GCS_HELPTEXT) { if (uFlags & GCS_UNICODE) { - LPCWSTR szText = idCmd == MENU_SIGN - ? L"Allkirjasta valitud failid digitaalselt" - : L"Krüpteeri valitud failid"; + LPCWSTR szText = idCmd == MENU_ENCRYPT ? L"Encrypt selected files" : L"Digitally sign selected files"; + switch(PRIMARYLANGID(GetUserDefaultUILanguage())) + { + case LANG_ESTONIAN: + szText = idCmd == MENU_ENCRYPT ? L"Krüpteeri valitud failid" : L"Allkirjasta valitud failid digitaalselt"; + break; + case LANG_RUSSIAN: + szText = idCmd == MENU_ENCRYPT ? L"Зашифровать выбранные файлы" : L"Цифровая подпись выбранных файлов"; + break; + default: break; + } // We need to cast pszName to a Unicode string, and then use the // Unicode string copy API. lstrcpynW(LPWSTR(pszName), szText, int(cchMax)); @@ -256,7 +318,7 @@ STDMETHODIMP CEsteidShlExt::ExecuteDigidocclient(LPCMINVOKECOMMANDINFO /* pCmdIn // Read the location of the installation from registry if (!FindRegistryInstallPath(path)) { // .. and fall back to directory where shellext resides if not found from registry - GetModuleFileName(instanceHandle, path.data(), path.size()); + GetModuleFileName(reinterpret_cast(&__ImageBase), path.data(), path.size()); path.resize(path.find_last_of(L'\\') + 1); } @@ -291,3 +353,43 @@ STDMETHODIMP CEsteidShlExt::InvokeCommand(LPCMINVOKECOMMANDINFO pCmdInfo) return E_INVALIDARG; } } + +struct CEsteidShlExtFactory : winrt::implements +{ + STDMETHODIMP CreateInstance( + IUnknown *pUnkOuter, REFIID riid, LPVOID *ppvObject) noexcept final try { + if(!ppvObject) + return E_POINTER; + *ppvObject = nullptr; + if(pUnkOuter) + return CLASS_E_NOAGGREGATION; + return winrt::make().as(riid, ppvObject); + } catch (...) { + return winrt::to_hresult(); + } + + STDMETHODIMP LockServer(BOOL /*fLock*/) noexcept final { + return S_OK; + } +}; + +// Used to determine whether the DLL can be unloaded by OLE +STDMETHODIMP DllCanUnloadNow() +{ + if (winrt::get_module_lock()) + return S_FALSE; + winrt::clear_factory_cache(); + return S_OK; +} + +// Returns a class factory to create an object of the requested type +//STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *result) +STDMETHODIMP DllGetClassObject(const GUID &clsid, const GUID &iid, LPVOID *result) try +{ + *result = nullptr; + if (clsid == __uuidof(CEsteidShlExt)) + return winrt::make().as(iid, result); + return winrt::hresult_class_not_available().to_abi(); +} catch (...) { + return winrt::to_hresult(); +} diff --git a/extensions/windows/EsteidShellExtension.rc b/extensions/windows/EsteidShellExtension.rc index 8eef11cf4..5b9fdb817 100644 --- a/extensions/windows/EsteidShellExtension.rc +++ b/extensions/windows/EsteidShellExtension.rc @@ -1,71 +1,37 @@ -// Microsoft Visual C++ generated resource script. -// +/* + * EsteidShellExtension + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include #include "resource.h" -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#ifndef APSTUDIO_INVOKED -#include "targetver.h" -#endif -#include "winres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (United States) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#ifndef APSTUDIO_INVOKED\r\n" - "#include ""targetver.h""\r\n" - "#endif\r\n" - "#include ""winres.h""\r\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - VS_VERSION_INFO VERSIONINFO FILEVERSION VERSION PRODUCTVERSION VERSION - FILEFLAGSMASK 0x3fL + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK #ifdef _DEBUG - FILEFLAGS 0x1L + FILEFLAGS VS_FF_DEBUG #else FILEFLAGS 0x0L #endif - FILEOS 0x4L - FILETYPE 0x2L - FILESUBTYPE 0x0L + FILEOS VOS_NT_WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_UNKNOWN BEGIN BLOCK "StringFileInfo" BEGIN @@ -87,47 +53,6 @@ BEGIN END END - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE -BEGIN - IDS_PROJNAME "EsteidShellExtension" -END - -#endif // English (United States) resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// Estonian (Estonia) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ETI) -LANGUAGE LANG_ESTONIAN, SUBLANG_DEFAULT -#pragma code_page(1257) - -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -IDB_DIGIDOCICO ICON "resources\\digidoc.ico" - -#endif // Estonian (Estonia) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - +#ifndef NO_ICON +IDB_DIGIDOCICO ICON "digidoc.ico" +#endif diff --git a/extensions/windows/EsteidShellExtensionV2.cpp b/extensions/windows/EsteidShellExtensionV2.cpp new file mode 100644 index 000000000..9ec0b3d0e --- /dev/null +++ b/extensions/windows/EsteidShellExtensionV2.cpp @@ -0,0 +1,188 @@ +/* + * EsteidShellExtension + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include +#include +#include +#include +#include +#include + +extern "C" IMAGE_DOS_HEADER __ImageBase; + +template +struct EsteidShellExtension : public winrt::implements, IExplorerCommand> +{ + // IExplorerCommand + STDMETHODIMP GetTitle(IShellItemArray */*psiItemArray*/, LPWSTR *ppszName) final + { + switch(PRIMARYLANGID(GetUserDefaultUILanguage())) + { + case LANG_ESTONIAN: + if constexpr (IsCrypto) return SHLocalStrDupW(L"Krüpteeri DigiDoc4-ga", ppszName); + else return SHLocalStrDupW(L"Allkirjasta DigiDoc4-ga", ppszName); + case LANG_RUSSIAN: + if constexpr (IsCrypto) return SHLocalStrDupW(L"Зашифровать с помощью DigiDoc4", ppszName); + else return SHLocalStrDupW(L"Подписать с помощью DigiDoc4", ppszName); + default: + if constexpr (IsCrypto) return SHLocalStrDupW(L"Encrypt with DigiDoc4", ppszName); + else return SHLocalStrDupW(L"Sign with DigiDoc4", ppszName); + } + } + STDMETHODIMP GetIcon(IShellItemArray */*psiItemArray*/, LPWSTR *ppszIcon) final + { + auto p = digidocPath() + L",0"; + return SHLocalStrDupW(p.data(), ppszIcon); + } + STDMETHODIMP GetToolTip(IShellItemArray */*psiItemArray*/, LPWSTR *ppszInfotip) final + { + switch(PRIMARYLANGID(GetUserDefaultUILanguage())) + { + case LANG_ESTONIAN: + if constexpr (IsCrypto) return SHLocalStrDupW(L"Krüpteeri valitud failid", ppszInfotip); + else return SHLocalStrDupW(L"Allkirjasta valitud failid digitaalselt", ppszInfotip); + case LANG_RUSSIAN: + if constexpr (IsCrypto) return SHLocalStrDupW(L"Зашифровать выбранные файлы", ppszInfotip); + else return SHLocalStrDupW(L"Цифровая подпись выбранных файлов", ppszInfotip); + default: + if constexpr (IsCrypto) return SHLocalStrDupW(L"Encrypt selected files", ppszInfotip); + else return SHLocalStrDupW(L"Digitally sign selected files", ppszInfotip); + } + } + STDMETHODIMP GetCanonicalName(GUID *pguidCommandName) final + { + *pguidCommandName = GUID_NULL; + return S_OK; + } + STDMETHODIMP GetState(IShellItemArray */*psiItemArray*/, BOOL /*fOkToBeSlow*/, EXPCMDSTATE *pCmdState) final + { + *pCmdState = ECS_ENABLED; + return S_OK; + } + STDMETHODIMP Invoke(IShellItemArray *psiItemArray, IBindCtx */*pbc*/) final + { + if(!psiItemArray) + return S_OK; + + DWORD count; + if(auto hr = psiItemArray->GetCount(&count); FAILED(hr)) + return hr; + if(count == 0) + return S_OK; + + std::wstring digidoc = digidocPath(); + std::wstring parameters; + if constexpr (IsCrypto) parameters += L"\"-crypto\" "; + else parameters += L"\"-sign\" "; + for (DWORD i = 0; i < count; ++i) + { + IShellItem* psi = nullptr; + if(auto hr = psiItemArray->GetItemAt(i, &psi); FAILED(hr)) + return hr; + LPWSTR path; + auto hr = psi->GetDisplayName(SIGDN_FILESYSPATH, &path); + psi->Release(); + if(FAILED(hr)) + return hr; + parameters += L"\""; + parameters += path; + parameters += L"\" "; + if(path) + CoTaskMemFree(path); + } + SHELLEXECUTEINFO seInfo{ + .cbSize = sizeof(SHELLEXECUTEINFO), + .lpFile = digidoc.c_str(), + .lpParameters = parameters.c_str(), + .nShow = SW_SHOW + }; + return ShellExecuteEx(&seInfo) ? S_OK : S_FALSE; + } + STDMETHODIMP GetFlags(EXPCMDFLAGS *pFlags) final + { + *pFlags = ECF_DEFAULT; + return S_OK; + } + STDMETHODIMP EnumSubCommands(IEnumExplorerCommand **ppEnum) final + { + *ppEnum = {}; + return E_NOTIMPL; + } + + static std::wstring digidocPath() + { + std::wstring path(MAX_PATH, 0); + if(auto size = GetModuleFileNameW(reinterpret_cast(&__ImageBase), path.data(), DWORD(path.size())); size > 0) + path.resize(size); + else + path.clear(); + if(auto pos = path.find_last_of('\\'); pos != std::wstring::npos) + { + path.resize(pos); + path += L"\\qdigidoc4.exe"; + } + return path; + } +}; + +struct __declspec(uuid("4ef3a5aa-125c-45f5-b5fd-d4c478050afa")) +EsteidShellExtensionSign : public EsteidShellExtension {}; + +struct __declspec(uuid("bb67aa19-089b-4ec9-a059-13d985987cdc")) +EsteidShellExtensionEnc : public EsteidShellExtension {}; + +template +struct EsteidShellExtensionFactory : winrt::implements, IClassFactory> +{ + STDMETHODIMP CreateInstance( + IUnknown *pUnkOuter, REFIID riid, LPVOID *ppvObject) noexcept final try { + if(!ppvObject) + return E_POINTER; + *ppvObject = nullptr; + if(pUnkOuter) + return CLASS_E_NOAGGREGATION; + return winrt::make().as(riid, ppvObject); + } catch (...) { + return winrt::to_hresult(); + } + + STDMETHODIMP LockServer(BOOL /*fLock*/) noexcept final { + return S_OK; + } +}; + +STDMETHODIMP DllCanUnloadNow() +{ + if (winrt::get_module_lock()) + return S_FALSE; + winrt::clear_factory_cache(); + return S_OK; +} + +STDMETHODIMP DllGetClassObject(const GUID &clsid, const GUID &iid, LPVOID *result) try +{ + *result = nullptr; + if (clsid == __uuidof(EsteidShellExtensionSign)) + return winrt::make>().as(iid, result); + if (clsid == __uuidof(EsteidShellExtensionEnc)) + return winrt::make>().as(iid, result); + return winrt::hresult_class_not_available().to_abi(); +} catch (...) { + return winrt::to_hresult(); +} diff --git a/extensions/windows/EsteidShlExt.h b/extensions/windows/EsteidShlExt.h deleted file mode 100644 index 7f6f62571..000000000 --- a/extensions/windows/EsteidShlExt.h +++ /dev/null @@ -1,44 +0,0 @@ -// EsteidShlExt.h : Declaration of the CEsteidShlExt - -#pragma once - -#include "targetver.h" - -#include -#include -#include -#include -#include - -class -#ifdef _WIN64 - __declspec(uuid("5606A547-759D-43DA-AEEB-D3BF1D1E816D")) -#else - __declspec(uuid("310AAB39-76FE-401B-8A7F-0F578C5F6AB5")) -#endif - CEsteidShlExt : public winrt::implements -{ -public: - CEsteidShlExt(); - ~CEsteidShlExt(); - - // IShellExtInit - STDMETHODIMP Initialize(LPCITEMIDLIST pidlFolder, LPDATAOBJECT pdtobj, HKEY hkeyProgID) final; - - // IContextMenu - STDMETHODIMP QueryContextMenu(HMENU, UINT, UINT, UINT, UINT) final; - STDMETHODIMP InvokeCommand(LPCMINVOKECOMMANDINFO) final; - STDMETHODIMP GetCommandString(UINT_PTR, UINT, UINT *, LPSTR, UINT) final; - -private: - enum { - MENU_SIGN = 0, - MENU_ENCRYPT = 1, - }; - - bool WINAPI FindRegistryInstallPath(std::wstring &path); - STDMETHODIMP ExecuteDigidocclient(LPCMINVOKECOMMANDINFO pCmdInfo, bool crypto = false); - - HBITMAP m_DigidocBmp = nullptr; - std::vector m_Files; -}; diff --git a/extensions/windows/resources/digidoc.ico b/extensions/windows/digidoc.ico similarity index 100% rename from extensions/windows/resources/digidoc.ico rename to extensions/windows/digidoc.ico diff --git a/extensions/windows/dllmain.cpp b/extensions/windows/dllmain.cpp deleted file mode 100644 index 91489a24f..000000000 --- a/extensions/windows/dllmain.cpp +++ /dev/null @@ -1,61 +0,0 @@ -// dllmain.cpp : Implementation of DllMain. - -#include "EsteidShlExt.h" - -HINSTANCE instanceHandle{}; - -// DLL Entry Point -BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved) -{ - switch (dwReason) { - case DLL_PROCESS_ATTACH: - instanceHandle = hModule; - DisableThreadLibraryCalls(hModule); - break; - case DLL_THREAD_ATTACH: - case DLL_THREAD_DETACH: - case DLL_PROCESS_DETACH: - break; - } - - return TRUE; -} - -struct CEsteidShlExtFactory : winrt::implements -{ - STDMETHODIMP CreateInstance( - IUnknown *pUnkOuter, REFIID riid, LPVOID *ppvObject) noexcept final try { - return winrt::make().as(riid, ppvObject); - } catch (...) { - return winrt::to_hresult(); - } - - STDMETHODIMP LockServer(BOOL fLock) noexcept final { - return S_OK; - } -}; - -// Used to determine whether the DLL can be unloaded by OLE -STDMETHODIMP DllCanUnloadNow() -{ - if (winrt::get_module_lock()) { - return S_FALSE; - } - - winrt::clear_factory_cache(); - return S_OK; -} - -// Returns a class factory to create an object of the requested type -STDMETHODIMP DllGetClassObject(const GUID &clsid, const GUID &iid, LPVOID *result) try -{ - *result = nullptr; - - if (clsid == __uuidof(CEsteidShlExt)) { - return winrt::make().as(iid, result); - } - - return winrt::hresult_class_not_available().to_abi(); -} catch (...) { - return winrt::to_hresult(); -} diff --git a/extensions/windows/resource.h b/extensions/windows/resource.h index 2e203ec2e..30e42c460 100644 --- a/extensions/windows/resource.h +++ b/extensions/windows/resource.h @@ -1,17 +1,22 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by EsteidShellExtension.rc -// -#define IDS_PROJNAME 100 -#define IDB_DIGIDOCICO 201 +/* + * EsteidShellExtension + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#pragma once -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 203 -#define _APS_NEXT_COMMAND_VALUE 32768 -#define _APS_NEXT_CONTROL_VALUE 201 -#define _APS_NEXT_SYMED_VALUE 103 -#endif -#endif +#define IDB_DIGIDOCICO 201 diff --git a/extensions/windows/targetver.h b/extensions/windows/targetver.h deleted file mode 100644 index 5f1a19420..000000000 --- a/extensions/windows/targetver.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once - -// The following macros define the minimum required platform. The minimum required platform -// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run -// your application. The macros work by enabling all features available on platform versions up to and -// including the version specified. - -#ifndef WINVER -#define WINVER 0x0A00 -#endif - -#ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x0A00 -#endif - -#ifndef _WIN32_WINDOWS -#define _WIN32_WINDOWS 0x0A00 -#endif - -#ifndef _WIN32_IE -#define _WIN32_IE 0x0A00 -#endif -