⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dlgdumpcdbwizard.c

📁 文件驱动加密,功能强大,可产生加密分区,支持AES,MD2,MD4,MD5MD2, MD4, MD5, RIPEMD-128, RIPEMD-160, SHA-1, SHA-224, SHA-256,
💻 C
📖 第 1 页 / 共 4 页
字号:
                        }
                    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;
                    }

                }

            break;
            }

        case PSN_SETACTIVE:
            {
            currPage = _dlgDumpCDBWizard_GetPageIdxOfPage(hDlg);

            _dlgDumpCDBWizard_DisplayDetailsTabPage(hDlg, currPage);
            _dlgDumpCDBWizard_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 = _dlgDumpCDBWizard_GetPageIdxOfPage(hDlg);
            DEBUGOUTGUI(DEBUGLEV_INFO, (TEXT("PSN_APPLY for page idx: %d\n"), currPage));

            SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_NOERROR);
            if (dlgDumpCDBWizard_ValidatePage(hDlg))
                {
                // If it's the last page, only succeed if the volume can be
                // created
                if (currPage != _dlgDumpCDBWizard_GetPageIdxOfLastPage())
                    {
                    SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_NOERROR);
                    }
                else
                    {
                    if (dlgDumpCDBWizard_Finish(hDlg))
                        {
                        // Already prompted user to display file created
                        SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_NOERROR);
                        }
                    else
                        {
                        MsgError(hDlg, TEXT("Unable to dump CDB; please check your password and other settings"));
                        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("dlgDumpCDBWizard_HandleMsg_WM_NOTIFY\n")));
    return TRUE;
}


// =========================================================================
// This function is required in order to get the WinCE look & feel to the
// tabbed dialog.
int CALLBACK dlgDumpCDBWizard_PropSheetProc(
  HWND hwndDlg, 
  UINT uMsg, 
  LPARAM lParam 
)
{
    int retval = 0;
    switch (uMsg)
        {
        case PSCB_GETVERSION:
            {
            // We do *NOT* set the version here. The resize causes the page
            // to be displayed *over* the property sheet's tabs. Setting
            // this version prevents this from working correctly
            retval = COMCTL32_VERSION;
            break; 
            }

        }

    return retval;
}


// =========================================================================
HWND _dlgDumpCDBWizard_CreateDialogWindow(
    HWND ParentHWND, 
    int ResourceID
)
{
    DLGTEMPLATE* dlgtempl;
    HRSRC hrsrc;
    HGLOBAL hglb;

    hrsrc = FindResource(
                         G_hInstance,
                         MAKEINTRESOURCE(ResourceID),
                         RT_DIALOG
                        );
    hglb = LoadResource(G_hInstance, hrsrc);
    dlgtempl = (DLGTEMPLATE*)LockResource(hglb); 
    return CreateDialogIndirectParam(
                            G_hInstance,
                            dlgtempl,
                            ParentHWND,
                            dlgDumpCDBWizard_PropSheetPageProc,
                            SUBTAB_FLAG
                           );

}


