1
0
mirror of https://github.com/veracrypt/VeraCrypt.git synced 2025-11-11 11:08:02 -06:00

Windows: Support direct password drag-n-drop from external applications (e.g. KeePass) which is more secure than using clipboard.

This commit is contained in:
Mounir IDRASSI
2020-07-06 18:00:25 +02:00
parent b54729de48
commit ff391d9a6a
5 changed files with 597 additions and 2 deletions

View File

@@ -2415,6 +2415,17 @@ BOOL CALLBACK PasswordChangeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
}
CheckCapsLock (hwndDlg, FALSE);
if (!bSecureDesktopOngoing)
{
PasswordEditDropTarget* pTarget = new PasswordEditDropTarget ();
if (pTarget->Register (hwndDlg))
{
SetWindowLongPtr (hwndDlg, DWLP_USER, (LONG_PTR) pTarget);
}
else
delete pTarget;
}
return 0;
}
@@ -2880,6 +2891,19 @@ err:
return 1;
}
return 0;
case WM_NCDESTROY:
{
/* unregister drap-n-drop support */
PasswordEditDropTarget* pTarget = (PasswordEditDropTarget*) GetWindowLongPtr (hwndDlg, DWLP_USER);
if (pTarget)
{
SetWindowLongPtr (hwndDlg, DWLP_USER, (LONG_PTR) 0);
pTarget->Revoke ();
pTarget->Release();
}
}
return 0;
}
return 0;
@@ -3014,9 +3038,18 @@ BOOL CALLBACK PasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
SetFocus (GetDlgItem (hwndDlg, IDC_PASSWORD));
/* Start the timer to check if we are foreground only if Secure Desktop is not used */
/* Implement Text drag-n-drop in order to support droping password from KeePass directly only if Secure Desktop is not used */
if (!bSecureDesktopOngoing)
{
SetTimer (hwndDlg, TIMER_ID_CHECK_FOREGROUND, TIMER_INTERVAL_CHECK_FOREGROUND, NULL);
PasswordEditDropTarget* pTarget = new PasswordEditDropTarget ();
if (pTarget->Register (hwndDlg))
{
SetWindowLongPtr (hwndDlg, DWLP_USER, (LONG_PTR) pTarget);
}
else
delete pTarget;
}
}
return 0;
@@ -3281,6 +3314,19 @@ BOOL CALLBACK PasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
}
return 0;
case WM_NCDESTROY:
{
/* unregister drap-n-drop support */
PasswordEditDropTarget* pTarget = (PasswordEditDropTarget*) GetWindowLongPtr (hwndDlg, DWLP_USER);
if (pTarget)
{
SetWindowLongPtr (hwndDlg, DWLP_USER, (LONG_PTR) 0);
pTarget->Revoke ();
pTarget->Release();
}
}
return 0;
case WM_CONTEXTMENU:
{
RECT buttonRect;
@@ -3694,6 +3740,17 @@ BOOL CALLBACK MountOptionsDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
ToHyperlink (hwndDlg, IDC_LINK_HIDVOL_PROTECTION_INFO);
if (!bSecureDesktopOngoing)
{
PasswordEditDropTarget* pTarget = new PasswordEditDropTarget ();
if (pTarget->Register (hwndDlg))
{
SetWindowLongPtr (hwndDlg, DWLP_USER, (LONG_PTR) pTarget);
}
else
delete pTarget;
}
}
return 0;
@@ -3851,6 +3908,19 @@ BOOL CALLBACK MountOptionsDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
}
return 0;
case WM_NCDESTROY:
{
/* unregister drap-n-drop support */
PasswordEditDropTarget* pTarget = (PasswordEditDropTarget*) GetWindowLongPtr (hwndDlg, DWLP_USER);
if (pTarget)
{
SetWindowLongPtr (hwndDlg, DWLP_USER, (LONG_PTR) 0);
pTarget->Revoke ();
pTarget->Release();
}
}
return 0;
}
return 0;