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

Windows: allow drag-n-drop of files and receiving Explorer restart message when VeraCrypt running as elevated process.

This commit is contained in:
Mounir IDRASSI
2016-04-03 08:29:34 +02:00
parent 09b22c175b
commit 409c0f79be
3 changed files with 38 additions and 0 deletions

View File

@@ -248,6 +248,9 @@ typedef LSTATUS (STDAPICALLTYPE *SHDeleteKeyWPtr)(HKEY hkey, LPCWSTR pszSubKey);
typedef HRESULT (STDAPICALLTYPE *SHStrDupWPtr)(LPCWSTR psz, LPWSTR *ppwsz); typedef HRESULT (STDAPICALLTYPE *SHStrDupWPtr)(LPCWSTR psz, LPWSTR *ppwsz);
// ChangeWindowMessageFilter
typedef BOOL (WINAPI *ChangeWindowMessageFilterPtr) (UINT, DWORD);
ImageList_CreatePtr ImageList_CreateFn = NULL; ImageList_CreatePtr ImageList_CreateFn = NULL;
ImageList_AddPtr ImageList_AddFn = NULL; ImageList_AddPtr ImageList_AddFn = NULL;
@@ -257,6 +260,7 @@ SetupInstallFromInfSectionWPtr SetupInstallFromInfSectionWFn = NULL;
SetupOpenInfFileWPtr SetupOpenInfFileWFn = NULL; SetupOpenInfFileWPtr SetupOpenInfFileWFn = NULL;
SHDeleteKeyWPtr SHDeleteKeyWFn = NULL; SHDeleteKeyWPtr SHDeleteKeyWFn = NULL;
SHStrDupWPtr SHStrDupWFn = NULL; SHStrDupWPtr SHStrDupWFn = NULL;
ChangeWindowMessageFilterPtr ChangeWindowMessageFilterFn = NULL;
/* Windows dialog class */ /* Windows dialog class */
#define WINDOWS_DIALOG_CLASS L"#32770" #define WINDOWS_DIALOG_CLASS L"#32770"
@@ -265,6 +269,16 @@ SHStrDupWPtr SHStrDupWFn = NULL;
#define TC_DLG_CLASS L"VeraCryptCustomDlg" #define TC_DLG_CLASS L"VeraCryptCustomDlg"
#define TC_SPLASH_CLASS L"VeraCryptSplashDlg" #define TC_SPLASH_CLASS L"VeraCryptSplashDlg"
/* constant used by ChangeWindowMessageFilter calls */
#ifndef MSGFLT_ADD
#define MSGFLT_ADD 1
#endif
/* undocumented message sent during drag-n-drop */
#ifndef WM_COPYGLOBALDATA
#define WM_COPYGLOBALDATA 0x0049
#endif
/* Benchmarks */ /* Benchmarks */
#ifndef SETUP #ifndef SETUP
@@ -2603,6 +2617,19 @@ void InitApp (HINSTANCE hInstance, wchar_t *lpszCommandLine)
if (!SHDeleteKeyWFn || !SHStrDupWFn) if (!SHDeleteKeyWFn || !SHStrDupWFn)
AbortProcess ("INIT_DLL"); AbortProcess ("INIT_DLL");
if (IsOSAtLeast (WIN_VISTA))
{
/* Get ChangeWindowMessageFilter used to enable some messages bypasss UIPI (User Interface Privilege Isolation) */
ChangeWindowMessageFilterFn = (ChangeWindowMessageFilterPtr) GetProcAddress (GetModuleHandle (L"user32.dll"), "ChangeWindowMessageFilter");
#ifndef SETUP
/* enable drag-n-drop when we are running elevated */
AllowMessageInUIPI (WM_DROPFILES);
AllowMessageInUIPI (WM_COPYDATA);
AllowMessageInUIPI (WM_COPYGLOBALDATA);
#endif
}
/* Save the instance handle for later */ /* Save the instance handle for later */
hInst = hInstance; hInst = hInstance;
@@ -11575,3 +11602,11 @@ void ProcessEntropyEstimate (HWND hProgress, DWORD* pdwInitialValue, DWORD dwCou
0); 0);
} }
} }
void AllowMessageInUIPI (UINT msg)
{
if (ChangeWindowMessageFilterFn)
{
ChangeWindowMessageFilterFn (msg, MSGFLT_ADD);
}
}

View File

@@ -500,6 +500,7 @@ HIMAGELIST CreateImageList(int cx, int cy, UINT flags, int cInitial, int cGrow)
int AddBitmapToImageList(HIMAGELIST himl, HBITMAP hbmImage, HBITMAP hbmMask); int AddBitmapToImageList(HIMAGELIST himl, HBITMAP hbmImage, HBITMAP hbmMask);
HRESULT VCStrDupW(LPCWSTR psz, LPWSTR *ppwsz); HRESULT VCStrDupW(LPCWSTR psz, LPWSTR *ppwsz);
void ProcessEntropyEstimate (HWND hProgress, DWORD* pdwInitialValue, DWORD dwCounter, DWORD dwMaxLevel, DWORD* pdwEntropy); void ProcessEntropyEstimate (HWND hProgress, DWORD* pdwInitialValue, DWORD dwCounter, DWORD dwMaxLevel, DWORD* pdwEntropy);
void AllowMessageInUIPI (UINT msg);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -6547,6 +6547,8 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
taskBarCreatedMsg = RegisterWindowMessage (L"TaskbarCreated"); taskBarCreatedMsg = RegisterWindowMessage (L"TaskbarCreated");
AllowMessageInUIPI (taskBarCreatedMsg);
SetFocus (GetDlgItem (hwndDlg, IDC_DRIVELIST)); SetFocus (GetDlgItem (hwndDlg, IDC_DRIVELIST));
/* Check system encryption status */ /* Check system encryption status */