void __error_s( HWND hwnd, wchar_t *pws_format, int e_code, ... ) { wchar_t msg[MAX_PATH - 20]; wchar_t est[20]; va_list args; va_start(args, e_code); if ( pws_format != NULL ) { _vsnwprintf( msg, sizeof_w(msg), pws_format, args ); } else { msg[0] = 0; } va_end(args); if (e_code != ST_OK) { _snwprintf( est, sizeof_w(est), L"\nError code: %d", e_code ); wcscat(msg, est); } __msg_e( hwnd, msg ); }
static int dc_cd_callback( u64 iso_sz, u64 enc_sz, void *lparam ) { _dnode *node = pv(lparam); if ( node != NULL ) { HWND h_iso_info = GetDlgItem( node->dlg.h_page, IDC_ISO_PROGRESS ); wchar_t s_enc_size[MAX_PATH] = { 0 }; wchar_t s_ttl_size[MAX_PATH] = { 0 }; wchar_t s_done[MAX_PATH] = { STR_EMPTY }; wchar_t s_speed[MAX_PATH] = { STR_EMPTY }; wchar_t s_percent[MAX_PATH] = { STR_EMPTY }; wchar_t s_elapsed[MAX_PATH] = { STR_EMPTY }; wchar_t s_estimated[MAX_PATH] = { STR_EMPTY }; int speed = _speed_stat_event( s_speed, sizeof_w(s_speed), &node->dlg.iso.speed, enc_sz, TRUE ); int new_pos = (int)( enc_sz / ( iso_sz / PRG_STEP ) ); if ( speed != 0 ) { _get_time_period( ( ( iso_sz - enc_sz ) / 1024 / 1024 ) / speed, s_estimated, TRUE ); } dc_format_byte_size( s_enc_size, sizeof_w(s_enc_size), enc_sz ); dc_format_byte_size( s_ttl_size, sizeof_w(s_ttl_size), iso_sz ); _snwprintf( s_done, sizeof_w(s_done), L"%s / %s", s_enc_size, s_ttl_size ); _get_time_period( node->dlg.iso.speed.t_begin.QuadPart, s_elapsed, FALSE ); _list_set_item_text( h_iso_info, 0, 1, _wcslwr( s_done ) ); _list_set_item_text( h_iso_info, 1, 1, _wcslwr( s_speed ) ); _list_set_item_text( h_iso_info, 3, 1, _wcslwr( s_elapsed ) ); _list_set_item_text( h_iso_info, 4, 1, _wcslwr( s_estimated ) ); SendMessage( GetDlgItem( node->dlg.h_page, IDC_PROGRESS_ISO ), PBM_SETPOS, (WPARAM)new_pos, 0 ); _snwprintf( s_percent, sizeof_w(s_percent), L"%.2f %%", (double)(enc_sz) / (double)(iso_sz) * 100 ); SetWindowText( GetDlgItem(node->dlg.h_page, IDC_STATUS_PROGRESS), s_percent); return node->dlg.rlt; } return ST_OK; }
static int dc_save_drv_file(wchar_t *d_name) { wchar_t dest[MAX_PATH]; wchar_t path[MAX_PATH]; wchar_t srcf[MAX_PATH]; int resl; do { dc_get_driver_path(dest, d_name); if (dc_get_prog_path(path, sizeof_w(path) - 10) == 0) { resl = ST_ERROR; break; } _snwprintf( srcf, MAX_PATH, L"%s\\%s.sys", path, d_name); if (CopyFile(srcf, dest, FALSE) != 0) { resl = ST_OK; } else { resl = ST_ACCESS_DENIED; } } while (0); return resl; }
BOOL CALLBACK _enum_proc( HWND hwnd, LPARAM lparam ) { wchar_t caption[200]; void *data; if ( *(HWND *)lparam == hwnd ) { return 1L; } data = wnd_get_long( hwnd, GWL_USERDATA ); if ( data ) { GetWindowText( hwnd, caption, sizeof_w(caption) ); if ( wcscmp(caption, DC_NAME) == 0 ) { *(HWND *)lparam = hwnd; } } return 1L; }
char _check_hotkeys( HWND hwnd, DWORD hotkeys[ ] ) { wchar_t display[400]; wchar_t key[200]; int k = 0; int j; for ( ; k < HOTKEYS; k++ ) { for ( j = 0; j < HOTKEYS; j++ ) { if ( k != j && hotkeys[k] && hotkeys[k] == hotkeys[j] ) { _key_name( HIWORD(hotkeys[k]), LOWORD(hotkeys[k]), key ); _snwprintf( display, sizeof_w(display), L"Duplicated Hotkey: \"%s\"", key ); MessageBox( hwnd, display, L"Error", MB_OK | MB_ICONERROR ); return FALSE; } } if ( hotkeys[k] && !RegisterHotKey( __dlg, k, LOWORD(hotkeys[k]), HIWORD(hotkeys[k]) ) ) { _key_name( HIWORD(hotkeys[k]), LOWORD(hotkeys[k]), key ); return FALSE; } else { UnregisterHotKey( __dlg, k ); } } return TRUE; }
void _log( wchar_t *pws_message, ... ) { PROCESS_BASIC_INFORMATION pbi; int last_error = GetLastError( ); wchar_t ws_args[MAX_PATH] = { 0 }; wchar_t ws_line[MAX_PATH] = { 0 }; HANDLE h_file; DWORD bytes; va_list args; static int count = 0; wchar_t ws_name[MAX_PATH]; NTSTATUS status; status = NtQueryInformationProcess( GetCurrentProcess( ), ProcessBasicInformation, &pbi, sizeof(pbi), NULL ); { _snwprintf( ws_name, sizeof_w(ws_name), L"dcrypt_%d.log", status == 0 ? pbi.UniqueProcessId : 0 ); } h_file = CreateFile( ws_name, GENERIC_WRITE, FILE_SHARE_READ, NULL, count == 0 ? CREATE_ALWAYS : OPEN_ALWAYS, 0, NULL ); if ( h_file == INVALID_HANDLE_VALUE ) return; if ( SetFilePointer(h_file, 0, 0, FILE_END) != INVALID_SET_FILE_POINTER ) { va_start( args, pws_message ); if ( pws_message != NULL ) { _vsnwprintf( ws_args, sizeof_w(ws_line), pws_message, args ); } va_end( args ); _snwprintf( ws_line, sizeof_w(ws_line), L"line:%0.4X last error:%0.8X message:%s\r\n", count++, last_error, ws_args ); WriteFile( h_file, _wcsupr(ws_line), d32(wcslen(ws_line) * sizeof(wchar_t)), &bytes, NULL ); CloseHandle(h_file); } }
static void dc_get_driver_path(wchar_t *path, wchar_t *d_name) { wchar_t tmpb[MAX_PATH]; GetSystemDirectory(tmpb, sizeof_w(tmpb)); _snwprintf( path, MAX_PATH, L"%s\\drivers\\%s.sys", tmpb, d_name); }
int dc_add_keyfiles(dc_pass *pass, wchar_t *path) { WIN32_FIND_DATA find; wchar_t name[MAX_PATH * 2]; HANDLE h_find; int resl; _snwprintf( name, sizeof_w(name), L"%s\\*", path); h_find = FindFirstFile(name, &find); if (h_find != INVALID_HANDLE_VALUE) { resl = ST_EMPTY_KEYFILES; do { if (find.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { /* recurse folder scanning not needed */ continue; } _snwprintf( name, sizeof_w(name), L"%s\\%s", path, find.cFileName); if ( (resl = dc_add_single_kf(pass, name)) != ST_OK ) { break; } } while (FindNextFile(h_find, &find) != 0); FindClose(h_find); } else { resl = dc_add_single_kf(pass, path); } /* prevent leaks */ zeroauto(&find, sizeof(find)); zeroauto(&name, sizeof(name)); return resl; }
void _init_main_dlg( HWND hwnd ) { MENUITEMINFO mnitem = { sizeof(mnitem) }; wchar_t display[MAX_PATH]; _snwprintf( display, sizeof_w(display), L"%s %S", DC_NAME, DC_FILE_VER ); SetWindowText( hwnd, display ); SendMessage( hwnd, WM_SYSCOLORCHANGE, 0, 0 ); _set_hotkeys( hwnd, __config.hotkeys, TRUE ); _tray_icon( TRUE ); mnitem.fMask = MIIM_FTYPE; mnitem.fType = MFT_RIGHTJUSTIFY; SetMenuItemInfo( GetMenu( hwnd ), ID_HOMEPAGE, FALSE, &mnitem ); SendMessage( GetDlgItem( hwnd, IDC_DRIVES_HEAD ), WM_SETFONT, (WPARAM)__font_bold, 0 ); { RECT rc, cr; void *res; int size; GetClientRect(hwnd, &rc); GetWindowRect(hwnd, &cr); if ( ( res = _extract_rsrc(IDD_MAIN_DLG, RT_DIALOG, &size) ) != NULL ) { _dlg_templateex *rs_template = pv(res); RECT rect = { rs_template->x, rs_template->y, rs_template->cx, rs_template->cy }; MapDialogRect(hwnd, &rect); _dlg_height = rect.bottom; _dlg_width = rect.right; _dlg_right = cr.right; _dlg_bottom = cr.bottom; if ( _dlg_height != rc.bottom ) { SendMessage( hwnd, WM_SIZE, 0, MAKELONG(rc.right, rc.bottom) ); } } } }
int dc_update_driver() { wchar_t buff[MAX_PATH]; dc_conf_data conf; int resl; do { if ( (resl = dc_save_drv_file(drv_dc)) != ST_OK ) { break; } if ( (resl = dc_load_conf(&conf)) != ST_OK ) { break; } if (conf.build < 692) { /* remove old file system filter driver */ if (dc_remove_service(drv_fsf) == ST_OK) { dc_get_driver_path(buff, drv_fsf); DeleteFile(buff); } /* add Altitude */ if ( (resl = dc_add_altitude()) != ST_OK ) { break; } } if (conf.build < 366) { /* add CDROM class filter */ dc_add_filter(cdr_key, drv_dc, 1); /* set new default flags */ conf.conf_flags |= CONF_HW_CRYPTO | CONF_AUTOMOUNT_BOOT; } if (conf.build < 642) { conf.conf_flags |= CONF_ENABLE_SSD_OPT; } resl = dc_save_conf(&conf); } while (0); if (resl == ST_OK) { _snwprintf( buff, sizeof_w(buff), L"DC_UPD_%d", dc_get_version()); GlobalAddAtom(buff); } return resl; }
int dc_unmount_volume(wchar_t *device, int flags) { HANDLE h_device = TlsGetValue(h_tls_idx); dc_ioctl dctl; dc_status status; u32 bytes; int succs; int resl; wchar_t mnt_p[MAX_PATH]; wcscpy(dctl.device, device); do { succs = DeviceIoControl( h_device, DC_CTL_STATUS, &dctl, sizeof(dc_ioctl), &status, sizeof(dc_status), &bytes, NULL ); if ( (succs == 0) || (IS_UNMOUNTABLE(&status) == 0) ) { resl = ST_UNMOUNTABLE; break; } dctl.flags = flags; succs = DeviceIoControl( h_device, DC_CTL_UNMOUNT, &dctl, sizeof(dc_ioctl), &dctl, sizeof(dc_ioctl), &bytes, NULL ); if (succs == 0) { resl = ST_ERROR; break; } if ( (resl = dctl.status) != ST_OK ) { break; } if ( (flags & MF_DELMP) || (status.mnt_flags & MF_DELMP) ) { _snwprintf( mnt_p, sizeof_w(mnt_p), L"%s\\", status.mnt_point); DeleteVolumeMountPoint(mnt_p); } } while (0); return resl; }
LRESULT CALLBACK _key_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) { char resolve; wchar_t text[500] = { 0 }; int shift = 0; _wnd_data *data = wnd_get_long( hwnd, GWL_USERDATA ); if ( !data ) return 1L; if ( _keyup(msg) || _keydown(msg) ) { wchar_t key[100] = { 0 }; if ( GetKeyState(VK_CONTROL) < 0 ) shift |= MOD_CONTROL; if ( GetKeyState(VK_SHIFT) < 0 ) shift |= MOD_SHIFT; if ( GetKeyState(VK_MENU) < 0 ) shift |= MOD_ALT; resolve = _key_name( wparam, shift, key ); if ( _keyup(msg) && !resolve ) { GetWindowText( hwnd, text, sizeof_w(text) ); if ( text[wcslen(text) - 2] == L'+' ) { SetWindowText(hwnd, STR_NULL); } return 0L; } if ( !_keyup(msg) && resolve ) { data->vk = MAKELONG(shift, wparam); } SetWindowText( hwnd, key ); return 0L; } CallWindowProc( data->old_proc, hwnd, msg, wparam, lparam ); return 1L; }
int _ext_disk_num( HWND hwnd ) { wchar_t vol[MAX_PATH]; wchar_t *num_offset; _get_item_text( hwnd, ListView_GetSelectionMark(hwnd), 0, vol, sizeof_w(vol) ); num_offset = wcschr(vol, ' '); return ( num_offset ? _wtoi(num_offset) : -1 ); }
int dc_first_volume(vol_inf *info) { wchar_t name[MAX_PATH]; info->find = FindFirstVolume(name, sizeof_w(name)); if (info->find != INVALID_HANDLE_VALUE) { if (dc_get_vol_info(name, info) != ST_OK) { return dc_next_volume(info); } else { return ST_OK; } } return ST_ERROR; }
static int dc_get_vol_info(wchar_t *name, vol_inf *info) { HANDLE h_device = TlsGetValue(h_tls_idx); dc_ioctl dctl; int succs; u32 bytes; int resl; do { wcschr(name, L'}')[1] = 0; wcscpy(info->w32_device, name); _snwprintf( dctl.device, sizeof_w(dctl.device), L"\\??\\Volume%s", wcschr(name, '{')); succs = DeviceIoControl( h_device, DC_CTL_RESOLVE, &dctl, sizeof(dctl), &dctl, sizeof(dctl), &bytes, NULL); if ( (succs == 0) || (dctl.status != ST_OK) ) { resl = ST_ERROR; break; } wcscpy(info->device, dctl.device); succs = DeviceIoControl( h_device, DC_CTL_STATUS, &dctl, sizeof(dc_ioctl), &info->status, sizeof(dc_status), &bytes, NULL); if (succs == 0) { resl = ST_ERROR; break; } else { if (info->status.mnt_point[0] == 0) { wcscpy(info->status.mnt_point, info->w32_device); } resl = ST_OK; } } while (0); return resl; }
int _get_combo_val( HWND hwnd, _init_list *list ) { int count = 0; wchar_t text[MAX_PATH]; GetWindowText( hwnd, text, sizeof_w(text) ); while ( wcslen(list[count].display) ) { if ( !wcscmp(list[count].display, text) ) { return list[count].val; } count++; } return -1; }
static int _msg_va( HWND hwnd, wchar_t *format, wchar_t *caption, int type, va_list args ) { wchar_t msg[MAX_PATH]; if (format != NULL) { _vsnwprintf( msg, sizeof_w(msg), format, args ); } else { msg[0] = 0; } return MessageBox(hwnd, msg, caption, type); }
int dc_next_volume(vol_inf *info) { wchar_t name[MAX_PATH]; FindNextVolume( info->find, name, sizeof_w(name)); if (GetLastError() != ERROR_NO_MORE_FILES) { if (dc_get_vol_info(name, info) != ST_OK) { return dc_next_volume(info); } else { return ST_OK; } } else { FindVolumeClose(info->find); } return ST_ERROR; }
BOOL _is_icon_show( HWND h_list, int idx ) { WINDOWINFO winfo = { 0 }; wchar_t s_header[200] = { STR_HEAD_NO_ICONS }; winfo.cbSize = sizeof( winfo ); GetWindowInfo( h_list, &winfo ); if (idx != -1) { _get_header_text( h_list, idx, s_header, sizeof_w(s_header) ); } return ( s_header[wcslen(s_header) - 1] == L' ' ); }
static u32 disk_id_select() { vol_inf *vol; u32 i, idn = 0; u32 ids[MAX_VOLUMES]; wchar_t s_size[MAX_PATH]; u32 id = 0; for (i = 0; i < vol_cnt; i++) { vol = &volumes[i]; if ( (vol->status.flags & F_ENABLED) && (vol->status.disk_id != 0) ) { dc_format_byte_size( s_size, sizeof_w(s_size), vol->status.dsk_size ); if (idn == 0) { wprintf(L"\nSelect partition:\n"); } ids[idn++] = vol->status.disk_id; wprintf( L"%d - pt%d (%s) (%s)\n", idn, i, vol->status.mnt_point, s_size); } } if (idn == 0) { wprintf(L"Mounted partitions with valid disk_id not found\n"); _getch(); } else { id = ids[getchr('1', '1'+(u8)idn-1) - '1']; } return id; }
INT_PTR CALLBACK _benchmark_dlg_proc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam ) { switch ( message ) { case WM_CLOSE : { __lists[HBENCHMARK] = HWND_NULL; EndDialog( hwnd, 0 ); return 0L; } break; case WM_COMMAND : { int code = HIWORD(wparam); int id = LOWORD(wparam); if ( ( id == IDOK ) || ( id == IDCANCEL ) ) { EndDialog( hwnd, 0 ); } if ( id == IDB_REFRESH_TEST ) { HWND h_button = GetDlgItem( hwnd, IDB_REFRESH_TEST ); SetCursor( __cur_wait ); EnableWindow( h_button, FALSE ); { bench_item bench[CF_CIPHERS_NUM]; wchar_t s_speed[50]; int cnt; int lvcount = 0; int k = 0; cnt = _benchmark(pv(&bench)); ListView_DeleteAllItems( __lists[HBENCHMARK] ); for ( k = 0; k < cnt; k++ ) { _list_insert_item( __lists[HBENCHMARK], lvcount, 0, bench[k].alg, 0 ); _list_set_item( __lists[HBENCHMARK], lvcount, 1, STR_EMPTY ); _snwprintf( s_speed, sizeof_w(s_speed), L"%-.2f mb/s", bench[k].speed ); _list_set_item( __lists[HBENCHMARK], lvcount++, 2, s_speed ); } } EnableWindow( h_button, TRUE ); SetCursor( __cur_arrow ); } } break; case WM_INITDIALOG : { __lists[HBENCHMARK] = GetDlgItem( hwnd, IDC_LIST_BENCHMARK ); _init_list_headers( __lists[HBENCHMARK], _benchmark_headers ); ListView_SetBkColor( __lists[HBENCHMARK], GetSysColor(COLOR_BTNFACE) ); ListView_SetTextBkColor( __lists[HBENCHMARK], GetSysColor(COLOR_BTNFACE) ); ListView_SetExtendedListViewStyle( __lists[HBENCHMARK], LVS_EX_FLATSB | LVS_EX_FULLROWSELECT ); SetForegroundWindow(hwnd); _sub_class(GetDlgItem(hwnd, IDC_BUTTON), SUB_STATIC_PROC, HWND_NULL); return 1L; } break; case WM_CTLCOLOREDIT : { return ( _ctl_color(wparam, _cl(COLOR_BTNFACE, LGHT_CLR)) ); } break; default: { int rlt = _draw_proc(message, lparam); if (rlt != -1) { return rlt; } } } return 0L; }
void _is_breaking_action( ) { list_entry *node; list_entry *sub; int count = 0; int k, flag; BOOL resume; wchar_t s_vol[MAX_PATH] = { 0 }; for ( k = 0; k < 4; k++ ) { if (k % 2 == 0) { memset(s_vol, 0, sizeof_w(s_vol)); // WTF? count = 0; resume = FALSE; } for ( node = __drives.flink; node != &__drives; node = node->flink ) { _dnode *root = contain_record(node, _dnode, list); for ( sub = root->root.vols.flink; sub != &root->root.vols; sub = sub->flink ) { _dnode *mnt = contain_record(sub, _dnode, list); switch (k) { case 0: case 1: flag = F_FORMATTING; break; case 2: case 3: flag = F_SYNC; break; default: flag = -1; break; } if (mnt->mnt.info.status.flags & flag) { if (k % 2 == 0) { if (s_vol[0] != L'\0') wcscat(s_vol, L", "); wcscat(s_vol, mnt->mnt.info.status.mnt_point); count++; } else { if (resume) { if (k == 1) _menu_format(mnt); if (k == 3) _menu_encrypt(mnt); } } } } } if ((k % 2 == 0) && count > 0) { if (__msg_q( __dlg, L"%s was suspended for volume%s %s.\n\n" L"Continue %s?", k != 0 ? L"Encrypting/decrypting" : L"Formatting", count > 1 ? L"s" : STR_NULL, s_vol, k != 0 ? L"encrypting" : L"formatting") ) { resume = TRUE; } } } }
INT_PTR CALLBACK _about_dlg_proc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam ) { _ctl_init ctl_links[ ] = { { DC_HOMEPAGE, IDC_ABOUT_URL1, 0 }, { DC_FORUMPAGE, IDC_ABOUT_URL2, 0 } }; static HICON h_icon; switch ( message ) { case WM_DESTROY : { DestroyIcon(h_icon); return 0L; } break; case WM_CLOSE : { EndDialog(hwnd, 0); return 0L; } break; case WM_COMMAND : { int id = LOWORD(wparam); int code = HIWORD(wparam); int k; if ( code == EN_SETFOCUS ) { SendMessage( (HWND)lparam, EM_SETSEL, -1, 0 ); } if ( id == IDCANCEL || id == IDOK ) { EndDialog(hwnd, 0); } for ( k = 0; k < array_num(ctl_links); k++ ) { if ( id == ctl_links[k].id ) { __execute(ctl_links[k].display); } } } break; case WM_SHOWWINDOW : { SetFocus( GetDlgItem(hwnd, IDC_EDIT_NOTICE) ); SendMessage( GetDlgItem(hwnd, IDC_EDIT_NOTICE), EM_SETSEL, -1, 0 ); } break; case WM_INITDIALOG : { HWND h_notice = GetDlgItem(hwnd, IDC_EDIT_NOTICE); wchar_t s_display[MAX_PATH]; BYTE *res; int size, id_icon; int k = 0; res = _extract_rsrc( IDI_ICON_TRAY, RT_GROUP_ICON, &size ); id_icon = LookupIconIdFromDirectoryEx( res, TRUE, 48, 48, 0 ); res = _extract_rsrc( id_icon, RT_ICON, &size ); h_icon = CreateIconFromResourceEx( res, size, TRUE, 0x00030000, 48, 48, 0 ); SendMessage( GetDlgItem(hwnd, IDC_ICON_MAIN), STM_SETICON, (WPARAM)h_icon, 0 ); { HWND h_title = GetDlgItem( hwnd, IDC_ABOUT1 ); _snwprintf( s_display, sizeof_w(s_display), L"%s %S", DC_NAME, DC_FILE_VER ); SetWindowText( h_title, s_display ); SetWindowText( h_notice, L"This program is free software: you can redistribute " L"it under the terms of the GNU General Public License " L"version 3 as published by the Free Software Foundation.\r\n\r\n" L"Contacts:\r\n" L"[email protected] (PGP key ID 0xC48251EB4F8E4E6E)\r\n\r\n" L"Special thanks to:\r\n" L"Aleksey Bragin and ReactOS Foundation\r\n\r\n" L"Portions of this software:\r\n" L"Copyright \xa9 1998, 2001, 2002 Brian Palmer\r\n" L"Copyright \xa9 2003, Dr Brian Gladman, Worcester, UK\r\n" L"Copyright \xa9 2006, Rik Snel <*****@*****.**>\r\n" L"Copyright \xa9 Vincent Rijmen <*****@*****.**>\r\n" L"Copyright \xa9 Antoon Bosselaers <*****@*****.**>\r\n" L"Copyright \xa9 Paulo Barreto <*****@*****.**>\r\n" L"Copyright \xa9 Tom St Denis <*****@*****.**>\r\n" L"Copyright \xa9 Juergen Schmied and Jon Griffiths\r\n" L"Copyright \xa9 Lynn McGuire\r\n" L"Copyright \xa9 Matthew Skala <*****@*****.**>\r\n" L"Copyright \xa9 Werner Koch\r\n" L"Copyright \xa9 Dag Arne Osvik <*****@*****.**>\r\n" L"Copyright \xa9 Herbert Valerio Riedel <*****@*****.**>\r\n" L"Copyright \xa9 Wei Dai\r\n" L"Copyright \xa9 Ruben Jesus Garcia Hernandez <*****@*****.**>\r\n" L"Copyright \xa9 Serge Trusov <*****@*****.**>" ); SendMessage( h_title, WM_SETFONT, (WPARAM)__font_bold, 0 ); for ( k = 0; k < array_num(ctl_links); k++ ) { HWND h_ctl = GetDlgItem(hwnd, ctl_links[k].id); SetWindowLongPtr( h_ctl, GWL_USERDATA, (LONG_PTR)GetWindowLongPtr( h_ctl, GWL_WNDPROC ) ); SetWindowLongPtr( h_ctl, GWL_WNDPROC, (LONG_PTR)_link_proc ); SetWindowText( h_ctl, ctl_links[k].display ); SendMessage( h_ctl, WM_SETFONT, (WPARAM)__font_link, 0 ); { WINDOWINFO pwi; SIZE size; HDC h_dc = GetDC( h_ctl ); SelectObject( h_dc, __font_link ); GetTextExtentPoint32( h_dc, ctl_links[k].display, d32(wcslen(ctl_links[k].display)), &size ); GetWindowInfo( h_ctl, &pwi ); ScreenToClient( hwnd, pv(&pwi.rcClient) ); MoveWindow( h_ctl, pwi.rcClient.left, pwi.rcClient.top, size.cx, size.cy, TRUE ); ReleaseDC( h_ctl, h_dc ); } } { dc_conf conf; if ( dc_get_conf_flags(&conf) == ST_OK ) { wchar_t *s_using = L"Not supported"; wchar_t *s_inset = L"Not supported"; if ( conf.load_flags & DST_HW_CRYPTO ) { s_using = ( conf.conf_flags & CONF_HW_CRYPTO ? L"Enabled" : L"Disabled" ); if ( conf.load_flags & DST_INTEL_NI ) s_inset = L"Intel® AES Instructions Set (AES-NI)"; if ( conf.load_flags & DST_VIA_PADLOCK ) s_inset = L"The VIA PadLock Advanced Cryptography Engine (ACE)"; } _snwprintf( s_display, sizeof_w(s_display), L"Hardware Cryptography: %s\r\n" L"Instruction Set: %s", s_using, s_inset ); SetWindowText( GetDlgItem(hwnd, IDC_EDIT_CIPHER_INFO), s_display ); EnableWindow( GetDlgItem(hwnd, IDC_EDIT_CIPHER_INFO), conf.load_flags & DST_HW_CRYPTO ); } } } SendMessage( h_notice, EM_SCROLLCARET, 0, 0 ); SetForegroundWindow( hwnd ); return 1L; } break; default: { int rlt = _draw_proc( message, lparam ); if ( rlt != -1 ) { return rlt; } } } return 0L; }
void _add_drive_node( _dnode *exist_node, drive_inf *new_drv, vol_inf *vol, int disk_number ) { wchar_t drvname[MAX_PATH]; wchar_t fs[MAX_PATH] = { 0 }; wchar_t label[MAX_PATH] = { 0 }; wchar_t path[MAX_PATH]; list_entry *node; BOOL root_exists = FALSE; _dnode *root; _dnode *mnt; mnt = exist_node; if ( mnt == NULL ) { mnt = malloc( sizeof(_dnode) ); memset( mnt, 0, sizeof(_dnode) ); } mnt->exists = TRUE; memcpy( &mnt->mnt.info, vol, sizeof(vol_inf) ); _snwprintf( path, sizeof_w(path), L"%s\\", vol->status.mnt_point ); GetVolumeInformation( path, label, sizeof_w(label), 0, 0, 0, fs, sizeof_w(fs) ); wcscpy( mnt->mnt.label, label ); wcscpy( mnt->mnt.fs, fs ); if (! exist_node ) { dc_get_hw_name( disk_number, vol->status.flags & F_CDROM, drvname, sizeof_w(drvname) ); if (! ( vol->status.flags & F_CDROM ) ) { for ( node = __drives.flink; node != &__drives; node = node->flink ) { root = contain_record(node, _dnode, list); if ( root->root.dsk_num == disk_number ) { root_exists = TRUE; break; } } } mnt->is_root = FALSE; memcpy( &mnt->root.info, new_drv, sizeof(drive_inf) ); if (! root_exists ) { root = malloc(sizeof(_dnode)); root->is_root = TRUE; memcpy(&root->mnt.info, vol, sizeof(vol_inf)); memcpy(&root->root.info, new_drv, sizeof(drive_inf)); wcscpy(root->root.dsk_name, drvname); root->root.dsk_num = disk_number; _init_list_head(&root->root.vols); _insert_tail_list(&__drives, &root->list); } _insert_tail_list(&root->root.vols, &mnt->list); } if ( vol->status.flags & F_SYNC && _create_act_thread(mnt, -1, -1) == NULL ) { _create_act_thread(mnt, ACT_ENCRYPT, ACT_PAUSED); } }
INT_PTR CALLBACK _password_dlg_proc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam ) { WORD code = HIWORD(wparam); WORD id = LOWORD(wparam); wchar_t display[MAX_PATH] = { 0 }; static dlgpass *info; static RECT rc_left = { 0, 0, 0, 0 }; static RECT rc_right = { 0, 0, 0, 0 }; static cut; switch ( message ) { case WM_DRAWITEM : { DRAWITEMSTRUCT *draw = pv(lparam); static RECT left; static RECT right; switch ( draw->CtlID ) { case IDC_FRAME_LEFT: { if ( !rc_left.right ) { _relative_rect( draw->hwndItem, &rc_left ); rc_left.bottom -= cut; } MoveWindow( draw->hwndItem, rc_left.left, rc_left.top, rc_left.right, rc_left.bottom, TRUE ); } break; case IDC_FRAME_RIGHT: { if ( !rc_right.right ) { _relative_rect( draw->hwndItem, &rc_right ); rc_right.bottom -= cut; } MoveWindow( draw->hwndItem, rc_right.left, rc_right.top, rc_right.right, rc_right.bottom, TRUE ); } break; } _draw_static( draw ); return 1L; } break; case WM_CTLCOLOREDIT : { return ( _ctl_color( wparam, _cl(COLOR_BTNFACE, LGHT_CLR) ) ); } break; case WM_INITDIALOG : { int ctl_resize[ ] = { IDC_FRAME_LEFT, IDC_FRAME_RIGHT, -1 }; info = (dlgpass *)lparam; _init_mount_points( GetDlgItem(hwnd, IDC_COMBO_MNPOINT) ); SendMessage( GetDlgItem(hwnd, IDC_COMBO_MNPOINT), CB_SETCURSEL, 1, 0 ); SendMessage( GetDlgItem(hwnd, IDE_PASS), EM_LIMITTEXT, MAX_PASSWORD, 0 ); if ( info->node ) { _snwprintf( display, sizeof_w(display), L"[%s] - %s", info->node->mnt.info.status.mnt_point, info->node->mnt.info.device ); } else { wcscpy(display, L"Enter password"); } SetWindowText( hwnd, display ); SetWindowText( GetDlgItem(hwnd, IDC_HEAD_PASS), L"# Current Password" ); SendMessage( GetDlgItem(hwnd, IDC_HEAD_PASS), WM_SETFONT, (WPARAM)__font_bold, 0 ); SetWindowText( GetDlgItem(hwnd, IDC_HEAD_MOUNT_OPTIONS), L"# Mount Options" ); SendMessage( GetDlgItem(hwnd, IDC_HEAD_MOUNT_OPTIONS), WM_SETFONT, (WPARAM)__font_bold, 0 ); _sub_class( GetDlgItem(hwnd, IDC_CHECK_SHOW), SUB_STATIC_PROC, HWND_NULL ); _set_check( hwnd, IDC_CHECK_SHOW, FALSE ); _sub_class( GetDlgItem(hwnd, IDC_USE_KEYFILES), SUB_STATIC_PROC, HWND_NULL ); _set_check( hwnd, IDC_USE_KEYFILES, FALSE ); { HWND mnt_combo = GetDlgItem( hwnd, IDC_COMBO_MNPOINT ); HWND mnt_check = GetDlgItem( hwnd, IDC_CHECK_MNT_SET ); HWND mnt_label = GetDlgItem( hwnd, IDC_MNT_POINT ); BOOL enable; RECT rc_main; GetWindowRect(hwnd, &rc_main); enable = info->node && ( info->node->mnt.info.status.mnt_point[0] == L'\\' ); EnableWindow( mnt_combo, enable ); EnableWindow( mnt_check, enable ); EnableWindow( mnt_label, enable ); _sub_class( GetDlgItem(hwnd, IDC_CHECK_MNT_SET), SUB_STATIC_PROC, HWND_NULL ); _set_check( hwnd, IDC_CHECK_MNT_SET, enable ); } SendMessage( hwnd, WM_COMMAND, MAKELONG(IDE_PASS, EN_CHANGE), (LPARAM)GetDlgItem(hwnd, IDE_PASS) ); SetForegroundWindow(hwnd); return 1L; } break; case WM_USER_CLICK : { if ( (HWND)wparam == GetDlgItem(hwnd, IDC_CHECK_MNT_SET) ) { EnableWindow( GetDlgItem(hwnd, IDC_COMBO_MNPOINT), _get_check(hwnd, IDC_CHECK_MNT_SET) ); EnableWindow( GetDlgItem(hwnd, IDC_MNT_POINT), _get_check(hwnd, IDC_CHECK_MNT_SET) ); return 1L; } if ( (HWND)wparam == GetDlgItem(hwnd, IDC_CHECK_SHOW) ) { int mask = _get_check(hwnd, IDC_CHECK_SHOW) ? 0 : '*'; SendMessage(GetDlgItem(hwnd, IDE_PASS), EM_SETPASSWORDCHAR, mask, 0 ); InvalidateRect(GetDlgItem(hwnd, IDE_PASS), NULL, TRUE); return 1L; } if ( (HWND)wparam == GetDlgItem(hwnd, IDC_USE_KEYFILES) ) { SendMessage( hwnd, WM_COMMAND, MAKELONG(IDE_PASS, EN_CHANGE), (LPARAM)GetDlgItem(hwnd, IDE_PASS) ); EnableWindow(GetDlgItem(hwnd, IDB_USE_KEYFILES), _get_check(hwnd, IDC_USE_KEYFILES)); return 1L; } } break; case WM_COMMAND : if ( id == IDB_USE_KEYFILES ) { _dlg_keyfiles(hwnd, KEYLIST_CURRENT); SendMessage( hwnd, WM_COMMAND, MAKELONG(IDE_PASS, EN_CHANGE), (LPARAM)GetDlgItem(hwnd, IDE_PASS) ); } if ( code == CBN_SELCHANGE && id == IDC_COMBO_MNPOINT ) { if ( SendMessage((HWND)lparam, CB_GETCURSEL, 0, 0) == 0 ) { HWND h_combo = GetDlgItem(hwnd, IDC_COMBO_MNPOINT); int sel_item = 1; wchar_t path[MAX_PATH]; if ( _folder_choice(hwnd, path, L"Choice folder for mount point") ) { sel_item = (int)SendMessage(h_combo, CB_GETCOUNT, 0, 0); SendMessage(h_combo, CB_ADDSTRING, 0, (LPARAM)path); } SendMessage(h_combo, CB_SETCURSEL, sel_item, 0); } } if (code == EN_CHANGE) { BOOL correct; int idx_status; dc_pass *pass = _get_pass(hwnd, IDE_PASS); int keylist = _get_check(hwnd, IDC_USE_KEYFILES) ? KEYLIST_CURRENT : KEYLIST_NONE; correct = _input_verify(pass, NULL, keylist, -1, &idx_status ); secure_free(pass); SetWindowText(GetDlgItem(hwnd, IDC_PASS_STATUS), _get_text_name(idx_status, pass_status)); EnableWindow(GetDlgItem(hwnd, IDOK), correct); return 1L; } if ((id == IDCANCEL) || (id == IDOK)) { if (id == IDOK) { info->pass = _get_pass_keyfiles(hwnd, IDE_PASS, IDC_USE_KEYFILES, KEYLIST_CURRENT); if (IsWindowEnabled(GetDlgItem(hwnd, IDC_COMBO_MNPOINT)) && info->mnt_point) { GetWindowText( GetDlgItem(hwnd, IDC_COMBO_MNPOINT), (wchar_t *)info->mnt_point, MAX_PATH ); } } EndDialog (hwnd, id); return 1L; } break; case WM_DESTROY: { _wipe_pass_control(hwnd, IDE_PASS); _keyfiles_wipe(KEYLIST_CURRENT); memset(&rc_right, 0, sizeof(rc_right)); memset(&rc_left, 0, sizeof(rc_left)); cut = 0; return 0L; } break; case WM_MEASUREITEM: { MEASUREITEMSTRUCT *item = pv(lparam); if (item->CtlType != ODT_LISTVIEW) item->itemHeight -= 3; } break; } return 0L; }
void _run_wizard_action( HWND hwnd, _wz_sheets *sheets, _dnode *node ) { BOOL set_loader = (BOOL) SendMessage( GetDlgItem(sheets[WPAGE_ENC_BOOT].hwnd, IDC_COMBO_BOOT_INST), CB_GETCURSEL, 0, 0 ); wchar_t *fs_name = fs_names[SendMessage( GetDlgItem(sheets[WPAGE_ENC_FRMT].hwnd, IDC_COMBO_FS_LIST), CB_GETCURSEL, 0, 0 )]; int kb_layout = _get_combo_val( GetDlgItem(sheets[WPAGE_ENC_PASS].hwnd, IDC_COMBO_KBLAYOUT), kb_layouts ); BOOL q_format = _get_check( sheets[WPAGE_ENC_FRMT].hwnd, IDC_CHECK_QUICK_FORMAT ); int is_small = ( IsWindowEnabled( GetDlgItem( sheets[WPAGE_ENC_CONF].hwnd, IDC_COMBO_ALGORT ) ) ? FALSE : TRUE ); crypt_info crypt; dc_pass *pass = NULL; crypt.cipher_id = _get_combo_val( GetDlgItem(sheets[WPAGE_ENC_CONF].hwnd, IDC_COMBO_ALGORT), cipher_names ); crypt.wp_mode = _get_combo_val( GetDlgItem(sheets[WPAGE_ENC_CONF].hwnd, IDC_COMBO_PASSES), wipe_modes ); node->dlg.rlt = ST_ERROR; switch ( node->dlg.act_type ) { /////////////////////////////////////////////////////////////// case ACT_REENCRYPT : /////////////////////////////////////////////////////////////// /////// REENCRYPT VOLUME ////////////////////////////////////// { wchar_t mnt_point[MAX_PATH] = { 0 }; wchar_t vol[MAX_PATH]; dlgpass dlg_info = { node, NULL, NULL, mnt_point }; ShowWindow(hwnd, FALSE); if ( _dlg_get_pass(__dlg, &dlg_info) == ST_OK ) { node->mnt.info.status.crypt.wp_mode = crypt.wp_mode; node->dlg.rlt = dc_start_re_encrypt( node->mnt.info.device, dlg_info.pass, &crypt ); secure_free( dlg_info.pass ); if ( mnt_point[0] != 0 ) { _snwprintf( vol, sizeof_w(vol), L"%s\\", node->mnt.info.w32_device ); _set_trailing_slash( mnt_point ); if ( SetVolumeMountPoint(mnt_point, vol) == 0 ) { __error_s( __dlg, L"Error when adding mount point", node->dlg.rlt ); } } } else { node->dlg.rlt = ST_CANCEL; } } break; /////////////////////////////////////////////////////////////// case ACT_ENCRYPT_CD : /////////////////////////////////////////////////////////////// /////// ENCRYPT CD //////////////////////////////////////////// { _init_speed_stat( &node->dlg.iso.speed ); pass = _get_pass_keyfiles( sheets[WPAGE_ENC_PASS].hwnd, IDE_PASS, IDC_USE_KEYFILES, KEYLIST_CURRENT ); if ( pass ) { DWORD resume; { wchar_t s_src_path[MAX_PATH] = { 0 }; wchar_t s_dst_path[MAX_PATH] = { 0 }; GetWindowText( GetDlgItem(sheets[WPAGE_ENC_ISO].hwnd, IDE_ISO_SRC_PATH), s_src_path, sizeof_w(s_src_path) ); GetWindowText( GetDlgItem(sheets[WPAGE_ENC_ISO].hwnd, IDE_ISO_DST_PATH), s_dst_path, sizeof_w(s_dst_path) ); wcscpy( node->dlg.iso.s_iso_src, s_src_path ); wcscpy( node->dlg.iso.s_iso_dst, s_dst_path ); node->dlg.iso.cipher_id = crypt.cipher_id; node->dlg.iso.pass = pass; } node->dlg.iso.h_thread = CreateThread( NULL, 0, _thread_enc_iso_proc, pv(node), CREATE_SUSPENDED, NULL ); SetThreadPriority( node->dlg.iso.h_thread, THREAD_PRIORITY_LOWEST ); resume = ResumeThread( node->dlg.iso.h_thread ); if ( !node->dlg.iso.h_thread || resume == (DWORD) -1 ) { __error_s( hwnd, L"Error create thread", -1 ); secure_free(pass); } } } break; /////////////////////////////////////////////////////////////// default : /////////////////////////////////////////////////////////////// { node->mnt.info.status.crypt.wp_mode = crypt.wp_mode; node->dlg.rlt = ST_OK; if ( sheets[WPAGE_ENC_BOOT].show ) { if ( set_loader ) { node->dlg.rlt = _set_boot_loader( hwnd, -1, is_small ); } } if ( ( node->dlg.rlt == ST_OK ) && ( IsWindowEnabled( GetDlgItem( sheets[WPAGE_ENC_PASS].hwnd, IDC_LAYOUTS_LIST ) ) ) ) { node->dlg.rlt = _update_layout( node, kb_layout, NULL ); } if ( node->dlg.rlt == ST_OK ) { switch ( node->dlg.act_type ) { /////////////////////////////////////////////////////////////// case ACT_ENCRYPT : /////////////////////////////////////////////////////////////// /////// ENCRYPT VOLUME //////////////////////////////////////// { pass = _get_pass_keyfiles( sheets[WPAGE_ENC_PASS].hwnd, IDE_PASS, IDC_USE_KEYFILES, KEYLIST_CURRENT ); if ( pass != NULL ) { node->dlg.rlt = dc_start_encrypt( node->mnt.info.device, pass, &crypt ); secure_free(pass); } } break; /////////////////////////////////////////////////////////////// case ACT_FORMAT : /////////////////////////////////////////////////////////////// /////// FORMAT VOLUME ///////////////////////////////////////// { pass = _get_pass_keyfiles( sheets[WPAGE_ENC_PASS].hwnd, IDE_PASS, IDC_USE_KEYFILES, KEYLIST_CURRENT ); if ( pass ) { node->dlg.rlt = dc_start_format( node->mnt.info.device, pass, &crypt ); secure_free(pass); } } break; } } } } node->dlg.q_format = q_format; node->dlg.fs_name = fs_name; if ( !node->dlg.iso.h_thread ) { EndDialog( hwnd, 0 ); } }
INT_PTR CALLBACK _main_dialog_proc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam ) { WORD id = LOWORD(wparam); WORD code = HIWORD(wparam); _wnd_data *wnd; _dnode *sel; _dmnt *mnt; int k = 0; switch ( message ) { case WM_INITDIALOG : { memset( __lists, HWND_NULL, sizeof(__lists) ); __lists[HMAIN_DRIVES] = GetDlgItem( hwnd, IDC_DISKDRIVES ); __dlg = hwnd; _init_main_dlg( hwnd ); _load_diskdrives( hwnd, &__drives, _list_volumes(0) ); { TCITEM tab_item = { TCIF_TEXT }; HWND h_tab = GetDlgItem(hwnd, IDT_INFO); _tab_data *d_tab = malloc(sizeof(_tab_data)); zeroauto( d_tab, sizeof(_tab_data) ); d_tab->curr_tab = 1; wnd_set_long( hwnd, GWL_USERDATA, d_tab ); wnd = _sub_class( h_tab, SUB_NONE, CreateDialog( __hinst, MAKEINTRESOURCE(DLG_MAIN_INFO), GetDlgItem(hwnd, IDC_MAIN_TAB), _tab_proc ), CreateDialog( __hinst, MAKEINTRESOURCE(DLG_MAIN_ACTION), GetDlgItem(hwnd, IDC_MAIN_TAB), _tab_proc ), HWND_NULL ); { __lists[HMAIN_INFO] = GetDlgItem( wnd->dlg[0], IDC_INF_TABLE ); __lists[HMAIN_ACT] = GetDlgItem( wnd->dlg[1], IDC_ACT_TABLE ); } { __dlg_act_info = wnd->dlg[1]; _list_insert_col( __lists[HMAIN_INFO], 380 ); _list_insert_col( __lists[HMAIN_INFO], 90 ); while ( _list_insert_item( __lists[HMAIN_INFO], k, 0, _info_table_items[k], 0 ) ) k++; _set_header_text( __lists[HMAIN_INFO], 0, STR_HEAD_NO_ICONS, sizeof_w(STR_HEAD_NO_ICONS) ); _list_insert_col( __lists[HMAIN_ACT], 90 ); _list_insert_col( __lists[HMAIN_ACT], 70 ); _list_insert_col( __lists[HMAIN_ACT], 85 ); _list_insert_col( __lists[HMAIN_ACT], 50 ); _list_insert_item( __lists[HMAIN_ACT], 0, 0, _act_table_items[0], 0 ); ListView_SetItemText( __lists[HMAIN_ACT], 0, 2, _act_table_items[3] ); _list_insert_item( __lists[HMAIN_ACT], 1, 0, _act_table_items[1], 0 ); ListView_SetItemText( __lists[HMAIN_ACT], 1, 2, _act_table_items[4] ); _init_combo( GetDlgItem( __dlg_act_info, IDC_COMBO_PASSES), wipe_modes, WP_NONE, FALSE, -1 ); SendMessage( GetDlgItem( __dlg_act_info, IDC_PROGRESS ), PBM_SETBARCOLOR, 0, _cl( COLOR_BTNSHADOW, DARK_CLR - 20 ) ); SendMessage( GetDlgItem( __dlg_act_info, IDC_PROGRESS ), PBM_SETRANGE, 0, MAKELPARAM(0, PRG_STEP) ); } tab_item.pszText = L"Info"; TabCtrl_InsertItem( h_tab, 0, &tab_item ); { NMHDR mhdr = { 0, 0, TCN_SELCHANGE }; TabCtrl_SetCurSel( h_tab, 0 ); SendMessage(hwnd, WM_NOTIFY, IDT_INFO, (LPARAM)&mhdr); } } SendMessage( hwnd, WM_SYSCOLORCHANGE, 0, 0 ); _set_timer( MAIN_TIMER, TRUE, TRUE ); _set_timer( RAND_TIMER, TRUE, FALSE ); _set_timer( POST_TIMER, TRUE, FALSE ); return 0L; } break; case WM_WINDOWPOSCHANGED : { WINDOWPOS *pos = (WINDOWPOS *)lparam; int flags = pos->flags; _dlg_right = pos->cx + pos->x; _dlg_bottom = pos->cy + pos->y; _dlg_left = pos->x; if ( ( flags & SWP_SHOWWINDOW ) || ( flags & SWP_HIDEWINDOW ) ) { _set_timer( MAIN_TIMER, flags & SWP_SHOWWINDOW, TRUE ); } return 0L; } break; case WM_ENTERSIZEMOVE : { //_middle_ctl( // GetDlgItem(hwnd, IDC_DISKDRIVES), // GetDlgItem(hwnd, IDC_RESIZING), // TRUE // ); //ShowWindow(GetDlgItem(hwnd, IDC_DISKDRIVES), SW_HIDE); return 0L; } break; case WM_EXITSIZEMOVE : { //ShowWindow(GetDlgItem(hwnd, IDC_DISKDRIVES), SW_SHOW); return 0L; } break; case WM_SIZING : { RECT *rect = ((RECT *)lparam); rect->right = _dlg_right; rect->left = _dlg_left; if ( rect->bottom - rect->top < MAIN_DLG_MIN_HEIGHT ) { rect->bottom = rect->top + MAIN_DLG_MIN_HEIGHT; } return 1L; } break; case WM_SIZE : { int height = HIWORD(lparam); int width = LOWORD(lparam); int k; _size_move_ctls _resize[ ] = { { -1, IDC_DISKDRIVES, FALSE, 0, 0 }, { -1, IDC_STATIC_LIST, TRUE, 0, 0 }, { -1, IDC_STATIC_RIGHT, TRUE, 0, 0 } }; _size_move_ctls _move[ ] = { { IDC_STATIC_LIST, IDC_MAIN_TAB, TRUE, 0, 6 }, { IDC_STATIC_LIST, IDT_INFO, FALSE, 0, 3 }, { IDT_INFO, IDC_LINE_BOTTOM, TRUE, 0, 2 } }; { int c_size_hide = _main_headers[1].width; int c_size_show = c_size_hide - GetSystemMetrics(SM_CXVSCROLL); int c_size_curr = ListView_GetColumnWidth( __lists[HMAIN_DRIVES], 1 ); if ( GetWindowLong(__lists[HMAIN_DRIVES], GWL_STYLE) & WS_VSCROLL ) { if ( c_size_curr != c_size_show ) ListView_SetColumnWidth( __lists[HMAIN_DRIVES], 1, c_size_show ); } else { if ( c_size_curr != c_size_hide ) ListView_SetColumnWidth( __lists[HMAIN_DRIVES], 1, c_size_hide ); } } if ( height == 0 || width == 0 ) { return 0L; } for ( k = 0; k < array_num(_resize); k++ ) { _resize_ctl( GetDlgItem(hwnd, _resize[k].id), height - _dlg_height, 0, _resize[k].val ); } _dlg_height = height; for ( k = 0; k < array_num(_move); k++ ) { _relative_move( GetDlgItem( hwnd, _move[k].anchor ), GetDlgItem( hwnd, _move[k].id ), _move[k].dy, _move[k].dy, _move[k].val ); InvalidateRect( GetDlgItem( hwnd, _move[k].id ), NULL, TRUE ); } _middle_ctl( GetDlgItem( hwnd, IDC_DISKDRIVES ), GetDlgItem( hwnd, IDC_RESIZING ), TRUE ); return 0L; } break; case WM_SYSCOMMAND : { if ( wparam == SC_MINIMIZE || wparam == SC_RESTORE ) { _set_timer( MAIN_TIMER, wparam == SC_RESTORE, TRUE ); } return 0L; } break; case WM_APP + WM_APP_SHOW : { ShowWindow( hwnd, SW_HIDE ); } break; case WM_NOTIFY : { if ( wparam == IDT_INFO ) { if ( ((NMHDR *)lparam)->code == TCN_SELCHANGE ) { HWND h_tab = GetDlgItem( hwnd, IDT_INFO ); if ( !_is_curr_in_group(h_tab) ) { _change_page( h_tab, TabCtrl_GetCurSel(h_tab) ); } } } if ( wparam == IDC_DISKDRIVES ) { sel = pv( _get_sel_item( __lists[HMAIN_DRIVES] ) ); mnt = &sel->mnt; if ( ((NMHDR *)lparam)->code == LVN_ITEMCHANGED && (((NMLISTVIEW *)lparam)->uNewState & LVIS_FOCUSED ) ) { _update_info_table( FALSE ); _activate_page( ); _refresh_menu( ); return 1L; } if ( ((NMHDR *)lparam)->code == LVN_ITEMACTIVATE ) { BOOL mount = ( !(sel->mnt.info.status.flags & F_ENABLED) ) && ( sel->mnt.fs[0] == '\0' ); if (! mount ) { if (! sel->is_root ) __execute( mnt->info.status.mnt_point ); } else { _menu_mount( sel ); } } switch( ((NM_LISTVIEW *)lparam)->hdr.code ) { case LVN_KEYDOWN : { WORD key = ((NMLVKEYDOWN *)lparam)->wVKey; int item = ListView_GetSelectionMark( __lists[HMAIN_DRIVES] ); switch ( key ) { case VK_UP: item -= 1; break; case VK_DOWN: item += 1; break; } if ( _is_root_item(_get_item_index( __lists[HMAIN_DRIVES], item )) ) { ListView_SetItemState( __lists[HMAIN_DRIVES], item, LVIS_FOCUSED, TRUE ); } if ( key != VK_APPS ) { break; } } case NM_RCLICK : { int item; HMENU h_popup = CreatePopupMenu( ); _dact *act = _create_act_thread( sel, -1, -1 ); _update_info_table( FALSE ); _activate_page( ); _set_timer(MAIN_TIMER, FALSE, FALSE); _refresh_menu( ); if ( ListView_GetSelectedCount( __lists[HMAIN_DRIVES] ) && !_is_root_item((LPARAM)sel) && _is_active_item((LPARAM)sel) ) { if ( mnt->info.status.flags & F_ENABLED ) { if ( mnt->info.status.flags & F_CDROM ) { AppendMenu( h_popup, MF_STRING, ID_VOLUMES_UNMOUNT, IDS_UNMOUNT ); } else { if ( mnt->info.status.flags & F_FORMATTING ) { AppendMenu( h_popup, MF_STRING, ID_VOLUMES_FORMAT, IDS_FORMAT ); } else { if ( IS_UNMOUNTABLE(&mnt->info.status) ) { AppendMenu( h_popup, MF_STRING, ID_VOLUMES_UNMOUNT, IDS_UNMOUNT ); } if ( !(mnt->info.status.flags & F_SYNC) ) { AppendMenu( h_popup, MF_SEPARATOR, 0, NULL ); AppendMenu( h_popup, MF_STRING, ID_VOLUMES_CHANGEPASS, IDS_CHPASS ); } if ( !(act && act->status == ACT_RUNNING) ) { if ( mnt->info.status.flags & F_SYNC ) { if ( GetMenuItemCount(h_popup) > 0 ) { AppendMenu( h_popup, MF_SEPARATOR, 0, NULL ); } AppendMenu( h_popup, MF_STRING, ID_VOLUMES_ENCRYPT, IDS_ENCRYPT ); } else { if ( GetMenuItemCount(h_popup) > 0 ) { AppendMenu( h_popup, MF_SEPARATOR, 0, NULL ); } AppendMenu( h_popup, MF_STRING, ID_VOLUMES_REENCRYPT, IDS_REENCRYPT ); } AppendMenu( h_popup, MF_STRING, ID_VOLUMES_DECRYPT, IDS_DECRYPT ); } } } } else { if ( mnt->info.status.flags & F_CDROM ) { if ( *mnt->fs == '\0' ) { AppendMenu( h_popup, MF_STRING, ID_VOLUMES_MOUNT, IDS_MOUNT ); } } else { if ( *mnt->fs == '\0' ) { AppendMenu( h_popup, MF_STRING, ID_VOLUMES_MOUNT, IDS_MOUNT ); } else { AppendMenu( h_popup, MF_STRING, ID_VOLUMES_ENCRYPT, IDS_ENCRYPT ); } if ( IS_UNMOUNTABLE(&mnt->info.status) ) { AppendMenu( h_popup, MF_SEPARATOR, 0, NULL ); AppendMenu( h_popup, MF_STRING, ID_VOLUMES_FORMAT, IDS_FORMAT ); } } } } /* _state_menu( popup, sel && sel->status.flags & F_LOCKED ? MF_GRAYED : MF_ENABLED ); */ item = TrackPopupMenu( h_popup, TPM_RETURNCMD | TPM_LEFTBUTTON, LOWORD(GetMessagePos( )), HIWORD(GetMessagePos( )), 0, hwnd, NULL ); DestroyMenu( h_popup ); switch ( item ) { case ID_VOLUMES_DECRYPT : _menu_decrypt(sel); break; case ID_VOLUMES_ENCRYPT : _menu_encrypt(sel); break; case ID_VOLUMES_FORMAT : _menu_format(sel); break; case ID_VOLUMES_REENCRYPT : _menu_reencrypt(sel); break; case ID_VOLUMES_UNMOUNT : _menu_unmount(sel); break; case ID_VOLUMES_MOUNT : _menu_mount(sel); break; case ID_VOLUMES_CHANGEPASS : _menu_change_pass(sel); break; } if ( item ) { _refresh( TRUE ); } _set_timer( MAIN_TIMER, TRUE, TRUE ); } break; case NM_CLICK : { sel = pv( _get_item_index( __lists[HMAIN_DRIVES], ((NM_LISTVIEW *)lparam)->iItem ) ); _update_info_table( FALSE ); _activate_page( ); _refresh_menu( ); } break; } } if ( ((NMHDR *)lparam)->code == HDN_ITEMCHANGED ) { InvalidateRect( __lists[HMAIN_DRIVES], NULL, TRUE ); } if ( ((NMHDR *)lparam)->code == HDN_ITEMCHANGING ) { return 0L; } if ( ((NMHDR *)lparam)->code == HDN_BEGINTRACK ) { return 1L; } } break; case WM_COMMAND: { _dnode *node = pv( _get_sel_item( __lists[HMAIN_DRIVES] ) ); switch (id) { case ID_SHIFT_TAB : case ID_TAB : { HWND h_current = GetFocus( ); HWND h_next = GetNextDlgTabItem( hwnd, h_current, id == ID_SHIFT_TAB ); SetFocus( h_next ); } break; case ID_TOOLS_DRIVER : { if ( __msg_q( __dlg, L"Remove DiskCryptor driver?") ) { int rlt; if ( (rlt = _drv_action(DA_REMOVE, 0)) != ST_OK ) { __error_s( __dlg, L"Error remove DiskCryptor driver", rlt ); } else { return 0L; } } } break; case ID_TOOLS_BENCHMARK : _dlg_benchmark( __dlg ); break; case ID_HELP_ABOUT : _dlg_about( __dlg ); break; case ID_HOMEPAGE : __execute( DC_HOMEPAGE ); break; case ID_EXIT : { SendMessage( hwnd, WM_CLOSE, 0, 1 ); } break; case IDC_BTN_WIZARD : _menu_wizard(node); break; case ID_VOLUMES_DELETE_MNTPOINT : { wchar_t *mnt_point = node->mnt.info.status.mnt_point; if ( __msg_q( __dlg, L"Are you sure you want to delete mount point [%s]?", mnt_point ) ) { _set_trailing_slash(mnt_point); DeleteVolumeMountPoint(mnt_point); } } break; case IDC_BTN_DECRYPT_ : case ID_VOLUMES_DECRYPT : _menu_decrypt( node ); break; case IDC_BTN_ENCRYPT_ : case ID_VOLUMES_ENCRYPT : _menu_encrypt( node ); break; case ID_VOLUMES_MOUNTALL : case IDC_BTN_MOUNTALL_ : _menu_mountall( ); break; case ID_VOLUMES_DISMOUNTALL : case IDC_BTN_UNMOUNTALL_ : _menu_unmountall( ); break; case ID_VOLUMES_DISMOUNT : _menu_unmount( node ); break; case ID_VOLUMES_MOUNT : _menu_mount( node ); break; case ID_VOLUMES_FORMAT : _menu_format(node); break; case ID_VOLUMES_REENCRYPT : _menu_reencrypt( node ); break; case ID_TOOLS_SETTINGS : _dlg_options( __dlg ); break; case ID_BOOT_OPTIONS : _dlg_config_loader( __dlg, FALSE ); break; case ID_VOLUMES_CHANGEPASS : _menu_change_pass( node ); break; case ID_TOOLS_CLEARCACHE : _menu_clear_cache( ); break; case ID_VOLUMES_BACKUPHEADER : _menu_backup_header( node ); break; case ID_VOLUMES_RESTOREHEADER : _menu_restore_header( node ); break; case ID_TOOLS_ENCRYPT_CD: _menu_encrypt_cd( ); break; } switch ( id ) { case IDC_BTN_MOUNT_: { node->mnt.info.status.flags & F_ENABLED ? _menu_unmount(node) : _menu_mount(node); } break; case ID_TOOLS_BSOD : { if ( __msg_q( __dlg, L"Crash?" ) ) { dc_get_bsod( ); } } break; } if ( id == IDCANCEL ) { ShowWindow(hwnd, SW_HIDE); } _refresh(TRUE); } break; case WM_CLOSE : { if ( lparam ) { _tray_icon(FALSE); EndDialog(hwnd, 0); ExitProcess(0); } else { ShowWindow(hwnd, SW_HIDE); } return 0L; } break; case WM_DESTROY : { PostQuitMessage(0); return 0L; } break; case WM_HOTKEY : { switch (wparam) { case 0 : { int mount_cnt; dc_mount_all(NULL, &mount_cnt, 0); } break; case 1 : dc_unmount_all( ); break; case 2 : dc_clean_pass_cache( ); break; case 3 : dc_get_bsod( ); break; } return 1L; } break; case WM_ENDSESSION : { if ( lparam & ENDSESSION_LOGOFF ) { if ( __config.conf_flags & CONF_DISMOUNT_LOGOFF ) { dc_unmount_all( ); } if ( __config.conf_flags & CONF_WIPEPAS_LOGOFF ) { dc_clean_pass_cache( ); } } } break; case WM_SYSCOLORCHANGE : { COLORREF cl_light = _cl( COLOR_BTNFACE, LGHT_CLR ); COLORREF cl_button = GetSysColor( COLOR_BTNFACE ); int k; for ( k = 0; k < array_num(__lists); k++ ) { if ( ( __lists[k] != HWND_NULL ) && ( __lists[k] != NULL ) ) { ListView_SetBkColor( __lists[k], cl_button ); ListView_SetTextBkColor( __lists[k], cl_button ); ListView_SetExtendedListViewStyle( __lists[k], LVS_EX_FULLROWSELECT ); if ( !IsWindowEnabled( __lists[k] ) ) { // EnableWindow( __lists[k], TRUE ); // EnableWindow( __lists[k], FALSE ); } } } TreeView_SetBkColor( GetDlgItem(hwnd, IDC_TREE), cl_light ); ListView_SetBkColor( __lists[HMAIN_DRIVES], cl_light ); ListView_SetTextBkColor( __lists[HMAIN_DRIVES], cl_light ); ListView_SetExtendedListViewStyle( __lists[HMAIN_DRIVES], LVS_EX_FULLROWSELECT ); ListView_SetImageList( __lists[HMAIN_DRIVES], __dsk_img, LVSIL_SMALL ); } break; case WM_APP + WM_APP_TRAY : { switch ( lparam ) { case WM_LBUTTONDOWN : { BOOL show = !IsWindowVisible(hwnd); ShowWindow(hwnd, show ? SW_SHOW : SW_HIDE); if ( show ) { SetForegroundWindow(hwnd); } } break; case WM_RBUTTONDOWN : { POINT pt; int item; HMENU menu = CreatePopupMenu( ); AppendMenu( menu, MF_STRING, ID_VOLUMES_UNMOUNTALL, IDS_UNMOUNTALL ); AppendMenu( menu, MF_STRING, ID_VOLUMES_MOUNTALL, IDS_MOUNTALL ); AppendMenu( menu, MF_SEPARATOR, 0, NULL ); AppendMenu( menu, MF_STRING, ID_TOOLS_SETTINGS, IDS_SETTINGS ); AppendMenu( menu, MF_STRING, ID_HELP_ABOUT, IDS_ABOUT ); AppendMenu( menu, MF_SEPARATOR, 0, NULL ); AppendMenu( menu, MF_STRING, ID_EXIT, IDS_EXIT ); GetCursorPos(&pt); SetForegroundWindow( hwnd ); item = TrackPopupMenu ( menu, TPM_RETURNCMD | TPM_LEFTALIGN | TPM_BOTTOMALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, 0, hwnd, NULL ); DestroyMenu( menu ); switch (item) { case ID_VOLUMES_UNMOUNTALL : _menu_unmountall( ); break; case ID_VOLUMES_MOUNTALL : _menu_mountall( ); break; case ID_HELP_ABOUT : _dlg_about( HWND_DESKTOP ); break; case ID_TOOLS_SETTINGS : _dlg_options( __dlg ); break; case ID_EXIT : { SendMessage(hwnd, WM_CLOSE, 0, 1); } break; } } break; } } break; default: { int rlt = _draw_proc( message, lparam ); if (rlt != -1) { return rlt; } } } return 0L; }
static void menu_0_3(ldr_config *conf) { wchar_t *methd = NULL; wchar_t part[MAX_PATH]; wchar_t s_size[MAX_PATH]; u32 i, found, id; char ch; vol_inf *vol; do { cls_console(); switch (conf->boot_type) { case BT_MBR_BOOT: methd = L"load boot disk MBR"; break; case BT_MBR_FIRST: methd = L"load first disk MBR"; break; case BT_ACTIVE: methd = L"load OS from active partition"; break; case BT_AP_PASSWORD: methd = L"boot from first partition with appropriate password"; break; case BT_DISK_ID: { /* find partition by disk_id */ found = 0; for (i = 0; i < vol_cnt; i++) { vol = &volumes[i]; if ( (vol->status.flags & F_ENABLED) && (vol->status.disk_id == conf->disk_id) ) { dc_format_byte_size( s_size, sizeof_w(s_size), vol->status.dsk_size); _snwprintf( part, sizeof_w(part), L"boot from pt%d (%s) (%s)", i, vol->status.mnt_point, s_size); found = 1; } } if (found == 0) { _snwprintf( part, sizeof_w(part), L"boot from unknown partition, id %0.8x", conf->disk_id); } methd = part; } break; } if (conf->options & OP_EXTERNAL) { wprintf( L"Current booting method: %s\n\n" L"1 - Set \"load first disk MBR\"\n" L"2 - Set \"boot from first partition with appropriate password\"\n" L"3 - Set \"boot from specified partition\"\n" L"4 - Return to main menu\n\n", methd); } else { wprintf( L"Current booting method: %s\n\n" L"1 - Set \"load boot disk MBR\"\n" L"2 - Set \"load first disk MBR\"\n" L"3 - Set \"load OS from active partition\"\n" L"4 - Set \"boot from first partition with appropriate password\"\n" L"5 - Set \"boot from specified partition\"\n" L"6 - Return to main menu\n\n", methd); } if (conf->options & OP_EXTERNAL) { if ( (ch = getchr('1', '4')) == '4' ) { break; } switch (ch) { case '1': conf->boot_type = BT_MBR_FIRST; break; case '2': conf->boot_type = BT_AP_PASSWORD; break; case '3': { if ( (id = disk_id_select()) != 0 ) { conf->disk_id = id; conf->boot_type = BT_DISK_ID; } } break; } } else { if ( (ch = getchr('1', '6')) == '6' ) { break; } switch (ch) { case '1': conf->boot_type = BT_MBR_BOOT; break; case '2': conf->boot_type = BT_MBR_FIRST; break; case '3': conf->boot_type = BT_ACTIVE; break; case '4': conf->boot_type = BT_AP_PASSWORD; break; case '5': { if ( (id = disk_id_select()) != 0 ) { conf->disk_id = id; conf->boot_type = BT_DISK_ID; } } break; } } } while (1); }
static void menu_0_1(ldr_config *conf) { wchar_t auth[MAX_PATH]; wchar_t *dp_type; char ch; do { cls_console(); if (conf->options & OP_EPS_TMO) { _snwprintf( auth, sizeof_w(auth), L"%d seconds", conf->timeout); } else { wcscpy(auth, L"disabled"); } if (conf->logon_type & LT_DSP_PASS) { dp_type = L"display \"*\""; } else { dp_type = L"disabled"; } wprintf( L"1 - On/Off \"enter password\" message (%s)\n" L"2 - Change display password type (%s)\n" L"3 - Change password prompt text (%S)\n" L"4 - Enable embedded keyfile (%s)\n" L"5 - Change authentication timeout (%s)\n" L"6 - Cancel timeout if any key pressed (%s)\n" L"7 - Return to main menu\n\n", on_off(conf->logon_type & LT_MESSAGE), dp_type, conf->eps_msg, conf->logon_type & LT_EMBED_KEY ? L"enabled":L"disabled", auth, on_off(conf->options & OP_TMO_STOP)); if ( (ch = getchr('1', '7')) == '7' ) { break; } if (ch == '1') { set_flag( conf->logon_type, LT_MESSAGE, onoff_req()); } if (ch == '2') { wprintf( L"1 - disabled\n" L"2 - display \"*\"\n"); if (getchr('1', '2') == '2') { conf->logon_type |= LT_DSP_PASS; } else { conf->logon_type &= ~LT_DSP_PASS; } } if (ch == '3') { wprintf(L"Enter new prompt text: "); s_gets(conf->eps_msg, sizeof(conf->eps_msg)); } if (ch == '4') { wchar_t path[MAX_PATH]; u8 *keyfile; u32 keysize; wprintf(L"Please enter path to keyfile: "); zeroauto(&conf->emb_key, sizeof(conf->emb_key)); conf->logon_type &= ~LT_EMBED_KEY; conf->logon_type |= LT_GET_PASS; if (s_wgets(path, sizeof(path)) != 0) { if (load_file(path, &keyfile, &keysize) != ST_OK) { wprintf(L"keyfile not loaded\n"); Sleep(1000); } else { if (keysize != 64) { wprintf(L"Embedded keyfile must be 64byte size\n"); Sleep(1000); } else { wprintf( L"1 - Use embedded keyfile and password\n" L"2 - Use only embedded keyfile\n"); if (getchr('1', '2') == '2') { conf->logon_type &= ~LT_GET_PASS; } autocpy(&conf->emb_key, keyfile, sizeof(conf->emb_key)); conf->logon_type |= LT_EMBED_KEY; } zeromem(keyfile, keysize); free(keyfile); } } } if (ch == '5') { wprintf(L"Enter new timeout in seconds or 0 to disable: "); if (wscanf(L"%d", &conf->timeout) == 0) { conf->timeout = 0; } set_flag( conf->options, OP_EPS_TMO, (conf->timeout != 0)); } if (ch == '6') { set_flag( conf->options, OP_TMO_STOP, onoff_req()); } } while (1); }
int boot_menu(int argc, wchar_t *argv[]) { ldr_config conf; int resl; int is_small; is_small = is_param(L"-small"); do { if ( (argc == 3) && (wcscmp(argv[2], L"-enum") == 0) ) { wchar_t s_size[MAX_PATH]; wchar_t h_name[MAX_PATH]; wchar_t *str; u64 size; int i, bd_1, bd_2; wprintf( L"--------------------------------------------------------------\n" L"HDD | name | size | bootable | bootloader\n" L"----+--------------------------+---------+----------+-----------\n"); if (dc_get_boot_disk(&bd_1, &bd_2) != ST_OK) { bd_1 = bd_2 = -1; } for (i = 0; i < 100; i++) { if (size = dc_dsk_get_size(i, 0)) { dc_format_byte_size(s_size, sizeof_w(s_size), size); if (dc_get_hw_name(i, 0, h_name, sizeof_w(h_name)) != ST_OK) { h_name[0] = 0; } if (dc_get_mbr_config(i, NULL, &conf) == ST_OK) { str = L"installed"; } else { str = L"none"; } wprintf( L"hd%d | %-24s | %-8s| %-8s | %s\n", i, h_name, s_size, (i == bd_1) || (i == bd_2) ? L"yes":L"no", str ); } } resl = ST_OK; break; } if ( (argc >= 4) && (wcscmp(argv[2], L"-setmbr") == 0) ) { int d_num; if (dsk_num(argv[3], &d_num) == 0) { resl = ST_OK; break; } if ( (resl = dc_set_boot_interactive(d_num, is_small)) == ST_OK) { wprintf(L"Bootloader successfully installed to %s\n", argv[3]); } break; } if ( (argc == 4) && (wcscmp(argv[2], L"-delmbr") == 0) ) { int d_num; if (dsk_num(argv[3], &d_num) == 0) { resl = ST_OK; break; } if ( (resl = dc_unset_mbr(d_num)) == ST_OK ) { wprintf(L"Bootloader successfully removed from %s\n", argv[3]); } break; } if ( (argc == 4) && (wcscmp(argv[2], L"-updmbr") == 0) ) { int d_num; if (dsk_num(argv[3], &d_num) == 0) { resl = ST_OK; break; } if ( (resl = dc_update_boot(d_num)) == ST_OK ) { wprintf(L"Bootloader on %s successfully updated\n", argv[3]); } break; } if ( (argc >= 4) && (wcscmp(argv[2], L"-setpar") == 0) ) { if ( (resl = dc_set_boot(argv[3], 0, is_small)) == ST_FORMAT_NEEDED ) { wprintf( L"Removable media not correctly formatted\n" L"Format media? (Y/N)\n" ); if (tolower(_getch()) == 'y') { resl = dc_set_boot(argv[3], 1, is_small); } else { resl = ST_OK; break; } } if (resl != ST_OK) { break; } if ( (resl = dc_mbr_config_by_partition(argv[3], 0, &conf)) != ST_OK ) { break; } conf.options |= OP_EXTERNAL; conf.boot_type = BT_AP_PASSWORD; boot_conf_menu( &conf, L"Please set bootloader options:"); if ( (resl = dc_mbr_config_by_partition(argv[3], 1, &conf)) == ST_OK ) { wprintf(L"Bootloader successfully installed\n"); } break; } if ( (argc >= 4) && (wcscmp(argv[2], L"-makeiso") == 0) ) { if ( (resl = dc_make_iso(argv[3], is_small)) != ST_OK ) { break; } if ( (resl = dc_get_mbr_config(0, argv[3], &conf)) != ST_OK ) { break; } conf.options |= OP_EXTERNAL; conf.boot_type = BT_MBR_FIRST; boot_conf_menu( &conf, L"Please set bootloader options:"); if ( (resl = dc_set_mbr_config(0, argv[3], &conf)) == ST_OK ) { wprintf(L"Bootloader .iso image successfully created\n", argv[3]); } break; } if ( (argc >= 4) && (wcscmp(argv[2], L"-makepxe") == 0) ) { if ( (resl = dc_make_pxe(argv[3], is_small)) != ST_OK ) { break; } if ( (resl = dc_get_mbr_config(0, argv[3], &conf)) != ST_OK ) { break; } conf.options |= OP_EXTERNAL; conf.boot_type = BT_MBR_FIRST; boot_conf_menu( &conf, L"Please set bootloader options:"); if ( (resl = dc_set_mbr_config(0, argv[3], &conf)) == ST_OK ) { wprintf(L"Bootloader PXE image successfully created\n", argv[3]); } break; } if ( (argc == 4) && (wcscmp(argv[2], L"-config") == 0) ) { int d_num; wchar_t *file; int ispar; if ( ((argv[3][1] == L':') && (argv[3][2] == 0)) || ((argv[3][0] == L'\\') && (argv[3][5] == L':')) ) { ispar = 1; } else { if (dsk_num(argv[3], &d_num) == 0) { file = argv[3]; d_num = 0; } else { file = NULL; } ispar = 0; } if (ispar != 0) { resl = dc_mbr_config_by_partition(argv[3], 0, &conf); } else { resl = dc_get_mbr_config(d_num, file, &conf); } if (resl != ST_OK) { break; } boot_conf_menu( &conf, L"Please change bootloader options:"); if (ispar != 0) { resl = dc_mbr_config_by_partition(argv[3], 1, &conf); } else { resl = dc_set_mbr_config(d_num, file, &conf); } if (resl == ST_OK) { wprintf(L"Bootloader configuration successfully changed\n"); } break; } } while (0); return resl; }