📄 dlgnewvolwizard.c
字号:
);
SecZeroAndFreeMemory(
tmpGUIDStr,
(wcslen(tmpGUIDStr) * sizeof(*tmpGUIDStr))
);
AppendStaticText(
hWnd,
IDC_EDIT_SUMMARY,
TEXT("]")
);
AppendStaticText(hWnd, IDC_EDIT_SUMMARY, EDIT_CRLF);
AppendStaticText(
hWnd,
IDC_EDIT_SUMMARY,
TEXT("Master key length: ")
);
if (G_dlgNewVolWizard_NewVolParams.KeySizeSelectedCypher >= 0)
{
_ultow(
G_dlgNewVolWizard_NewVolParams.KeySizeSelectedCypher,
strLARGE_INTEGER,
10
);
}
else
{
_ultow(
G_dlgNewVolWizard_NewVolParams.KeySizeUser,
strLARGE_INTEGER,
10
);
}
AppendStaticText(
hWnd,
IDC_EDIT_SUMMARY,
strLARGE_INTEGER
);
AppendStaticText(hWnd, IDC_EDIT_SUMMARY, EDIT_CRLF);
AppendStaticText(
hWnd,
IDC_EDIT_SUMMARY,
TEXT("RNG: ")
);
firstInList = TRUE;
if (G_dlgNewVolWizard_NewVolParams.SelectedRNG.UseMSCryptoAPI)
{
if (!(firstInList))
{
AppendStaticText(
hWnd,
IDC_EDIT_SUMMARY,
TEXT(", ")
);
}
AppendStaticText(
hWnd,
IDC_EDIT_SUMMARY,
TEXT("Microsoft CryptoAPI")
);
firstInList = FALSE;
}
if (G_dlgNewVolWizard_NewVolParams.SelectedRNG.UseUserInput)
{
if (!(firstInList))
{
AppendStaticText(
hWnd,
IDC_EDIT_SUMMARY,
TEXT(", ")
);
}
AppendStaticText(
hWnd,
IDC_EDIT_SUMMARY,
TEXT("User input")
);
firstInList = FALSE;
}
AppendStaticText(hWnd, IDC_EDIT_SUMMARY, EDIT_CRLF);
AppendStaticText(
hWnd,
IDC_EDIT_SUMMARY,
TEXT("Password: <entered>")
);
AppendStaticText(hWnd, IDC_EDIT_SUMMARY, EDIT_CRLF);
AppendStaticText(
hWnd,
IDC_EDIT_SUMMARY,
TEXT("Salt length: ")
);
_ultow(
G_dlgNewVolWizard_NewVolParams.SaltLength,
strLARGE_INTEGER,
10
);
AppendStaticText(
hWnd,
IDC_EDIT_SUMMARY,
strLARGE_INTEGER
);
AppendStaticText(
hWnd,
IDC_EDIT_SUMMARY,
TEXT(" bits")
);
AppendStaticText(hWnd, IDC_EDIT_SUMMARY, EDIT_CRLF);
AppendStaticText(hWnd, IDC_EDIT_SUMMARY, EDIT_CRLF);
AppendStaticText(
hWnd,
IDC_EDIT_SUMMARY,
TEXT("Select \"Finish\" to create the above volume")
);
AppendStaticText(hWnd, IDC_EDIT_SUMMARY, EDIT_CRLF);
SecZeroMemory(strLARGE_INTEGER, sizeof(strLARGE_INTEGER));
SecZeroMemory(&totalSize, sizeof(totalSize));
SecZeroMemory(&tmpLargeInt, sizeof(tmpLargeInt));
SecZeroMemory(
strPrettySectorIVGenMethod,
sizeof(strPrettySectorIVGenMethod)
);
}
// =========================================================================
BOOL CALLBACK dlgNewVolWizard_HandleMsg_WM_NOTIFY(HWND hDlg, WPARAM wParam, LPARAM lParam)
{
BOOL retval = FALSE;
int idCtrl;
NMHDR* notifHdr;
NMUPDOWN* lpnmud;
NMUSERRNG_BYTEGEN* lpnmRNG;
int currPage;
DEBUGOUTGUI(DEBUGLEV_ENTER, (TEXT("dlgNewVolWizard_HandleMsg_WM_NOTIFY\n")));
idCtrl = (int)wParam;
notifHdr = (NMHDR*)lParam;
switch (notifHdr->code)
{
case URNG_BYTEGEN:
{
if (idCtrl == IDCTRL_USERRNG)
{
lpnmRNG = (NMUSERRNG_BYTEGEN*)lParam;
if ((G_dlgNewVolWizard_NewVolParams.RandomPoolFilled_UserInput / 8) < sizeof(G_dlgNewVolWizard_NewVolParams.RandomPool_UserInput))
{
// Store random byte...
G_dlgNewVolWizard_NewVolParams.RandomPool_UserInput[G_dlgNewVolWizard_NewVolParams.RandomPoolFilled_UserInput / 8] = lpnmRNG->Byte;
G_dlgNewVolWizard_NewVolParams.RandomPoolFilled_UserInput += 8;
// Update display of bits generated...
SetDlgItemInt(
hDlg,
IDC_STATIC_USERRNG_STORED,
G_dlgNewVolWizard_NewVolParams.RandomPoolFilled_UserInput,
TRUE
);
// Disable control if the userRNG pool is full...
if ((G_dlgNewVolWizard_NewVolParams.RandomPoolFilled_UserInput / 8) >= sizeof(G_dlgNewVolWizard_NewVolParams.RandomPool_UserInput))
{
SetControlEnabled(hDlg, IDCTRL_USERRNG, FALSE);
}
}
break;
}
}
// Spin edit up/down button
case UDN_DELTAPOS:
{
switch(idCtrl)
{
case IDC_SPIN_OFFSET:
{
lpnmud = (NMUPDOWN*)lParam;
AdjustSpinControl(
hDlg,
IDC_EDIT_OFFSET,
0,
INT_MAX,
-(lpnmud->iDelta)
);
retval = TRUE;
break;
}
case IDC_SPIN_SALTLENGTH:
{
lpnmud = (NMUPDOWN*)lParam;
AdjustSpinControl(
hDlg,
IDC_EDIT_SALTLENGTH,
0,
INT_MAX,
(-(lpnmud->iDelta) * DELTA_SALT_LENGTH)
);
retval = TRUE;
break;
}
case IDC_SPIN_KEYITERATIONS:
{
lpnmud = (NMUPDOWN*)lParam;
AdjustSpinControl(
hDlg,
IDC_EDIT_KEYITERATIONS,
MIN_KEYITERATIONS,
INT_MAX,
(-(lpnmud->iDelta) * DELTA_KEY_ITERATIONS)
);
retval = TRUE;
break;
}
case IDC_SPIN_SIZE:
{
lpnmud = (NMUPDOWN*)lParam;
AdjustSpinControl(
hDlg,
IDC_EDIT_SIZE,
MIN_VOLUME_SIZE,
INT_MAX,
-(lpnmud->iDelta)
);
retval = TRUE;
break;
}
case IDC_SPIN_MASTERKEYLEN:
{
lpnmud = (NMUPDOWN*)lParam;
AdjustSpinControl(
hDlg,
IDC_EDIT_MASTERKEYLEN,
0,
INT_MAX,
(-(lpnmud->iDelta) * DELTA_CYPHERKEYLENGTH)
);
retval = TRUE;
break;
}
}
break;
}
case PSN_SETACTIVE:
{
currPage = _dlgNewVolWizard_GetPageIdxOfPage(hDlg);
if (currPage == PAGE_IDX_SUMMARY)
{
_dlgNewVolWizard_WriteSummary(hDlg);
}
else if (currPage == PAGE_IDX_SALT)
{
// If the user got to this page, we have the minimum set of
// information we mandate that the user enters
// Allow "Finish" button
if (G_dlgNewVolWizard_AllowFinish == FALSE)
{
// Let the user know
MsgInfo(hDlg, TEXT("You have now entered all the information required to create a new volume.\n\nYou may now click \"Finish\" to create it, or continue with the wizard to setup more advanced options."));
}
G_dlgNewVolWizard_AllowFinish = TRUE;
}
_dlgNewVolWizard_SetWizardButtons(currPage);
break;
}
case PSN_KILLACTIVE:
{
// (Validate if necessary here)
// Set the DWL_MSGRESULT to PSNRET_NOERROR to receive PSN_APPLY
SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_NOERROR);
break;
}
case PSN_APPLY:
{
// This notification is received when the user clicks
// "OK"/"Apply"
// This is called once for each of the tabs.
// When called, we validate the tab it is called for (this
// has the effect that the first invalid tab will be automatically
// selected)
// If the tab being called for is the last one (the summary),
// we create the new volume.
currPage = _dlgNewVolWizard_GetPageIdxOfPage(hDlg);
DEBUGOUTGUI(DEBUGLEV_INFO, (TEXT("PSN_APPLY for page idx: %d\n"), currPage));
SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_NOERROR);
if (dlgNewVolWizard_ValidatePage(hDlg))
{
// If it's the last page, only succeed if the volume can be
// created
if (currPage != PAGE_IDX_SUMMARY)
{
SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_NOERROR);
}
else
{
if (dlgNewVolWizard_CreateNew(hDlg))
{
MsgInfo(hDlg, TEXT("New volume created successfully\n\nPlease tap \"File | Mount\" to begin using it"));
SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_NOERROR);
}
else
{
MsgError(hDlg, TEXT("New volume could not be created; please check your settings, and ensure you have sufficient storage to hold the new volume"));
SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_INVALID);
}
}
}
else
{
SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_INVALID);
}
break;
}
case PSN_RESET:
{
// This notification is received when the user clicks
// "Close"/"Cancel"
DEBUGOUTGUI(DEBUGLEV_INFO, (TEXT("Dialog cancelled by user\n")));
SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_NOERROR);
break;
}
}
DEBUGOUTGUI(DEBUGLEV_EXIT, (TEXT("dlgNewVolWizard_HandleMsg_WM_NOTIFY\n")));
return TRUE;
}
// =========================================================================
// This function is required in order to get the WinCE look & feel to the
// tabbed dialog.
int CALLBACK dlgNewVolWizard_PropSheetProc(
HWND hwndDlg,
UINT uMsg,
LPARAM lParam
)
{
int retval = 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -