📄 dlgdumpcdbwizard.c
字号:
NULL,
rcTab.left,
rcTab.top,
(rcTab.right - rcTab.left),
(rcTab.bottom - rcTab.top),
SWP_NOZORDER
);
}
}
// =========================================================================
void _dlgDumpCDBWizard_SizeWindowTab_CtrlID(
HWND hTabParentWnd,
int tabCtrlID,
HWND hWnd
)
{
HWND tmpHWND;
if (
(hTabParentWnd != NULL) &&
(hWnd != NULL)
)
{
tmpHWND = GetDlgItem(hTabParentWnd, tabCtrlID);
if (tmpHWND != NULL)
{
_dlgDumpCDBWizard_SizeWindowTab(tmpHWND, hWnd);
}
}
}
// =========================================================================
// Resize the property sheet page so that the tabs at the top are
// hidden by it; we don't want them shown for our wizard
BOOL CALLBACK dlgDumpCDBWizard_HandleMsg_WM_SIZE(HWND hDlg)
{
RECT rcParent;
#if DBG
// Nothing; tab header displayed under debug
#else
RECT rcClient;
#endif
static BOOL resizing = FALSE;
DEBUGOUTGUI(DEBUGLEV_ENTER, (TEXT("dlgDumpCDBWizard_HandleMsg_WM_SIZE\n")));
if (
(hDlg == hDumpCDBSrcDetailsWndPassword) ||
(hDlg == hDumpCDBSrcDetailsWndAdvanced)
)
{
// Do nothing; handed when the parent window (tabbed window) is
// resized
return TRUE;
}
// Prevent infinite recursion as we resize the dialog...
if (!(resizing))
{
resizing = TRUE;
#if DBG
// Nothing; tab header displayed under debug
#else
// Get size of display area...
GetClientRect(GetParent(hDlg), &rcClient);
// Resize...
SetWindowPos(
hDlg,
NULL,
0,
0,
rcClient.right,
rcClient.bottom,
SWP_NOZORDER
);
#endif
// Resize specific property sheets...
GetClientRect(hDlg, &rcParent);
switch (_dlgDumpCDBWizard_GetPageIdxOfPage(hDlg))
{
case PAGE_IDX_SRCDETAILS:
{
// Resize src tab window...
SizeControlToParent(hDlg, IDC_TAB1);
// Resize the tabsheets within the src tab window...
_dlgDumpCDBWizard_SizeWindowTab_CtrlID(
hDlg,
IDC_TAB1,
hDumpCDBSrcDetailsWndPassword
);
_dlgDumpCDBWizard_SizeWindowTab_CtrlID(
hDlg,
IDC_TAB1,
hDumpCDBSrcDetailsWndAdvanced
);
break;
}
}
resizing = FALSE;
}
DEBUGOUTGUI(DEBUGLEV_EXIT, (TEXT("dlgDumpCDBWizard_HandleMsg_WM_SIZE\n")));
return TRUE;
}
// =========================================================================
void _dlgDumpCDBWizard_SecZeroParams()
{
if (G_dlgDumpCDBWizard_UserParams.SrcUserPassword != NULL)
{
SecZeroAndFreeMemory(
G_dlgDumpCDBWizard_UserParams.SrcUserPassword,
strlen(G_dlgDumpCDBWizard_UserParams.SrcUserPassword)
);
G_dlgDumpCDBWizard_UserParams.SrcUserPassword = NULL;
}
SecZeroMemory(
&G_dlgDumpCDBWizard_UserParams,
sizeof(G_dlgDumpCDBWizard_UserParams)
);
}
// =========================================================================
// Pass this the HWND for the *main* dialog
BOOL _dlgDumpCDBWizard_QuerySiblings(HWND hDlg)
{
BOOL retval = FALSE;
DEBUGOUTGUI(DEBUGLEV_ENTER, (TEXT("_dlgDumpCDBWizard_QuerySiblings\n")));
G_dlgDumpCDBWizard_UserParams.ParamsOK = TRUE;
if (PropSheet_QuerySiblings(hDlg, 0, 0) != 0)
{
DEBUGOUTGUI(DEBUGLEV_INFO, (TEXT("PropSheet_QuerySiblings returned non-zero; not proceeding with new volume\n")));
// Do nothing; retval already set to FALSE
}
// Not clear why, but regardless of whether the dlgProc returns
// TRUE/FALSE for the QuerySiblings call, the above always returns zero?!
// Therefore, we use a kludge to get the *real* result...
else if (G_dlgDumpCDBWizard_UserParams.ParamsOK == FALSE)
{
DEBUGOUTGUI(DEBUGLEV_INFO, (TEXT("ParamsOK set to FALSE; not proceeding with new volume\n")));
// Do nothing; retval already set to FALSE
}
else
{
retval = TRUE;
}
DEBUGOUTGUI(DEBUGLEV_EXIT, (TEXT("_dlgDumpCDBWizard_QuerySiblings\n")));
return retval;
}
// =========================================================================
// Pass this the HWND for the *main* dialog
void _dlgDumpCDBWizard_UpdateLastPageGlobal(HWND hDlg)
{
// Get the latest information entered by the user...
_dlgDumpCDBWizard_QuerySiblings(hDlg);
G_dlgDumpCDBWizard_LastPageIdx = PAGE_IDX_DESTFILENAME;
// In case any of the navigation buttsons need changing...
_dlgDumpCDBWizard_SetWizardButtons(
_dlgDumpCDBWizard_GetCurrPageIdx(hDlg)
);
}
// =========================================================================
// Dialog OK'd; change password or create keyfile
BOOL CALLBACK dlgDumpCDBWizard_Finish(HWND hDlg)
{
BOOL retval = FALSE;
CDB_DETAILS CDBDetails;
CDB_METADATA CDBMetaData;
DEBUGOUTGUI(DEBUGLEV_ENTER, (TEXT("dlgDumpCDBWizard_Finish\n")));
memset(
&G_dlgDumpCDBWizard_UserParams,
0,
sizeof(G_dlgDumpCDBWizard_UserParams)
);
G_dlgDumpCDBWizard_UserParams.ParamsOK = TRUE;
// Check the user's input is OK...
if (!(dlgDumpCDBWizard_ValidateAll(GetParent(hDlg))))
{
DEBUGOUTGUI(DEBUGLEV_INFO, (TEXT("Can't validate all of user input successfully\n")));
// retval already set to FALSE, just switch to the appropriate tab
PropSheet_SetCurSel(
GetParent(hDlg),
NULL,
G_dlgDumpCDBWizard_UserParams.ErrorPageIdx
);
}
else
{
HCURSOR csrHourglass;
HCURSOR csrPrevious;
csrHourglass = LoadCursor(NULL, IDC_WAIT);
csrPrevious = SetCursor(csrHourglass);
retval = driver_DumpCDB(
G_dlgDumpCDBWizard_UserParams.SrcFilename,
G_dlgDumpCDBWizard_UserParams.SrcOffset,
G_dlgDumpCDBWizard_UserParams.SrcUserPassword,
G_dlgDumpCDBWizard_UserParams.SrcSaltLength,
G_dlgDumpCDBWizard_UserParams.SrcKeyIterations,
G_dlgDumpCDBWizard_UserParams.DestFilename
);
SetCursor(csrPrevious);
}
if (retval)
{
_dlgDumpCDBWizard_PromptDisplayDump(hDlg);
}
// Cleardown sensitive information
_dlgDumpCDBWizard_SecZeroParams();
SecZeroMemory(&CDBDetails, sizeof(CDBDetails));
SecZeroMemory(&CDBMetaData, sizeof(CDBMetaData));
DEBUGOUTGUI(DEBUGLEV_EXIT, (TEXT("dlgDumpCDBWizard_Finish\n")));
return retval;
}
// =========================================================================
void _dlgDumpCDBWizard_EnableDisableControls(HWND hDlg)
{
BOOL enableCtrl;
enableCtrl = (IsDlgButtonChecked(
hDlg,
IDC_RADIO_CDBINKEYFILE
) == BST_CHECKED);
SetControlEnabled(hDlg, IDC_STATIC_KEYFILE, enableCtrl);
SetControlEnabled(hDlg, IDC_EDIT_KEYFILE, enableCtrl);
SetControlEnabled(hDlg, IDC_BUTTON_BROWSEKEYFILE, enableCtrl);
}
// =========================================================================
// Navigate forwards/backwards in the wizard
// PageDirection - Set to +1 to go onto the next page; -1 to go back
void CALLBACK _dlgDumpCDBWizard_PageChange(
HWND hDlg,
int PageDirection
)
{
int currPage;
int newPage;
BOOL identifiedNewPage;
currPage = _dlgDumpCDBWizard_GetPageIdxOfPage(PropSheet_GetCurrentPageHwnd(GetParent(hDlg)));
newPage = currPage;
// Get the latest information entered by the user...
_dlgDumpCDBWizard_QuerySiblings(hDlg);
identifiedNewPage = FALSE;
while (!(identifiedNewPage))
{
if (PageDirection < 0)
{
newPage = max((newPage - 1), 0);
}
else if (PageDirection > 0)
{
// Note: Any error message will have been displayed to user
// during validation
if (dlgDumpCDBWizard_ValidatePage(PropSheet_GetCurrentPageHwnd(GetParent(hDlg))))
{
// -1 here as DUMP_CDB_WIZARD_STEPS is the total number; not
// the largest page indexe
newPage = min((newPage + 1), (DUMP_CDB_WIZARD_STEPS - 1));
}
}
// Check if the new page is skipped
identifiedNewPage = TRUE;
}
if (currPage != newPage)
{
PropSheet_SetCurSel(
GetParent(hDlg),
NULL,
newPage
);
}
// It would make more sense for this to be called *after* all the
// WM_INITDIALOGs
_dlgDumpCDBWizard_UpdateLastPageGlobal(GetParent(hDlg));
}
// =========================================================================
BOOL CALLBACK dlgDumpCDBWizard_HandleMsg_WM_COMMAND(HWND hDlg, WPARAM wParam)
{
BOOL retval = FALSE;
int ctrlID;
DEBUGOUTGUI(DEBUGLEV_ENTER, (TEXT("dlgDumpCDBWizard_HandleMsg_WM_COMMAND\n")));
DEBUGOUTGUI(DEBUGLEV_INFO, (TEXT("Command: %d\n"), LOWORD(wParam)));
ctrlID = LOWORD(wParam);
switch(ctrlID)
{
case IDOK:
{
// IMPORTANT: EndDialog *not* called for property sheet dialog
// We just forward the msg received by the *page* to the owning
// parent; the property sheet dialog
PropSheet_PressButton(GetParent(hDlg), PSBTN_OK);
retval = TRUE;
break;
}
case IDCANCEL:
{
// IMPORTANT: EndDialog *not* called for property sheet dialog
// We just forward the msg received by the *page* to the owning
// parent; the property sheet dialog
PropSheet_PressButton(GetParent(hDlg), PSBTN_CANCEL);
retval = TRUE;
break;
}
case ID_WIZ_BACK:
{
_dlgDumpCDBWizard_PageChange(hDlg, -1);
retval = TRUE;
break;
}
case ID_WIZ_NEXT:
{
_dlgDumpCDBWizard_PageChange(hDlg, +1);
retval = TRUE;
break;
}
case IDC_CHECK_RNGMSCRYPTOAPI:
case IDC_CHECK_RNGUSERINPUT:
{
int currPage;
// If the user selected a different RNG, update the "<BACK"/"NEXT>"
// navigation; the user may have other steps to carry out
_dlgDumpCDBWizard_UpdateLastPageGlobal(GetParent(hDlg));
currPage = _dlgDumpCDBWizard_GetPageIdxOfPage(hDlg);
_dlgDumpCDBWizard_SetWizardButtons(currPage);
break;
}
case IDC_BUTTON_BROWSEFILENAME:
case IDC_BUTTON_BROWSEKEYFILE:
{
OPENFILENAME ofn;
DWORD flags;
WCHAR filename[FREEOTFE_MAX_FILENAME_LENGTH];
BOOL fileDlgOK;
DEBUGOUTGUI(DEBUGLEV_INFO, (TEXT("Browse...\n")));
memset(filename, 0, sizeof(filename));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hDlg;
ofn.hInstance = NULL;
ofn.lpstrCustomFilter = NULL;
ofn.lpstrFile = filename;
ofn.nMaxFile = (sizeof(filename) / sizeof(filename[0]));
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.lpstrTitle = NULL;
flags = (
// OFN_HIDEREADONLY |
OFN_FILEMUSTEXIST |
OFN_PATHMUSTEXIST
);
ofn.Flags = flags;
ofn.nFileOffset = 0;
ofn.nFileExtension = 0;
ofn.lpstrDefExt = NULL;
ofn.lCustData = 0;
ofn.lpfnHook = NULL;
ofn.lpTemplateName = NULL;
if (_dlgDumpCDBWizard_GetPageIdxOfPage(hDlg) == PAGE_IDX_SRCFILENAME)
{
ofn.lpstrFilter = FILE_FILTER_FLT_VOLUMESANDKEYFILES;
ofn.nMaxCustFilter = FILE_FILTER_CNT_VOLUMESANDKEYFILES;
ofn.nFilterIndex = FILE_FILTER_DFLT_VOLUMESANDKEYFILES;
}
else
{
ofn.lpstrFilter = FILE_FILTER_FLT_TEXTFILES;
ofn.nMaxCustFilter = FILE_FILTER_CNT_TEXTFILES;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -