ReactOS  0.4.13-dev-92-gf251225
send.cpp
Go to the documentation of this file.
1 /* Copyright (c) Mark Harmstone 2017
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 #include "shellext.h"
19 #include "send.h"
20 #include "resource.h"
21 #include <stddef.h>
22 #include <shlobj.h>
23 #ifdef __REACTOS__
24 #undef DeleteFile
25 #endif
26 #include <iostream>
27 
28 #define SEND_BUFFER_LEN 1048576
29 
31  try {
34  btrfs_send_subvol* bss;
37  ULONG bss_size, i;
38 
39  buf = (char*)malloc(SEND_BUFFER_LEN);
40 
41  try {
45 
46  try {
47  bss_size = offsetof(btrfs_send_subvol, clones[0]) + (clones.size() * sizeof(HANDLE));
48  bss = (btrfs_send_subvol*)malloc(bss_size);
49  memset(bss, 0, bss_size);
50 
51  if (incremental) {
53  HANDLE parenth;
54 
55  parent[0] = 0;
56 
58 
60  if (parenth == INVALID_HANDLE_VALUE)
62 
63  bss->parent = parenth;
64  } else
65  bss->parent = nullptr;
66 
67  bss->num_clones = clones.size();
68 
69  for (i = 0; i < bss->num_clones; i++) {
70  HANDLE h;
71 
73  if (h == INVALID_HANDLE_VALUE) {
74  auto le = GetLastError();
75  ULONG j;
76 
77  for (j = 0; j < i; j++) {
78  CloseHandle(bss->clones[j]);
79  }
80 
81  if (bss->parent) CloseHandle(bss->parent);
82 
83  throw string_error(IDS_SEND_CANT_OPEN_DIR, clones[i].c_str(), le, format_message(le).c_str());
84  }
85 
86  bss->clones[i] = h;
87  }
88 
89  Status = NtFsControlFile(dirh, nullptr, nullptr, nullptr, &iosb, FSCTL_BTRFS_SEND_SUBVOL, bss, bss_size, nullptr, 0);
90 
91  for (i = 0; i < bss->num_clones; i++) {
92  CloseHandle(bss->clones[i]);
93  }
94 
95  if (!NT_SUCCESS(Status)) {
99  auto le = GetLastError();
100  if (bss->parent) CloseHandle(bss->parent);
102  }
103 
104  if (!(fileinfo.dwFileAttributes & FILE_ATTRIBUTE_READONLY)) {
105  if (bss->parent) CloseHandle(bss->parent);
107  }
108 
109  if (bss->parent) {
111  auto le = GetLastError();
112  CloseHandle(bss->parent);
114  }
115 
116  if (!(fileinfo.dwFileAttributes & FILE_ATTRIBUTE_READONLY)) {
117  CloseHandle(bss->parent);
119  }
120  }
121  }
122 
123  if (bss->parent) CloseHandle(bss->parent);
125  }
126 
127  if (bss->parent) CloseHandle(bss->parent);
128 
132 
133  try {
134  memcpy(header.magic, BTRFS_SEND_MAGIC, sizeof(header.magic));
135  header.version = 1;
136 
137  if (!WriteFile(stream, &header, sizeof(header), nullptr, nullptr))
139 
140  do {
141  Status = NtFsControlFile(dirh, nullptr, nullptr, nullptr, &iosb, FSCTL_BTRFS_READ_SEND_BUFFER, nullptr, 0, buf, SEND_BUFFER_LEN);
142 
143  if (NT_SUCCESS(Status)) {
144  if (!WriteFile(stream, buf, iosb.Information, nullptr, nullptr))
146  }
147  } while (NT_SUCCESS(Status));
148 
149  if (Status != STATUS_END_OF_FILE)
151 
152  end.length = 0;
153  end.cmd = BTRFS_SEND_CMD_END;
154  end.csum = 0x9dc96c50;
155 
156  if (!WriteFile(stream, &end, sizeof(end), nullptr, nullptr))
158 
160  } catch (...) {
161  FILE_DISPOSITION_INFO fdi;
162 
163  fdi.DeleteFile = true;
164 
165  SetFileInformationByHandle(stream, FileDispositionInfo, &fdi, sizeof(FILE_DISPOSITION_INFO));
166 
169 
170  throw;
171  }
172 
175  } catch (...) {
176  CloseHandle(dirh);
178 
179  throw;
180  }
181 
182  CloseHandle(dirh);
184  } catch (...) {
185  free(buf);
186  buf = nullptr;
187 
188  started = false;
189 
191  EnableWindow(GetDlgItem(hwnd, IDOK), true);
194 
195  throw;
196  }
197  } catch (const exception& e) {
198  wstring msg;
199 
200  utf8_to_utf16(e.what(), msg);
201 
203  return 0;
204  }
205 
206 
207  free(buf);
208  buf = nullptr;
209 
210  started = false;
211 
213  EnableWindow(GetDlgItem(hwnd, IDOK), true);
216 
217  wstring success;
218 
220 
222 
223  return 0;
224 }
225 
228 
229  return bs->Thread();
230 }
231 
233  wstring s;
234  HWND cl;
235  ULONG num_clones;
236 
237  if (started)
238  return;
239 
240  GetDlgItemTextW(hwnd, IDC_STREAM_DEST, file, sizeof(file) / sizeof(WCHAR));
241 
242  if (file[0] == 0)
243  return;
244 
245  if (incremental) {
247 
249 
250  if (parent[0] == 0)
251  return;
252  }
253 
254  started = true;
255 
256  wstring writing;
257 
259 
260  SetDlgItemTextW(hwnd, IDC_SEND_STATUS, writing.c_str());
261 
263  SetDlgItemTextW(hwnd, IDCANCEL, s.c_str());
264 
265  EnableWindow(GetDlgItem(hwnd, IDOK), false);
268 
269  clones.clear();
270 
272  num_clones = SendMessageW(cl, LB_GETCOUNT, 0, 0);
273 
274  if ((LRESULT)num_clones != LB_ERR) {
275  ULONG i;
276 
277  for (i = 0; i < num_clones; i++) {
278  WCHAR* t;
279  ULONG len;
280 
281  len = SendMessageW(cl, LB_GETTEXTLEN, i, 0);
282  t = (WCHAR*)malloc((len + 1) * sizeof(WCHAR));
283 
284  SendMessageW(cl, LB_GETTEXT, i, (LPARAM)t);
285 
286  clones.push_back(t);
287 
288  free(t);
289  }
290  }
291 
292  thread = CreateThread(nullptr, 0, send_thread, this, 0, nullptr);
293 
294  if (!thread)
295  throw last_error(GetLastError());
296 }
297 
300 
301  file[0] = 0;
302 
303  memset(&ofn, 0, sizeof(OPENFILENAMEW));
304  ofn.lStructSize = sizeof(OPENFILENAMEW);
305  ofn.hwndOwner = hwnd;
306  ofn.hInstance = module;
307  ofn.lpstrFile = file;
308  ofn.nMaxFile = sizeof(file) / sizeof(WCHAR);
309 
310  if (!GetSaveFileNameW(&ofn))
311  return;
312 
314 }
315 
317  BROWSEINFOW bi;
318  PIDLIST_ABSOLUTE root, pidl;
319  HRESULT hr;
320  WCHAR parent[MAX_PATH], volpathw[MAX_PATH];
323  btrfs_get_file_ids bgfi;
324 
325  if (!GetVolumePathNameW(subvol.c_str(), volpathw, (sizeof(volpathw) / sizeof(WCHAR)) - 1))
327 
328  hr = SHParseDisplayName(volpathw, 0, &root, 0, 0);
329  if (FAILED(hr))
331 
332  memset(&bi, 0, sizeof(BROWSEINFOW));
333 
334  bi.hwndOwner = hwnd;
335  bi.pidlRoot = root;
337 
338  pidl = SHBrowseForFolderW(&bi);
339 
340  if (!pidl)
341  return;
342 
343  if (!SHGetPathFromIDListW(pidl, parent))
345 
346  {
348  if (h == INVALID_HANDLE_VALUE)
350 
351  Status = NtFsControlFile(h, nullptr, nullptr, nullptr, &iosb, FSCTL_BTRFS_GET_FILE_IDS, nullptr, 0, &bgfi, sizeof(btrfs_get_file_ids));
352  if (!NT_SUCCESS(Status))
354  }
355 
356  if (bgfi.inode != 0x100 || bgfi.top)
358 
360 }
361 
363  BROWSEINFOW bi;
364  PIDLIST_ABSOLUTE root, pidl;
365  HRESULT hr;
366  WCHAR path[MAX_PATH], volpathw[MAX_PATH];
369  btrfs_get_file_ids bgfi;
370 
371  if (!GetVolumePathNameW(subvol.c_str(), volpathw, (sizeof(volpathw) / sizeof(WCHAR)) - 1))
373 
374  hr = SHParseDisplayName(volpathw, 0, &root, 0, 0);
375  if (FAILED(hr))
377 
378  memset(&bi, 0, sizeof(BROWSEINFOW));
379 
380  bi.hwndOwner = hwnd;
381  bi.pidlRoot = root;
383 
384  pidl = SHBrowseForFolderW(&bi);
385 
386  if (!pidl)
387  return;
388 
389  if (!SHGetPathFromIDListW(pidl, path))
391 
392  {
394  if (h == INVALID_HANDLE_VALUE)
396 
397  Status = NtFsControlFile(h, nullptr, nullptr, nullptr, &iosb, FSCTL_BTRFS_GET_FILE_IDS, nullptr, 0, &bgfi, sizeof(btrfs_get_file_ids));
398  if (!NT_SUCCESS(Status))
400  }
401 
402  if (bgfi.inode != 0x100 || bgfi.top)
404 
406 }
407 
409  LRESULT sel;
411 
412  sel = SendMessageW(cl, LB_GETCURSEL, 0, 0);
413 
414  if (sel == LB_ERR)
415  return;
416 
417  SendMessageW(cl, LB_DELETESTRING, sel, 0);
418 
419  if (SendMessageW(cl, LB_GETCURSEL, 0, 0) == LB_ERR)
421 }
422 
424  try {
425  switch (uMsg) {
426  case WM_INITDIALOG:
427  this->hwnd = hwndDlg;
428 
429  GetDlgItemTextW(hwndDlg, IDCANCEL, closetext, sizeof(closetext) / sizeof(WCHAR));
430  break;
431 
432  case WM_COMMAND:
433  switch (HIWORD(wParam)) {
434  case BN_CLICKED:
435  switch (LOWORD(wParam)) {
436  case IDOK:
437  StartSend(hwndDlg);
438  return true;
439 
440  case IDCANCEL:
441  if (started) {
443 
444  if (stream != INVALID_HANDLE_VALUE) {
445  FILE_DISPOSITION_INFO fdi;
446 
447  fdi.DeleteFile = true;
448 
449  SetFileInformationByHandle(stream, FileDispositionInfo, &fdi, sizeof(FILE_DISPOSITION_INFO));
451  }
452 
453  if (dirh != INVALID_HANDLE_VALUE)
454  CloseHandle(dirh);
455 
456  started = false;
457 
459 
460  EnableWindow(GetDlgItem(hwnd, IDOK), true);
463  } else
464  EndDialog(hwndDlg, 1);
465  return true;
466 
467  case IDC_BROWSE:
468  Browse(hwndDlg);
469  return true;
470 
471  case IDC_INCREMENTAL:
473 
476  return true;
477 
478  case IDC_PARENT_BROWSE:
479  BrowseParent(hwndDlg);
480  return true;
481 
482  case IDC_CLONE_ADD:
483  AddClone(hwndDlg);
484  return true;
485 
486  case IDC_CLONE_REMOVE:
487  RemoveClone(hwndDlg);
488  return true;
489  }
490  break;
491 
492  case LBN_SELCHANGE:
493  switch (LOWORD(wParam)) {
494  case IDC_CLONE_LIST:
496  return true;
497  }
498  break;
499  }
500  break;
501  }
502  } catch (const exception& e) {
503  error_message(hwnd, e.what());
504  }
505 
506  return false;
507 }
508 
510  BtrfsSend* bs;
511 
512  if (uMsg == WM_INITDIALOG) {
514  bs = (BtrfsSend*)lParam;
515  } else
517 
518  if (bs)
519  return bs->SendDlgProc(hwndDlg, uMsg, wParam, lParam);
520  else
521  return false;
522 }
523 
525  subvol = path;
526 
528  throw last_error(GetLastError());
529 }
530 
531 #ifdef __REACTOS__
532 extern "C" {
533 #endif
534 
535 void CALLBACK SendSubvolGUIW(HWND hwnd, HINSTANCE hinst, LPWSTR lpszCmdLine, int nCmdShow) {
536  try {
539  LUID luid;
540 
541  set_dpi_aware();
542 
544  throw last_error(GetLastError());
545 
546  if (!LookupPrivilegeValueW(nullptr, L"SeManageVolumePrivilege", &luid))
547  throw last_error(GetLastError());
548 
549  tp.PrivilegeCount = 1;
550  tp.Privileges[0].Luid = luid;
551  tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
552 
553  if (!AdjustTokenPrivileges(token, false, &tp, sizeof(TOKEN_PRIVILEGES), nullptr, nullptr))
554  throw last_error(GetLastError());
555 
556  BtrfsSend bs;
557 
558  bs.Open(hwnd, lpszCmdLine);
559  } catch (const exception& e) {
560  error_message(hwnd, e.what());
561  }
562 }
563 
564 #ifdef __REACTOS__
565 } /* extern "C" */
566 #endif
567 
568 static void send_subvol(const wstring& subvol, const wstring& file, const wstring& parent, const vector<wstring>& clones) {
569  char* buf;
570  win_handle dirh, stream;
571  ULONG bss_size, i;
572  btrfs_send_subvol* bss;
577 
578  buf = (char*)malloc(SEND_BUFFER_LEN);
579 
580  try {
582  if (dirh == INVALID_HANDLE_VALUE)
583  throw last_error(GetLastError());
584 
585  stream = CreateFileW(file.c_str(), FILE_WRITE_DATA | DELETE, 0, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
587  throw last_error(GetLastError());
588 
589  try {
590  bss_size = offsetof(btrfs_send_subvol, clones[0]) + (clones.size() * sizeof(HANDLE));
591  bss = (btrfs_send_subvol*)malloc(bss_size);
592  memset(bss, 0, bss_size);
593 
594  if (parent != L"") {
595  HANDLE parenth;
596 
598  if (parenth == INVALID_HANDLE_VALUE)
599  throw last_error(GetLastError());
600 
601  bss->parent = parenth;
602  } else
603  bss->parent = nullptr;
604 
605  bss->num_clones = clones.size();
606 
607  for (i = 0; i < bss->num_clones; i++) {
608  HANDLE h;
609 
611  if (h == INVALID_HANDLE_VALUE) {
612  auto le = GetLastError();
613  ULONG j;
614 
615  for (j = 0; j < i; j++) {
616  CloseHandle(bss->clones[j]);
617  }
618 
619  if (bss->parent) CloseHandle(bss->parent);
620 
621  throw last_error(le);
622  }
623 
624  bss->clones[i] = h;
625  }
626 
627  Status = NtFsControlFile(dirh, nullptr, nullptr, nullptr, &iosb, FSCTL_BTRFS_SEND_SUBVOL, bss, bss_size, nullptr, 0);
628 
629  for (i = 0; i < bss->num_clones; i++) {
630  CloseHandle(bss->clones[i]);
631  }
632 
633  if (bss->parent) CloseHandle(bss->parent);
634 
635  if (!NT_SUCCESS(Status))
636  throw ntstatus_error(Status);
637 
638  memcpy(header.magic, BTRFS_SEND_MAGIC, sizeof(header.magic));
639  header.version = 1;
640 
641  if (!WriteFile(stream, &header, sizeof(header), nullptr, nullptr))
642  throw last_error(GetLastError());
643 
644  do {
645  Status = NtFsControlFile(dirh, nullptr, nullptr, nullptr, &iosb, FSCTL_BTRFS_READ_SEND_BUFFER, nullptr, 0, buf, SEND_BUFFER_LEN);
646 
647  if (NT_SUCCESS(Status))
648  WriteFile(stream, buf, iosb.Information, nullptr, nullptr);
649  } while (NT_SUCCESS(Status));
650 
651  if (Status != STATUS_END_OF_FILE)
652  throw ntstatus_error(Status);
653 
654  end.length = 0;
655  end.cmd = BTRFS_SEND_CMD_END;
656  end.csum = 0x9dc96c50;
657 
658  if (!WriteFile(stream, &end, sizeof(end), nullptr, nullptr))
659  throw last_error(GetLastError());
660 
662  } catch (...) {
663  FILE_DISPOSITION_INFO fdi;
664 
665  fdi.DeleteFile = true;
666 
667  SetFileInformationByHandle(stream, FileDispositionInfo, &fdi, sizeof(FILE_DISPOSITION_INFO));
668 
669  throw;
670  }
671  } catch (...) {
672  free(buf);
673  throw;
674  }
675 
676  free(buf);
677 }
678 
679 #ifdef __REACTOS__
680 extern "C" {
681 #endif
682 
683 void CALLBACK SendSubvolW(HWND hwnd, HINSTANCE hinst, LPWSTR lpszCmdLine, int nCmdShow) {
685  wstring subvol = L"", parent = L"", file = L"";
686  vector<wstring> clones;
687 
688  command_line_to_args(lpszCmdLine, args);
689 
690  if (args.size() >= 2) {
692  LUID luid;
693 
694  {
696 
698  return;
699 
700  if (!LookupPrivilegeValueW(nullptr, L"SeManageVolumePrivilege", &luid))
701  return;
702 
703  tp.PrivilegeCount = 1;
704  tp.Privileges[0].Luid = luid;
705  tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
706 
707  if (!AdjustTokenPrivileges(token, false, &tp, sizeof(TOKEN_PRIVILEGES), nullptr, nullptr))
708  return;
709  }
710 
711  for (unsigned int i = 0; i < args.size(); i++) {
712  if (args[i][0] == '-') {
713  if (args[i][2] == 0 && i < args.size() - 1) {
714  if (args[i][1] == 'p') {
715  parent = args[i+1];
716  i++;
717  } else if (args[i][1] == 'c') {
718  clones.push_back(args[i+1]);
719  i++;
720  }
721  }
722  } else {
723  if (subvol == L"")
724  subvol = args[i];
725  else if (file == L"")
726  file = args[i];
727  }
728  }
729 
730  if (subvol != L"" && file != L"") {
731  try {
732  send_subvol(subvol, file, parent, clones);
733  } catch (const exception& e) {
734  cerr << "Error: " << e.what() << endl;
735  }
736  }
737  }
738 }
739 
740 #ifdef __REACTOS__
741 } /* extern "C" */
742 #endif
bool started
Definition: send.h:55
#define IDS_SEND_CANT_OPEN_FILE
Definition: resource.h:177
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
static PIO_STATUS_BLOCK iosb
Definition: file.c:98
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2195
#define IDOK
Definition: winuser.h:824
#define CloseHandle
Definition: compat.h:398
HMODULE module
Definition: main.cpp:47
BOOL WINAPI LookupPrivilegeValueW(LPCWSTR lpSystemName, LPCWSTR lpPrivilegeName, PLUID lpLuid)
Definition: misc.c:782
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
#define IDC_CLONE_REMOVE
Definition: resource.h:291
wstring format_ntstatus(NTSTATUS Status)
Definition: main.cpp:184
BOOL WINAPI TerminateThread(IN HANDLE hThread, IN DWORD dwExitCode)
Definition: thread.c:549
HRESULT hr
Definition: shlfolder.c:183
#define IDC_SEND_STATUS
Definition: resource.h:327
#define LB_ADDSTRING
Definition: winuser.h:1992
#define IDS_SEND_PARENT_NOT_READONLY
Definition: resource.h:189
#define IDS_SEND_GET_FILE_INFO_FAILED
Definition: resource.h:183
DWORD Thread()
Definition: send.cpp:30
HWND hwndOwner
Definition: commdlg.h:330
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define IDS_SEND_NOT_READONLY
Definition: resource.h:184
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
GLsizei const GLchar ** path
Definition: glext.h:7234
#define IDS_SEND_SUCCESS
Definition: resource.h:181
#define IDC_BROWSE
Definition: resource.h:21
#define free
Definition: debug_ros.c:5
struct _root root
BOOL WINAPI SetEndOfFile(HANDLE hFile)
Definition: fileinfo.c:1154
LONG NTSTATUS
Definition: precomp.h:26
static void send_subvol(const wstring &subvol, const wstring &file, const wstring &parent, const vector< wstring > &clones)
Definition: send.cpp:568
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1280
#define CALLBACK
Definition: compat.h:27
static INT_PTR CALLBACK stub_SendDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: send.cpp:509
GLdouble GLdouble t
Definition: gl.h:2047
OPENFILENAME ofn
Definition: main.cpp:37
#define SEND_BUFFER_LEN
Definition: send.cpp:28
HWND hwndOwner
Definition: shlobj.h:1118
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
WCHAR file[MAX_PATH]
Definition: send.h:57
#define IDC_STREAM_DEST
Definition: resource.h:325
NTSYSCALLAPI NTSTATUS NTAPI NtFsControlFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, ULONG FsControlCode, PVOID InputBuffer, ULONG InputBufferLength, PVOID OutputBuffer, ULONG OutputBufferLength)
BOOL WINAPI GetVolumePathNameW(IN LPCWSTR lpszFileName, IN LPWSTR lpszVolumePathName, IN DWORD cchBufferLength)
Definition: volume.c:815
UINT_PTR WPARAM
Definition: windef.h:207
#define BIF_NONEWFOLDERBUTTON
Definition: shlobj.h:1145
GLuint GLuint end
Definition: gl.h:1545
_In_ UINT64 _In_ UINT64 _In_ UINT64 _In_opt_ traverse_ptr * tp
Definition: btrfs.c:2645
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
int32_t INT_PTR
Definition: typedefs.h:62
Definition: match.c:390
#define LBN_SELCHANGE
Definition: winuser.h:2036
#define IDS_SEND_WRITING
Definition: resource.h:191
#define SetWindowLongPtr
Definition: treelist.c:70
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
#define IDC_CLONE_ADD
Definition: resource.h:287
BOOL WINAPI GetSaveFileNameW(LPOPENFILENAMEW ofn)
Definition: filedlg.c:4286
#define FILE_SHARE_READ
Definition: compat.h:125
#define IDS_SHPARSEDISPLAYNAME_FAILED
Definition: resource.h:187
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define IDC_PARENT_BROWSE
Definition: resource.h:282
DWORD nMaxFile
Definition: commdlg.h:337
#define STATUS_END_OF_FILE
Definition: shellext.h:62
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define FILE_TRAVERSE
Definition: nt_native.h:643
#define IDC_INCREMENTAL
Definition: resource.h:319
#define SE_PRIVILEGE_ENABLED
Definition: setypes.h:63
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
void RemoveClone(HWND hwnd)
Definition: send.cpp:408
Definition: send.h:27
void error_message(HWND hwnd, const char *msg)
Definition: main.cpp:738
bool incremental
Definition: send.h:56
basic_ostream< _CharT, _Traits > &_STLP_CALL endl(basic_ostream< _CharT, _Traits > &__os)
Definition: _ostream.h:357
#define LB_ERR
Definition: winuser.h:2386
#define e
Definition: ke_i.h:82
#define IDS_SEND_FSCTL_BTRFS_READ_SEND_BUFFER_FAILED
Definition: resource.h:180
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
#define IDC_CLONE_LIST
Definition: resource.h:330
#define GWLP_USERDATA
Definition: treelist.c:63
#define FSCTL_BTRFS_SEND_SUBVOL
Definition: btrfsioctl.h:37
void Open(HWND hwnd, WCHAR *path)
Definition: send.cpp:524
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:112
void BrowseParent(HWND hwnd)
Definition: send.cpp:316
#define offsetof(TYPE, MEMBER)
#define IDS_NOT_SUBVOL
Definition: resource.h:185
LONG_PTR LPARAM
Definition: windef.h:208
void StartSend(HWND hwnd)
Definition: send.cpp:232
HINSTANCE hInstance
Definition: commdlg.h:331
#define LB_GETTEXTLEN
Definition: winuser.h:2011
#define LB_GETCOUNT
Definition: winuser.h:1999
UINT WINAPI IsDlgButtonChecked(_In_ HWND, _In_ int)
#define FILE_WRITE_DATA
Definition: nt_native.h:631
#define OPEN_EXISTING
Definition: compat.h:426
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
LPCITEMIDLIST pidlRoot
Definition: shlobj.h:1119
void AddClone(HWND hwnd)
Definition: send.cpp:362
#define TOKEN_QUERY
Definition: setypes.h:874
r parent
Definition: btrfs.c:2659
BOOL WINAPI GetFileInformationByHandle(HANDLE hFile, LPBY_HANDLE_FILE_INFORMATION lpFileInformation)
Definition: fileinfo.c:608
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_STLP_DECLSPEC _Stl_aligned_buffer< ostream > cerr
Definition: iostream.cpp:102
LONG HRESULT
Definition: typedefs.h:77
HANDLE WINAPI GetCurrentProcess(VOID)
Definition: proc.c:1168
void push_back(const _Tp &__x=_STLP_DEFAULT_CONSTRUCTED(_Tp))
Definition: _vector.h:376
vector< wstring > clones
Definition: send.h:62
#define MAX_PATH
Definition: compat.h:26
DWORD lStructSize
Definition: commdlg.h:329
#define WINAPI
Definition: msvc.h:8
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
HANDLE clones[1]
Definition: btrfsioctl.h:283
#define BN_CLICKED
Definition: winuser.h:1886
PVOID HANDLE
Definition: typedefs.h:71
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IDS_SEND_FSCTL_BTRFS_SEND_SUBVOL_FAILED
Definition: resource.h:179
#define FSCTL_BTRFS_READ_SEND_BUFFER
Definition: btrfsioctl.h:38
#define success(from, fromstr, to, tostr)
static DWORD WINAPI send_thread(LPVOID lpParameter)
Definition: send.cpp:226
#define OPEN_ALWAYS
Definition: disk.h:70
#define BIF_USENEWUI
Definition: shlobj.h:1142
void CALLBACK SendSubvolGUIW(HWND hwnd, HINSTANCE hinst, LPWSTR lpszCmdLine, int nCmdShow)
Definition: send.cpp:535
#define FILE_READ_ATTRIBUTES
Definition: nt_native.h:647
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
#define LB_GETTEXT
Definition: winuser.h:2010
static const WCHAR L[]
Definition: oid.c:1250
struct tagOFNW OPENFILENAMEW
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
LPVOID lpParameter
Definition: kernel32.h:234
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
format_message(j_common_ptr cinfo, char *buffer)
Definition: jerror.c:158
HWND hwnd
Definition: send.h:59
GLdouble s
Definition: gl.h:2039
#define FSCTL_BTRFS_GET_FILE_IDS
Definition: btrfsioctl.h:8
#define WM_COMMAND
Definition: winuser.h:1716
#define BTRFS_SEND_CMD_END
Definition: btrfs.h:538
BOOL WINAPI AdjustTokenPrivileges(HANDLE TokenHandle, BOOL DisableAllPrivileges, PTOKEN_PRIVILEGES NewState, DWORD BufferLength, PTOKEN_PRIVILEGES PreviousState, PDWORD ReturnLength)
Definition: security.c:376
#define IDD_SEND_SUBVOL
Definition: resource.h:88
Status
Definition: gdiplustypes.h:24
wstring subvol
Definition: send.h:60
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define BTRFS_SEND_MAGIC
Definition: btrfs.h:566
LPITEMIDLIST WINAPI SHBrowseForFolderW(LPBROWSEINFOW lpbi)
Definition: brsfolder.c:1156
UINT ulFlags
Definition: shlobj.h:1122
#define BIF_RETURNONLYFSDIRS
Definition: shlobj.h:1135
LPSTR lpstrFile
Definition: commdlg.h:336
#define IDS_SEND_CANCEL
Definition: resource.h:190
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
Definition: services.c:325
HRESULT WINAPI SHParseDisplayName(LPCWSTR pszName, IBindCtx *pbc, LPITEMIDLIST *ppidl, SFGAOF sfgaoIn, SFGAOF *psfgaoOut)
Definition: pidl.c:1367
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define LB_GETCURSEL
Definition: winuser.h:2000
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:296
#define IDS_SEND_CANT_OPEN_DIR
Definition: resource.h:178
static int load_string(HINSTANCE hModule, UINT resId, LPWSTR pwszBuffer, INT cMaxChars)
Definition: muireg.c:10
void Browse(HWND hwnd)
Definition: send.cpp:298
#define IDC_PARENT_SUBVOL
Definition: resource.h:329
#define CreateFileW
Definition: compat.h:400
HANDLE dirh
Definition: send.h:58
#define msg(x)
Definition: auth_time.c:54
BOOL WINAPI SetFileInformationByHandle(HANDLE hFile, FILE_INFO_BY_HANDLE_CLASS FileInformationClass, LPVOID lpFileInformation, DWORD dwBufferSize)
Definition: reactos.cpp:177
#define FILE_FLAG_BACKUP_SEMANTICS
Definition: disk.h:41
WCHAR closetext[255]
Definition: send.h:57
#define IDS_SEND_WRITEFILE_FAILED
Definition: resource.h:182
size_type size() const
Definition: _vector.h:192
#define HIWORD(l)
Definition: typedefs.h:246
unsigned int ULONG
Definition: retypes.h:1
static HINSTANCE hinst
Definition: edit.c:551
#define IDS_SHGETPATHFROMIDLIST_FAILED
Definition: resource.h:188
#define malloc
Definition: debug_ros.c:4
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define GetWindowLongPtr
Definition: treelist.c:73
INT_PTR SendDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: send.cpp:423
#define IDS_GET_FILE_IDS_FAILED
Definition: resource.h:186
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define IDCANCEL
Definition: winuser.h:825
LONG_PTR LRESULT
Definition: windef.h:209
void CALLBACK SendSubvolW(HWND hwnd, HINSTANCE hinst, LPWSTR lpszCmdLine, int nCmdShow)
Definition: send.cpp:683
static struct msdos_boot_sector bs
Definition: mkdosfs.c:539
void clear()
Definition: _vector.h:650
#define LB_DELETESTRING
Definition: winuser.h:1993
#define memset(x, y, z)
Definition: compat.h:39
#define TOKEN_ADJUST_PRIVILEGES
Definition: setypes.h:876
#define args
Definition: format.c:66
void set_dpi_aware()
Definition: main.cpp:50
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
struct CFHEADER header
Definition: fdi.c:109
HANDLE thread
Definition: send.h:58
#define DELETE
Definition: nt_native.h:57
void utf8_to_utf16(const string &utf8, wstring &utf16)
Definition: main.cpp:667
void command_line_to_args(LPWSTR cmdline, vector< wstring > args)
Definition: main.cpp:610
Definition: fci.c:126
#define IDS_RECV_GETVOLUMEPATHNAME_FAILED
Definition: resource.h:168