VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2015-09-20 17:24:09 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2015-09-26 17:43:51 +0200
commitd98367f53b9a1268845d68cde1d02bd6ca35f213 (patch)
treebbd7ac1182187edcae0d4af015fded01bfb60b2d /src
parent03de885b133fe7355a1d758ad91cf374132f516f (diff)
downloadVeraCrypt-d98367f53b9a1268845d68cde1d02bd6ca35f213.tar.gz
VeraCrypt-d98367f53b9a1268845d68cde1d02bd6ca35f213.zip
Window: Solve Unicode issues in GUI (e.g. Chinese text not always displayed correctly) by using Unicode API for dialogs and window message handling.
Diffstat (limited to 'src')
-rw-r--r--src/Common/Dlgcode.c122
-rw-r--r--src/Format/FormatCom.cpp4
-rw-r--r--src/Format/Tcformat.cbin315583 -> 631176 bytes
-rw-r--r--src/Mount/MainCom.cpp4
-rw-r--r--src/Mount/Mount.c14
5 files changed, 72 insertions, 72 deletions
diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c
index 01f1bc67..a295d5b5 100644
--- a/src/Common/Dlgcode.c
+++ b/src/Common/Dlgcode.c
@@ -193,9 +193,9 @@ HMODULE hRichEditDll = NULL;
/* Windows dialog class */
-#define WINDOWS_DIALOG_CLASS "#32770"
+#define WINDOWS_DIALOG_CLASS L"#32770"
/* Custom class names */
-#define TC_DLG_CLASS "VeraCryptCustomDlg"
-#define TC_SPLASH_CLASS "VeraCryptSplashDlg"
+#define TC_DLG_CLASS L"VeraCryptCustomDlg"
+#define TC_SPLASH_CLASS L"VeraCryptSplashDlg"
/* Benchmarks */
@@ -266,7 +266,7 @@ void cleanup ()
/* Cleanup our dialog class */
if (hDlgClass)
- UnregisterClass (TC_DLG_CLASS, hInst);
+ UnregisterClassW (TC_DLG_CLASS, hInst);
if (hSplashClass)
- UnregisterClass (TC_SPLASH_CLASS, hInst);
+ UnregisterClassW (TC_SPLASH_CLASS, hInst);
/* Close the device driver handle */
@@ -727,5 +727,5 @@ std::string FitPathInGfxWidth (HWND hwnd, HFONT hFont, LONG width, const std::st
static LRESULT CALLBACK HyperlinkProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- WNDPROC wp = (WNDPROC) GetWindowLongPtr (hwnd, GWLP_USERDATA);
+ WNDPROC wp = (WNDPROC) GetWindowLongPtrW (hwnd, GWLP_USERDATA);
switch (message)
@@ -752,5 +752,5 @@ static LRESULT CALLBACK HyperlinkProc (HWND hwnd, UINT message, WPARAM wParam, L
}
- return CallWindowProc (wp, hwnd, message, wParam, lParam);
+ return CallWindowProcW (wp, hwnd, message, wParam, lParam);
}
@@ -766,8 +766,8 @@ BOOL ToCustHyperlink (HWND hwndDlg, UINT ctrlId, HFONT hFont)
HWND hwndCtrl = GetDlgItem (hwndDlg, ctrlId);
- SendMessage (hwndCtrl, WM_SETFONT, (WPARAM) hFont, 0);
+ SendMessageW (hwndCtrl, WM_SETFONT, (WPARAM) hFont, 0);
- SetWindowLongPtr (hwndCtrl, GWLP_USERDATA, (LONG_PTR) GetWindowLongPtr (hwndCtrl, GWLP_WNDPROC));
- SetWindowLongPtr (hwndCtrl, GWLP_WNDPROC, (LONG_PTR) HyperlinkProc);
+ SetWindowLongPtrW (hwndCtrl, GWLP_USERDATA, (LONG_PTR) GetWindowLongPtrW (hwndCtrl, GWLP_WNDPROC));
+ SetWindowLongPtrW (hwndCtrl, GWLP_WNDPROC, (LONG_PTR) HyperlinkProc);
// Resize the field according to its actual size in pixels and move it if centered or right-aligned.
@@ -791,5 +791,5 @@ void AccommodateTextField (HWND hwndDlg, UINT ctrlId, BOOL bFirstUpdate, HFONT h
wchar_t text [MAX_URL_LENGTH];
WINDOWINFO windowInfo;
- BOOL bBorderlessWindow = !(GetWindowLongPtr (hwndDlg, GWL_STYLE) & (WS_BORDER | WS_DLGFRAME));
+ BOOL bBorderlessWindow = !(GetWindowLongPtrW (hwndDlg, GWL_STYLE) & (WS_BORDER | WS_DLGFRAME));
// Resize the field according to its length and font size and move if centered or right-aligned
@@ -870,5 +870,5 @@ void EnableCloseButton (HWND hwndDlg)
static LRESULT CALLBACK BootPwdFieldProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- WNDPROC wp = (WNDPROC) GetWindowLongPtr (hwnd, GWLP_USERDATA);
+ WNDPROC wp = (WNDPROC) GetWindowLongPtrW (hwnd, GWLP_USERDATA);
switch (message)
@@ -1348,7 +1348,7 @@ void ProcessPaintMessages (HWND hwnd, int maxMessagesToProcess)
int msgCounter = maxMessagesToProcess;
- while (PeekMessage (&paintMsg, hwnd, 0, 0, PM_REMOVE | PM_QS_PAINT) != 0 && msgCounter-- > 0)
+ while (PeekMessageW (&paintMsg, hwnd, 0, 0, PM_REMOVE | PM_QS_PAINT) != 0 && msgCounter-- > 0)
{
- DispatchMessage (&paintMsg);
+ DispatchMessageW (&paintMsg);
}
}
@@ -1507,5 +1507,5 @@ RedTick (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
bEndPaint = TRUE;
if (hDC == NULL)
- return DefWindowProc (hwnd, uMsg, wParam, lParam);
+ return DefWindowProcW (hwnd, uMsg, wParam, lParam);
}
else
@@ -1542,5 +1542,5 @@ RedTick (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
- return DefWindowProc (hwnd, uMsg, wParam, lParam);
+ return DefWindowProcW (hwnd, uMsg, wParam, lParam);
}
@@ -1548,5 +1548,5 @@ BOOL
RegisterRedTick (HINSTANCE hInstance)
{
- WNDCLASS wc;
+ WNDCLASSW wc;
ULONG rc;
@@ -1560,8 +1560,8 @@ RegisterRedTick (HINSTANCE hInstance)
wc.hCursor = NULL;
wc.hbrBackground = (HBRUSH) GetStockObject (LTGRAY_BRUSH);
- wc.lpszClassName = "VCREDTICK";
+ wc.lpszClassName = L"VCREDTICK";
wc.lpfnWndProc = &RedTick;
- rc = (ULONG) RegisterClass (&wc);
+ rc = (ULONG) RegisterClassW (&wc);
return rc == 0 ? FALSE : TRUE;
@@ -1571,5 +1571,5 @@ BOOL
UnregisterRedTick (HINSTANCE hInstance)
{
- return UnregisterClass ("VCREDTICK", hInstance);
+ return UnregisterClassW (L"VCREDTICK", hInstance);
}
@@ -1577,5 +1577,5 @@ LRESULT CALLBACK
SplashDlgProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- return DefDlgProc (hwnd, uMsg, wParam, lParam);
+ return DefDlgProcW (hwnd, uMsg, wParam, lParam);
}
@@ -1738,5 +1738,5 @@ LRESULT CALLBACK CustomDlgProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPar
}
- return DefDlgProc (hwnd, uMsg, wParam, lParam);
+ return DefDlgProcW (hwnd, uMsg, wParam, lParam);
}
@@ -2003,5 +2003,5 @@ void InvalidParameterHandler (const wchar_t *expression, const wchar_t *function
static LRESULT CALLBACK NonInstallUacWndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- return DefWindowProc (hWnd, message, wParam, lParam);
+ return DefWindowProcW (hWnd, message, wParam, lParam);
}
@@ -2398,5 +2398,5 @@ void InitOSVersionInfo ()
void InitApp (HINSTANCE hInstance, char *lpszCommandLine)
{
- WNDCLASS wc;
+ WNDCLASSW wc;
char langId[6];
char dllPath[MAX_PATH];
@@ -2448,5 +2448,5 @@ void InitApp (HINSTANCE hInstance, char *lpszCommandLine)
{
char modPath[MAX_PATH], newCmdLine[4096];
- WNDCLASSEX wcex;
+ WNDCLASSEXW wcex;
HWND hWnd;
@@ -2461,10 +2461,10 @@ void InitApp (HINSTANCE hInstance, char *lpszCommandLine)
wcex.lpfnWndProc = (WNDPROC) NonInstallUacWndProc;
wcex.hInstance = hInstance;
- wcex.lpszClassName = "VeraCrypt";
- RegisterClassEx (&wcex);
+ wcex.lpszClassName = L"VeraCrypt";
+ RegisterClassExW (&wcex);
// A small transparent window is necessary to bring the new instance to foreground
- hWnd = CreateWindowEx (WS_EX_TOOLWINDOW | WS_EX_LAYERED,
- "VeraCrypt", "VeraCrypt", 0,
+ hWnd = CreateWindowExW (WS_EX_TOOLWINDOW | WS_EX_LAYERED,
+ L"VeraCrypt", L"VeraCrypt", 0,
GetSystemMetrics (SM_CXSCREEN)/2,
GetSystemMetrics (SM_CYSCREEN)/2,
@@ -2545,5 +2545,5 @@ void InitApp (HINSTANCE hInstance, char *lpszCommandLine)
/* Get the attributes for the standard dialog class */
- if ((GetClassInfo (hInst, WINDOWS_DIALOG_CLASS, &wc)) == 0)
+ if ((GetClassInfoW (hInst, WINDOWS_DIALOG_CLASS, &wc)) == 0)
{
handleWin32Error (NULL, SRC_POS);
@@ -2562,5 +2562,5 @@ void InitApp (HINSTANCE hInstance, char *lpszCommandLine)
wc.cbWndExtra = DLGWINDOWEXTRA;
- hDlgClass = RegisterClass (&wc);
+ hDlgClass = RegisterClassW (&wc);
if (hDlgClass == 0)
{
@@ -2574,5 +2574,5 @@ void InitApp (HINSTANCE hInstance, char *lpszCommandLine)
wc.cbWndExtra = DLGWINDOWEXTRA;
- hSplashClass = RegisterClass (&wc);
+ hSplashClass = RegisterClassW (&wc);
if (hSplashClass == 0)
{
@@ -4266,8 +4266,8 @@ static BOOL CALLBACK LocalizeDialogEnum( HWND hwnd, LPARAM font)
if (ctrlId != 0)
{
- char name[10] = { 0 };
- GetClassName (hwnd, name, sizeof (name));
+ WCHAR name[10] = { 0 };
+ GetClassNameW (hwnd, name, array_capacity (name));
- if (_stricmp (name, "Button") == 0 || _stricmp (name, "Static") == 0)
+ if (_wcsicmp (name, L"Button") == 0 || _wcsicmp (name, L"Static") == 0)
{
wchar_t *str = (wchar_t *) GetDictionaryValueByInt (ctrlId);
@@ -4279,5 +4279,5 @@ static BOOL CALLBACK LocalizeDialogEnum( HWND hwnd, LPARAM font)
// Font
- SendMessage (hwnd, WM_SETFONT, (WPARAM) font, 0);
+ SendMessageW (hwnd, WM_SETFONT, (WPARAM) font, 0);
return TRUE;
@@ -4287,9 +4287,9 @@ void LocalizeDialog (HWND hwnd, char *stringId)
{
LastDialogId = stringId;
- SetWindowLongPtr (hwnd, GWLP_USERDATA, (LONG_PTR) 'VERA');
- SendMessage (hwnd, WM_SETFONT, (WPARAM) hUserFont, 0);
+ SetWindowLongPtrW (hwnd, GWLP_USERDATA, (LONG_PTR) 'VERA');
+ SendMessageW (hwnd, WM_SETFONT, (WPARAM) hUserFont, 0);
if (stringId == NULL)
- SetWindowText (hwnd, "VeraCrypt");
+ SetWindowTextW (hwnd, L"VeraCrypt");
else
SetWindowTextW (hwnd, GetString (stringId));
@@ -4317,10 +4317,10 @@ static HWND explorerTopLevelWindow;
static BOOL CALLBACK CloseVolumeExplorerWindowsChildEnum (HWND hwnd, LPARAM driveStr)
{
- char s[MAX_PATH];
- SendMessage (hwnd, WM_GETTEXT, sizeof (s), (LPARAM) s);
+ WCHAR s[MAX_PATH];
+ SendMessageW (hwnd, WM_GETTEXT, array_capacity (s), (LPARAM) s);
- if (strstr (s, (char *) driveStr) != NULL)
+ if (wcsstr (s, (WCHAR *) driveStr) != NULL)
{
- PostMessage (explorerTopLevelWindow, WM_CLOSE, 0, 0);
+ PostMessageW (explorerTopLevelWindow, WM_CLOSE, 0, 0);
explorerCloseSent = TRUE;
return FALSE;
@@ -4332,16 +4332,16 @@ static BOOL CALLBACK CloseVolumeExplorerWindowsChildEnum (HWND hwnd, LPARAM driv
static BOOL CALLBACK CloseVolumeExplorerWindowsEnum (HWND hwnd, LPARAM driveNo)
{
- char driveStr[10];
- char s[MAX_PATH];
+ WCHAR driveStr[10];
+ WCHAR s[MAX_PATH];
- StringCbPrintfA (driveStr, sizeof(driveStr), "%c:\\", driveNo + 'A');
+ StringCbPrintfW (driveStr, sizeof(driveStr), L"%c:\\", driveNo + L'A');
- GetClassName (hwnd, s, sizeof s);
- if (strcmp (s, "CabinetWClass") == 0)
+ GetClassNameW (hwnd, s, array_capacity (s));
+ if (wcscmp (s, L"CabinetWClass") == 0)
{
- GetWindowText (hwnd, s, sizeof s);
- if (strstr (s, driveStr) != NULL)
+ GetWindowTextW (hwnd, s, array_capacity (s));
+ if (wcsstr (s, driveStr) != NULL)
{
- PostMessage (hwnd, WM_CLOSE, 0, 0);
+ PostMessageW (hwnd, WM_CLOSE, 0, 0);
explorerCloseSent = TRUE;
return TRUE;
@@ -6550,6 +6550,6 @@ BOOL CALLBACK WaitDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
if (hProgress)
{
- SetWindowLongPtr (hProgress, GWL_STYLE, PBS_MARQUEE | GetWindowLongPtr (hProgress, GWL_STYLE));
- ::SendMessage(hProgress, PBM_SETMARQUEE, (WPARAM) TRUE, (LPARAM) 0);
+ SetWindowLongPtrW (hProgress, GWL_STYLE, PBS_MARQUEE | GetWindowLongPtrW (hProgress, GWL_STYLE));
+ ::SendMessageW(hProgress, PBM_SETMARQUEE, (WPARAM) TRUE, (LPARAM) 0);
}
@@ -9487,5 +9487,5 @@ void HandleDriveNotReadyError (HWND hwnd)
BOOL CALLBACK CloseTCWindowsEnum (HWND hwnd, LPARAM lParam)
{
- LONG_PTR userDataVal = GetWindowLongPtr (hwnd, GWLP_USERDATA);
+ LONG_PTR userDataVal = GetWindowLongPtrW (hwnd, GWLP_USERDATA);
if ((userDataVal == (LONG_PTR) 'VERA') || (userDataVal == (LONG_PTR) 'TRUE')) // Prior to 1.0e, 'TRUE' was used for VeraCrypt dialogs
{
@@ -9510,5 +9510,5 @@ BOOL CALLBACK FindTCWindowEnum (HWND hwnd, LPARAM lParam)
return TRUE;
- LONG_PTR userDataVal = GetWindowLongPtr (hwnd, GWLP_USERDATA);
+ LONG_PTR userDataVal = GetWindowLongPtrW (hwnd, GWLP_USERDATA);
if ((userDataVal == (LONG_PTR) 'VERA') || (userDataVal == (LONG_PTR) 'TRUE')) // Prior to 1.0e, 'TRUE' was used for VeraCrypt dialogs
{
@@ -10762,5 +10762,5 @@ BOOL RemoveDeviceWriteProtection (HWND hwndDlg, char *devicePath)
static LRESULT CALLBACK EnableElevatedCursorChangeWndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- return DefWindowProc (hWnd, message, wParam, lParam);
+ return DefWindowProcW (hWnd, message, wParam, lParam);
}
@@ -10771,6 +10771,6 @@ void EnableElevatedCursorChange (HWND parent)
if (UacElevated)
{
- const char *className = "VeraCryptEnableElevatedCursorChange";
- WNDCLASSEX winClass;
+ const wchar_t *className = L"VeraCryptEnableElevatedCursorChange";
+ WNDCLASSEXW winClass;
HWND hWnd;
@@ -10780,7 +10780,7 @@ void EnableElevatedCursorChange (HWND parent)
winClass.hInstance = hInst;
winClass.lpszClassName = className;
- RegisterClassEx (&winClass);
+ RegisterClassExW (&winClass);
- hWnd = CreateWindowEx (WS_EX_TOOLWINDOW | WS_EX_LAYERED, className, "VeraCrypt UAC", 0, 0, 0, GetSystemMetrics (SM_CXSCREEN), GetSystemMetrics (SM_CYSCREEN), parent, NULL, hInst, NULL);
+ hWnd = CreateWindowExW (WS_EX_TOOLWINDOW | WS_EX_LAYERED, className, L"VeraCrypt UAC", 0, 0, 0, GetSystemMetrics (SM_CXSCREEN), GetSystemMetrics (SM_CYSCREEN), parent, NULL, hInst, NULL);
if (hWnd)
{
@@ -10790,5 +10790,5 @@ void EnableElevatedCursorChange (HWND parent)
DestroyWindow (hWnd);
}
- UnregisterClass (className, hInst);
+ UnregisterClassW (className, hInst);
}
}
diff --git a/src/Format/FormatCom.cpp b/src/Format/FormatCom.cpp
index cc7d2082..aac5ae7e 100644
--- a/src/Format/FormatCom.cpp
+++ b/src/Format/FormatCom.cpp
@@ -155,5 +155,5 @@ extern "C" BOOL ComServerFormat ()
MSG msg;
- while (int r = GetMessage (&msg, NULL, 0, 0))
+ while (int r = GetMessageW (&msg, NULL, 0, 0))
{
if (r == -1)
@@ -161,5 +161,5 @@ extern "C" BOOL ComServerFormat ()
TranslateMessage (&msg);
- DispatchMessage (&msg);
+ DispatchMessageW (&msg);
if (msg.message == WM_APP
diff --git a/src/Format/Tcformat.c b/src/Format/Tcformat.c
index 141900b0..9f31ae30 100644
--- a/src/Format/Tcformat.c
+++ b/src/Format/Tcformat.c
Binary files differ
diff --git a/src/Mount/MainCom.cpp b/src/Mount/MainCom.cpp
index 67fd5d25..c810e3ea 100644
--- a/src/Mount/MainCom.cpp
+++ b/src/Mount/MainCom.cpp
@@ -210,5 +210,5 @@ extern "C" BOOL ComServerMain ()
MSG msg;
- while (int r = GetMessage (&msg, NULL, 0, 0))
+ while (int r = GetMessageW (&msg, NULL, 0, 0))
{
if (r == -1)
@@ -216,5 +216,5 @@ extern "C" BOOL ComServerMain ()
TranslateMessage (&msg);
- DispatchMessage (&msg);
+ DispatchMessageW (&msg);
if (msg.message == WM_APP
diff --git a/src/Mount/Mount.c b/src/Mount/Mount.c
index 0895915a..122f8f00 100644
--- a/src/Mount/Mount.c
+++ b/src/Mount/Mount.c
@@ -299,9 +299,9 @@ static void InitMainDialog (HWND hwndDlg)
LocalizeDialog (hwndDlg, NULL);
- SetWindowLongPtr (hwndDlg, DWLP_USER, (LONG_PTR) (IsAdmin() ? TC_MAIN_WINDOW_FLAG_ADMIN_PRIVILEGES : 0));
+ SetWindowLongPtrW (hwndDlg, DWLP_USER, (LONG_PTR) (IsAdmin() ? TC_MAIN_WINDOW_FLAG_ADMIN_PRIVILEGES : 0));
DragAcceptFiles (hwndDlg, TRUE);
- SendMessage (GetDlgItem (hwndDlg, IDC_VOLUME), CB_LIMITTEXT, TC_MAX_PATH, 0);
+ SendMessageW (GetDlgItem (hwndDlg, IDC_VOLUME), CB_LIMITTEXT, TC_MAX_PATH, 0);
SetWindowTextW (hwndDlg, (IsAdmin() && !IsBuiltInAdmin() && IsUacSupported() && !IsNonInstallMode()) ? (wstring (lpszTitle) + L" [" + GetString ("ADMINISTRATOR") + L"]").c_str() : lpszTitle);
@@ -6286,5 +6286,5 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
if (h != hwndDlg
- && (!IsAdmin() || (GetWindowLongPtr (h, DWLP_USER) & TC_MAIN_WINDOW_FLAG_ADMIN_PRIVILEGES) != 0))
+ && (!IsAdmin() || (GetWindowLongPtrW (h, DWLP_USER) & TC_MAIN_WINDOW_FLAG_ADMIN_PRIVILEGES) != 0))
{
if (CmdLineVolumeSpecified)
@@ -10512,5 +10512,5 @@ static BOOL HandleDriveListMouseWheelEvent (UINT uMsg, WPARAM wParam, LPARAM lPa
static LRESULT CALLBACK MouseWheelProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- WNDPROC wp = (WNDPROC) GetWindowLongPtr (hwnd, GWLP_USERDATA);
+ WNDPROC wp = (WNDPROC) GetWindowLongPtrW (hwnd, GWLP_USERDATA);
switch (message)
@@ -10522,5 +10522,5 @@ static LRESULT CALLBACK MouseWheelProc (HWND hwnd, UINT message, WPARAM wParam,
}
- return CallWindowProc (wp, hwnd, message, wParam, lParam);
+ return CallWindowProcW (wp, hwnd, message, wParam, lParam);
}
@@ -10530,5 +10530,5 @@ void HookMouseWheel (HWND hwndDlg, UINT ctrlId)
HWND hwndCtrl = GetDlgItem (hwndDlg, ctrlId);
- SetWindowLongPtr (hwndCtrl, GWLP_USERDATA, (LONG_PTR) GetWindowLongPtr (hwndCtrl, GWLP_WNDPROC));
- SetWindowLongPtr (hwndCtrl, GWLP_WNDPROC, (LONG_PTR) MouseWheelProc);
+ SetWindowLongPtrW (hwndCtrl, GWLP_USERDATA, (LONG_PTR) GetWindowLongPtrW (hwndCtrl, GWLP_WNDPROC));
+ SetWindowLongPtrW (hwndCtrl, GWLP_WNDPROC, (LONG_PTR) MouseWheelProc);
}