summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-01-11 15:20:57 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-01-11 15:20:57 +0000
commit4f9f118ed6d053f4bdb530e7412a9229df3d10c4 (patch)
treea2240db3114422759fcae177b830592088ed4103 /plugins
parent60ed8dfff0234f4c9c6f0a7b7323e3a3faec2995 (diff)
- database preset file removed (as the atavism & rudiment);
- message about randomly chosen cryptor also removed git-svn-id: http://svn.miranda-ng.org/main/trunk@3057 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Dbx_mmap_SA/db3x_mmap_sa_10.vcxproj1
-rw-r--r--plugins/Dbx_mmap_SA/db3x_mmap_sa_10.vcxproj.filters3
-rw-r--r--plugins/Dbx_mmap_SA/db3x_mmap_sa_11.vcxproj1
-rw-r--r--plugins/Dbx_mmap_SA/db3x_mmap_sa_11.vcxproj.filters3
-rw-r--r--plugins/Dbx_mmap_SA/src/commonheaders.h5
-rw-r--r--plugins/Dbx_mmap_SA/src/dbpreset.cpp296
-rw-r--r--plugins/Dbx_mmap_SA/src/dialogs.cpp11
-rw-r--r--plugins/Dbx_mmap_SA/src/init.cpp2
-rw-r--r--plugins/Dbx_mmap_SA/src/security.cpp32
9 files changed, 16 insertions, 338 deletions
diff --git a/plugins/Dbx_mmap_SA/db3x_mmap_sa_10.vcxproj b/plugins/Dbx_mmap_SA/db3x_mmap_sa_10.vcxproj
index 1b8fdbd554..8b305bd2c2 100644
--- a/plugins/Dbx_mmap_SA/db3x_mmap_sa_10.vcxproj
+++ b/plugins/Dbx_mmap_SA/db3x_mmap_sa_10.vcxproj
@@ -228,7 +228,6 @@
<PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
<ClCompile Include="src\dbintf_sa.cpp" />
- <ClCompile Include="src\dbpreset.cpp" />
<ClCompile Include="src\dialogs.cpp" />
<ClCompile Include="src\stdafx.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
diff --git a/plugins/Dbx_mmap_SA/db3x_mmap_sa_10.vcxproj.filters b/plugins/Dbx_mmap_SA/db3x_mmap_sa_10.vcxproj.filters
index ece164e77b..ecddf5d298 100644
--- a/plugins/Dbx_mmap_SA/db3x_mmap_sa_10.vcxproj.filters
+++ b/plugins/Dbx_mmap_SA/db3x_mmap_sa_10.vcxproj.filters
@@ -21,9 +21,6 @@
</Filter>
</ItemGroup>
<ItemGroup>
- <ClCompile Include="src\dbpreset.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="src\dialogs.cpp">
<Filter>Source Files</Filter>
</ClCompile>
diff --git a/plugins/Dbx_mmap_SA/db3x_mmap_sa_11.vcxproj b/plugins/Dbx_mmap_SA/db3x_mmap_sa_11.vcxproj
index 34b828f089..51ef18c8fe 100644
--- a/plugins/Dbx_mmap_SA/db3x_mmap_sa_11.vcxproj
+++ b/plugins/Dbx_mmap_SA/db3x_mmap_sa_11.vcxproj
@@ -232,7 +232,6 @@
<PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
<ClCompile Include="src\dbintf_sa.cpp" />
- <ClCompile Include="src\dbpreset.cpp" />
<ClCompile Include="src\dialogs.cpp" />
<ClCompile Include="src\stdafx.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
diff --git a/plugins/Dbx_mmap_SA/db3x_mmap_sa_11.vcxproj.filters b/plugins/Dbx_mmap_SA/db3x_mmap_sa_11.vcxproj.filters
index ece164e77b..ecddf5d298 100644
--- a/plugins/Dbx_mmap_SA/db3x_mmap_sa_11.vcxproj.filters
+++ b/plugins/Dbx_mmap_SA/db3x_mmap_sa_11.vcxproj.filters
@@ -21,9 +21,6 @@
</Filter>
</ItemGroup>
<ItemGroup>
- <ClCompile Include="src\dbpreset.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="src\dialogs.cpp">
<Filter>Source Files</Filter>
</ClCompile>
diff --git a/plugins/Dbx_mmap_SA/src/commonheaders.h b/plugins/Dbx_mmap_SA/src/commonheaders.h
index ae6c07d2b5..a322878055 100644
--- a/plugins/Dbx_mmap_SA/src/commonheaders.h
+++ b/plugins/Dbx_mmap_SA/src/commonheaders.h
@@ -96,15 +96,14 @@ struct DlgChangePassParam
INT_PTR CALLBACK DlgChangePass(HWND hDlg, UINT uMsg,WPARAM wParam,LPARAM lParam);
INT_PTR CALLBACK DlgStdNewPass(HWND hDlg, UINT uMsg,WPARAM wParam,LPARAM lParam);
+INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+
void xModifyMenu(HANDLE hMenu,long flags,const TCHAR* name, HICON hIcon);
extern DBSignature dbSignature, dbSignatureSecured, dbSignatureNonSecured;
extern LIST<CDbxMmapSA> g_Dbs;
-int InitPreset();
-void UninitPreset();
-
typedef struct{
void* (__stdcall *GenerateKey)(char* pwd);
void (__stdcall *FreeKey)(void* key);
diff --git a/plugins/Dbx_mmap_SA/src/dbpreset.cpp b/plugins/Dbx_mmap_SA/src/dbpreset.cpp
deleted file mode 100644
index 564bbf3c40..0000000000
--- a/plugins/Dbx_mmap_SA/src/dbpreset.cpp
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
-
-Miranda IM: the free IM client for Microsoft* Windows*
-
-Copyright 2000-2003 Miranda ICQ/IM project,
-all portions of this codebase are copyrighted to the people
-listed in contributors.txt.
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program 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 General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-// Miranda Memory-Mapped Secured DataBase
-// (C) Artem Shpynov aka FYR, Igonin Vitaliy aka chaos.persei, Victor Pavlychko aka nullbie, 2007 - 2008
-
-#include "commonheaders.h"
-
-/* Public API */
-int DBPreset_QuerySetting (const char *szModule, const char *szSetting, DBVARIANT *dbv, BOOL isStatic);
-int DBPreset_CompareSetting (const char *szModule, const char *szSetting, DBVARIANT *dbv);
-
-/* Preset cache item */
-typedef struct
-{
- DWORD dwHash;
- char *szModule;
- char *szSetting;
- DBVARIANT dbv;
-} DBPresetItem;
-
-static DBPresetItem * DBPresetItem_Create (char *szModule, char *szSetting, BYTE bType);
-static void DBPresetItem_Destroy (DBPresetItem *item);
-static void DBPresetItem_Hash (DBPresetItem *item);
-static int DBPresetItem_Cmp (DBPresetItem *item1, DBPresetItem *item2);
-
-SortedList *lstPresets = NULL;
-
-int InitPreset()
-{
- char szIniPath[MAX_PATH];
- char szLine[2048];
- int lineLength;
- char szSection[128];
- FILE *fp;
-
- GetModuleFileNameA(GetModuleHandle(NULL), szIniPath, SIZEOF(szIniPath));
- strcpy(strrchr(szIniPath, '\\')+1, "dbpreset.ini");
-
- fp = fopen(szIniPath,"rt");
-
- // no preset
- if (!fp) return 0;
-
- lstPresets = List_Create(0, 50);
- lstPresets->sortFunc = (FSortFunc)DBPresetItem_Cmp;
-
- while(!feof(fp))
- {
- if (fgets(szLine,sizeof(szLine),fp) == NULL) break;
- lineLength = lstrlenA(szLine);
- while(lineLength && (BYTE)(szLine[lineLength-1]) <= ' ') szLine[--lineLength] = '\0';
- if (szLine[0] == ';' || szLine[0] <= ' ') continue;
- if (szLine[0] == '[')
- {
- char *szEnd = strchr(szLine+1,']');
- if (szEnd == NULL) continue;
- if (szLine[1] == '!')
- szSection[0] = '\0';
- else
- lstrcpynA(szSection, szLine+1, (int)min(sizeof(szSection), szEnd-szLine));
- } else
- {
- char *szValue;
- char szName[128];
- DBPresetItem *item;
-
- if (szSection[0] == '\0') continue;
- szValue = strchr(szLine,' = ');
- if (szValue == NULL) continue;
- lstrcpynA(szName, szLine, (int)min(sizeof(szName), szValue-szLine+1));
- szValue++;
-
- switch(szValue[0])
- {
- case 'b':
- case 'B':
- item = DBPresetItem_Create(szSection, szName, DBVT_BYTE);
- item->dbv.bVal = (BYTE)strtol(szValue+1,NULL,0);
- List_InsertPtr(lstPresets, item);
- break;
- case 'w':
- case 'W':
- item = DBPresetItem_Create(szSection, szName, DBVT_WORD);
- item->dbv.wVal = (WORD)strtol(szValue+1,NULL,0);
- List_InsertPtr(lstPresets, item);
- break;
- case 'd':
- case 'D':
- item = DBPresetItem_Create(szSection, szName, DBVT_DWORD);
- item->dbv.dVal = (DWORD)strtoul(szValue+1,NULL,0);
- List_InsertPtr(lstPresets, item);
- break;
- case 's':
- case 'S':
- item = DBPresetItem_Create(szSection, szName, DBVT_ASCIIZ);
- item->dbv.pszVal = mir_strdup(szValue+1);
- List_InsertPtr(lstPresets, item);
- break;
- case 'u':
- case 'U':
- item = DBPresetItem_Create(szSection, szName, DBVT_UTF8);
- item->dbv.pszVal = mir_strdup(szValue+1);
- List_InsertPtr(lstPresets, item);
- break;
- case 'n':
- case 'N':
- {
- PBYTE buf;
- int len;
- char *pszValue,*pszEnd;
-
- buf = (PBYTE)mir_alloc(lstrlenA(szValue+1));
- for (len = 0,pszValue = szValue+1;;len++) {
- buf[len] = (BYTE)strtol(pszValue,&pszEnd,0x10);
- if (pszValue == pszEnd) break;
- pszValue = pszEnd;
- }
-
- item = DBPresetItem_Create(szSection, szName, DBVT_BLOB);
- item->dbv.pbVal = buf;
- item->dbv.cpbVal = len;
- List_InsertPtr(lstPresets, item);
- break;
- }
- }
- }
- }
- fclose(fp);
-
- return 0;
-}
-
-void UninitPreset()
-{
- int i;
- if (!lstPresets) return;
- for (i = 0; i < lstPresets->realCount; ++i)
- DBPresetItem_Destroy((DBPresetItem *)lstPresets->items[i]);
- List_Destroy(lstPresets);
-}
-
-int DBPreset_QuerySetting(const char *szModule, const char *szSetting, DBVARIANT *dbv, BOOL isStatic)
-{
- DBPresetItem *item;
- DBPresetItem search = {0};
-
- if (!lstPresets) return FALSE;
-
- search.szModule = (char *)szModule;
- search.szSetting = (char *)szSetting;
- DBPresetItem_Hash(&search);
- item = (DBPresetItem *)List_Find(lstPresets, &search);
-
- if (!item) return FALSE;
-
- dbv->type = item->dbv.type;
- switch (item->dbv.type)
- {
- case DBVT_BYTE: dbv->bVal = item->dbv.bVal; return TRUE;
- case DBVT_WORD: dbv->wVal = item->dbv.wVal; return TRUE;
- case DBVT_DWORD: dbv->dVal = item->dbv.dVal; return TRUE;
-
- case DBVT_UTF8:
- case DBVT_ASCIIZ:
- if (isStatic && dbv->pszVal)
- lstrcpynA(dbv->pszVal, item->dbv.pszVal, dbv->cchVal);
- else if (!isStatic)
- dbv->pszVal = mir_strdup(item->dbv.pszVal);
- return TRUE;
-
- default:
- return FALSE;
- }
-
- return FALSE;
-}
-
-int DBPreset_CompareSetting(const char *szModule, const char *szSetting, DBVARIANT *dbv)
-{
- DBPresetItem *item;
- DBPresetItem search = {0};
-
- if (!lstPresets) return FALSE;
-
- search.szModule = (char *)szModule;
- search.szSetting = (char *)szSetting;
- DBPresetItem_Hash(&search);
- item = (DBPresetItem *)List_Find(lstPresets, &search);
-
- if (!item) return FALSE;
- if (item->dbv.type != item->dbv.type) return FALSE;
- switch (item->dbv.type)
- {
- case DBVT_BYTE: return dbv->bVal == item->dbv.bVal ? TRUE : FALSE;
- case DBVT_WORD: return dbv->wVal == item->dbv.wVal ? TRUE : FALSE;
- case DBVT_DWORD: return dbv->dVal == item->dbv.dVal ? TRUE : FALSE;
- case DBVT_UTF8:
- case DBVT_ASCIIZ: return strcmp(dbv->pszVal, item->dbv.pszVal) ? FALSE : TRUE;
- }
-
- return FALSE;
-}
-
-static DBPresetItem *DBPresetItem_Create(char *szModule, char *szSetting, BYTE bType)
-{
- DBPresetItem *item = (DBPresetItem *)mir_alloc(sizeof(DBPresetItem));
- item->szModule = mir_strdup(szModule);
- item->szSetting = mir_strdup(szSetting);
- DBPresetItem_Hash(item);
- item->dbv.type = bType;
- return item;
-}
-
-static void DBPresetItem_Destroy(DBPresetItem *item)
-{
- if (!item) return;
- if (item->szModule)
- {
- mir_free(item->szModule);
- item->szModule = NULL;
- }
- if (item->szSetting)
- {
- mir_free(item->szSetting);
- item->szSetting = NULL;
- }
-
- switch (item->dbv.type)
- {
- case DBVT_ASCIIZ:
- case DBVT_UTF8:
- case DBVT_WCHAR:
- {
- if (item->dbv.pszVal)
- mir_free(item->dbv.pszVal);
- item->dbv.pszVal = 0;
- break;
- }
- case DBVT_BLOB:
- {
- if (item->dbv.pbVal)
- mir_free(item->dbv.pbVal);
- item->dbv.pbVal = 0;
- break;
- }
- }
- item->dbv.type = 0;
-}
-
-static void DBPresetItem_Hash(DBPresetItem *item)
-{
- int i;
- int shift = 0;
- item->dwHash = 0;
- for (i = 0;item->szModule[i];i++)
- {
- item->dwHash ^= item->szModule[i]<<shift;
- if (shift>24) item->dwHash ^= (item->szModule[i]>>(32-shift))&0x7F;
- shift = (shift+5)&0x1F;
- }
- for (i = 0;item->szSetting[i];i++)
- {
- item->dwHash ^= item->szSetting[i]<<shift;
- if (shift>24) item->dwHash ^= (item->szSetting[i]>>(32-shift))&0x7F;
- shift = (shift+5)&0x1F;
- }
-}
-
-static int DBPresetItem_Cmp(DBPresetItem *item1, DBPresetItem *item2)
-{
- int cmp;
- if (item1->dwHash < item2->dwHash) return -1;
- if (item1->dwHash > item2->dwHash) return 1;
- if (cmp = strcmp(item1->szModule, item2->szModule)) return cmp;
- return strcmp(item1->szSetting, item2->szSetting);
-}
diff --git a/plugins/Dbx_mmap_SA/src/dialogs.cpp b/plugins/Dbx_mmap_SA/src/dialogs.cpp
index cbe35bb4d1..1d5c4fe4df 100644
--- a/plugins/Dbx_mmap_SA/src/dialogs.cpp
+++ b/plugins/Dbx_mmap_SA/src/dialogs.cpp
@@ -10,7 +10,6 @@ extern LIST<CryptoModule> arCryptors;
HANDLE hSetPwdMenu;
-INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
BOOL ShowDlgItem(HWND hwndDlg, int iIDCtrl, BOOL bShow)
{
HWND hwndCtrl = GetDlgItem(hwndDlg, iIDCtrl);
@@ -165,7 +164,7 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
ListView_SetExtendedListViewStyleEx(hwndList, 0, LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT | LVS_EX_SUBITEMIMAGES);
- uid = DBGetContactSettingWord(NULL, "SecureMMAP", "CryptoModule", 0);
+ uid = db_get_w(NULL, "SecureMMAP", "CryptoModule", 0);
for (i = 0; i < arCryptors.getCount(); i++) {
TCHAR buf[100];
@@ -261,12 +260,12 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
if (alg > -1){
if (!p_Db->m_bEncoding){
- DBWriteContactSettingWord(NULL, "SecureMMAP", "CryptoModule", arCryptors[alg]->cryptor->uid);
+ db_set_w(NULL, "SecureMMAP", "CryptoModule", arCryptors[alg]->cryptor->uid);
p_Db->EncryptDB();
}
else {
- if (arCryptors[alg]->cryptor->uid != DBGetContactSettingWord(NULL, "SecureMMAP", "CryptoModule", -1)) {
- DBWriteContactSettingWord(NULL, "SecureMMAP", "CryptoModule", arCryptors[alg]->cryptor->uid);
+ if (arCryptors[alg]->cryptor->uid != db_get_w(NULL, "SecureMMAP", "CryptoModule", -1)) {
+ db_set_w(NULL, "SecureMMAP", "CryptoModule", arCryptors[alg]->cryptor->uid);
p_Db->RecryptDB();
}
}
@@ -274,7 +273,7 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
else if (p_Db->m_bEncoding)
p_Db->DecryptDB();
- uid = DBGetContactSettingWord(NULL, "SecureMMAP", "CryptoModule", 0);
+ uid = db_get_w(NULL, "SecureMMAP", "CryptoModule", 0);
for (i = 0; i < arCryptors.getCount(); i++) {
if (uid == arCryptors[i]->cryptor->uid && p_Db->m_bEncoding)
diff --git a/plugins/Dbx_mmap_SA/src/init.cpp b/plugins/Dbx_mmap_SA/src/init.cpp
index 688cd36716..65cfd44561 100644
--- a/plugins/Dbx_mmap_SA/src/init.cpp
+++ b/plugins/Dbx_mmap_SA/src/init.cpp
@@ -133,7 +133,6 @@ extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_DATABAS
extern "C" __declspec(dllexport) int Load(void)
{
InitSecurity();
- InitPreset();
RegisterDatabasePlugin(&dblink);
return 0;
@@ -143,7 +142,6 @@ extern "C" __declspec(dllexport) int Unload(void)
{
g_Dbs.destroy();
UnloadSecurity();
- UninitPreset();
return 0;
}
diff --git a/plugins/Dbx_mmap_SA/src/security.cpp b/plugins/Dbx_mmap_SA/src/security.cpp
index 9755d55e6a..8b075a37a0 100644
--- a/plugins/Dbx_mmap_SA/src/security.cpp
+++ b/plugins/Dbx_mmap_SA/src/security.cpp
@@ -164,37 +164,23 @@ int CDbxMmapSA::CheckPassword(WORD checkWord, TCHAR *szDBName)
int SelectEncoder()
{
- WORD uid;
- int i;
-
if (arCryptors.getCount() == 0){
MessageBox(0, TranslateT("Crypto modules not found"), TranslateT("Error"), MB_OK | MB_ICONERROR);
return 1;
}
- uid = DBGetContactSettingWord(NULL, "SecureMMAP", "CryptoModule", 0);
-
- if (uid == 0){
- MessageBox(0, TranslateT("Crypto module hasn't been chosen, using first one found"), TranslateT("Notice"), MB_OK | MB_ICONINFORMATION);
- DBWriteContactSettingWord(NULL, "SecureMMAP", "CryptoModule", arCryptors[0]->cryptor->uid);
- CryptoEngine = arCryptors[0]->cryptor;
- }
- else{
- int Found = 0;
- for (i = 0; i < arCryptors.getCount(); i++) {
- if (arCryptors[i]->cryptor->uid == uid){
+ WORD uid = db_get_w(NULL, "SecureMMAP", "CryptoModule", 0);
+ if (uid != 0) {
+ for (int i = 0; i < arCryptors.getCount(); i++) {
+ if (arCryptors[i]->cryptor->uid == uid) {
CryptoEngine = arCryptors[i]->cryptor;
- Found = 1;
- break;
+ return 0;
}
}
- if (!Found){
- MessageBox(0, TranslateT("Crypto module hasn't been chosen, using first one found"), TranslateT("Notice"), MB_OK | MB_ICONINFORMATION);
- DBWriteContactSettingWord(NULL, "SecureMMAP", "CryptoModule", arCryptors[0]->cryptor->uid);
- CryptoEngine = arCryptors[0]->cryptor;
- }
}
+ db_set_w(NULL, "SecureMMAP", "CryptoModule", arCryptors[0]->cryptor->uid);
+ CryptoEngine = arCryptors[0]->cryptor;
return 0;
}
@@ -319,7 +305,7 @@ void CDbxMmapSA::DecryptDB()
xModifyMenu(hSetPwdMenu, 0, LPGENT("Set Password"), 0);
- DBWriteContactSettingWord(NULL, "SecureMMAP", "CryptoModule", 0);
+ db_set_w(NULL, "SecureMMAP", "CryptoModule", 0);
CryptoEngine->FreeKey(key);
@@ -368,7 +354,7 @@ void CDbxMmapSA::ChangePwd()
m_bEncoding = 0;
CryptoEngine = NULL;
- DBWriteContactSettingWord(NULL, "SecureMMAP", "CryptoModule", 0);
+ db_set_w(NULL, "SecureMMAP", "CryptoModule", 0);
zero_fill((BYTE *)encryptKey, sizeof encryptKey);