// =========================================================================
BOOL CALLBACK dlgDumpCDBWizard_HandleMsg_WM_INITDIALOG(HWND hDlg, LPARAM lParam)
{
    SHINITDLGINFO shidi;
    int i;

    DEBUGOUTGUI(DEBUGLEV_ENTER, (TEXT("dlgDumpCDBWizard_HandleMsg_WM_INITDIALOG\n")));

    // Setup globals...

    // Don't recreate menu if it's already been done
    if (G_dlgDumpCDBWizard_MenuBar == NULL)
        {
        G_dlgDumpCDBWizard_MenuBar = SetupMenu(hDlg, IDR_MENU_WIZARD);
        }

    for (i = 0; i < DUMP_CDB_WIZARD_STEPS; i++)
        {
        G_dlgDumpCDBWizard_PageCompleted[i] = FALSE;
        }
    memset(
           &G_dlgDumpCDBWizard_UserParams, 
           0,
           sizeof(G_dlgDumpCDBWizard_UserParams)
          );


//xxx - get rid of this?
    // This isn't actually needed for property sheet dialog...
    shidi.dwMask = SHIDIM_FLAGS;
    shidi.dwFlags = (
                     SHIDIF_DONEBUTTON | 
                     SHIDIF_SIPDOWN | 
                     SHIDIF_SIZEDLGFULLSCREEN
                    );
    shidi.hDlg = hDlg;
    SHInitDialog(&shidi);

    // Set userdata on the page being initialized; we use this to identify
    // the different pages
    // Because this procedure is called to initialize both the propertysheet
    // pages *and* the dialogs (windows) created for the Password/Advanced tabs
    // on the src/dest details propertysheet page, we ensure this isn't set
    // for those windows.
    // This is done by passing a flag lParam to them when they're created,
    // and detecting it here
    // Note: You will get a "Data Abort" error here if lParam is dereferenced    
    //       here and it's NULL
    if (lParam != SUBTAB_FLAG)
        {
        SetWindowLong(
                      hDlg,
                      GWL_USERDATA,
                      ((LPPROPSHEETPAGE)lParam)->lParam
                     );
        }

    // Default values for controls...
    SetDlgItemText(hDlg, IDC_EDIT_FILENAME,   DEFAULT_FILENAME);
    SetDlgItemText(hDlg, IDC_EDIT_PASSWORD,   DEFAULT_PASSWORD);
    SetDlgItemText(hDlg, IDC_EDIT_PASSWORDCONFIRM, DEFAULT_PASSWORD);
    SetDlgItemInt(hDlg, IDC_EDIT_OFFSET, DEFAULT_OFFSET, TRUE);

    SetDlgItemInt(hDlg, IDC_EDIT_SALTLENGTH, DEFAULT_SALTLENGTH, TRUE);
    SetDlgItemInt(hDlg, IDC_EDIT_KEYITERATIONS, DEFAULT_KEYITERATIONS, TRUE);

	if (_dlgDumpCDBWizard_GetPageIdxOfPage(hDlg) == PAGE_IDX_SRCFILENAME)
        {
        SetStaticText(hDlg, IDC_STATIC_FILENAME, TEXT("Volume/keyfile:"));

        SetDlgItemString(
                         G_hInstance,
                         hDlg,
                         IDC_STATIC_INSTRUCTION,
                         IDS_STRING_INST_DUMPCDB_SRCFILE
                        );
        }
    else if (_dlgDumpCDBWizard_GetPageIdxOfPage(hDlg) == PAGE_IDX_SRCDETAILS)
        {
        HWND tmpHWND;
        TCITEM tci;

        // Setup the tab control to get the WinCE look and feel...
        tmpHWND = GetDlgItem(hDlg, IDC_TAB1);
        SendMessage(tmpHWND, CCM_SETVERSION, COMCTL32_VERSION, 0); 
        
        tci.mask = TCIF_TEXT;
        tci.pszText = TEXT("Password");
        TabCtrl_InsertItem(tmpHWND, SRCDETAILSTAB_IDX_PASSWORD, &tci);
        tci.mask = TCIF_TEXT;
        tci.pszText = TEXT("Advanced");
        TabCtrl_InsertItem(tmpHWND, SRCDETAILSTAB_IDX_ADVANCED, &tci);

        // Create the contents for the two tabs    
        hDumpCDBSrcDetailsWndPassword = _dlgDumpCDBWizard_CreateDialogWindow(
                                        tmpHWND,
                                        IDD_NEWVOLWIZARD_PASSWORD
                                       );
        hDumpCDBSrcDetailsWndAdvanced = _dlgDumpCDBWizard_CreateDialogWindow(
                                        tmpHWND,
                                        IDD_VOL_ADV_OPTS
                                       );

        // Adjust controls for the context in which they will appear...
        SetControlVisible(
                          hDumpCDBSrcDetailsWndAdvanced,
                          IDC_STATIC_MOUNTPOINT,
                          FALSE
                         );
        SetControlVisible(
                          hDumpCDBSrcDetailsWndAdvanced,
                          IDC_EDIT_MOUNTPOINT,
                          FALSE
                         );
        SetControlVisible(
                          hDumpCDBSrcDetailsWndPassword,
                          IDC_STATIC_PASSWORDCONFIRM,
                          FALSE
                         );
        SetControlVisible(
                          hDumpCDBSrcDetailsWndPassword,
                          IDC_EDIT_PASSWORDCONFIRM,
                          FALSE
                         );


        // Set defaults...
        // Password...
        SetDlgItemText(
                       hDumpCDBSrcDetailsWndPassword,
                       IDC_EDIT_PASSWORD,
                       DEFAULT_PASSWORD
                      );

        SetDlgItemString(
                         G_hInstance,
                         hDumpCDBSrcDetailsWndPassword,
                         IDC_STATIC_INSTRUCTION,
                         IDS_STRING_INSTWIZDUMPCDBPASSWORD
                        );


        // Advanced...
        SetDlgItemInt(
                      hDumpCDBSrcDetailsWndAdvanced, 
                      IDC_EDIT_OFFSET, 
                      DEFAULT_OFFSET,
                      TRUE
                     );
        CheckDlgButton(
                       hDumpCDBSrcDetailsWndAdvanced,    
                       IDC_CHECK_CDBATOFFSET,
                       BST_CHECKED
                      );
        SetControlEnabled(
                          hDumpCDBSrcDetailsWndAdvanced,
                          IDC_CHECK_CDBATOFFSET,
                          FALSE
                         );
        SetDlgItemInt(
                      hDumpCDBSrcDetailsWndAdvanced,
                      IDC_EDIT_SALTLENGTH,
                      DEFAULT_SALTLENGTH,
                      TRUE
                     );
        SetDlgItemInt(
                      hDumpCDBSrcDetailsWndAdvanced,
                      IDC_EDIT_KEYITERATIONS,
                      DEFAULT_KEYITERATIONS,
                      TRUE
                     );

        }
    else if (_dlgDumpCDBWizard_GetPageIdxOfPage(hDlg) == PAGE_IDX_DESTFILENAME)
        {
        SetStaticText(hDlg, IDC_STATIC_FILENAME, TEXT("Dump filename:"));

        // Note: Only used when creating a new keyfile
        SetDlgItemString(
                         G_hInstance,
                         hDlg,
                         IDC_STATIC_INSTRUCTION,
                         IDS_STRING_INST_DUMPCDB_DESTFILE
                        );
        }

    SizeControlMaxWidthBorder(
                              hDlg,
                              IDC_STATIC_INSTRUCTION,
                              FREEOTFE_DLG_BORDER
                             );
    SizeControlMaxDepth(hDlg, IDC_STATIC_INSTRUCTION);

    _dlgDumpCDBWizard_EnableDisableControls(hDlg);

    // Set menu buttons as on the first page
    _dlgDumpCDBWizard_SetWizardButtons(0);

    DEBUGOUTGUI(DEBUGLEV_EXIT, (TEXT("dlgDumpCDBWizard_HandleMsg_WM_INITDIALOG\n")));
    return TRUE;
}


