📄 dlgnewvolwizard.c
字号:
if (itemIdx != CB_ERR)
{
if (SelectedUserData != NULL)
{
lResult = SendMessage(
GetDlgItem(hDlg, ComboboxID),
(UINT)CB_GETITEMDATA,
itemIdx,
0
);
if (lResult != CB_ERR)
{
*SelectedUserData = (void*)lResult;
retval = TRUE;
}
}
}
return retval;
}
// =========================================================================
// Returns the index of the item added, or -1 on error
int dlgNewVolWizard_Combobox_AddItem(
HWND hDlg,
UINT ComboboxID,
WCHAR* ItemText,
void* ItemUserData
)
{
LRESULT itemIdx;
itemIdx = SendMessage(
GetDlgItem(hDlg, ComboboxID),
(UINT)CB_ADDSTRING,
0, // From API docs, must be zero
(LPARAM)ItemText
);
if (
(itemIdx == CB_ERR) ||
(itemIdx == CB_ERRSPACE)
)
{
itemIdx = -1;
}
else
{
if (SendMessage(
GetDlgItem(hDlg, ComboboxID),
(UINT)CB_SETITEMDATA,
itemIdx,
(LPARAM)ItemUserData
) == CB_ERR)
{
// Oh well... Back out that one!
SendMessage(
GetDlgItem(hDlg, ComboboxID),
(UINT)CB_DELETESTRING,
itemIdx,
0
);
}
}
return itemIdx;
}
// =========================================================================
void _dlgNewVolWizard_PopulateComboboxes(HWND hDlg)
{
int i;
SECTOR_IV_GEN_METHOD currSectIVGenMethod;
WCHAR strPrettySectorIVGenMethod[MAX_PRETTYPRINTED_SECTORIVGENMETHOD];
int implIdx;
int cbItemIdx;
int cbDefaultItemIdx;
DEBUGOUTGUI(DEBUGLEV_ENTER, (TEXT("_dlgNewVolWizard_PopulateComboboxes\n")));
if (!(G_dlgNewVolWizard_GotImplDetails))
{
G_dlgNewVolWizard_GotImplDetails =
driver_GetAllAlgorithmDriverOptions(
&G_dlgNewVolWizard_CountImplHash,
&G_dlgNewVolWizard_ImplHash,
&G_dlgNewVolWizard_CountImplCypher,
&G_dlgNewVolWizard_ImplCypher
);
}
if (G_dlgNewVolWizard_GotImplDetails)
{
cbDefaultItemIdx = -1;
// Add hashes to combobox...
for (
implIdx = 0;
implIdx < G_dlgNewVolWizard_CountImplHash;
implIdx++
)
{
// Strip out all hashes which have:
// length <= 0 or blocksize <= 0
// - they cannot be used to create new FreeOTFE volumes as they use
// PBKDF2 (HMAC) to derive the critical data key; and PBKDF2 with HMAC
// requires that the hash used has a defined length of greater than zero
if (
(G_dlgNewVolWizard_ImplHash[implIdx].HashLength > 0) &&
(G_dlgNewVolWizard_ImplHash[implIdx].HashBlockSize > 0)
)
{
cbItemIdx = dlgNewVolWizard_Combobox_AddItem(
hDlg,
IDC_COMBO_HASH,
G_dlgNewVolWizard_ImplHash[implIdx].PrettyName,
(&G_dlgNewVolWizard_ImplHash[implIdx])
);
if (wcscmp(
G_dlgNewVolWizard_ImplHash[implIdx].PrettyName,
DEFAULT_HASH
) == 0)
{
cbDefaultItemIdx = cbItemIdx;
}
}
}
// Set default (if possible)
if (cbDefaultItemIdx != -1)
{
SendMessage(
GetDlgItem(hDlg, IDC_COMBO_HASH),
(UINT)CB_SETCURSEL,
cbDefaultItemIdx,
0
);
}
// Add cyphers to combobox...
for (
implIdx = 0;
implIdx < G_dlgNewVolWizard_CountImplCypher;
implIdx++
)
{
cbItemIdx = dlgNewVolWizard_Combobox_AddItem(
hDlg,
IDC_COMBO_CYPHER,
G_dlgNewVolWizard_ImplCypher[implIdx].PrettyName,
(&G_dlgNewVolWizard_ImplCypher[implIdx])
);
if (wcscmp(
G_dlgNewVolWizard_ImplCypher[implIdx].PrettyName,
DEFAULT_CYPHER
) == 0)
{
cbDefaultItemIdx = cbItemIdx;
}
}
// Set default (if possible)
if (cbDefaultItemIdx != -1)
{
SendMessage(
GetDlgItem(hDlg, IDC_COMBO_CYPHER),
(UINT)CB_SETCURSEL,
cbDefaultItemIdx,
0
);
}
}
// Sector IV generation methods...
cbDefaultItemIdx = -1;
for (
i = 0;
i < (sizeof(ARR_SECTOR_IV_GEN_METHOD) / sizeof(ARR_SECTOR_IV_GEN_METHOD[0]));
i++
)
{
currSectIVGenMethod = ARR_SECTOR_IV_GEN_METHOD[i];
// Skip the "<Unknown>" method!
if (currSectIVGenMethod != SCTRIVGEN_UNKNOWN)
{
driver_PrettyprintSectorIVGenMethod(
currSectIVGenMethod,
strPrettySectorIVGenMethod,
sizeof(strPrettySectorIVGenMethod)
);
cbItemIdx = dlgNewVolWizard_Combobox_AddItem(
hDlg,
IDC_COMBO_SECTORIV,
strPrettySectorIVGenMethod,
(void*)currSectIVGenMethod
);
if (wcscmp(
strPrettySectorIVGenMethod,
DEFAULT_SECTORIVGEN
) == 0)
{
cbDefaultItemIdx = cbItemIdx;
}
}
}
// Set default (if possible)
if (cbDefaultItemIdx != -1)
{
SendMessage(
GetDlgItem(hDlg, IDC_COMBO_SECTORIV),
(UINT)CB_SETCURSEL,
cbDefaultItemIdx,
0
);
}
SecZeroMemory(
strPrettySectorIVGenMethod,
sizeof(strPrettySectorIVGenMethod)
);
DEBUGOUTGUI(DEBUGLEV_EXIT, (TEXT("_dlgNewVolWizard_PopulateComboboxes\n")));
}
// =========================================================================
BOOL CALLBACK dlgNewVolWizard_HandleMsg_WM_DESTROY(HWND hWnd)
{
DEBUGOUTGUI(DEBUGLEV_ENTER, (TEXT("dlgNewVolWizard_HandleMsg_WM_DESTROY\n")));
if (G_dlgNewVolWizard_MenuBar != NULL)
{
DestroyWindow(G_dlgNewVolWizard_MenuBar);
G_dlgNewVolWizard_MenuBar = NULL;
}
if (G_dlgNewVolWizard_UserRNG != NULL)
{
DestroyWindow(G_dlgNewVolWizard_UserRNG);
G_dlgNewVolWizard_UserRNG = NULL;
}
if (G_dlgNewVolWizard_GotImplDetails)
{
driver_FreeAllAlgorithmDriverOptions(
&G_dlgNewVolWizard_CountImplHash,
&G_dlgNewVolWizard_ImplHash,
&G_dlgNewVolWizard_CountImplCypher,
&G_dlgNewVolWizard_ImplCypher
);
G_dlgNewVolWizard_GotImplDetails = FALSE;
}
G_dlgNewVolWizard_GotImplDetails = FALSE;
G_dlgNewVolWizard_CountImplCypher = 0;
G_dlgNewVolWizard_ImplCypher = NULL; // Array of options
G_dlgNewVolWizard_CountImplHash = 0;
G_dlgNewVolWizard_ImplHash = NULL; // Array of options
G_dlgNewVolWizard_AllowFinish = FALSE;
DEBUGOUTGUI(DEBUGLEV_EXIT, (TEXT("dlgNewVolWizard_HandleMsg_WM_DESTROY\n")));
return TRUE;
}
// =========================================================================
// 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 dlgNewVolWizard_HandleMsg_WM_SIZE(HWND hDlg)
{
RECT rcParent;
#if DBG
// Nothing; tab header displayed under debug
#else
RECT rcClient;
#endif
static BOOL resizing = FALSE;
HWND hWndTmp;
DEBUGOUTGUI(DEBUGLEV_ENTER, (TEXT("dlgNewVolWizard_HandleMsg_WM_SIZE\n")));
// 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 (_dlgNewVolWizard_GetPageIdxOfPage(hDlg))
{
case PAGE_IDX_WELCOME:
{
SizeControlMaxWidthBorder(
hDlg,
IDC_STATIC_WELCOME_TITLE,
FREEOTFE_DLG_BORDER
);
SizeControlMaxWidthBorder(
hDlg,
IDC_STATIC_WELCOME,
FREEOTFE_DLG_BORDER
);
SizeControlMaxWidthBorder(
hDlg,
IDC_STATIC_WELCOME_NEXT,
FREEOTFE_DLG_BORDER
);
break;
}
case PAGE_IDX_RNGMOUSEMOVEMENT:
{
_dlgNewVolWizard_ResizeUserRNG(hDlg, FALSE);
break;
}
case PAGE_IDX_SUMMARY:
{
hWndTmp = GetDlgItem(hDlg, IDC_EDIT_SUMMARY);
if (hWndTmp != NULL)
{
SetWindowPos(
hWndTmp,
NULL,
0,
0,
rcParent.right,
rcParent.bottom,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -