VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Common/Dlgcode.h
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2020-07-06 18:00:25 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2020-07-06 18:18:47 +0200
commitff391d9a6afb856e20e827edbad0aff9e6caffe3 (patch)
treee754e62b246821b7ebf222de94e6785b724776c7 /src/Common/Dlgcode.h
parentb54729de48020ca18faa82a92e95bcc130b454ff (diff)
downloadVeraCrypt-ff391d9a6afb856e20e827edbad0aff9e6caffe3.tar.gz
VeraCrypt-ff391d9a6afb856e20e827edbad0aff9e6caffe3.zip
Windows: Support direct password drag-n-drop from external applications (e.g. KeePass) which is more secure than using clipboard.
Diffstat (limited to 'src/Common/Dlgcode.h')
-rw-r--r--src/Common/Dlgcode.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/Common/Dlgcode.h b/src/Common/Dlgcode.h
index 9e77c0a9..52d94f10 100644
--- a/src/Common/Dlgcode.h
+++ b/src/Common/Dlgcode.h
@@ -691,6 +691,61 @@ typedef void (CALLBACK* WaitThreadProc)(void* pArg, HWND hWaitDlg);
void BringToForeground(HWND hWnd);
void ShowWaitDialog(HWND hwnd, BOOL bUseHwndAsParent, WaitThreadProc callback, void* pArg);
+// classes used to implement support for password drag-n-drop from KeePass Password Safe
+// Implementation based the following source code with many modifications to fix isses and add features
+// URL: https://www.codeguru.com/cpp/misc/misc/draganddrop/article.php/c349/Drag-And-Drop-between-Window-Controls.htm
+
+interface GenericDropTarget : public IDropTarget
+{
+public:
+ GenericDropTarget(CLIPFORMAT* pFormats, size_t count);
+ ~GenericDropTarget();
+
+ // basic IUnknown stuff
+ HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void ** ppvObject);
+ ULONG STDMETHODCALLTYPE AddRef(void);
+ ULONG STDMETHODCALLTYPE Release(void);
+
+ HRESULT STDMETHODCALLTYPE DragEnter(struct IDataObject *,unsigned long,struct _POINTL,unsigned long *);
+ HRESULT STDMETHODCALLTYPE DragOver(unsigned long,struct _POINTL,unsigned long *);
+ HRESULT STDMETHODCALLTYPE DragLeave(void);
+ HRESULT STDMETHODCALLTYPE Drop(struct IDataObject *,unsigned long,struct _POINTL,unsigned long *);
+
+ // called by parents
+ BOOL Register(HWND hWnd);
+ void Revoke();
+
+ // call parent we have goodies
+ virtual void GotDrop(CLIPFORMAT format);
+ virtual DWORD GotDrag(void);
+ virtual void GotLeave(void);
+ virtual DWORD GotEnter(void);
+public:
+ BYTE *m_Data;
+
+ POINT m_DropPoint;
+
+ DWORD m_KeyState;
+
+protected:
+ HWND m_DropTargetWnd;
+ std::vector<CLIPFORMAT> m_SupportedFormat;
+ volatile LONG m_dwRefCount;
+};
+
+class PasswordEditDropTarget : public GenericDropTarget
+{
+public:
+ PasswordEditDropTarget();
+
+ // called by child we have drop
+ void GotDrop(CLIPFORMAT format);
+ DWORD GotDrag(void);
+ void GotLeave(void);
+ DWORD GotEnter(void);
+};
+
+
#endif // __cplusplus
#endif // TC_HEADER_DLGCODE