// =========================================================================
BOOL CALLBACK dlgDumpCDBWizard_HandleMsg_WM_DESTROY(HWND hWnd)
{
    DEBUGOUTGUI(DEBUGLEV_ENTER, (TEXT("dlgDumpCDBWizard_HandleMsg_WM_DESTROY\n")));

    if (G_dlgDumpCDBWizard_MenuBar != NULL)
        {
        DestroyWindow(G_dlgDumpCDBWizard_MenuBar);
        G_dlgDumpCDBWizard_MenuBar = NULL;
        }

    if (hDumpCDBSrcDetailsWndPassword != NULL)
        {
        DestroyWindow(hDumpCDBSrcDetailsWndPassword);
        hDumpCDBSrcDetailsWndPassword = NULL;
        }
    if (hDumpCDBSrcDetailsWndAdvanced != NULL)
        {
        DestroyWindow(hDumpCDBSrcDetailsWndAdvanced);
        hDumpCDBSrcDetailsWndAdvanced = NULL;
        }

    G_dlgDumpCDBWizard_AllowFinish = FALSE;

    _dlgDumpCDBWizard_SecZeroParams();

    DEBUGOUTGUI(DEBUGLEV_EXIT, (TEXT("dlgDumpCDBWizard_HandleMsg_WM_DESTROY\n")));
    return TRUE;
}


// =========================================================================
// hTabWnd - The tab window
// hWnd - The window to be displayed on the tab
void _dlgDumpCDBWizard_SizeWindowTab(
    HWND hTabWnd,
    HWND hWnd
)
{
    RECT rcTab;
    RECT rcAdjust;

    if (GetWindowRect(hTabWnd, &rcTab))
        {
        rcAdjust = rcTab;
        TabCtrl_AdjustRect(hTabWnd, FALSE, &rcAdjust);
        rcTab.bottom = rcAdjust.bottom;

        DEBUGOUTGUI(DEBUGLEV_INFO, (TEXT("Window: 0x%0.8x\n"), hWnd));
        DEBUGOUTGUI(DEBUGLEV_INFO, (TEXT("  left  : %.3d\n"), rcTab.left));
        DEBUGOUTGUI(DEBUGLEV_INFO, (TEXT("  top   : %.3d\n"), rcTab.top));
        DEBUGOUTGUI(DEBUGLEV_INFO, (TEXT("  right : %.3d\n"), rcTab.right));
        DEBUGOUTGUI(DEBUGLEV_INFO, (TEXT("  bottom: %.3d\n"), rcTab.bottom));

        SetWindowPos(
                     hWnd, 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -