ReactOS 0.4.15-dev-7918-g2a2556c
volpropsheet.cpp File Reference
#include "shellext.h"
#include <windows.h>
#include <strsafe.h>
#include <winternl.h>
#include <shlwapi.h>
#include <uxtheme.h>
#include "volpropsheet.h"
#include "resource.h"
#include "mountmgr.h"
Include dependency graph for volpropsheet.cpp:

Go to the source code of this file.

Classes

struct  dev
 

Macros

#define ISOLATION_AWARE_ENABLED   1
 
#define STRSAFE_NO_DEPRECATE
 
#define NO_SHLWAPI_STRFCNS
 

Functions

static INT_PTR CALLBACK stub_UsageDlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static void add_lv_column (HWND list, int string, int cx)
 
static int CALLBACK lv_sort (LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
 
static uint64_t find_dev_alloc (uint64_t dev_id, btrfs_usage *usage)
 
static INT_PTR CALLBACK stub_StatsDlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static INT_PTR CALLBACK stub_DeviceDlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static INT_PTR CALLBACK PropSheetDlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static INT_PTR __stdcall dlg_proc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
void CALLBACK ResetStatsW (HWND hwnd, HINSTANCE hinst, LPWSTR lpszCmdLine, int nCmdShow)
 
void CALLBACK ShowChangeDriveLetterW (HWND hwnd, HINSTANCE hinst, LPWSTR lpszCmdLine, int nCmdShow)
 

Variables

static const NTSTATUS STATUS_OBJECT_NAME_NOT_FOUND = 0xC0000034
 

Macro Definition Documentation

◆ ISOLATION_AWARE_ENABLED

#define ISOLATION_AWARE_ENABLED   1

Definition at line 18 of file volpropsheet.cpp.

◆ NO_SHLWAPI_STRFCNS

#define NO_SHLWAPI_STRFCNS

Definition at line 35 of file volpropsheet.cpp.

◆ STRSAFE_NO_DEPRECATE

#define STRSAFE_NO_DEPRECATE

Definition at line 19 of file volpropsheet.cpp.

Function Documentation

◆ add_lv_column()

static void add_lv_column ( HWND  list,
int  string,
int  cx 
)
static

Definition at line 586 of file volpropsheet.cpp.

586 {
587 LVCOLUMNW lvc;
588 wstring s;
589
590 if (!load_string(module, string, s))
591 throw last_error(GetLastError());
592
594 lvc.pszText = (WCHAR*)s.c_str();
595 lvc.cx = cx;
597}
Definition: list.h:37
GLdouble s
Definition: gl.h:2039
static int load_string(HINSTANCE hModule, UINT resId, LPWSTR pwszBuffer, INT cMaxChars)
Definition: muireg.c:10
#define LVCF_WIDTH
Definition: commctrl.h:2587
_Out_opt_ int * cx
Definition: commctrl.h:585
#define LVM_INSERTCOLUMNW
Definition: commctrl.h:2632
#define LVCF_TEXT
Definition: commctrl.h:2588
LPWSTR pszText
Definition: commctrl.h:2567
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
LONG_PTR LPARAM
Definition: windef.h:208
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by BtrfsVolPropSheet::DeviceDlgProc().

◆ dlg_proc()

static INT_PTR __stdcall dlg_proc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 1593 of file volpropsheet.cpp.

1593 {
1595
1596 if (uMsg == WM_INITDIALOG) {
1599 } else
1601
1602 return bcdl->DlgProc(hwndDlg, uMsg, wParam, lParam);
1603}
INT_PTR DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define GWLP_USERDATA
Definition: treelist.c:63
#define GetWindowLongPtrW
Definition: winuser.h:4829
#define WM_INITDIALOG
Definition: winuser.h:1739
#define SetWindowLongPtrW
Definition: winuser.h:5346

Referenced by BtrfsChangeDriveLetter::show().

◆ find_dev_alloc()

static uint64_t find_dev_alloc ( uint64_t  dev_id,
btrfs_usage usage 
)
static

Definition at line 608 of file volpropsheet.cpp.

608 {
609 btrfs_usage* bue;
611
612 alloc = 0;
613
614 bue = usage;
615 while (true) {
616 uint64_t k;
617
618 for (k = 0; k < bue->num_devices; k++) {
619 if (bue->devices[k].dev_id == dev_id)
620 alloc += bue->devices[k].alloc;
621 }
622
623 if (bue->next_entry > 0)
624 bue = (btrfs_usage*)((uint8_t*)bue + bue->next_entry);
625 else
626 break;
627 }
628
629 return alloc;
630}
UINT64 uint64_t
Definition: types.h:77
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
int k
Definition: mpi.c:3369
BYTE uint8_t
Definition: msvideo1.c:66
#define alloc
Definition: rosglue.h:13
uint32_t next_entry
Definition: btrfsioctl.h:122
btrfs_usage_device devices[1]
Definition: btrfsioctl.h:127
uint64_t num_devices
Definition: btrfsioctl.h:126

Referenced by BtrfsVolPropSheet::RefreshDevList().

◆ lv_sort()

static int CALLBACK lv_sort ( LPARAM  lParam1,
LPARAM  lParam2,
LPARAM  lParamSort 
)
static

Definition at line 599 of file volpropsheet.cpp.

599 {
600 if (lParam1 < lParam2)
601 return -1;
602 else if (lParam1 > lParam2)
603 return 1;
604 else
605 return 0;
606}

Referenced by BtrfsVolPropSheet::RefreshDevList().

◆ PropSheetDlgProc()

static INT_PTR CALLBACK PropSheetDlgProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 1329 of file volpropsheet.cpp.

1329 {
1330 try {
1331 switch (uMsg) {
1332 case WM_INITDIALOG:
1333 {
1336 btrfs_device* bd;
1337
1339
1341
1342 bps->readonly = true;
1343 bd = bps->devices;
1344
1345 while (true) {
1346 if (!bd->readonly) {
1347 bps->readonly = false;
1348 break;
1349 }
1350
1351 if (bd->next_entry > 0)
1352 bd = (btrfs_device*)((uint8_t*)bd + bd->next_entry);
1353 else
1354 break;
1355 }
1356
1357 if (bps->uuid_set) {
1358 WCHAR s[255];
1359 wstring t;
1360
1361 GetDlgItemTextW(hwndDlg, IDC_UUID, s, sizeof(s) / sizeof(WCHAR));
1362
1363 wstring_sprintf(t, s, bps->uuid.uuid[0], bps->uuid.uuid[1], bps->uuid.uuid[2], bps->uuid.uuid[3], bps->uuid.uuid[4], bps->uuid.uuid[5],
1364 bps->uuid.uuid[6], bps->uuid.uuid[7], bps->uuid.uuid[8], bps->uuid.uuid[9], bps->uuid.uuid[10], bps->uuid.uuid[11],
1365 bps->uuid.uuid[12], bps->uuid.uuid[13], bps->uuid.uuid[14], bps->uuid.uuid[15]);
1366
1367 SetDlgItemTextW(hwndDlg, IDC_UUID, t.c_str());
1368 } else
1369 SetDlgItemTextW(hwndDlg, IDC_UUID, L"");
1370
1373
1374 return false;
1375 }
1376
1377 case WM_NOTIFY:
1378 {
1379 switch (((LPNMHDR)lParam)->code) {
1380 case PSN_KILLACTIVE:
1381 SetWindowLongPtrW(hwndDlg, DWLP_MSGRESULT, false);
1382 break;
1383 }
1384 break;
1385 }
1386
1387 case WM_COMMAND:
1388 {
1390
1391 if (bps) {
1392 switch (HIWORD(wParam)) {
1393 case BN_CLICKED: {
1394 switch (LOWORD(wParam)) {
1395 case IDC_VOL_SHOW_USAGE:
1396 bps->ShowUsage(hwndDlg);
1397 break;
1398
1399 case IDC_VOL_BALANCE:
1400 bps->balance->ShowBalance(hwndDlg);
1401 break;
1402
1403 case IDC_VOL_DEVICES:
1404 bps->ShowDevices(hwndDlg);
1405 break;
1406
1407 case IDC_VOL_SCRUB:
1408 bps->ShowScrub(hwndDlg);
1409 break;
1410
1412 bps->ShowChangeDriveLetter(hwndDlg);
1413 break;
1414 }
1415 }
1416 }
1417 }
1418
1419 break;
1420 }
1421 }
1422 } catch (const exception& e) {
1423 error_message(hwndDlg, e.what());
1424 }
1425
1426 return false;
1427}
void ShowBalance(HWND hwndDlg)
Definition: balance.cpp:981
void ShowScrub(HWND hwndDlg)
void ShowDevices(HWND hwndDlg)
BtrfsBalance * balance
Definition: volpropsheet.h:102
void ShowUsage(HWND hwndDlg)
btrfs_device * devices
Definition: volpropsheet.h:100
void ShowChangeDriveLetter(HWND hwndDlg)
void error_message(HWND hwnd, const char *msg)
Definition: main.cpp:783
void wstring_sprintf(wstring &s, wstring fmt,...)
Definition: main.cpp:225
#define IDC_VOL_BALANCE
Definition: resource.h:238
#define IDC_VOL_SCRUB
Definition: resource.h:248
#define IDC_VOL_DEVICES
Definition: resource.h:245
#define IDC_UUID
Definition: resource.h:306
#define IDC_VOL_CHANGE_DRIVE_LETTER
Definition: resource.h:337
#define IDC_VOL_SHOW_USAGE
Definition: resource.h:237
#define ETDT_ENABLETAB
Definition: dxdiag.c:30
GLdouble GLdouble t
Definition: gl.h:2047
#define e
Definition: ke_i.h:82
#define L(x)
Definition: ntvdm.h:50
#define LOWORD(l)
Definition: pedump.c:82
#define PSN_KILLACTIVE
Definition: prsht.h:116
#define BCM_SETSHIELD
Definition: commctrl.h:4653
#define WM_NOTIFY
Definition: richedit.h:61
uint8_t uuid[16]
Definition: btrfs.h:140
LPARAM lParam
Definition: prsht.h:227
Definition: inflate.c:139
#define HIWORD(l)
Definition: typedefs.h:247
HRESULT WINAPI EnableThemeDialogTexture(_In_ HWND hwnd, _In_ DWORD dwFlags)
Definition: uxthemesupp.c:55
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2263
#define WM_COMMAND
Definition: winuser.h:1740
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define DWLP_MSGRESULT
Definition: winuser.h:870
#define BN_CLICKED
Definition: winuser.h:1925

◆ ResetStatsW()

void CALLBACK ResetStatsW ( HWND  hwnd,
HINSTANCE  hinst,
LPWSTR  lpszCmdLine,
int  nCmdShow 
)

Definition at line 1613 of file volpropsheet.cpp.

1613 {
1614 try {
1618 LUID luid;
1619 uint64_t devid;
1620 wstring cmdline, vol, dev;
1621 size_t pipe;
1623
1624 set_dpi_aware();
1625
1626 cmdline = lpszCmdLine;
1627
1629 throw last_error(GetLastError());
1630
1631 if (!LookupPrivilegeValueW(nullptr, L"SeManageVolumePrivilege", &luid))
1632 throw last_error(GetLastError());
1633
1634 tp.PrivilegeCount = 1;
1635 tp.Privileges[0].Luid = luid;
1636 tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
1637
1638 if (!AdjustTokenPrivileges(token, false, &tp, sizeof(TOKEN_PRIVILEGES), nullptr, nullptr))
1639 throw last_error(GetLastError());
1640
1641 pipe = cmdline.find(L"|");
1642
1643 if (pipe == string::npos)
1644 return;
1645
1646 vol = cmdline.substr(0, pipe);
1647 dev = cmdline.substr(pipe + 1);
1648
1649 devid = _wtoi(dev.c_str());
1650 if (devid == 0)
1651 return;
1652
1655
1656 if (h == INVALID_HANDLE_VALUE)
1657 throw last_error(GetLastError());
1658
1659 Status = NtFsControlFile(h, nullptr, nullptr, nullptr, &iosb, FSCTL_BTRFS_RESET_STATS, &devid, sizeof(uint64_t), nullptr, 0);
1660 if (!NT_SUCCESS(Status))
1661 throw ntstatus_error(Status);
1662 } catch (const exception& e) {
1663 error_message(hwnd, e.what());
1664 }
1665}
LONG NTSTATUS
Definition: precomp.h:26
#define FSCTL_BTRFS_RESET_STATS
Definition: btrfsioctl.h:29
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
void set_dpi_aware()
Definition: main.cpp:50
BOOL WINAPI LookupPrivilegeValueW(LPCWSTR lpSystemName, LPCWSTR lpPrivilegeName, PLUID lpLuid)
Definition: misc.c:782
BOOL WINAPI AdjustTokenPrivileges(HANDLE TokenHandle, BOOL DisableAllPrivileges, PTOKEN_PRIVILEGES NewState, DWORD BufferLength, PTOKEN_PRIVILEGES PreviousState, PDWORD ReturnLength)
Definition: security.c:374
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:294
#define OPEN_EXISTING
Definition: compat.h:775
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GetCurrentProcess()
Definition: compat.h:759
#define CreateFileW
Definition: compat.h:741
#define FILE_SHARE_READ
Definition: compat.h:136
_In_ uint64_t _In_ uint64_t _In_ uint64_t _In_opt_ traverse_ptr * tp
Definition: btrfs.c:2996
Status
Definition: gdiplustypes.h:25
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat token
Definition: glfuncs.h:210
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
#define FILE_FLAG_OPEN_REPARSE_POINT
Definition: disk.h:39
#define FILE_FLAG_BACKUP_SEMANTICS
Definition: disk.h:41
static PIO_STATUS_BLOCK iosb
Definition: file.c:98
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_READ_ATTRIBUTES
Definition: nt_native.h:647
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
#define FILE_TRAVERSE
Definition: nt_native.h:643
NTSYSAPI NTSTATUS NTAPI NtFsControlFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG DeviceIoControlCode, IN PVOID InBuffer OPTIONAL, IN ULONG InBufferLength, OUT PVOID OutBuffer OPTIONAL, IN ULONG OutBufferLength)
TCHAR * cmdline
Definition: stretchblt.cpp:32
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define TOKEN_ADJUST_PRIVILEGES
Definition: setypes.h:930
#define TOKEN_QUERY
Definition: setypes.h:928
#define SE_PRIVILEGE_ENABLED
Definition: setypes.h:63

