ReactOS 0.4.15-dev-7788-g1ad9096
devices.cpp
Go to the documentation of this file.
1/* Copyright (c) Mark Harmstone 2016-17
2 *
3 * This file is part of WinBtrfs.
4 *
5 * WinBtrfs is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public Licence as published by
7 * the Free Software Foundation, either version 3 of the Licence, or
8 * (at your option) any later version.
9 *
10 * WinBtrfs is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public Licence for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public Licence
16 * along with WinBtrfs. If not, see <http://www.gnu.org/licenses/>. */
17
18#define ISOLATION_AWARE_ENABLED 1
19#define STRSAFE_NO_DEPRECATE
20
21#include "shellext.h"
22#include "devices.h"
23#include "resource.h"
24#include "balance.h"
25#include <stddef.h>
26#include <uxtheme.h>
27#include <setupapi.h>
28#include <strsafe.h>
29#include <mountmgr.h>
30#ifndef __REACTOS__
31#include <algorithm>
32#include "../btrfs.h"
33#include "mountmgr.h"
34#else
35#include <ntddstor.h>
36#include <ndk/rtlfuncs.h>
37#include <ndk/obfuncs.h>
38#include "btrfs.h"
39#include "mountmgr_local.h"
40#endif
41
42DEFINE_GUID(GUID_DEVINTERFACE_HIDDEN_VOLUME, 0x7f108a28L, 0x9833, 0x4b3b, 0xb7, 0x80, 0x2c, 0x6b, 0x5f, 0xa5, 0xc0, 0x62);
43
44static wstring get_mountdev_name(const nt_handle& h ) {
47 MOUNTDEV_NAME mdn, *mdn2;
48 wstring name;
49
51 nullptr, 0, &mdn, sizeof(MOUNTDEV_NAME));
53 return L"";
54
55 size_t mdnsize = offsetof(MOUNTDEV_NAME, Name[0]) + mdn.NameLength;
56
57 mdn2 = (MOUNTDEV_NAME*)malloc(mdnsize);
58
60 nullptr, 0, mdn2, (ULONG)mdnsize);
61 if (!NT_SUCCESS(Status)) {
62 free(mdn2);
63 return L"";
64 }
65
66 name = wstring(mdn2->Name, mdn2->NameLength / sizeof(WCHAR));
67
68 free(mdn2);
69
70 return name;
71}
72
73static void find_devices(HWND hwnd, const GUID* guid, const mountmgr& mm, vector<device>& device_list) {
74 HDEVINFO h;
75
76 static const wstring dosdevices = L"\\DosDevices\\";
77
79
80 if (h != INVALID_HANDLE_VALUE) {
81 DWORD index = 0;
83
84 did.cbSize = sizeof(did);
85
86 if (!SetupDiEnumDeviceInterfaces(h, nullptr, guid, index, &did))
87 return;
88
89 do {
92 DWORD size;
93
94 dd.cbSize = sizeof(dd);
95
96 SetupDiGetDeviceInterfaceDetailW(h, &did, nullptr, 0, &size, nullptr);
97
99 memset(detail, 0, size);
100
102
103 if (SetupDiGetDeviceInterfaceDetailW(h, &did, detail, size, &size, &dd)) {
106 device dev;
112 ULONG i;
113 uint8_t sb[4096];
114
115 path.Buffer = detail->DevicePath;
116 path.Length = path.MaximumLength = (uint16_t)(wcslen(detail->DevicePath) * sizeof(WCHAR));
117
118 if (path.Length > 4 * sizeof(WCHAR) && path.Buffer[0] == '\\' && path.Buffer[1] == '\\' && path.Buffer[2] == '?' && path.Buffer[3] == '\\')
119 path.Buffer[1] = '?';
120
121 InitializeObjectAttributes(&attr, &path, 0, nullptr, nullptr);
122
124
125 if (!NT_SUCCESS(Status)) {
126 free(detail);
127 index++;
128 continue;
129 }
130
131 dev.pnp_name = detail->DevicePath;
132
133 Status = NtDeviceIoControlFile(file, nullptr, nullptr, nullptr, &iosb, IOCTL_DISK_GET_LENGTH_INFO, nullptr, 0, &gli, sizeof(GET_LENGTH_INFORMATION));
134 if (!NT_SUCCESS(Status)) {
135 free(detail);
136 index++;
137 continue;
138 }
139
140 dev.size = gli.Length.QuadPart;
141
142 Status = NtDeviceIoControlFile(file, nullptr, nullptr, nullptr, &iosb, IOCTL_STORAGE_GET_DEVICE_NUMBER, nullptr, 0, &sdn, sizeof(STORAGE_DEVICE_NUMBER));
143 if (!NT_SUCCESS(Status)) {
144 dev.disk_num = 0xffffffff;
145 dev.part_num = 0xffffffff;
146 } else {
147 dev.disk_num = sdn.DeviceNumber;
148 dev.part_num = sdn.PartitionNumber;
149 }
150
151 dev.friendly_name = L"";
152 dev.drive = L"";
153 dev.fstype = L"";
154 dev.has_parts = false;
155 dev.ignore = false;
156 dev.multi_device = false;
157
158 dev.is_disk = RtlCompareMemory(guid, &GUID_DEVINTERFACE_DISK, sizeof(GUID)) == sizeof(GUID);
159
160 if (dev.is_disk) {
162 STORAGE_DEVICE_DESCRIPTOR sdd, *sdd2;
163 ULONG dlisize;
164 DRIVE_LAYOUT_INFORMATION_EX* dli;
165
168 spq.AdditionalParameters[0] = 0;
169
170 Status = NtDeviceIoControlFile(file, nullptr, nullptr, nullptr, &iosb, IOCTL_STORAGE_QUERY_PROPERTY,
171 &spq, sizeof(STORAGE_PROPERTY_QUERY), &sdd, sizeof(STORAGE_DEVICE_DESCRIPTOR));
172
174 sdd2 = (STORAGE_DEVICE_DESCRIPTOR*)malloc(sdd.Size);
175
176 Status = NtDeviceIoControlFile(file, nullptr, nullptr, nullptr, &iosb, IOCTL_STORAGE_QUERY_PROPERTY,
177 &spq, sizeof(STORAGE_PROPERTY_QUERY), sdd2, sdd.Size);
178 if (NT_SUCCESS(Status)) {
179 string desc2;
180
181 desc2 = "";
182
183 if (sdd2->VendorIdOffset != 0) {
184 desc2 += (char*)((uint8_t*)sdd2 + sdd2->VendorIdOffset);
185
186 while (desc2.length() > 0 && desc2[desc2.length() - 1] == ' ')
187 desc2 = desc2.substr(0, desc2.length() - 1);
188 }
189
190 if (sdd2->ProductIdOffset != 0) {
191 if (sdd2->VendorIdOffset != 0 && desc2.length() != 0 && desc2[desc2.length() - 1] != ' ')
192 desc2 += " ";
193
194 desc2 += (char*)((uint8_t*)sdd2 + sdd2->ProductIdOffset);
195
196 while (desc2.length() > 0 && desc2[desc2.length() - 1] == ' ')
197 desc2 = desc2.substr(0, desc2.length() - 1);
198 }
199
200 if (sdd2->VendorIdOffset != 0 || sdd2->ProductIdOffset != 0) {
201 ULONG ss;
202
203 ss = MultiByteToWideChar(CP_OEMCP, MB_PRECOMPOSED, desc2.c_str(), -1, nullptr, 0);
204
205 if (ss > 0) {
206 WCHAR* desc3 = (WCHAR*)malloc(ss * sizeof(WCHAR));
207
208 if (MultiByteToWideChar(CP_OEMCP, MB_PRECOMPOSED, desc2.c_str(), -1, desc3, ss))
209 dev.friendly_name = desc3;
210
211 free(desc3);
212 }
213 }
214 }
215
216 free(sdd2);
217 }
218
219 dlisize = 0;
220 dli = nullptr;
221
222 do {
223 dlisize += 1024;
224
225 if (dli)
226 free(dli);
227
228 dli = (DRIVE_LAYOUT_INFORMATION_EX*)malloc(dlisize);
229
231 nullptr, 0, dli, dlisize);
232 } while (Status == STATUS_BUFFER_TOO_SMALL);
233
234 if (NT_SUCCESS(Status) && dli->PartitionCount > 0)
235 dev.has_parts = true;
236
237 free(dli);
238 } else {
239 try {
240 auto v = mm.query_points(L"", L"", wstring_view(path.Buffer, path.Length / sizeof(WCHAR)));
241
242#ifndef __REACTOS__
243 for (const auto& p : v) {
244 if (p.symlink.length() == 14 && p.symlink.substr(0, dosdevices.length()) == dosdevices && p.symlink[13] == ':') {
245#else
246 for(auto p = v.begin(); p != v.end(); ++p) {
247 if ((*p).symlink.length() == 14 && (*p).symlink.substr(0, dosdevices.length()) == dosdevices && (*p).symlink[13] == ':') {
248#endif
249 WCHAR dr[3];
250
251#ifndef __REACTOS__
252 dr[0] = p.symlink[12];
253#else
254 dr[0] = (*p).symlink[12];
255#endif
256 dr[1] = ':';
257 dr[2] = 0;
258
259 dev.drive = dr;
260 break;
261 }
262 }
263 } catch (...) { // don't fail entirely if mountmgr refuses to co-operate
264 }
265 }
266
267 if (!dev.is_disk || !dev.has_parts) {
268 i = 0;
269 while (fs_ident[i].name) {
270 if (i == 0 || fs_ident[i].kboff != fs_ident[i-1].kboff) {
271 LARGE_INTEGER off;
272
273 off.QuadPart = fs_ident[i].kboff * 1024;
274 Status = NtReadFile(file, nullptr, nullptr, nullptr, &iosb, sb, sizeof(sb), &off, nullptr);
275 }
276
277 if (NT_SUCCESS(Status)) {
278 if (RtlCompareMemory(sb + fs_ident[i].sboff, fs_ident[i].magic, fs_ident[i].magiclen) == fs_ident[i].magiclen) {
279 dev.fstype = fs_ident[i].name;
280
281 if (dev.fstype == L"Btrfs") {
282 superblock* bsb = (superblock*)sb;
283
284 RtlCopyMemory(&dev.fs_uuid, &bsb->uuid, sizeof(BTRFS_UUID));
285 RtlCopyMemory(&dev.dev_uuid, &bsb->dev_item.device_uuid, sizeof(BTRFS_UUID));
286 }
287
288 break;
289 }
290 }
291
292 i++;
293 }
294
295 if (dev.fstype == L"Btrfs" && RtlCompareMemory(guid, &GUID_DEVINTERFACE_DISK, sizeof(GUID)) != sizeof(GUID)) {
296 wstring name;
297 wstring pref = L"\\Device\\Btrfs{";
298
300
301 if (name.length() > pref.length() && RtlCompareMemory(name.c_str(), pref.c_str(), pref.length() * sizeof(WCHAR)) == pref.length() * sizeof(WCHAR))
302 dev.ignore = true;
303 }
304 }
305
306 device_list.push_back(dev);
307 }
308
309 free(detail);
310
311 index++;
312 } while (SetupDiEnumDeviceInterfaces(h, nullptr, guid, index, &did));
313
315 } else
316 throw last_error(GetLastError());
317}
318
319#ifndef __REACTOS__ // Disabled because building with our <algorithm> seems complex right now...
320static bool sort_devices(device i, device j) {
321 if (i.disk_num < j.disk_num)
322 return true;
323
324 if (i.disk_num == j.disk_num && i.part_num < j.part_num)
325 return true;
326
327 return false;
328}
329#endif
330
333 unsigned int i;
334 ULONG last_disk_num = 0xffffffff;
335 HTREEITEM diskitem;
340 btrfs_filesystem* bfs = nullptr;
341
342 static WCHAR btrfs[] = L"\\Btrfs";
343
345
346 {
347 mountmgr mm;
348
349 {
350 nt_handle btrfsh;
351
352 us.Length = us.MaximumLength = (uint16_t)(wcslen(btrfs) * sizeof(WCHAR));
353 us.Buffer = btrfs;
354
355 InitializeObjectAttributes(&attr, &us, 0, nullptr, nullptr);
356
359 if (NT_SUCCESS(Status)) {
360 ULONG bfssize = 0;
361
362 do {
363 bfssize += 1024;
364
365 if (bfs) free(bfs);
366 bfs = (btrfs_filesystem*)malloc(bfssize);
367
368 Status = NtDeviceIoControlFile(btrfsh, nullptr, nullptr, nullptr, &iosb, IOCTL_BTRFS_QUERY_FILESYSTEMS, nullptr, 0, bfs, bfssize);
370 free(bfs);
371 bfs = nullptr;
372 break;
373 }
374 } while (Status == STATUS_BUFFER_OVERFLOW);
375
376 if (bfs && bfs->num_devices == 0) { // no mounted filesystems found
377 free(bfs);
378 bfs = nullptr;
379 }
380 }
381 }
382
383 find_devices(hwnd, &GUID_DEVINTERFACE_DISK, mm, device_list);
384 find_devices(hwnd, &GUID_DEVINTERFACE_VOLUME, mm, device_list);
385 find_devices(hwnd, &GUID_DEVINTERFACE_HIDDEN_VOLUME, mm, device_list);
386 }
387
388#ifndef __REACTOS__ // Disabled because building with our <algorithm> seems complex right now...
390#endif
391
392 for (i = 0; i < device_list.size(); i++) {
393 if (!device_list[i].ignore) {
394 TVINSERTSTRUCTW tis;
396 wstring name, size;
397
398 if (device_list[i].disk_num != 0xffffffff && device_list[i].disk_num == last_disk_num)
399 tis.hParent = diskitem;
400 else
401 tis.hParent = TVI_ROOT;
402
407
408 if (device_list[i].disk_num != 0xffffffff) {
409 wstring t;
410
411 if (!load_string(module, device_list[i].part_num != 0 ? IDS_PARTITION : IDS_DISK_NUM, t))
412 throw last_error(GetLastError());
413
414 wstring_sprintf(name, t, device_list[i].part_num != 0 ? device_list[i].part_num : device_list[i].disk_num);
415 } else
416 name = device_list[i].pnp_name;
417
418 // match child Btrfs devices to their parent
419 if (bfs && device_list[i].drive == L"" && device_list[i].fstype == L"Btrfs") {
420 btrfs_filesystem* bfs2 = bfs;
421
422 while (true) {
423 if (RtlCompareMemory(&bfs2->uuid, &device_list[i].fs_uuid, sizeof(BTRFS_UUID)) == sizeof(BTRFS_UUID)) {
424 ULONG j, k;
426
427 for (j = 0; j < bfs2->num_devices; j++) {
428 if (j == 0)
429 dev = &bfs2->device;
430 else
432
433 if (RtlCompareMemory(&device_list[i].dev_uuid, &device_list[i].dev_uuid, sizeof(BTRFS_UUID)) == sizeof(BTRFS_UUID)) {
434 for (k = 0; k < device_list.size(); k++) {
435 if (k != i && device_list[k].fstype == L"Btrfs" && device_list[k].drive != L"" &&
436 RtlCompareMemory(&device_list[k].fs_uuid, &device_list[i].fs_uuid, sizeof(BTRFS_UUID)) == sizeof(BTRFS_UUID)) {
437 device_list[i].drive = device_list[k].drive;
438 break;
439 }
440 }
441
442 device_list[i].multi_device = bfs2->num_devices > 1;
443
444 break;
445 }
446 }
447
448 break;
449 }
450
451 if (bfs2->next_entry != 0)
452 bfs2 = (btrfs_filesystem*)((uint8_t*)bfs2 + bfs2->next_entry);
453 else
454 break;
455 }
456 }
457
458 name += L" (";
459
460 if (device_list[i].friendly_name != L"") {
461 name += device_list[i].friendly_name;
462 name += L", ";
463 }
464
465 if (device_list[i].drive != L"") {
466 name += device_list[i].drive;
467 name += L", ";
468 }
469
470 if (device_list[i].fstype != L"") {
471 name += device_list[i].fstype;
472 name += L", ";
473 }
474
476 name += size;
477
478 name += L")";
479
480 tis.itemex.pszText = (WCHAR*)name.c_str();
481 tis.itemex.cchTextMax = (int)name.length();
483
485 if (!item)
487
488 if (device_list[i].part_num == 0) {
489 diskitem = item;
490 last_disk_num = device_list[i].disk_num;
491 }
492 }
493 }
494}
495
497 wstring mess, title;
502
503 if (!sel) {
504 EndDialog(hwndDlg, 0);
505 return;
506 }
507
508 if (sel->fstype != L"") {
509 wstring s;
510
512 throw last_error(GetLastError());
513
514 wstring_sprintf(mess, s, sel->fstype.c_str());
515 } else {
517 throw last_error(GetLastError());
518 }
519
521 throw last_error(GetLastError());
522
523 if (MessageBoxW(hwndDlg, mess.c_str(), title.c_str(), MB_YESNO) != IDYES)
524 return;
525
528
529 if (h == INVALID_HANDLE_VALUE)
530 throw last_error(GetLastError());
531
532 {
533 nt_handle h2;
534
535 vn.Length = vn.MaximumLength = (uint16_t)(sel->pnp_name.length() * sizeof(WCHAR));
536 vn.Buffer = (WCHAR*)sel->pnp_name.c_str();
537
539
541 if (!NT_SUCCESS(Status))
542 throw ntstatus_error(Status);
543
544 if (!sel->is_disk) {
545 Status = NtFsControlFile(h2, nullptr, nullptr, nullptr, &iosb, FSCTL_LOCK_VOLUME, nullptr, 0, nullptr, 0);
546 if (!NT_SUCCESS(Status))
548 }
549
550 Status = NtFsControlFile(h, nullptr, nullptr, nullptr, &iosb, FSCTL_BTRFS_ADD_DEVICE, &h2, sizeof(HANDLE), nullptr, 0);
551 if (!NT_SUCCESS(Status))
552 throw ntstatus_error(Status);
553
554 if (!sel->is_disk) {
555 Status = NtFsControlFile(h2, nullptr, nullptr, nullptr, &iosb, FSCTL_DISMOUNT_VOLUME, nullptr, 0, nullptr, 0);
556 if (!NT_SUCCESS(Status))
557 throw ntstatus_error(Status);
558
559 Status = NtFsControlFile(h2, nullptr, nullptr, nullptr, &iosb, FSCTL_UNLOCK_VOLUME, nullptr, 0, nullptr, 0);
560 if (!NT_SUCCESS(Status))
561 throw ntstatus_error(Status);
562 }
563 }
564
565 EndDialog(hwndDlg, 0);
566}
567
569 try {
570 switch (uMsg) {
571 case WM_INITDIALOG:
572 {
575 EnableWindow(GetDlgItem(hwndDlg, IDOK), false);
576 break;
577 }
578
579 case WM_COMMAND:
580 switch (HIWORD(wParam)) {
581 case BN_CLICKED:
582 switch (LOWORD(wParam)) {
583 case IDOK:
584 AddDevice(hwndDlg);
585 return true;
586
587 case IDCANCEL:
588 EndDialog(hwndDlg, 0);
589 return true;
590 }
591 break;
592 }
593 break;
594
595 case WM_NOTIFY:
596 switch (((LPNMHDR)lParam)->code) {
597 case TVN_SELCHANGEDW:
598 {
600 TVITEMW tvi;
601 bool enable = false;
602
603 RtlZeroMemory(&tvi, sizeof(TVITEMW));
604 tvi.hItem = nmtv->itemNew.hItem;
606
608 sel = tvi.lParam == 0 ? nullptr : (device*)tvi.lParam;
609 else
610 sel = nullptr;
611
612 if (sel)
614
616 break;
617 }
618 }
619 break;
620 }
621 } catch (const exception& e) {
622 error_message(hwndDlg, e.what());
623 }
624
625 return false;
626}
627
629 BtrfsDeviceAdd* bda;
630
631 if (uMsg == WM_INITDIALOG) {
633 bda = (BtrfsDeviceAdd*)lParam;
634 } else {
636 }
637
638 if (bda)
639 return bda->DeviceAddDlgProc(hwndDlg, uMsg, wParam, lParam);
640 else
641 return false;
642}
643
646}
647
649 this->hinst = hinst;
650 this->hwnd = hwnd;
651 this->cmdline = cmdline;
652
653 sel = nullptr;
654}
655
659 btrfs_resize br;
660
661 {
664
665 if (h == INVALID_HANDLE_VALUE)
666 throw last_error(GetLastError());
667
668 br.device = dev_id;
669 br.size = new_size;
670
671 Status = NtFsControlFile(h, nullptr, nullptr, nullptr, &iosb, FSCTL_BTRFS_RESIZE, &br, sizeof(btrfs_resize), nullptr, 0);
672
674 throw ntstatus_error(Status);
675 }
676
678 wstring s, t, u;
679
681 format_size(new_size, u, true);
682 wstring_sprintf(t, s, dev_id, u.c_str());
683 MessageBoxW(hwndDlg, t.c_str(), L"", MB_OK);
684
685 EndDialog(hwndDlg, 0);
686 } else {
687 HWND par;
688
689 par = GetParent(hwndDlg);
690 EndDialog(hwndDlg, 0);
691
692 BtrfsBalance bb(fn, false, true);
693 bb.ShowBalance(par);
694 }
695}
696
698 try {
699 switch (uMsg) {
700 case WM_INITDIALOG:
701 {
703 WCHAR s[255];
704 wstring t, u;
705
707
708 GetDlgItemTextW(hwndDlg, IDC_RESIZE_DEVICE_ID, s, sizeof(s) / sizeof(WCHAR));
710 SetDlgItemTextW(hwndDlg, IDC_RESIZE_DEVICE_ID, t.c_str());
711
714
715 if (h != INVALID_HANDLE_VALUE) {
718 btrfs_device *devices, *bd;
719 ULONG devsize;
720 bool found = false;
721 HWND slider;
722
723 devsize = 1024;
724 devices = (btrfs_device*)malloc(devsize);
725
726 while (true) {
727 Status = NtFsControlFile(h, nullptr, nullptr, nullptr, &iosb, FSCTL_BTRFS_GET_DEVICES, nullptr, 0, devices, devsize);
729 devsize += 1024;
730
731 free(devices);
732 devices = (btrfs_device*)malloc(devsize);
733 } else
734 break;
735 }
736
737 if (!NT_SUCCESS(Status)) {
738 free(devices);
739 return false;
740 }
741
742 bd = devices;
743
744 while (true) {
745 if (bd->dev_id == dev_id) {
746 memcpy(&dev_info, bd, sizeof(btrfs_device));
747 found = true;
748 break;
749 }
750
751 if (bd->next_entry > 0)
752 bd = (btrfs_device*)((uint8_t*)bd + bd->next_entry);
753 else
754 break;
755 }
756
757 if (!found) {
758 free(devices);
759 return false;
760 }
761
762 free(devices);
763
764 GetDlgItemTextW(hwndDlg, IDC_RESIZE_CURSIZE, s, sizeof(s) / sizeof(WCHAR));
765 format_size(dev_info.size, u, true);
766 wstring_sprintf(t, s, u.c_str());
767 SetDlgItemTextW(hwndDlg, IDC_RESIZE_CURSIZE, t.c_str());
768
770
772 wstring_sprintf(t, new_size_text, u.c_str());
773 SetDlgItemTextW(hwndDlg, IDC_RESIZE_NEWSIZE, t.c_str());
774
778 SendMessageW(slider, TBM_SETPOS, true, (LPARAM)(new_size / 1048576));
779 } else
780 return false;
781
782 break;
783 }
784
785 case WM_COMMAND:
786 switch (HIWORD(wParam)) {
787 case BN_CLICKED:
788 switch (LOWORD(wParam)) {
789 case IDOK:
790 do_resize(hwndDlg);
791 return true;
792
793 case IDCANCEL:
794 EndDialog(hwndDlg, 0);
795 return true;
796 }
797 break;
798 }
799 break;
800
801 case WM_HSCROLL:
802 {
803 wstring t, u;
804
806
807 format_size(new_size, u, true);
808 wstring_sprintf(t, new_size_text, u.c_str());
809 SetDlgItemTextW(hwndDlg, IDC_RESIZE_NEWSIZE, t.c_str());
810
811 EnableWindow(GetDlgItem(hwndDlg, IDOK), new_size > 0 ? true : false);
812
813 break;
814 }
815 }
816 } catch (const exception& e) {
817 error_message(hwndDlg, e.what());
818 }
819
820 return false;
821}
822
825
826 if (uMsg == WM_INITDIALOG) {
829 } else
831
832 if (bdr)
833 return bdr->DeviceResizeDlgProc(hwndDlg, uMsg, wParam, lParam);
834 else
835 return false;
836}
837
838void BtrfsDeviceResize::ShowDialog(HWND hwnd, const wstring& fn, uint64_t dev_id) {
839 this->dev_id = dev_id;
840 this->fn = fn;
841
843}
844
845#ifdef __cplusplus
846extern "C" {
847#endif
848
849void CALLBACK AddDeviceW(HWND hwnd, HINSTANCE hinst, LPWSTR lpszCmdLine, int nCmdShow) {
850 try {
853 LUID luid;
854
856
858 throw last_error(GetLastError());
859
860 if (!LookupPrivilegeValueW(nullptr, L"SeManageVolumePrivilege", &luid))
861 throw last_error(GetLastError());
862
863 tp.PrivilegeCount = 1;
864 tp.Privileges[0].Luid = luid;
865 tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
866
867 if (!AdjustTokenPrivileges(token, false, &tp, sizeof(TOKEN_PRIVILEGES), nullptr, nullptr))
868 throw last_error(GetLastError());
869
870 BtrfsDeviceAdd bda(hinst, hwnd, lpszCmdLine);
871 bda.ShowDialog();
872 } catch (const exception& e) {
873 error_message(hwnd, e.what());
874 }
875}
876
877void CALLBACK RemoveDeviceW(HWND hwnd, HINSTANCE hinst, LPWSTR lpszCmdLine, int nCmdShow) {
878 try {
879 WCHAR *s, *vol, *dev;
880 uint64_t devid;
883 LUID luid;
886
888
890 throw last_error(GetLastError());
891
892 if (!LookupPrivilegeValueW(nullptr, L"SeManageVolumePrivilege", &luid))
893 throw last_error(GetLastError());
894
895 tp.PrivilegeCount = 1;
896 tp.Privileges[0].Luid = luid;
897 tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
898
899 if (!AdjustTokenPrivileges(token, false, &tp, sizeof(TOKEN_PRIVILEGES), nullptr, nullptr))
900 throw last_error(GetLastError());
901
902 s = wcsstr(lpszCmdLine, L"|");
903 if (!s)
904 return;
905
906 s[0] = 0;
907
908 vol = lpszCmdLine;
909 dev = &s[1];
910
911 devid = _wtoi(dev);
912 if (devid == 0)
913 return;
914
917
918 if (h == INVALID_HANDLE_VALUE)
919 throw last_error(GetLastError());
920
921 Status = NtFsControlFile(h, nullptr, nullptr, nullptr, &iosb, FSCTL_BTRFS_REMOVE_DEVICE, &devid, sizeof(uint64_t), nullptr, 0);
922 if (!NT_SUCCESS(Status)) {
925 else
926 throw ntstatus_error(Status);
927
928 return;
929 }
930
931 BtrfsBalance bb(vol, true);
932 bb.ShowBalance(hwnd);
933 } catch (const exception& e) {
934 error_message(hwnd, e.what());
935 }
936}
937
938void CALLBACK ResizeDeviceW(HWND hwnd, HINSTANCE hinst, LPWSTR lpszCmdLine, int nCmdShow) {
939 try {
940 WCHAR *s, *vol, *dev;
941 uint64_t devid;
944 LUID luid;
945
947
949 throw last_error(GetLastError());
950
951 if (!LookupPrivilegeValueW(nullptr, L"SeManageVolumePrivilege", &luid))
952 throw last_error(GetLastError());
953
954 tp.PrivilegeCount = 1;
955 tp.Privileges[0].Luid = luid;
956 tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
957
958 if (!AdjustTokenPrivileges(token, false, &tp, sizeof(TOKEN_PRIVILEGES), nullptr, nullptr))
959 throw last_error(GetLastError());
960
961 s = wcsstr(lpszCmdLine, L"|");
962 if (!s)
963 return;
964
965 s[0] = 0;
966
967 vol = lpszCmdLine;
968 dev = &s[1];
969
970 devid = _wtoi(dev);
971 if (devid == 0)
972 return;
973
975 bdr.ShowDialog(hwnd, vol, devid);
976 } catch (const exception& e) {
977 error_message(hwnd, e.what());
978 }
979}
980
981#ifdef __cplusplus
982}
983#endif
_STLP_MOVE_TO_STD_NAMESPACE void sort(_RandomAccessIter __first, _RandomAccessIter __last)
Definition: _algo.c:993
LONG NTSTATUS
Definition: precomp.h:26
#define IOCTL_BTRFS_QUERY_FILESYSTEMS
Definition: btrfsioctl.h:21
#define FSCTL_BTRFS_ADD_DEVICE
Definition: btrfsioctl.h:19
#define FSCTL_BTRFS_RESIZE
Definition: btrfsioctl.h:38
#define FSCTL_BTRFS_REMOVE_DEVICE
Definition: btrfsioctl.h:20
#define FSCTL_BTRFS_GET_DEVICES
Definition: btrfsioctl.h:12
void ShowBalance(HWND hwndDlg)
Definition: balance.cpp:981
INT_PTR CALLBACK DeviceAddDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: devices.cpp:568
void AddDevice(HWND hwndDlg)
Definition: devices.cpp:496
HINSTANCE hinst
Definition: devices.h:149
vector< device > device_list
Definition: devices.h:153
void ShowDialog()
Definition: devices.cpp:644
WCHAR * cmdline
Definition: devices.h:151
BtrfsDeviceAdd(HINSTANCE hinst, HWND hwnd, WCHAR *cmdline)
Definition: devices.cpp:648
device * sel
Definition: devices.h:152
void populate_device_tree(HWND tree)
Definition: devices.cpp:331
void do_resize(HWND hwndDlg)
Definition: devices.cpp:656
void ShowDialog(HWND hwnd, const wstring &fn, uint64_t dev_id)
Definition: devices.cpp:838
WCHAR new_size_text[255]
Definition: devices.h:166
uint64_t dev_id
Definition: devices.h:164
uint64_t new_size
Definition: devices.h:164
INT_PTR CALLBACK DeviceResizeDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: devices.cpp:697
btrfs_device dev_info
Definition: devices.h:167
_Self substr(size_type __pos=0, size_type __n=npos) const
Definition: _string.h:1022
const _CharT * c_str() const
Definition: _string.h:949
size_type length() const
Definition: _string.h:401
std::vector< mountmgr_point > query_points(const std::wstring_view &symlink=L"", const std::wstring_view &unique_id=L"", const std::wstring_view &device_name=L"") const
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
static wstring get_mountdev_name(const nt_handle &h)
Definition: devices.cpp:44
static void find_devices(HWND hwnd, const GUID *guid, const mountmgr &mm, vector< device > &device_list)
Definition: devices.cpp:73
void CALLBACK AddDeviceW(HWND hwnd, HINSTANCE hinst, LPWSTR lpszCmdLine, int nCmdShow)
Definition: devices.cpp:849
static bool sort_devices(device i, device j)
Definition: devices.cpp:320
static INT_PTR CALLBACK stub_DeviceResizeDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: devices.cpp:823
static INT_PTR CALLBACK stub_DeviceAddDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: devices.cpp:628
void CALLBACK RemoveDeviceW(HWND hwnd, HINSTANCE hinst, LPWSTR lpszCmdLine, int nCmdShow)
Definition: devices.cpp:877
void CALLBACK ResizeDeviceW(HWND hwnd, HINSTANCE hinst, LPWSTR lpszCmdLine, int nCmdShow)
Definition: devices.cpp:938
UINT64 uint64_t
Definition: types.h:77
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const fs_identifier fs_ident[]
Definition: devices.h:64
void set_dpi_aware()
Definition: main.cpp:50
void error_message(HWND hwnd, const char *msg)
Definition: main.cpp:783
void wstring_sprintf(wstring &s, wstring fmt,...)
Definition: main.cpp:225
void format_size(uint64_t size, wstring &s, bool show_bytes)
Definition: main.cpp:65
#define IDD_DEVICE_ADD
Definition: resource.h:80
#define IDS_DISK_NUM
Definition: resource.h:102
#define IDS_ADD_DEVICE_CONFIRMATION_FS
Definition: resource.h:99
#define IDC_DEVICE_TREE
Definition: resource.h:304
#define IDS_ADD_DEVICE_CONFIRMATION
Definition: resource.h:98
#define IDC_RESIZE_NEWSIZE
Definition: resource.h:336
#define IDC_RESIZE_CURSIZE
Definition: resource.h:334
#define IDS_TVM_INSERTITEM_FAILED
Definition: resource.h:207
#define IDS_LOCK_FAILED
Definition: resource.h:122
#define IDS_RESIZE_SUCCESSFUL
Definition: resource.h:194
#define IDS_CONFIRMATION_TITLE
Definition: resource.h:97
#define IDD_RESIZE
Definition: resource.h:90
#define IDC_RESIZE_DEVICE_ID
Definition: resource.h:333
#define IDC_RESIZE_SLIDER
Definition: resource.h:335
#define IDS_PARTITION
Definition: resource.h:92
#define IDS_CANNOT_REMOVE_RAID
Definition: resource.h:94
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 CALLBACK
Definition: compat.h:35
#define MultiByteToWideChar
Definition: compat.h:110
#define FILE_SHARE_READ
Definition: compat.h:136
BOOL WINAPI SetupDiEnumDeviceInterfaces(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, CONST GUID *InterfaceClassGuid, DWORD MemberIndex, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData)
Definition: devinst.c:2780
HDEVINFO WINAPI SetupDiGetClassDevsW(CONST GUID *class, LPCWSTR enumstr, HWND parent, DWORD flags)
Definition: devinst.c:2292
BOOL WINAPI SetupDiGetDeviceInterfaceDetailW(HDEVINFO DeviceInfoSet, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData, PSP_DEVICE_INTERFACE_DETAIL_DATA_W DeviceInterfaceDetailData, DWORD DeviceInterfaceDetailDataSize, PDWORD RequiredSize, PSP_DEVINFO_DATA DeviceInfoData)
Definition: devinst.c:3011
BOOL WINAPI SetupDiDestroyDeviceInfoList(HDEVINFO devinfo)
Definition: devinst.c:2893
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
_In_ uint64_t _In_ uint64_t _In_ uint64_t _In_opt_ traverse_ptr * tp
Definition: btrfs.c:2996
superblock * sb
Definition: btrfs.c:4261
static struct all_devices * devices
Definition: dsm_ctrl.c:48
#define ETDT_ENABLETAB
Definition: dxdiag.c:30
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IOCTL_DISK_GET_DRIVE_LAYOUT_EX
Definition: ntddk_ex.h:207
#define FILE_SYNCHRONOUS_IO_ALERT
Definition: from_kernel.h:30
Status
Definition: gdiplustypes.h:25
const GLdouble * v
Definition: gl.h:2040
GLdouble s
Definition: gl.h:2039
GLdouble GLdouble t
Definition: gl.h:2047
GLsizeiptr size
Definition: glext.h:5919
GLuint index
Definition: glext.h:6031
GLfloat GLfloat p
Definition: glext.h:8902
GLboolean enable
Definition: glext.h:11120
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 GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
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 GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
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
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 GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
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 GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint vn
Definition: glfuncs.h:238
#define ss
Definition: i386-dis.c:441
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define UInt32x32To64(a, b)
Definition: intsafe.h:252
#define e
Definition: ke_i.h:82
if(dx< 0)
Definition: linetemp.h:194
const GUID * guid
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define FILE_FLAG_OPEN_REPARSE_POINT
Definition: disk.h:39
#define FILE_FLAG_BACKUP_SEMANTICS
Definition: disk.h:41
#define IOCTL_MOUNTDEV_QUERY_DEVICE_NAME
Definition: imports.h:93
#define IOCTL_DISK_GET_LENGTH_INFO
Definition: imports.h:192
static HINSTANCE hinst
Definition: edit.c:551
static const BYTE us[]
Definition: encode.c:689
static const WCHAR friendly_name[]
Definition: devenum.c:40
static PIO_STATUS_BLOCK iosb
Definition: file.c:98
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
static ATOM item
Definition: dde.c:856
int k
Definition: mpi.c:3369
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
BYTE uint8_t
Definition: msvideo1.c:66
static int load_string(HINSTANCE hModule, UINT resId, LPWSTR pwszBuffer, INT cMaxChars)
Definition: muireg.c:10
unsigned int UINT
Definition: ndis.h:50
u32_t magic(void)
#define uint16_t
Definition: nsiface.idl:60
NTSYSAPI NTSTATUS NTAPI NtOpenFile(OUT PHANDLE phFile, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG ShareMode, IN ULONG OpenMode)
Definition: file.c:3952
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define SYNCHRONIZE
Definition: nt_native.h:61
#define FSCTL_LOCK_VOLUME
Definition: nt_native.h:832
#define FILE_READ_ATTRIBUTES
Definition: nt_native.h:647
NTSYSAPI NTSTATUS NTAPI NtDeviceIoControlFile(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)
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
#define FILE_TRAVERSE
Definition: nt_native.h:643
#define FSCTL_UNLOCK_VOLUME
Definition: nt_native.h:833
#define FSCTL_DISMOUNT_VOLUME
Definition: nt_native.h:834
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)
#define FILE_GENERIC_READ
Definition: nt_native.h:653
#define FILE_GENERIC_WRITE
Definition: nt_native.h:660
#define IOCTL_STORAGE_QUERY_PROPERTY
Definition: ntddstor.h:178
#define IOCTL_STORAGE_GET_DEVICE_NUMBER
Definition: ntddstor.h:143
@ StorageDeviceProperty
Definition: ntddstor.h:512
STORAGE_DEVICE_DESCRIPTOR
Definition: ntddstor.h:576
@ PropertyStandardQuery
Definition: ntddstor.h:505
#define L(x)
Definition: ntvdm.h:50
DRIVER_ADD_DEVICE AddDevice
Definition: parport.h:72
#define LOWORD(l)
Definition: pedump.c:82
static char title[]
Definition: ps.c:92
#define TVI_LAST
Definition: commctrl.h:3370
#define TVIF_TEXT
Definition: commctrl.h:3266
#define TVM_GETITEMW
Definition: commctrl.h:3486
#define TBM_GETPOS
Definition: commctrl.h:2031
#define TVN_SELCHANGEDW
Definition: commctrl.h:3648
#define TBM_SETRANGEMIN
Definition: commctrl.h:2038
struct _TREEITEM * HTREEITEM
Definition: commctrl.h:3264
#define TVI_ROOT
Definition: commctrl.h:3368
#define TBM_SETPOS
Definition: commctrl.h:2036
#define TVM_INSERTITEMW
Definition: commctrl.h:3408
#define TVIF_HANDLE
Definition: commctrl.h:3270
#define TVIS_EXPANDED
Definition: commctrl.h:3284
#define TBM_SETRANGEMAX
Definition: commctrl.h:2039
#define TVIF_PARAM
Definition: commctrl.h:3268
#define TVIF_STATE
Definition: commctrl.h:3269
#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8)
Definition: guiddef.h:68
#define WM_NOTIFY
Definition: richedit.h:61
#define offsetof(TYPE, MEMBER)
#define memset(x, y, z)
Definition: compat.h:39
#define DIGCF_DEVICEINTERFACE
Definition: setupapi.h:174
struct _SP_DEVICE_INTERFACE_DETAIL_DATA_W SP_DEVICE_INTERFACE_DETAIL_DATA_W
#define DIGCF_PRESENT
Definition: setupapi.h:171
#define STATUS_CANNOT_DELETE
Definition: shellext.h:71
#define STATUS_MORE_PROCESSING_REQUIRED
Definition: shellext.h:68
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
NTSTATUS NTAPI NtReadFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, PVOID Buffer, ULONG Length, PLARGE_INTEGER ByteOffset, PULONG Key)
HWND slider
Definition: sndrec32.cpp:39
TCHAR * cmdline
Definition: stretchblt.cpp:32
BTRFS_UUID device_uuid
Definition: btrfs.h:190
LARGE_INTEGER Length
Definition: winioctl.h:560
USHORT NameLength
Definition: imports.h:143
WCHAR Name[1]
Definition: imports.h:144
WCHAR DevicePath[ANYSIZE_ARRAY]
Definition: setupapi.h:855
STORAGE_QUERY_TYPE QueryType
Definition: ntddstor.h:553
UCHAR AdditionalParameters[1]
Definition: ntddstor.h:554
STORAGE_PROPERTY_ID PropertyId
Definition: ntddstor.h:552
Definition: cookie.c:202
uint64_t dev_id
Definition: btrfsioctl.h:104
uint64_t max_size
Definition: btrfsioctl.h:106
uint64_t size
Definition: btrfsioctl.h:105
uint32_t next_entry
Definition: btrfsioctl.h:103
uint8_t uuid[16]
Definition: btrfsioctl.h:190
uint32_t next_entry
Definition: btrfsioctl.h:189
uint32_t num_devices
Definition: btrfsioctl.h:191
btrfs_filesystem_device device
Definition: btrfsioctl.h:192
uint64_t size
Definition: btrfsioctl.h:281
uint64_t device
Definition: btrfsioctl.h:280
Definition: inflate.c:139
uint64_t size
Definition: devices.h:37
bool multi_device
Definition: devices.h:49
bool has_parts
Definition: devices.h:45
wstring fstype
Definition: devices.h:41
wstring pnp_name
Definition: devices.h:38
bool is_disk
Definition: devices.h:50
Definition: fci.c:127
uint32_t kboff
Definition: devices.h:58
const WCHAR * name
Definition: devices.h:54
Definition: name.c:39
BTRFS_UUID uuid
Definition: btrfs.h:225
DEV_ITEM dev_item
Definition: btrfs.h:251
TVITEMW itemNew
Definition: commctrl.h:3638
TVITEMEXW itemex
Definition: commctrl.h:3396
HTREEITEM hParent
Definition: commctrl.h:3393
HTREEITEM hInsertAfter
Definition: commctrl.h:3394
LPARAM lParam
Definition: commctrl.h:3355
LPWSTR pszText
Definition: commctrl.h:3350
UINT stateMask
Definition: commctrl.h:3349
int cchTextMax
Definition: commctrl.h:3351
HTREEITEM hItem
Definition: commctrl.h:3317
LPARAM lParam
Definition: commctrl.h:3325
UINT mask
Definition: commctrl.h:3316
iterator end()
Definition: _vector.h:184
void push_back(const _Tp &__x=_STLP_DEFAULT_CONSTRUCTED(_Tp))
Definition: _vector.h:379
iterator begin()
Definition: _vector.h:182
size_type size() const
Definition: _vector.h:192
void clear()
Definition: _vector.h:653
#define GWLP_USERDATA
Definition: treelist.c:63
int32_t INT_PTR
Definition: typedefs.h:64
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG
Definition: typedefs.h:59
#define HIWORD(l)
Definition: typedefs.h:247
LONGLONG QuadPart
Definition: typedefs.h:114
HRESULT WINAPI EnableThemeDialogTexture(_In_ HWND hwnd, _In_ DWORD dwFlags)
Definition: uxthemesupp.c:55
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2263
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
#define CP_OEMCP
Definition: winnls.h:231
#define MB_PRECOMPOSED
Definition: winnls.h:281
#define GetWindowLongPtrW
Definition: winuser.h:4829
#define WM_HSCROLL
Definition: winuser.h:1743
#define IDCANCEL
Definition: winuser.h:831
#define WM_COMMAND
Definition: winuser.h:1740
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define WM_INITDIALOG
Definition: winuser.h:1739
#define MB_YESNO
Definition: winuser.h:817
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:830
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define MB_OK
Definition: winuser.h:790
HWND WINAPI GetParent(_In_ HWND)
#define BN_CLICKED
Definition: winuser.h:1925
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define IDYES
Definition: winuser.h:835
#define SetWindowLongPtrW
Definition: winuser.h:5346
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
#define TOKEN_ADJUST_PRIVILEGES
Definition: setypes.h:930
#define TOKEN_QUERY
Definition: setypes.h:928
#define SE_PRIVILEGE_ENABLED
Definition: setypes.h:63
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184