void DecryptDB() { char oldKey[255]; strcpy(oldKey, encryptKey); if(!CheckPassword(dbHeader.checkWord, Translate("current database"))){strcpy(encryptKey, oldKey); encryptKeyLength = strlen(oldKey); return;} WritePlainHeader(); EnterCriticalSection(&csDbAccess); DecodeAll(); LeaveCriticalSection(&csDbAccess); bEncoding = 0; zero_fill(encryptKey, sizeof encryptKey); if (gl_bUnicodeAwareCore) xModifyMenu(hSetPwdMenu, 0, LPGENT("Set Password"), 0); else xModifyMenu(hSetPwdMenu, 0, (TCHAR*) LPGEN("Set Password"), 0); //ugly hack DBWriteContactSettingWord(NULL, "SecureMMAP", "CryptoModule", 0); CryptoEngine->FreeKey(key); CryptoEngine = NULL; }
void updateMenus(){ xModifyMenu(hVirtualizeMenu,0,isDBvirtual?"Realize":"Virtualize",iconList[isDBvirtual?1:0]); xModifyMenu(hSaveFileMenu,isDBvirtual?0:CMIF_GRAYED,NULL,iconList[2]); #ifdef SECUREDB xModifyMenu(hDelPwdMenu,g_secured?0:CMIF_GRAYED,NULL,iconList[4]); #endif }
void ChangePwd() { char newpass[255] = {0}; int action = DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_CHANGEPASS), NULL, (DLGPROC)DlgChangePass, (LPARAM)newpass); if(action == IDCANCEL || (action == IDOK && !strlen(newpass))) return; EnterCriticalSection(&csDbAccess); DecodeAll(); CryptoEngine->FreeKey(key); if(action == IDREMOVE){ WritePlainHeader(); bEncoding = 0; CryptoEngine = NULL; DBWriteContactSettingWord(NULL, "SecureMMAP", "CryptoModule", 0); zero_fill(encryptKey, sizeof encryptKey); if (gl_bUnicodeAwareCore) xModifyMenu(hSetPwdMenu, 0, LPGENT("Set Password"), 0); else xModifyMenu(hSetPwdMenu, 0, (TCHAR*) LPGEN("Set Password"), 0); //ugly hack } if(action == IDOK){ strcpy(encryptKey, newpass); encryptKeyLength = strlen(newpass); bEncoding = 1; EncoderInit(); EncodeAll(); WriteCryptHeader(); } zero_fill(newpass, sizeof newpass); LeaveCriticalSection(&csDbAccess); }
void EncryptDB() { int action = 0; if(bEncProcess) return; if(memcmp(dbHeader.signature, &dbSignatureSecured, sizeof(dbHeader.signature)) == 0){ if (gl_bUnicodeAwareCore) MessageBox(0, TranslateT("DB is already secured!"), TranslateT("Error"), MB_OK); else MessageBoxA(0, Translate("DB is already secured!"), Translate("Error"), MB_OK); return; } if(SelectEncoder()){ return; } bEncProcess = 1; action = DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_NEWPASS), NULL, (DLGPROC)DlgStdNewPass, (LPARAM)NULL); if(action != IDOK || !strlen(encryptKey)){ bEncProcess = 0; DBWriteContactSettingByte(NULL, "SecureMMAP", "CryptoModule", 0); return; } EnterCriticalSection(&csDbAccess); bEncoding = 1; EncoderInit(); EncodeAll(); LeaveCriticalSection(&csDbAccess); WriteCryptHeader(); if (gl_bUnicodeAwareCore) xModifyMenu(hSetPwdMenu, 0, LPGENT("Change Password"), 0); else xModifyMenu(hSetPwdMenu, 0, (TCHAR*) LPGEN ("Change Password"), 0); //ugly hack bEncProcess = 0; }