From 93b3fbbd45e45ec24c9d06ee529840cc3c2d4f29 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 29 Dec 2013 20:27:41 +0000 Subject: when mmap_sa opens a database, it must decrypt it, change signature to mmap and die git-svn-id: http://svn.miranda-ng.org/main/trunk@7416 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Dbx_mmap_SA/src/dbintf_sa.cpp | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'plugins') diff --git a/plugins/Dbx_mmap_SA/src/dbintf_sa.cpp b/plugins/Dbx_mmap_SA/src/dbintf_sa.cpp index a06af08da7..8427c75b8b 100644 --- a/plugins/Dbx_mmap_SA/src/dbintf_sa.cpp +++ b/plugins/Dbx_mmap_SA/src/dbintf_sa.cpp @@ -48,10 +48,21 @@ int CDbxMmapSA::Load(bool bSkipInit) if (!p) return 1; - if (m_bEncoding && !CheckPassword(LOWORD(m_dbHeader.version), p + 1)) - return 1; + if (m_bEncoding) { + if (!CheckPassword(LOWORD(m_dbHeader.version), p + 1)) + return 1; + + // password validated ok? decrypt database + DecodeAll(); + } + + // write back mmap's signature not to open this profile again + memcpy(&m_dbHeader.signature, &dbSignatureU, sizeof(dbSignatureU)); + DBWrite(0, &dbSignatureU, sizeof(dbSignatureU)); + return 1; - InitDialogs(); + // no need to init that crap again + // InitDialogs(); } return 0; @@ -63,13 +74,9 @@ int CDbxMmapSA::CheckDbHeaders() m_bEncoding = true; else if (memcmp(m_dbHeader.signature, &dbSignatureNonSecured, sizeof(m_dbHeader.signature)) == 0) m_bEncoding = false; - else { - m_bEncoding = false; - if (memcmp(m_dbHeader.signature, &dbSignatureIM, sizeof(m_dbHeader.signature))) - return EGROKPRF_UNKHEADER; - if (LOWORD(m_dbHeader.version) != 0x0700) - return EGROKPRF_VERNEWER; - } + else + return EGROKPRF_UNKHEADER; + if (m_dbHeader.ofsUser == 0) return EGROKPRF_DAMAGED; return 0; -- cgit v1.2.3