summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/Db3x_mmap/src/dbsettings.cpp2
-rw-r--r--plugins/Dbx_mmap_SA/src/commonheaders.h16
-rw-r--r--plugins/Dbx_mmap_SA/src/dbintf_sa.cpp26
-rw-r--r--plugins/Dbx_mmap_SA/src/dbintf_sa.h7
-rw-r--r--plugins/Dbx_mmap_SA/src/dialogs.cpp184
-rw-r--r--plugins/Dbx_mmap_SA/src/init.cpp14
-rw-r--r--plugins/Dbx_mmap_SA/src/security.cpp36
7 files changed, 153 insertions, 132 deletions
diff --git a/plugins/Db3x_mmap/src/dbsettings.cpp b/plugins/Db3x_mmap/src/dbsettings.cpp
index 55c43622d4..71b64c7df1 100644
--- a/plugins/Db3x_mmap/src/dbsettings.cpp
+++ b/plugins/Db3x_mmap/src/dbsettings.cpp
@@ -328,7 +328,7 @@ STDMETHODIMP_(BOOL) CDb3Base::FreeVariant(DBVARIANT *dbv)
STDMETHODIMP_(BOOL) CDb3Base::SetSettingResident(BOOL bIsResident, const char *pszSettingName)
{
- char *szSetting = m_cache->GetCachedSetting(NULL, pszSettingName, 0, strlen(pszSettingName));
+ char *szSetting = m_cache->GetCachedSetting(NULL, pszSettingName, 0, (int)strlen(pszSettingName));
szSetting[-1] = (char)bIsResident;
mir_cslock lck(m_csDbAccess);
diff --git a/plugins/Dbx_mmap_SA/src/commonheaders.h b/plugins/Dbx_mmap_SA/src/commonheaders.h
index 6f4aa0b4b3..ae6c07d2b5 100644
--- a/plugins/Dbx_mmap_SA/src/commonheaders.h
+++ b/plugins/Dbx_mmap_SA/src/commonheaders.h
@@ -81,14 +81,26 @@ void DecodeCopyMemory(void * dst, void * src, size_t size );
void EncodeDBWrite(DWORD ofs, void * src, size_t size);
void DecodeDBWrite(DWORD ofs, void * src, size_t size);
+struct DlgStdInProcParam
+{
+ CDbxMmapSA *p_Db;
+ const TCHAR *pStr;
+};
INT_PTR CALLBACK DlgStdInProc(HWND hDlg, UINT uMsg,WPARAM wParam,LPARAM lParam);
-INT_PTR CALLBACK DlgStdNewPass(HWND hDlg, UINT uMsg,WPARAM wParam,LPARAM lParam);
+
+struct DlgChangePassParam
+{
+ CDbxMmapSA *p_Db;
+ char *pszNewPass;
+};
INT_PTR CALLBACK DlgChangePass(HWND hDlg, UINT uMsg,WPARAM wParam,LPARAM lParam);
+
+INT_PTR CALLBACK DlgStdNewPass(HWND hDlg, UINT uMsg,WPARAM wParam,LPARAM lParam);
void xModifyMenu(HANDLE hMenu,long flags,const TCHAR* name, HICON hIcon);
extern DBSignature dbSignature, dbSignatureSecured, dbSignatureNonSecured;
-extern LIST<CDdxMmapSA> g_Dbs;
+extern LIST<CDbxMmapSA> g_Dbs;
int InitPreset();
void UninitPreset();
diff --git a/plugins/Dbx_mmap_SA/src/dbintf_sa.cpp b/plugins/Dbx_mmap_SA/src/dbintf_sa.cpp
index b7dec7c908..04c125f31e 100644
--- a/plugins/Dbx_mmap_SA/src/dbintf_sa.cpp
+++ b/plugins/Dbx_mmap_SA/src/dbintf_sa.cpp
@@ -27,19 +27,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define MoveAlong(n) {int x=n; pBlob+=(x); ofsBlobPtr+=(x); bytesRemaining-=(x);}
#define VLT(n) ((n==DBVT_UTF8)?DBVT_ASCIIZ:n)
-extern CDdxMmapSA* g_Db;
-
-int InitDialogs(void);
-
DBSignature dbSignatureSecured = {"Miranda ICQ SD",0x1A};
DBSignature dbSignatureNonSecured = {"Miranda ICQ SA",0x1A};
-CDdxMmapSA::CDdxMmapSA(const TCHAR* tszFileName) :
+CDbxMmapSA::CDbxMmapSA(const TCHAR* tszFileName) :
CDb3Mmap(tszFileName)
{
}
-int CDdxMmapSA::Load(bool bSkipInit)
+int CDbxMmapSA::Load(bool bSkipInit)
{
if ( CDb3Mmap::Load(bSkipInit) != ERROR_SUCCESS)
return 1;
@@ -52,7 +48,6 @@ int CDdxMmapSA::Load(bool bSkipInit)
if (!p)
return 1;
- g_Db = this;
if (m_bEncoding && !CheckPassword( LOWORD(m_dbHeader.version), p+1))
return 1;
@@ -62,7 +57,7 @@ int CDdxMmapSA::Load(bool bSkipInit)
return 0;
}
-int CDdxMmapSA::CheckDbHeaders()
+int CDbxMmapSA::CheckDbHeaders()
{
if ( memcmp(m_dbHeader.signature, &dbSignatureSecured, sizeof(m_dbHeader.signature)) == 0)
m_bEncoding = true;
@@ -88,7 +83,7 @@ static DWORD __inline GetSettingValueLength(PBYTE pSetting)
return pSetting[0];
}
-void CDdxMmapSA::EncodeContactSettings(HANDLE hContact)
+void CDbxMmapSA::EncodeContactSettings(HANDLE hContact)
{
if (!hContact)
hContact = (HANDLE)m_dbHeader.ofsUser;
@@ -146,7 +141,7 @@ void CDdxMmapSA::EncodeContactSettings(HANDLE hContact)
}
}
-void CDdxMmapSA::DecodeContactSettings(HANDLE hContact)
+void CDbxMmapSA::DecodeContactSettings(HANDLE hContact)
{
if (!hContact)
hContact = (HANDLE)m_dbHeader.ofsUser;
@@ -204,21 +199,21 @@ void CDdxMmapSA::DecodeContactSettings(HANDLE hContact)
}
}
-void CDdxMmapSA::EncodeEvent(HANDLE hEvent)
+void CDbxMmapSA::EncodeEvent(HANDLE hEvent)
{
DBEvent *dbe = (DBEvent*)DBRead((DWORD)hEvent,sizeof(DBEvent),NULL);
if (dbe->signature = DBEVENT_SIGNATURE)
CryptoEngine->EncryptMem(DBRead((DWORD)hEvent + offsetof(DBEvent,blob), dbe->cbBlob, NULL), dbe->cbBlob, key);
}
-void CDdxMmapSA::DecodeEvent(HANDLE hEvent)
+void CDbxMmapSA::DecodeEvent(HANDLE hEvent)
{
DBEvent *dbe = (DBEvent*)DBRead((DWORD)hEvent,sizeof(DBEvent),NULL);
if (dbe->signature = DBEVENT_SIGNATURE)
CryptoEngine->DecryptMem(DBRead((DWORD)hEvent + offsetof(DBEvent,blob), dbe->cbBlob, NULL), dbe->cbBlob, key);
}
-void CDdxMmapSA::EncodeContactEvents(HANDLE hContact)
+void CDbxMmapSA::EncodeContactEvents(HANDLE hContact)
{
HANDLE hEvent = FindFirstEvent(hContact);
while (hEvent != 0) {
@@ -227,7 +222,7 @@ void CDdxMmapSA::EncodeContactEvents(HANDLE hContact)
}
}
-void CDdxMmapSA::DecodeContactEvents(HANDLE hContact)
+void CDbxMmapSA::DecodeContactEvents(HANDLE hContact)
{
HANDLE hEvent = FindFirstEvent(hContact);
while (hEvent != 0) {
@@ -236,7 +231,7 @@ void CDdxMmapSA::DecodeContactEvents(HANDLE hContact)
}
}
-int CDdxMmapSA::WorkInitialCheckHeaders(void)
+int CDbxMmapSA::WorkInitialCheckHeaders(void)
{
if (m_bEncoding) {
cb->pfnAddLogMessage(STATUS_SUCCESS,TranslateT("Database is Secured MMAP database"));
@@ -245,7 +240,6 @@ int CDdxMmapSA::WorkInitialCheckHeaders(void)
if (!p)
return ERROR_BAD_FORMAT;
- g_Db = this;
if (!CheckPassword( LOWORD(m_dbHeader.version), p+1)) {
cb->pfnAddLogMessage(STATUS_FATAL,TranslateT("You are not authorized for access to Database"));
return ERROR_BAD_FORMAT;
diff --git a/plugins/Dbx_mmap_SA/src/dbintf_sa.h b/plugins/Dbx_mmap_SA/src/dbintf_sa.h
index a65b4ebe3d..bd96407e2a 100644
--- a/plugins/Dbx_mmap_SA/src/dbintf_sa.h
+++ b/plugins/Dbx_mmap_SA/src/dbintf_sa.h
@@ -25,9 +25,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "..\Db3x_mmap\src\dbintf.h"
-struct CDdxMmapSA : public CDb3Mmap
+struct CDbxMmapSA : public CDb3Mmap
{
- CDdxMmapSA(const TCHAR* tszFileName);
+ CDbxMmapSA(const TCHAR* tszFileName);
int CheckPassword(WORD checkWord, TCHAR *szDBName);
int CheckDbHeaders(void);
@@ -70,4 +70,7 @@ protected:
public:
char encryptKey[255];
size_t encryptKeyLength;
+
+private:
+ void InitDialogs(void);
};
diff --git a/plugins/Dbx_mmap_SA/src/dialogs.cpp b/plugins/Dbx_mmap_SA/src/dialogs.cpp
index 295385fc30..8d3800d3c2 100644
--- a/plugins/Dbx_mmap_SA/src/dialogs.cpp
+++ b/plugins/Dbx_mmap_SA/src/dialogs.cpp
@@ -8,7 +8,6 @@
extern LIST<CryptoModule> arCryptors;
-CDdxMmapSA* g_Db;
HANDLE hSetPwdMenu;
INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
@@ -43,7 +42,7 @@ BOOL IsDlgItemEnabled(HWND hwndDlg, int iIDCtrl)
return IsWindowEnabled(hwndCtrl);
}
-static int OptionsInit(WPARAM wParam, LPARAM lParam)
+static int OptionsInit(void *obj, WPARAM wParam, LPARAM lParam)
{
OPTIONSDIALOGPAGE odp = { 0 };
odp.cbSize = sizeof(odp);
@@ -54,16 +53,19 @@ static int OptionsInit(WPARAM wParam, LPARAM lParam)
odp.ptszTitle = LPGENT("Database Features");
odp.ptszGroup = LPGENT("Database");
odp.pfnDlgProc = DlgProcOptions;
+ odp.dwInitParam = (LPARAM)obj;
Options_AddPage(wParam, &odp);
return 0;
}
-INT_PTR ChangePassword(WPARAM wParam, LPARAM lParam)
+INT_PTR ChangePassword(void* obj, LPARAM wParam, LPARAM lParam)
{
- if (g_Db->m_bEncoding)
- g_Db->ChangePwd();
+ CDbxMmapSA *p = (CDbxMmapSA*)obj;
+
+ if (p->m_bEncoding)
+ p->ChangePwd();
else
- g_Db->EncryptDB();
+ p->EncryptDB();
return 0;
}
@@ -86,9 +88,11 @@ static IconItem iconList[] =
{ LPGEN("Change Password"), "password", IDI_ICON3 }
};
-int InitMenus(WPARAM, LPARAM)
+int InitMenus(void *obj, WPARAM, LPARAM)
{
- HookEvent(ME_OPT_INITIALISE, OptionsInit);
+ CDbxMmapSA *p = (CDbxMmapSA*)obj;
+
+ HookEventObj(ME_OPT_INITIALISE, OptionsInit, obj);
Icon_Register(g_hInst, LPGEN("Database"), iconList, SIZEOF(iconList));
@@ -96,7 +100,7 @@ int InitMenus(WPARAM, LPARAM)
CLISTMENUITEM mi = { sizeof(mi) };
mi.flags = CMIM_ALL | CMIF_TCHAR | CMIF_ICONFROMICOLIB;
mi.icolibItem = iconList[1].hIcolib;
- mi.ptszName = (g_Db->m_bEncoding) ? LPGENT("Change password") : LPGENT("Set password");
+ mi.ptszName = (p->m_bEncoding) ? LPGENT("Change password") : LPGENT("Set password");
mi.ptszPopupName = LPGENT("Database");
mi.pszService = MS_DB_CHANGEPASSWORD;
mi.position = 500100000;
@@ -104,11 +108,10 @@ int InitMenus(WPARAM, LPARAM)
return 0;
}
-int InitDialogs()
+void CDbxMmapSA::InitDialogs()
{
- HookEvent(ME_SYSTEM_MODULESLOADED, InitMenus);
- CreateServiceFunction(MS_DB_CHANGEPASSWORD, ChangePassword);
- return 0;
+ HookEventObj(ME_SYSTEM_MODULESLOADED, InitMenus, this);
+ CreateServiceFunctionObj(MS_DB_CHANGEPASSWORD, ChangePassword, this);
}
int ImageList_AddIcon_IconLibLoaded(HIMAGELIST hIml, char* name)
@@ -121,6 +124,7 @@ int ImageList_AddIcon_IconLibLoaded(HIMAGELIST hIml, char* name)
INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
HWND hwndList = GetDlgItem(hwndDlg, IDC_MODULES);
+ CDbxMmapSA *p_Db = (CDbxMmapSA*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
LVCOLUMN col;
LVITEM item;
int i, iRow, iIndex;
@@ -132,6 +136,8 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
case WM_INITDIALOG:
hIml = ImageList_Create(16, 16, ILC_MASK | (IsWinVerXPPlus()? ILC_COLOR32 : ILC_COLOR16), 2, 0);
TranslateDialogDefault( hwndDlg );
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
+ p_Db = (CDbxMmapSA*)lParam;
ImageList_AddIcon_IconLibLoaded( hIml, "core_main_29" );
ImageList_AddIcon_IconLibLoaded( hIml, "core_main_30" );
@@ -176,13 +182,13 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
mir_sntprintf(buf,SIZEOF(buf),_T("%d.%d.%d.%d"), HIBYTE(HIWORD(arCryptors[i]->cryptor->Version)), LOBYTE(HIWORD(arCryptors[i]->cryptor->Version)), HIBYTE(LOWORD(arCryptors[i]->cryptor->Version)), LOBYTE(LOWORD(arCryptors[i]->cryptor->Version)));
ListView_SetItemText(hwndList, iRow, 3, buf);
- if (uid == arCryptors[i]->cryptor->uid && g_Db->m_bEncoding)
+ if (uid == arCryptors[i]->cryptor->uid && p_Db->m_bEncoding)
ListView_SetCheckState(hwndList, i, 1);
item.mask = LVIF_IMAGE;
item.iItem = iRow;
item.iSubItem = 0;
- item.iImage = ( CryptoEngine == arCryptors[i]->cryptor && g_Db->m_bEncoding ) ? 0 : 1;
+ item.iImage = ( CryptoEngine == arCryptors[i]->cryptor && p_Db->m_bEncoding ) ? 0 : 1;
ListView_SetItem( hwndList, &item );
}
@@ -254,30 +260,30 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
}
if (alg > -1){
- if (!g_Db->m_bEncoding){
+ if (!p_Db->m_bEncoding){
DBWriteContactSettingWord(NULL, "SecureMMAP", "CryptoModule", arCryptors[alg]->cryptor->uid);
- g_Db->EncryptDB();
+ p_Db->EncryptDB();
}
else {
if (arCryptors[alg]->cryptor->uid != DBGetContactSettingWord(NULL, "SecureMMAP", "CryptoModule", -1)) {
DBWriteContactSettingWord(NULL, "SecureMMAP", "CryptoModule", arCryptors[alg]->cryptor->uid);
- g_Db->RecryptDB();
+ p_Db->RecryptDB();
}
}
}
- else if (g_Db->m_bEncoding)
- g_Db->DecryptDB();
+ else if (p_Db->m_bEncoding)
+ p_Db->DecryptDB();
uid = DBGetContactSettingWord(NULL, "SecureMMAP", "CryptoModule", 0);
for (i = 0; i < arCryptors.getCount(); i++) {
- if (uid == arCryptors[i]->cryptor->uid && g_Db->m_bEncoding)
+ if (uid == arCryptors[i]->cryptor->uid && p_Db->m_bEncoding)
ListView_SetCheckState(hwndList, i, 1);
item.mask = LVIF_IMAGE;
item.iItem = i;
item.iSubItem = 0;
- item.iImage = ( CryptoEngine == arCryptors[i]->cryptor && g_Db->m_bEncoding ) ? 0 : 1;
+ item.iImage = ( CryptoEngine == arCryptors[i]->cryptor && p_Db->m_bEncoding ) ? 0 : 1;
ListView_SetItem( hwndList, &item );
}
@@ -310,29 +316,32 @@ extern BOOL wrongPass;
INT_PTR CALLBACK DlgStdInProc(HWND hDlg, UINT uMsg,WPARAM wParam,LPARAM lParam)
{
- HICON hIcon = 0;
TCHAR tszHeaderTxt[256];
switch(uMsg) {
case WM_INITDIALOG:
TranslateDialogDefault(hDlg);
+ {
+ HICON hIcon = LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_ICON2));
+ SendMessage(GetDlgItem(hDlg, IDC_HEADERBAR), WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
- hIcon = LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_ICON2));
- SendMessage(GetDlgItem(hDlg, IDC_HEADERBAR), WM_SETICON, 0, (LPARAM)hIcon);
+ DlgStdInProcParam *param = (DlgStdInProcParam*)lParam;
+ SetWindowLongPtr(hDlg, GWLP_USERDATA, (LPARAM)param->p_Db);
- if (!wrongPass) {
- mir_sntprintf(tszHeaderTxt, SIZEOF(tszHeaderTxt), _T("%s\n%s"), TranslateT("Please type in your password for"), (TCHAR*)lParam);
- SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), tszHeaderTxt);
- }
- else {
- if (wrongPass > 2) {
- HWND hwndCtrl = GetDlgItem(hDlg, IDC_USERPASS);
- EnableWindow(hwndCtrl, FALSE);
- hwndCtrl = GetDlgItem(hDlg, IDOK);
- EnableWindow(hwndCtrl, FALSE);
- SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Too many errors!"));
+ if (!wrongPass) {
+ mir_sntprintf(tszHeaderTxt, SIZEOF(tszHeaderTxt), _T("%s\n%s"), TranslateT("Please type in your password for"), param->pStr);
+ SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), tszHeaderTxt);
+ }
+ else {
+ if (wrongPass > 2) {
+ HWND hwndCtrl = GetDlgItem(hDlg, IDC_USERPASS);
+ EnableWindow(hwndCtrl, FALSE);
+ hwndCtrl = GetDlgItem(hDlg, IDOK);
+ EnableWindow(hwndCtrl, FALSE);
+ SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Too many errors!"));
+ }
+ else SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Password is not correct!"));
}
- else SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Password is not correct!"));
}
oldLangID = 0;
SetTimer(hDlg,1,200,NULL);
@@ -351,7 +360,8 @@ INT_PTR CALLBACK DlgStdInProc(HWND hDlg, UINT uMsg,WPARAM wParam,LPARAM lParam)
switch( LOWORD(wParam)) {
case IDOK:
if (!GetWindowLongPtr(hDlg,GWLP_USERDATA)) {
- g_Db->encryptKeyLength = GetDlgItemTextA(hDlg, IDC_USERPASS, g_Db->encryptKey, 254);
+ CDbxMmapSA *p_Db = (CDbxMmapSA*)GetWindowLongPtr(hDlg, GWLP_USERDATA);
+ p_Db->encryptKeyLength = GetDlgItemTextA(hDlg, IDC_USERPASS, p_Db->encryptKey, 254);
EndDialog(hDlg,IDOK);
}
break;
@@ -367,7 +377,7 @@ INT_PTR CALLBACK DlgStdInProc(HWND hDlg, UINT uMsg,WPARAM wParam,LPARAM lParam)
case WM_DESTROY:
KillTimer(hDlg, 1);
- DestroyIcon(hIcon);
+ DestroyIcon((HICON)SendMessage(hDlg, WM_GETICON, ICON_SMALL, 0));
}
return FALSE;
@@ -375,14 +385,12 @@ INT_PTR CALLBACK DlgStdInProc(HWND hDlg, UINT uMsg,WPARAM wParam,LPARAM lParam)
INT_PTR CALLBACK DlgStdNewPass(HWND hDlg, UINT uMsg,WPARAM wParam,LPARAM lParam)
{
- HICON hIcon = 0;
-
switch(uMsg) {
case WM_INITDIALOG:
TranslateDialogDefault(hDlg);
+ SetWindowLongPtr(hDlg, GWLP_USERDATA, (LPARAM)lParam);
- hIcon = LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_ICON2));
- SendMessage(GetDlgItem(hDlg, IDC_HEADERBAR), WM_SETICON, 0, (LPARAM)hIcon);
+ SendMessage(GetDlgItem(hDlg, IDC_HEADERBAR), WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_ICON2)));
SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Please enter your new password"));
@@ -404,6 +412,7 @@ INT_PTR CALLBACK DlgStdNewPass(HWND hDlg, UINT uMsg,WPARAM wParam,LPARAM lParam)
UINT uid = LOWORD(wParam);
if (uid == IDOK) {
if (!GetWindowLongPtr(hDlg,GWLP_USERDATA)) {
+ CDbxMmapSA *p_Db = (CDbxMmapSA*)GetWindowLongPtr(hDlg, GWLP_USERDATA);
char pass1[255], pass2[255];
if (GetDlgItemTextA(hDlg, IDC_USERPASS1, pass1, 254) < 3){
SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Password is too short!"));
@@ -414,8 +423,8 @@ INT_PTR CALLBACK DlgStdNewPass(HWND hDlg, UINT uMsg,WPARAM wParam,LPARAM lParam)
else {
GetDlgItemTextA(hDlg, IDC_USERPASS2, pass2, 254);
if (!strcmp(pass1, pass2)) {
- g_Db->encryptKeyLength = strlen(pass1);
- strcpy(g_Db->encryptKey, pass1);
+ p_Db->encryptKeyLength = strlen(pass1);
+ strcpy(p_Db->encryptKey, pass1);
EndDialog(hDlg,IDOK);
}
else {
@@ -438,31 +447,31 @@ INT_PTR CALLBACK DlgStdNewPass(HWND hDlg, UINT uMsg,WPARAM wParam,LPARAM lParam)
case WM_DESTROY:
KillTimer(hDlg, 1);
- DestroyIcon(hIcon);
+ DestroyIcon((HICON)SendMessage(hDlg, WM_GETICON, ICON_SMALL, 0));
return FALSE;
}
return FALSE;
}
-char* newPass;
-
INT_PTR CALLBACK DlgChangePass(HWND hDlg, UINT uMsg,WPARAM wParam,LPARAM lParam)
{
- HICON hIcon = 0;
+ static char* newPass;
+ CDbxMmapSA *p_Db = (CDbxMmapSA*)GetWindowLongPtr(hDlg, GWLP_USERDATA);
switch(uMsg) {
case WM_INITDIALOG:
TranslateDialogDefault(hDlg);
- hIcon = LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_ICON2));
- SendMessage(GetDlgItem(hDlg, IDC_HEADERBAR), WM_SETICON, 0, (LPARAM)hIcon);
+ SendMessage(GetDlgItem(hDlg, IDC_HEADERBAR), WM_SETICON, 0, (LPARAM)LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_ICON2)));
SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Change password"));
-
- newPass = (char*)lParam;
+ {
+ DlgChangePassParam *param = (DlgChangePassParam*)lParam;
+ newPass = param->pszNewPass;
+ SetWindowLongPtr(hDlg, GWLP_USERDATA, (LPARAM)param->p_Db);
+ }
oldLangID = 0;
SetTimer(hDlg,1,200,NULL);
LanguageChanged(hDlg);
-
return TRUE;
case WM_CTLCOLORSTATIC:
@@ -475,45 +484,45 @@ INT_PTR CALLBACK DlgChangePass(HWND hDlg, UINT uMsg,WPARAM wParam,LPARAM lParam)
return FALSE;
case WM_COMMAND:
- {
- UINT uid = LOWORD(wParam);
- if (uid == IDOK) {
- char pass1[255], pass2[255], oldpass[255];
- GetDlgItemTextA(hDlg, IDC_OLDPASS, oldpass, 254);
- if (strcmp(oldpass, g_Db->encryptKey)) {
- SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Wrong password!"));
- SendMessage(GetDlgItem(hDlg, IDC_HEADERBAR), WM_NCPAINT, 0, 0);
- break;
- }
- if (GetDlgItemTextA(hDlg, IDC_NEWPASS1, pass1, 254) < 3){
- SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Password is too short!"));
- SendMessage(GetDlgItem(hDlg, IDC_HEADERBAR), WM_NCPAINT, 0, 0);
+ switch( LOWORD(wParam)) {
+ char pass1[255], pass2[255], oldpass[255];
+ case IDOK:
+ GetDlgItemTextA(hDlg, IDC_OLDPASS, oldpass, 254);
+ if (strcmp(oldpass, p_Db->encryptKey)) {
+ SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Wrong password!"));
+ SendMessage(GetDlgItem(hDlg, IDC_HEADERBAR), WM_NCPAINT, 0, 0);
+ break;
+ }
+ if (GetDlgItemTextA(hDlg, IDC_NEWPASS1, pass1, 254) < 3){
+ SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Password is too short!"));
+ SendMessage(GetDlgItem(hDlg, IDC_HEADERBAR), WM_NCPAINT, 0, 0);
+ }
+ else {
+ GetDlgItemTextA(hDlg, IDC_NEWPASS2, pass2, 254);
+ if (!strcmp(pass1, pass2)) {
+ strcpy(newPass, pass1);
+ EndDialog(hDlg,IDOK);
}
else {
- GetDlgItemTextA(hDlg, IDC_NEWPASS2, pass2, 254);
- if (!strcmp(pass1, pass2)) {
- strcpy(newPass, pass1);
- EndDialog(hDlg,IDOK);
- }
- else {
- SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Passwords do not match!"));
- SendMessage(GetDlgItem(hDlg, IDC_HEADERBAR), WM_NCPAINT, 0, 0);
- }
- }
- }
- else if (uid == IDCANCEL)
- EndDialog(hDlg,IDCANCEL);
- else if (uid == IDREMOVE) {
- char oldpass[255];
- GetDlgItemTextA(hDlg, IDC_OLDPASS, oldpass, 254);
- if (strcmp(oldpass, g_Db->encryptKey)) {
- SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Wrong password!"));
+ SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Passwords do not match!"));
SendMessage(GetDlgItem(hDlg, IDC_HEADERBAR), WM_NCPAINT, 0, 0);
- break;
}
- EndDialog(hDlg, IDREMOVE);
}
+ break;
+
+ case IDCANCEL:
+ EndDialog(hDlg,IDCANCEL);
+ break;
+
+ case IDREMOVE:
+ GetDlgItemTextA(hDlg, IDC_OLDPASS, oldpass, 254);
+ if (strcmp(oldpass, p_Db->encryptKey)) {
+ SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Wrong password!"));
+ SendMessage(GetDlgItem(hDlg, IDC_HEADERBAR), WM_NCPAINT, 0, 0);
+ break;
+ }
+ EndDialog(hDlg, IDREMOVE);
}
break;
@@ -523,6 +532,7 @@ INT_PTR CALLBACK DlgChangePass(HWND hDlg, UINT uMsg,WPARAM wParam,LPARAM lParam)
case WM_DESTROY:
KillTimer(hDlg, 1);
+ DestroyIcon((HICON)SendMessage(hDlg, WM_GETICON, ICON_SMALL, 0));
return FALSE;
}
return FALSE;
diff --git a/plugins/Dbx_mmap_SA/src/init.cpp b/plugins/Dbx_mmap_SA/src/init.cpp
index 77bf5dc953..688cd36716 100644
--- a/plugins/Dbx_mmap_SA/src/init.cpp
+++ b/plugins/Dbx_mmap_SA/src/init.cpp
@@ -44,14 +44,14 @@ PLUGININFOEX pluginInfo = {
{ 0x28ff9b91, 0x3e4d, 0x4f1c, { 0xb4, 0x7c, 0xc6, 0x41, 0xb0, 0x37, 0xff, 0x40 } }
};
-LIST<CDdxMmapSA> g_Dbs(1, (LIST<CDdxMmapSA>::FTSortFunc)HandleKeySort);
+LIST<CDbxMmapSA> g_Dbs(1, (LIST<CDbxMmapSA>::FTSortFunc)HandleKeySort);
/////////////////////////////////////////////////////////////////////////////////////////
// returns 0 if the profile is created, EMKPRF*
static int makeDatabase(const TCHAR *profile)
{
- std::auto_ptr<CDdxMmapSA> db( new CDdxMmapSA(profile));
+ std::auto_ptr<CDbxMmapSA> db( new CDbxMmapSA(profile));
if (db->Create() == ERROR_SUCCESS) {
db->CreateDbHeaders(dbSignatureNonSecured);
return 0;
@@ -63,7 +63,7 @@ static int makeDatabase(const TCHAR *profile)
// returns 0 if the given profile has a valid header
static int grokHeader(const TCHAR *profile)
{
- std::auto_ptr<CDdxMmapSA> db( new CDdxMmapSA(profile));
+ std::auto_ptr<CDbxMmapSA> db( new CDbxMmapSA(profile));
if (db->Load(true) != ERROR_SUCCESS)
return EGROKPRF_CANTREAD;
@@ -76,7 +76,7 @@ static MIDatabase* LoadDatabase(const TCHAR *profile)
// set the memory, lists & UTF8 manager
mir_getLP( &pluginInfo );
- std::auto_ptr<CDdxMmapSA> db( new CDdxMmapSA(profile));
+ std::auto_ptr<CDbxMmapSA> db( new CDbxMmapSA(profile));
if (db->Load(false) != ERROR_SUCCESS)
return NULL;
@@ -86,14 +86,14 @@ static MIDatabase* LoadDatabase(const TCHAR *profile)
static int UnloadDatabase(MIDatabase* db)
{
- g_Dbs.remove((CDdxMmapSA*)db);
- delete (CDdxMmapSA*)db;
+ g_Dbs.remove((CDbxMmapSA*)db);
+ delete (CDbxMmapSA*)db;
return 0;
}
MIDatabaseChecker* CheckDb(const TCHAR* profile, int *error)
{
- std::auto_ptr<CDdxMmapSA> db( new CDdxMmapSA(profile));
+ std::auto_ptr<CDbxMmapSA> db( new CDbxMmapSA(profile));
if (db->Load(true) != ERROR_SUCCESS) {
*error = EGROKPRF_CANTREAD;
return NULL;
diff --git a/plugins/Dbx_mmap_SA/src/security.cpp b/plugins/Dbx_mmap_SA/src/security.cpp
index 97120953c6..9755d55e6a 100644
--- a/plugins/Dbx_mmap_SA/src/security.cpp
+++ b/plugins/Dbx_mmap_SA/src/security.cpp
@@ -57,7 +57,7 @@ void UnloadSecurity()
arCryptors.destroy();
}
-void CDdxMmapSA::EncoderInit()
+void CDbxMmapSA::EncoderInit()
{
if (!m_bEncoding) return;
@@ -65,7 +65,7 @@ void CDdxMmapSA::EncoderInit()
key = CryptoEngine->GenerateKey(encryptKey);
}
-void CDdxMmapSA::EncodeCopyMemory(void * dst, void * src, size_t size )
+void CDbxMmapSA::EncodeCopyMemory(void * dst, void * src, size_t size )
{
memcpy(dst, src, size);
@@ -75,7 +75,7 @@ void CDdxMmapSA::EncodeCopyMemory(void * dst, void * src, size_t size )
CryptoEngine->EncryptMem((BYTE *)dst, (int)size, key);
}
-void CDdxMmapSA::DecodeCopyMemory(void * dst, void * src, size_t size )
+void CDbxMmapSA::DecodeCopyMemory(void * dst, void * src, size_t size )
{
memcpy(dst, src, size);
@@ -85,7 +85,7 @@ void CDdxMmapSA::DecodeCopyMemory(void * dst, void * src, size_t size )
CryptoEngine->DecryptMem((BYTE *)dst, (int)size, key);
}
-void CDdxMmapSA::EncodeDBWrite(DWORD ofs, void *src, int size)
+void CDbxMmapSA::EncodeDBWrite(DWORD ofs, void *src, int size)
{
if (m_bEncoding)
{
@@ -102,7 +102,7 @@ void CDdxMmapSA::EncodeDBWrite(DWORD ofs, void *src, int size)
}
}
-void CDdxMmapSA::DecodeDBWrite(DWORD ofs, void *src, int size)
+void CDbxMmapSA::DecodeDBWrite(DWORD ofs, void *src, int size)
{
if (m_bEncoding) {
BYTE *buf = (BYTE*)GlobalAlloc(GPTR, sizeof(BYTE)*size);
@@ -115,7 +115,7 @@ void CDdxMmapSA::DecodeDBWrite(DWORD ofs, void *src, int size)
int bCheckingPass = 0;
-int CDdxMmapSA::CheckPassword(WORD checkWord, TCHAR *szDBName)
+int CDbxMmapSA::CheckPassword(WORD checkWord, TCHAR *szDBName)
{
if (bCheckingPass)
return 0;
@@ -137,7 +137,8 @@ int CDdxMmapSA::CheckPassword(WORD checkWord, TCHAR *szDBName)
}
while(1) {
- int res = DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_LOGIN), NULL, DlgStdInProc, (LPARAM)szDBName);
+ DlgStdInProcParam param = { this, szDBName };
+ int res = DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_LOGIN), NULL, DlgStdInProc, (LPARAM)&param);
if (res == IDCANCEL) {
wrongPass = 0;
bCheckingPass = 0;
@@ -197,7 +198,7 @@ int SelectEncoder()
return 0;
}
-void CDdxMmapSA::EncodeAll()
+void CDbxMmapSA::EncodeAll()
{
HANDLE hContact;
@@ -214,7 +215,7 @@ void CDdxMmapSA::EncodeAll()
EncodeContactSettings(NULL);
}
-void CDdxMmapSA::DecodeAll()
+void CDbxMmapSA::DecodeAll()
{
HANDLE hContact;
@@ -229,7 +230,7 @@ void CDdxMmapSA::DecodeAll()
DecodeContactSettings(NULL);
}
-void CDdxMmapSA::WritePlainHeader()
+void CDbxMmapSA::WritePlainHeader()
{
DWORD bytesWritten;
@@ -241,7 +242,7 @@ void CDdxMmapSA::WritePlainHeader()
WriteFile(m_hDbFile,&m_dbHeader.version, sizeof(m_dbHeader.version),&bytesWritten,NULL);
}
-void CDdxMmapSA::WriteCryptHeader()
+void CDbxMmapSA::WriteCryptHeader()
{
DWORD bytesWritten;
@@ -255,7 +256,7 @@ void CDdxMmapSA::WriteCryptHeader()
WriteFile(m_hDbFile,&m_dbHeader.version, sizeof(m_dbHeader.version),&bytesWritten,NULL);
}
-void CDdxMmapSA::EncryptDB()
+void CDbxMmapSA::EncryptDB()
{
int action = 0;
if (bEncProcess)
@@ -272,7 +273,7 @@ void CDdxMmapSA::EncryptDB()
bEncProcess = 1;
- action = DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_NEWPASS), NULL, DlgStdNewPass, 0);
+ action = DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_NEWPASS), NULL, DlgStdNewPass, (LPARAM)this);
if (action != IDOK || !strlen(encryptKey)) {
bEncProcess = 0;
db_set_b(NULL, "SecureMMAP", "CryptoModule", 0);
@@ -295,7 +296,7 @@ void CDdxMmapSA::EncryptDB()
bEncProcess = 0;
}
-void CDdxMmapSA::DecryptDB()
+void CDbxMmapSA::DecryptDB()
{
char oldKey[255];
strcpy(oldKey, encryptKey);
@@ -325,7 +326,7 @@ void CDdxMmapSA::DecryptDB()
CryptoEngine = NULL;
}
-void CDdxMmapSA::RecryptDB()
+void CDbxMmapSA::RecryptDB()
{
EnterCriticalSection(&m_csDbAccess);
@@ -346,11 +347,12 @@ void CDdxMmapSA::RecryptDB()
LeaveCriticalSection(&m_csDbAccess);
}
-void CDdxMmapSA::ChangePwd()
+void CDbxMmapSA::ChangePwd()
{
char newpass[255] = {0};
- int action = DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_CHANGEPASS), NULL, DlgChangePass, (LPARAM)newpass);
+ DlgChangePassParam param = { this, newpass };
+ int action = DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_CHANGEPASS), NULL, DlgChangePass, (LPARAM)&param);
if (action == IDCANCEL || (action == IDOK && !strlen(newpass)))
return;