VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Common/Dlgcode.c
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2016-05-29 01:30:53 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2016-05-29 01:33:18 +0200
commit99c4031d89ce4f72e3899b3cac660082a1820a48 (patch)
tree6fc381d9789326a6b132fd17e6cf9a6c3e1dc411 /src/Common/Dlgcode.c
parenta0d8b8a3b78b1d0db50de2a7d841efaec2a55c36 (diff)
downloadVeraCrypt-99c4031d89ce4f72e3899b3cac660082a1820a48.tar.gz
VeraCrypt-99c4031d89ce4f72e3899b3cac660082a1820a48.zip
Windows: better implementation for support of smart card PIN in command line. Supported now also on Format.
Diffstat (limited to 'src/Common/Dlgcode.c')
-rw-r--r--src/Common/Dlgcode.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c
index 13a439e0..d70dfbcd 100644
--- a/src/Common/Dlgcode.c
+++ b/src/Common/Dlgcode.c
@@ -78,6 +78,7 @@ char *LastDialogId;
wchar_t szHelpFile[TC_MAX_PATH];
wchar_t szHelpFile2[TC_MAX_PATH];
wchar_t SecurityTokenLibraryPath[TC_MAX_PATH];
+char CmdTokenPin [TC_MAX_PATH] = {0};
HFONT hFixedDigitFont = NULL;
HFONT hBoldFont = NULL;
@@ -329,6 +330,8 @@ typedef struct
void cleanup ()
{
+ burn (&CmdTokenPin, sizeof (CmdTokenPin));
+
/* Cleanup the GDI fonts */
if (hFixedFont != NULL)
DeleteObject (hFixedFont);
@@ -2535,6 +2538,8 @@ void InitApp (HINSTANCE hInstance, wchar_t *lpszCommandLine)
InitOSVersionInfo();
+ VirtualLock (&CmdTokenPin, sizeof (CmdTokenPin));
+
InitializeCriticalSection (&csWNetCalls);
LoadSystemDll (L"ntmarta.dll", &hntmartadll, TRUE, SRC_POS);
@@ -10980,15 +10985,27 @@ BOOL InitSecurityTokenLibrary (HWND hwndDlg)
PinRequestHandler(HWND hwnd) : m_hwnd(hwnd) {}
virtual void operator() (string &str)
{
- HWND hParent = IsWindow (m_hwnd)? m_hwnd : GetActiveWindow();
- if (!hParent)
- hParent = GetForegroundWindow ();
- if (DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_TOKEN_PASSWORD), hParent, (DLGPROC) SecurityTokenPasswordDlgProc, (LPARAM) &str) == IDCANCEL)
- throw UserAbort (SRC_POS);
-
+ if (CmdTokenPin[0])
+ {
+ str = CmdTokenPin;
+ }
+ else
+ {
+ HWND hParent = IsWindow (m_hwnd)? m_hwnd : GetActiveWindow();
+ if (!hParent)
+ hParent = GetForegroundWindow ();
+ if (DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_TOKEN_PASSWORD), hParent, (DLGPROC) SecurityTokenPasswordDlgProc, (LPARAM) &str) == IDCANCEL)
+ throw UserAbort (SRC_POS);
+ }
if (hCursor != NULL)
SetCursor (hCursor);
}
+
+ virtual void notifyIncorrectPin ()
+ {
+ // clear wrong PIN
+ burn (&CmdTokenPin, sizeof (CmdTokenPin));
+ }
};
struct WarningHandler : public SendExceptionFunctor