◆ ShowChangeDriveLetterW()

void CALLBACK ShowChangeDriveLetterW ( HWND  hwnd,
HINSTANCE  hinst,
LPWSTR  lpszCmdLine,
int  nCmdShow 
)

Definition at line 1667 of file volpropsheet.cpp.

1667 {
1668 BtrfsChangeDriveLetter bcdl(hwnd, lpszCmdLine);
1669
1670 bcdl.show();
1671}

◆ stub_DeviceDlgProc()

static INT_PTR CALLBACK stub_DeviceDlgProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 1249 of file volpropsheet.cpp.

1249 {
1250 BtrfsVolPropSheet* bvps;
1251
1252 if (uMsg == WM_INITDIALOG) {
1254 bvps = (BtrfsVolPropSheet*)lParam;
1255 } else {
1257 }
1258
1259 if (bvps)
1260 return bvps->DeviceDlgProc(hwndDlg, uMsg, wParam, lParam);
1261 else
1262 return false;
1263}
INT_PTR CALLBACK DeviceDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)

Referenced by BtrfsVolPropSheet::ShowDevices().

◆ stub_StatsDlgProc()

static INT_PTR CALLBACK stub_StatsDlgProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 942 of file volpropsheet.cpp.

942 {
943 BtrfsVolPropSheet* bvps;
944
945 if (uMsg == WM_INITDIALOG) {
947 bvps = (BtrfsVolPropSheet*)lParam;
948 } else {
950 }
951
952 if (bvps)
953 return bvps->StatsDlgProc(hwndDlg, uMsg, wParam, lParam);
954 else
955 return false;
956}
INT_PTR CALLBACK StatsDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)

Referenced by BtrfsVolPropSheet::ShowStats().

◆ stub_UsageDlgProc()

static INT_PTR CALLBACK stub_UsageDlgProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 566 of file volpropsheet.cpp.

566 {
567 BtrfsVolPropSheet* bvps;
568
569 if (uMsg == WM_INITDIALOG) {
571 bvps = (BtrfsVolPropSheet*)lParam;
572 } else {
574 }
575
576 if (bvps)
577 return bvps->UsageDlgProc(hwndDlg, uMsg, wParam, lParam);
578 else
579 return false;
580}
INT_PTR CALLBACK UsageDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)

Referenced by BtrfsVolPropSheet::ShowUsage().

Variable Documentation

◆ STATUS_OBJECT_NAME_NOT_FOUND

const NTSTATUS STATUS_OBJECT_NAME_NOT_FOUND = 0xC0000034
static

Definition at line 48 of file volpropsheet.cpp.