From d01ef0db6be8b7cb45eef8f41d69fd4e567cb7cf Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 22 May 2018 19:39:57 +0300 Subject: m_crypto.h => CMPlugin --- include/m_crypto.h | 19 +++++-------------- plugins/Db3x_mmap/src/ui.h | 2 +- plugins/Dbx_mdbx/src/ui.h | 4 ++-- src/core/stdcrypt/src/encrypt.cpp | 5 +++-- src/mir_app/src/encrypt.cpp | 8 ++++---- 5 files changed, 15 insertions(+), 23 deletions(-) diff --git a/include/m_crypto.h b/include/m_crypto.h index ed59a858e6..31007715a4 100644 --- a/include/m_crypto.h +++ b/include/m_crypto.h @@ -57,7 +57,7 @@ struct MICryptoEngine ///////////////////////////////////////////////////////////////////////////////////////// // registers a crypto provider v0.94+ -// wParam = (int)hLangpack +// wParam = 0 // lParam = (CRYPTO_PROVIDER*) // returns HANDLE on success or NULL on failure @@ -65,29 +65,20 @@ typedef MICryptoEngine* (__cdecl *pfnCryptoProviderFactory)(void); #define CPF_UNICODE 1 -typedef struct tagCRYPTOPROVIDER +struct CRYPTO_PROVIDER { DWORD dwSize; DWORD dwFlags; // one of CPF_* constants + int iLangId; char *pszName; // unique id - union { - char *pszDescr; // description - wchar_t *ptszDescr; // auto translated by core - wchar_t *pwszDescr; - }; + MAllStrings szDescr; // description pfnCryptoProviderFactory pFactory; -} - CRYPTO_PROVIDER; +}; #define MS_CRYPTO_REGISTER_ENGINE "Crypto/RegisterEngine" -__forceinline HANDLE Crypto_RegisterEngine(CRYPTO_PROVIDER *pProvider) -{ - return (HANDLE)CallService(MS_CRYPTO_REGISTER_ENGINE, hLangpack, (LPARAM)pProvider); -} - /////////////////////////////////////////////////////////////////////////////////////////////// // retrieves list of all available crypto providers // wParam = (WPARAM)(int*)piNumProviders diff --git a/plugins/Db3x_mmap/src/ui.h b/plugins/Db3x_mmap/src/ui.h index 36bec825e9..09e27961f8 100644 --- a/plugins/Db3x_mmap/src/ui.h +++ b/plugins/Db3x_mmap/src/ui.h @@ -42,7 +42,7 @@ public: void SetDescr(CRYPTO_PROVIDER *prov) { - m_descr.SetText(prov->ptszDescr); + m_descr.SetText(prov->szDescr.w); } inline CRYPTO_PROVIDER* GetSelected() diff --git a/plugins/Dbx_mdbx/src/ui.h b/plugins/Dbx_mdbx/src/ui.h index c510cc89da..29eed1c792 100644 --- a/plugins/Dbx_mdbx/src/ui.h +++ b/plugins/Dbx_mdbx/src/ui.h @@ -68,7 +68,7 @@ class CSelectCryptoDialog : public CDlgBase m_combo.AddStringA(prov->pszName, i); } m_combo.SetCurSel(0); - m_descr.SetText(m_provs[0]->ptszDescr); + m_descr.SetText(m_provs[0]->szDescr.w); } void OnClose() @@ -79,7 +79,7 @@ class CSelectCryptoDialog : public CDlgBase void OnComboChanged(CCtrlCombo*) { - m_descr.SetText(m_provs[m_combo.GetItemData(m_combo.GetCurSel())]->ptszDescr); + m_descr.SetText(m_provs[m_combo.GetItemData(m_combo.GetCurSel())]->szDescr.w); } public: diff --git a/src/core/stdcrypt/src/encrypt.cpp b/src/core/stdcrypt/src/encrypt.cpp index 6721f733a2..1fe6cd083b 100644 --- a/src/core/stdcrypt/src/encrypt.cpp +++ b/src/core/stdcrypt/src/encrypt.cpp @@ -209,8 +209,9 @@ int LoadEncryptionModule(void) { CRYPTO_PROVIDER cp = { sizeof(cp) }; cp.pszName = "AES (Rjindale)"; - cp.pszDescr = LPGEN("Standard crypto provider"); + cp.szDescr.a = LPGEN("Standard crypto provider"); cp.pFactory = builder; - Crypto_RegisterEngine(&cp); + cp.iLangId = g_plugin.m_hLang; + CallService(MS_CRYPTO_REGISTER_ENGINE, 0, LPARAM(&cp)); return 0; } diff --git a/src/mir_app/src/encrypt.cpp b/src/mir_app/src/encrypt.cpp index 48464f8258..b31f2c6d3e 100644 --- a/src/mir_app/src/encrypt.cpp +++ b/src/mir_app/src/encrypt.cpp @@ -32,7 +32,7 @@ static int CompareFunc(const CRYPTO_PROVIDER *p1, const CRYPTO_PROVIDER *p2) static LIST arProviders(5, CompareFunc); -static INT_PTR srvRegister(WPARAM wParam, LPARAM lParam) +static INT_PTR srvRegister(WPARAM, LPARAM lParam) { CRYPTO_PROVIDER *p = (CRYPTO_PROVIDER*)lParam; if (p == nullptr || p->dwSize != sizeof(CRYPTO_PROVIDER)) @@ -41,9 +41,9 @@ static INT_PTR srvRegister(WPARAM wParam, LPARAM lParam) CRYPTO_PROVIDER *pNew = new CRYPTO_PROVIDER(*p); pNew->pszName = mir_strdup(p->pszName); if (pNew->dwFlags & CPF_UNICODE) - pNew->ptszDescr = mir_wstrdup(TranslateW_LP(p->pwszDescr, wParam)); + pNew->szDescr.w = mir_wstrdup(TranslateW_LP(p->szDescr.w, p->iLangId)); else - pNew->ptszDescr = mir_a2u(TranslateA_LP(p->pszDescr, wParam)); + pNew->szDescr.w = mir_a2u(TranslateA_LP(p->szDescr.a, p->iLangId)); arProviders.insert(pNew); return 0; } @@ -81,7 +81,7 @@ void UninitCrypt(void) { for (auto &p : arProviders) { mir_free(p->pszName); - mir_free(p->pszDescr); + mir_free(p->szDescr.w); delete p; } } -- cgit v1.2.3