From 00d71971d9cf831b991d391bb073dd846a15855f Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 13 Jun 2018 14:14:35 +0300 Subject: profile lock detection unbound from contact list services --- plugins/Dbx_mdbx/src/dbintf.cpp | 12 +++++++++--- plugins/Dbx_mdbx/src/init.cpp | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'plugins') diff --git a/plugins/Dbx_mdbx/src/dbintf.cpp b/plugins/Dbx_mdbx/src/dbintf.cpp index 21c6c3a988..4247806e0a 100644 --- a/plugins/Dbx_mdbx/src/dbintf.cpp +++ b/plugins/Dbx_mdbx/src/dbintf.cpp @@ -150,7 +150,7 @@ int CDbxMDBX::Load() } size_t iDefHeaderOffset = 0; -BYTE bDefHeader[] = { 0 }; +BYTE bDefHeader[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0 }; int CDbxMDBX::Check(void) { @@ -215,6 +215,9 @@ STDMETHODIMP_(void) CDbxMDBX::SetCacheSafetyMode(BOOL bIsSet) int CDbxMDBX::Map() { + if (!LockName(m_tszProfileName)) + return EGROKPRF_CANTREAD; + #ifdef _WIN64 __int64 upperLimit = 0x400000000ul; #else @@ -229,13 +232,16 @@ int CDbxMDBX::Map() 512ul << 10, // 512K shrink threshold -1); // default page size if (rc != MDBX_SUCCESS) - return rc; + return EGROKPRF_CANTREAD; unsigned int mode = MDBX_NOSUBDIR | MDBX_MAPASYNC | MDBX_WRITEMAP | MDBX_NOSYNC | MDBX_COALESCE; if (m_bReadOnly) mode |= MDBX_RDONLY; - return mdbx_env_open(m_env, _T2A(m_tszProfileName), mode, 0664); + if (mdbx_env_open(m_env, _T2A(m_tszProfileName), mode, 0664) != MDBX_SUCCESS) + return EGROKPRF_CANTREAD; + + return EGROKPRF_NOERROR; } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/plugins/Dbx_mdbx/src/init.cpp b/plugins/Dbx_mdbx/src/init.cpp index 3419fd6c78..6a85913bde 100644 --- a/plugins/Dbx_mdbx/src/init.cpp +++ b/plugins/Dbx_mdbx/src/init.cpp @@ -67,7 +67,7 @@ extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_DATABA static int makeDatabase(const TCHAR *profile) { std::unique_ptr db(new CDbxMDBX(profile, 0)); - return (db->Map() == MDBX_SUCCESS) ? 0 : EGROKPRF_CANTREAD; + return db->Map(); } // returns 0 if the given profile has a valid header -- cgit v1.2.3