ReactOS  0.4.15-dev-4863-gba0d16f
main.cpp File Reference
#include "shellext.h"
#include <windows.h>
#include <commctrl.h>
#include <strsafe.h>
#include <stddef.h>
#include <stdexcept>
#include "factory.h"
#include "resource.h"
Include dependency graph for main.cpp:

Go to the source code of this file.

Macros

#define COM_DESCRIPTION_ICON_HANDLER   L"WinBtrfs shell extension (icon handler)"
 
#define COM_DESCRIPTION_CONTEXT_MENU   L"WinBtrfs shell extension (context menu)"
 
#define COM_DESCRIPTION_PROP_SHEET   L"WinBtrfs shell extension (property sheet)"
 
#define COM_DESCRIPTION_VOL_PROP_SHEET   L"WinBtrfs shell extension (volume property sheet)"
 
#define ICON_OVERLAY_NAME   L"WinBtrfs"
 

Typedefs

typedef enum _PROCESS_DPI_AWARENESS PROCESS_DPI_AWARENESS
 
typedef ULONG(WINAPI_RtlNtStatusToDosError) (NTSTATUS Status)
 
typedef HRESULT(WINAPI_SetProcessDpiAwareness) (PROCESS_DPI_AWARENESS value)
 

Enumerations

enum  _PROCESS_DPI_AWARENESS { PROCESS_DPI_UNAWARE, PROCESS_SYSTEM_DPI_AWARE, PROCESS_PER_MONITOR_DPI_AWARE }
 

Functions

void set_dpi_aware ()
 
void format_size (uint64_t size, wstring &s, bool show_bytes)
 
wstring format_message (ULONG last_error)
 
wstring format_ntstatus (NTSTATUS Status)
 
bool load_string (HMODULE module, UINT id, wstring &s)
 
void wstring_sprintf (wstring &s, wstring fmt,...)
 
STDAPI DllCanUnloadNow (void)
 
STDAPI DllGetClassObject (REFCLSID rclsid, REFIID riid, LPVOID *ppv)
 
static void write_reg_key (HKEY root, const wstring &keyname, const WCHAR *val, const wstring &data)
 
static void register_clsid (const GUID clsid, const WCHAR *description)
 
static void reg_delete_tree (HKEY hkey, const wstring &keyname)
 
static void unregister_clsid (const GUID clsid)
 
static void reg_icon_overlay (const GUID clsid, const wstring &name)
 
static void unreg_icon_overlay (const wstring &name)
 
static void reg_context_menu_handler (const GUID clsid, const wstring &filetype, const wstring &name)
 
static void unreg_context_menu_handler (const wstring &filetype, const wstring &name)
 
static void reg_prop_sheet_handler (const GUID clsid, const wstring &filetype, const wstring &name)
 
static void unreg_prop_sheet_handler (const wstring &filetype, const wstring &name)
 
STDAPI DllRegisterServer (void)
 
STDAPI DllUnregisterServer (void)
 
STDAPI DllInstall (BOOL bInstall, LPCWSTR pszCmdLine)
 
BOOL APIENTRY DllMain (HANDLE hModule, DWORD dwReason, void *lpReserved)
 
static void create_subvol (const wstring &fn)
 
void CALLBACK CreateSubvolW (HWND hwnd, HINSTANCE hinst, LPWSTR lpszCmdLine, int nCmdShow)
 
static void create_snapshot2 (const wstring &source, const wstring &fn)
 
void CALLBACK CreateSnapshotW (HWND hwnd, HINSTANCE hinst, LPWSTR lpszCmdLine, int nCmdShow)
 
void command_line_to_args (LPWSTR cmdline, vector< wstring > &args)
 
static string utf16_to_utf8 (const wstring_view &utf16)
 
wstring utf8_to_utf16 (const string_view &utf8)
 
void error_message (HWND hwnd, const char *msg)
 

Variables

static const GUID CLSID_ShellBtrfsIconHandler = { 0x2690b74f, 0xf353, 0x422d, { 0xbb, 0x12, 0x40, 0x15, 0x81, 0xee, 0xf8, 0xf0 } }
 
static const GUID CLSID_ShellBtrfsContextMenu = { 0x2690b74f, 0xf353, 0x422d, { 0xbb, 0x12, 0x40, 0x15, 0x81, 0xee, 0xf8, 0xf1 } }
 
static const GUID CLSID_ShellBtrfsPropSheet = { 0x2690b74f, 0xf353, 0x422d, { 0xbb, 0x12, 0x40, 0x15, 0x81, 0xee, 0xf8, 0xf2 } }
 
static const GUID CLSID_ShellBtrfsVolPropSheet = { 0x2690b74f, 0xf353, 0x422d, { 0xbb, 0x12, 0x40, 0x15, 0x81, 0xee, 0xf8, 0xf3 } }
 
HMODULE module
 
LONG objs_loaded = 0
 

Macro Definition Documentation

◆ COM_DESCRIPTION_CONTEXT_MENU

#define COM_DESCRIPTION_CONTEXT_MENU   L"WinBtrfs shell extension (context menu)"

Definition at line 33 of file main.cpp.

◆ COM_DESCRIPTION_ICON_HANDLER

#define COM_DESCRIPTION_ICON_HANDLER   L"WinBtrfs shell extension (icon handler)"

Definition at line 32 of file main.cpp.

◆ COM_DESCRIPTION_PROP_SHEET

#define COM_DESCRIPTION_PROP_SHEET   L"WinBtrfs shell extension (property sheet)"

Definition at line 34 of file main.cpp.

◆ COM_DESCRIPTION_VOL_PROP_SHEET

#define COM_DESCRIPTION_VOL_PROP_SHEET   L"WinBtrfs shell extension (volume property sheet)"

Definition at line 35 of file main.cpp.

◆ ICON_OVERLAY_NAME

#define ICON_OVERLAY_NAME   L"WinBtrfs"

Definition at line 36 of file main.cpp.

Typedef Documentation

◆ _RtlNtStatusToDosError

typedef ULONG(WINAPI * _RtlNtStatusToDosError) (NTSTATUS Status)

Definition at line 44 of file main.cpp.

◆ _SetProcessDpiAwareness

typedef HRESULT(WINAPI * _SetProcessDpiAwareness) (PROCESS_DPI_AWARENESS value)

Definition at line 45 of file main.cpp.

◆ PROCESS_DPI_AWARENESS

Enumeration Type Documentation

◆ _PROCESS_DPI_AWARENESS

Enumerator
PROCESS_DPI_UNAWARE 
PROCESS_SYSTEM_DPI_AWARE 
PROCESS_PER_MONITOR_DPI_AWARE 

Definition at line 38 of file main.cpp.

Function Documentation

◆ command_line_to_args()

void command_line_to_args ( LPWSTR  cmdline,
vector< wstring > &  args 
)

Definition at line 645 of file main.cpp.

645  {
646  LPWSTR* l;
647  int num_args;
648 
649  args.clear();
650 
651  l = CommandLineToArgvW(cmdline, &num_args);
652 
653  if (!l)
654  return;
655 
656  try {
657  args.reserve(num_args);
658 
659  for (unsigned int i = 0; i < (unsigned int)num_args; i++) {
660  args.push_back(l[i]);
661  }
662  } catch (...) {
663  LocalFree(l);
664  throw;
665  }
666 
667  LocalFree(l);
668 }
TCHAR * cmdline
Definition: stretchblt.cpp:32
Definition: match.c:390
LPWSTR *WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int *numargs)
Definition: shell32_main.c:80
r l[0]
Definition: byte_order.h:167
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
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
WCHAR * LPWSTR
Definition: xmlstorage.h:184
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by CreateSnapshotW(), CreateSubvolW(), RecvSubvolW(), ReflinkCopyW(), SendSubvolW(), StartScrubW(), and StopScrubW().

◆ create_snapshot2()

static void create_snapshot2 ( const wstring &  source,
const wstring &  fn 
)
static

Definition at line 599 of file main.cpp.

599  {
600  size_t found = fn.rfind(L"\\");
601  wstring path, file;
602  win_handle h, src;
605 
606  if (found == wstring::npos) {
607  path = L"";
608  file = fn;
609  } else {
610  path = fn.substr(0, found);
611  file = fn.substr(found + 1);
612  }
613  path += L"\\";
614 
616  if (src == INVALID_HANDLE_VALUE)
617  return;
618 
620 
621  if (h == INVALID_HANDLE_VALUE)
622  return;
623 
624  size_t bcslen = offsetof(btrfs_create_snapshot, name[0]) + (file.length() * sizeof(WCHAR));
625  bcs = (btrfs_create_snapshot*)malloc(bcslen);
626 
627  bcs->readonly = false;
628  bcs->posix = false;
629  bcs->namelen = (uint16_t)(file.length() * sizeof(WCHAR));
630  memcpy(bcs->name, file.c_str(), bcs->namelen);
631  bcs->subvol = src;
632 
633  NtFsControlFile(h, nullptr, nullptr, nullptr, &iosb, FSCTL_BTRFS_CREATE_SNAPSHOT, bcs, (ULONG)bcslen, nullptr, 0);
634 }
static PIO_STATUS_BLOCK iosb
Definition: file.c:98
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
GLsizei const GLchar ** path
Definition: glext.h:7234
static const size_t npos
Definition: _string_npos.h:26
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define uint16_t
Definition: nsiface.idl:60
#define FILE_SHARE_READ
Definition: compat.h:136
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define FILE_TRAVERSE
Definition: nt_native.h:643
#define L(x)
Definition: ntvdm.h:50
#define FSCTL_BTRFS_CREATE_SNAPSHOT
Definition: btrfsioctl.h:9
#define offsetof(TYPE, MEMBER)
#define OPEN_EXISTING
Definition: compat.h:634
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)
__wchar_t WCHAR
Definition: xmlstorage.h:180
const char file[]
Definition: icontest.c:11
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
#define FILE_ADD_SUBDIRECTORY
Definition: nt_native.h:635
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum src
Definition: glext.h:6340
#define CreateFileW
Definition: compat.h:600
Definition: name.c:38
#define FILE_FLAG_BACKUP_SEMANTICS
Definition: disk.h:41
unsigned int ULONG
Definition: retypes.h:1
#define malloc
Definition: debug_ros.c:4
Definition: fci.c:126

Referenced by CreateSnapshotW().

◆ create_subvol()

static void create_subvol ( const wstring &  fn)
static

Definition at line 558 of file main.cpp.

558  {
559  size_t found = fn.rfind(L"\\");
560  wstring path, file;
561  win_handle h;
562  btrfs_create_subvol* bcs;
564 
565  if (found == wstring::npos) {
566  path = L"";
567  file = fn;
568  } else {
569  path = fn.substr(0, found);
570  file = fn.substr(found + 1);
571  }
572  path += L"\\";
573 
575 
576  if (h == INVALID_HANDLE_VALUE)
577  return;
578 
579  size_t bcslen = offsetof(btrfs_create_subvol, name[0]) + (file.length() * sizeof(WCHAR));
580  bcs = (btrfs_create_subvol*)malloc(bcslen);
581 
582  bcs->readonly = false;
583  bcs->posix = false;
584  bcs->namelen = (uint16_t)(file.length() * sizeof(WCHAR));
585  memcpy(bcs->name, file.c_str(), bcs->namelen);
586 
587  NtFsControlFile(h, nullptr, nullptr, nullptr, &iosb, FSCTL_BTRFS_CREATE_SUBVOL, bcs, (ULONG)bcslen, nullptr, 0);
588 }
static PIO_STATUS_BLOCK iosb
Definition: file.c:98
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
GLsizei const GLchar ** path
Definition: glext.h:7234
static const size_t npos
Definition: _string_npos.h:26
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define uint16_t
Definition: nsiface.idl:60
#define FILE_SHARE_READ
Definition: compat.h:136
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define L(x)
Definition: ntvdm.h:50
#define offsetof(TYPE, MEMBER)
#define OPEN_EXISTING
Definition: compat.h:634
#define FSCTL_BTRFS_CREATE_SUBVOL
Definition: btrfsioctl.h:8
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)
__wchar_t WCHAR
Definition: xmlstorage.h:180
const char file[]
Definition: icontest.c:11
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
#define FILE_ADD_SUBDIRECTORY
Definition: nt_native.h:635
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define CreateFileW
Definition: compat.h:600
Definition: name.c:38
#define FILE_FLAG_BACKUP_SEMANTICS
Definition: disk.h:41
unsigned int ULONG
Definition: retypes.h:1
#define malloc
Definition: debug_ros.c:4
Definition: fci.c:126

Referenced by CreateSubvolW().

◆ CreateSnapshotW()

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

Definition at line 636 of file main.cpp.

636  {
638 
639  command_line_to_args(lpszCmdLine, args);
640 
641  if (args.size() >= 2)
642  create_snapshot2(args[0], args[1]);
643 }
#define args
Definition: format.c:66
Definition: match.c:390
static void create_snapshot2(const wstring &source, const wstring &fn)
Definition: main.cpp:599
void command_line_to_args(LPWSTR cmdline, vector< wstring > &args)
Definition: main.cpp:645

◆ CreateSubvolW()

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

Definition at line 590 of file main.cpp.

590  {
592 
593  command_line_to_args(lpszCmdLine, args);
594 
595  if (args.size() >= 1)
596  create_subvol(args[0]);
597 }
#define args
Definition: format.c:66
static void create_subvol(const wstring &fn)
Definition: main.cpp:558
Definition: match.c:390
void command_line_to_args(LPWSTR cmdline, vector< wstring > &args)
Definition: main.cpp:645

◆ DllCanUnloadNow()

STDAPI DllCanUnloadNow ( void  )

Definition at line 246 of file main.cpp.

246  {
247  return objs_loaded == 0 ? S_OK : S_FALSE;
248 }
#define S_FALSE
Definition: winerror.h:2357
LONG objs_loaded
Definition: main.cpp:48
#define S_OK
Definition: intsafe.h:52

◆ DllGetClassObject()

STDAPI DllGetClassObject ( REFCLSID  rclsid,
REFIID  riid,
LPVOID ppv 
)

Definition at line 250 of file main.cpp.

250  {
251  if (rclsid == CLSID_ShellBtrfsIconHandler) {
252  Factory* fact = new Factory;
253  if (!fact)
254  return E_OUTOFMEMORY;
255  else {
256  fact->type = FactoryIconHandler;
257 
258  return fact->QueryInterface(riid, ppv);
259  }
260  } else if (rclsid == CLSID_ShellBtrfsContextMenu) {
261  Factory* fact = new Factory;
262  if (!fact)
263  return E_OUTOFMEMORY;
264  else {
265  fact->type = FactoryContextMenu;
266 
267  return fact->QueryInterface(riid, ppv);
268  }
269  } else if (rclsid == CLSID_ShellBtrfsPropSheet) {
270  Factory* fact = new Factory;
271  if (!fact)
272  return E_OUTOFMEMORY;
273  else {
274  fact->type = FactoryPropSheet;
275 
276  return fact->QueryInterface(riid, ppv);
277  }
278  } else if (rclsid == CLSID_ShellBtrfsVolPropSheet) {
279  Factory* fact = new Factory;
280  if (!fact)
281  return E_OUTOFMEMORY;
282  else {
283  fact->type = FactoryVolPropSheet;
284 
285  return fact->QueryInterface(riid, ppv);
286  }
287  }
288 
290 }
HRESULT __stdcall QueryInterface(REFIID riid, void **ppObj)
Definition: factory.cpp:26
REFIID riid
Definition: precomp.h:44
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:2663
static const GUID CLSID_ShellBtrfsPropSheet
Definition: main.cpp:29
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static const GUID CLSID_ShellBtrfsContextMenu
Definition: main.cpp:28
factory_type type
Definition: factory.h:64
static const GUID CLSID_ShellBtrfsVolPropSheet
Definition: main.cpp:30
static const GUID CLSID_ShellBtrfsIconHandler
Definition: main.cpp:27

◆ DllInstall()

STDAPI DllInstall ( BOOL  bInstall,
LPCWSTR  pszCmdLine 
)

Definition at line 544 of file main.cpp.

544  {
545  if (bInstall)
546  return DllRegisterServer();
547  else
548  return DllUnregisterServer();
549 }
STDAPI DllRegisterServer(void)
Definition: main.cpp:500
STDAPI DllUnregisterServer(void)
Definition: main.cpp:523

◆ DllMain()

BOOL APIENTRY DllMain ( HANDLE  hModule,
DWORD  dwReason,
void lpReserved 
)

Definition at line 551 of file main.cpp.

551  {
554 
555  return true;
556 }
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
DWORD dwReason
Definition: misc.cpp:154
HANDLE HMODULE
Definition: typedefs.h:77
HMODULE hModule
Definition: animate.c:44

◆ DllRegisterServer()

STDAPI DllRegisterServer ( void  )

Definition at line 500 of file main.cpp.

500  {
501  try {
506 
508 
511 
515  } catch (const exception& e) {
516  error_message(nullptr, e.what());
517  return E_FAIL;
518  }
519 
520  return S_OK;
521 }
#define ICON_OVERLAY_NAME
Definition: main.cpp:36
#define E_FAIL
Definition: ddrawi.h:102
#define COM_DESCRIPTION_PROP_SHEET
Definition: main.cpp:34
static const GUID CLSID_ShellBtrfsPropSheet
Definition: main.cpp:29
#define COM_DESCRIPTION_ICON_HANDLER
Definition: main.cpp:32
#define L(x)
Definition: ntvdm.h:50
void error_message(HWND hwnd, const char *msg)
Definition: main.cpp:783
static void reg_prop_sheet_handler(const GUID clsid, const wstring &filetype, const wstring &name)
Definition: main.cpp:472
#define e
Definition: ke_i.h:82
static const GUID CLSID_ShellBtrfsContextMenu
Definition: main.cpp:28
static void register_clsid(const GUID clsid, const WCHAR *description)
Definition: main.cpp:310
#define S_OK
Definition: intsafe.h:52
static void reg_context_menu_handler(const GUID clsid, const wstring &filetype, const wstring &name)
Definition: main.cpp:444
#define COM_DESCRIPTION_CONTEXT_MENU
Definition: main.cpp:33
#define COM_DESCRIPTION_VOL_PROP_SHEET
Definition: main.cpp:35
static const GUID CLSID_ShellBtrfsVolPropSheet
Definition: main.cpp:30
static const GUID CLSID_ShellBtrfsIconHandler
Definition: main.cpp:27
static void reg_icon_overlay(const GUID clsid, const wstring &name)
Definition: main.cpp:414

Referenced by DllInstall().

◆ DllUnregisterServer()

STDAPI DllUnregisterServer ( void  )

Definition at line 523 of file main.cpp.

523  {
524  try {
529  unreg_context_menu_handler(L"Directory\\Background", ICON_OVERLAY_NAME);
531 
536  } catch (const exception& e) {
537  error_message(nullptr, e.what());
538  return E_FAIL;
539  }
540 
541  return S_OK;
542 }
#define ICON_OVERLAY_NAME
Definition: main.cpp:36
#define E_FAIL
Definition: ddrawi.h:102
static const GUID CLSID_ShellBtrfsPropSheet
Definition: main.cpp:29
#define L(x)
Definition: ntvdm.h:50
void error_message(HWND hwnd, const char *msg)
Definition: main.cpp:783
#define e
Definition: ke_i.h:82
static const GUID CLSID_ShellBtrfsContextMenu
Definition: main.cpp:28
static void unreg_prop_sheet_handler(const wstring &filetype, const wstring &name)
Definition: main.cpp:491
static void unregister_clsid(const GUID clsid)
Definition: main.cpp:394
#define S_OK
Definition: intsafe.h:52
static void unreg_context_menu_handler(const wstring &filetype, const wstring &name)
Definition: main.cpp:463
static void unreg_icon_overlay(const wstring &name)
Definition: main.cpp:435
static const GUID CLSID_ShellBtrfsVolPropSheet
Definition: main.cpp:30
static const GUID CLSID_ShellBtrfsIconHandler
Definition: main.cpp:27

Referenced by DllInstall().

◆ error_message()

void error_message ( HWND  hwnd,
const char msg 
)

Definition at line 783 of file main.cpp.

783  {
784  wstring title;
785 
787 
788  auto wmsg = utf8_to_utf16(msg);
789 
790  MessageBoxW(hwnd, wmsg.c_str(), title.c_str(), MB_ICONERROR);
791 }
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
wstring utf8_to_utf16(const string_view &utf8)
Definition: main.cpp:734
#define MB_ICONERROR
Definition: winuser.h:781
bool load_string(HMODULE module, UINT id, wstring &s)
Definition: main.cpp:206
#define msg(x)
Definition: auth_time.c:54
#define IDS_ERROR
Definition: resource.h:18
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4022
static char title[]
Definition: ps.c:92

Referenced by AddDeviceW(), BtrfsVolPropSheet::AddPages(), BtrfsPropSheet::AddPages(), BtrfsBalance::BalanceDlgProc(), BtrfsBalance::BalanceOptsDlgProc(), BtrfsDeviceAdd::DeviceAddDlgProc(), BtrfsVolPropSheet::DeviceDlgProc(), BtrfsDeviceResize::DeviceResizeDlgProc(), BtrfsChangeDriveLetter::DlgProc(), DllRegisterServer(), DllUnregisterServer(), BtrfsChangeDriveLetter::do_change(), BtrfsPropSheet::Initialize(), BtrfsContextMenu::InvokeCommand(), PauseBalanceW(), PropSheetDlgProc(), RecvSubvolGUIW(), RemoveDeviceW(), ResetStatsW(), ResizeDeviceW(), BtrfsScrub::ScrubDlgProc(), BtrfsSend::SendDlgProc(), SendSubvolGUIW(), ShowPropSheetW(), ShowScrubW(), SizeDetailsDlgProc(), StartBalanceW(), BtrfsVolPropSheet::StatsDlgProc(), StopBalanceW(), and BtrfsVolPropSheet::UsageDlgProc().

◆ format_message()

wstring format_message ( ULONG  last_error)

Definition at line 164 of file main.cpp.

164  {
165  WCHAR* buf;
166  wstring s;
167 
169  last_error, 0, (WCHAR*)&buf, 0, nullptr) == 0) {
170  return L"(error retrieving message)";
171  }
172 
173  s = buf;
174 
175  LocalFree(buf);
176 
177  // remove trailing newline
178  while (s.length() > 0 && (s.substr(s.length() - 1, 1) == L"\r" || s.substr(s.length() - 1, 1) == L"\n"))
179  s = s.substr(0, s.length() - 1);
180 
181  return s;
182 }
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define L(x)
Definition: ntvdm.h:50
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:416
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:420
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLdouble s
Definition: gl.h:2039
#define FORMAT_MESSAGE_IGNORE_INSERTS
Definition: winbase.h:417
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577

Referenced by format_ntstatus().

◆ format_ntstatus()

wstring format_ntstatus ( NTSTATUS  Status)

Definition at line 184 of file main.cpp.

184  {
186  wstring s;
187  HMODULE ntdll = LoadLibraryW(L"ntdll.dll");
188 
189  if (!ntdll)
190  return L"(error loading ntdll.dll)";
191 
192  RtlNtStatusToDosError = (_RtlNtStatusToDosError)GetProcAddress(ntdll, "RtlNtStatusToDosError");
193 
194  if (!RtlNtStatusToDosError) {
195  FreeLibrary(ntdll);
196  return L"(error loading RtlNtStatusToDosError)";
197  }
198 
200 
201  FreeLibrary(ntdll);
202 
203  return s;
204 }
#define L(x)
Definition: ntvdm.h:50
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
ULONG(WINAPI * _RtlNtStatusToDosError)(NTSTATUS Status)
Definition: main.cpp:44
#define LoadLibraryW(x)
Definition: compat.h:606
Status
Definition: gdiplustypes.h:24
#define FreeLibrary(x)
Definition: compat.h:607
GLdouble s
Definition: gl.h:2039
wstring format_message(ULONG last_error)
Definition: main.cpp:164
#define GetProcAddress(x, y)
Definition: compat.h:612

Referenced by BtrfsSend::AddClone(), BtrfsSend::BrowseParent(), BtrfsRecv::cmd_chmod(), BtrfsRecv::cmd_chown(), BtrfsRecv::cmd_clone(), BtrfsRecv::cmd_mkfile(), BtrfsRecv::cmd_removexattr(), BtrfsRecv::cmd_setxattr(), BtrfsRecv::cmd_snapshot(), BtrfsRecv::cmd_subvol(), BtrfsRecv::do_recv(), BtrfsBalance::RefreshBalanceDlg(), and BtrfsSend::Thread().

◆ format_size()

void format_size ( uint64_t  size,
wstring &  s,
bool  show_bytes 
)

Definition at line 65 of file main.cpp.

65  {
66  wstring t, bytes, kb, nb;
67  WCHAR nb2[255];
68  ULONG sr;
69  float f;
71  WCHAR dec[2], thou[4], grouping[64], *c;
72 #ifdef __REACTOS__
73  WCHAR buffer[64];
74 #endif
75 
76 #ifndef __REACTOS__
77  nb = to_wstring(size);
78 #else
79  swprintf(buffer, L"%I64d", size);
80  nb = wstring(buffer);
81 #endif
82 
83  GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, thou, sizeof(thou) / sizeof(WCHAR));
84 
85  dec[0] = '.'; dec[1] = 0; // not used, but silences gcc warning
86 
87  fmt.NumDigits = 0;
88  fmt.LeadingZero = 1;
89  fmt.lpDecimalSep = dec;
90  fmt.lpThousandSep = thou;
91  fmt.NegativeOrder = 0;
92 
93  // Grouping code copied from dlls/shlwapi/string.c in Wine - thank you
94 
95  fmt.Grouping = 0;
96  GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SGROUPING, grouping, sizeof(grouping) / sizeof(WCHAR));
97 
98  c = grouping;
99  while (*c) {
100  if (*c >= '0' && *c < '9') {
101  fmt.Grouping *= 10;
102  fmt.Grouping += *c - '0';
103  }
104 
105  c++;
106  }
107 
108  if (fmt.Grouping % 10 == 0)
109  fmt.Grouping /= 10;
110  else
111  fmt.Grouping *= 10;
112 
113  GetNumberFormatW(LOCALE_USER_DEFAULT, 0, nb.c_str(), &fmt, nb2, sizeof(nb2) / sizeof(WCHAR));
114 
115  if (size < 1024) {
117  throw last_error(GetLastError());
118 
119  wstring_sprintf(s, t, nb2);
120  return;
121  }
122 
123  if (show_bytes) {
125  throw last_error(GetLastError());
126 
127  wstring_sprintf(bytes, t, nb2);
128  }
129 
130  if (size >= 1152921504606846976) {
131  sr = IDS_SIZE_EB;
132  f = (float)size / 1152921504606846976.0f;
133  } else if (size >= 1125899906842624) {
134  sr = IDS_SIZE_PB;
135  f = (float)size / 1125899906842624.0f;
136  } else if (size >= 1099511627776) {
137  sr = IDS_SIZE_TB;
138  f = (float)size / 1099511627776.0f;
139  } else if (size >= 1073741824) {
140  sr = IDS_SIZE_GB;
141  f = (float)size / 1073741824.0f;
142  } else if (size >= 1048576) {
143  sr = IDS_SIZE_MB;
144  f = (float)size / 1048576.0f;
145  } else {
146  sr = IDS_SIZE_KB;
147  f = (float)size / 1024.0f;
148  }
149 
150  if (!load_string(module, sr, t))
151  throw last_error(GetLastError());
152 
153  if (show_bytes) {
154  wstring_sprintf(kb, t, f);
155 
157  throw last_error(GetLastError());
158 
159  wstring_sprintf(s, t, kb.c_str(), bytes.c_str());
160  } else
161  wstring_sprintf(s, t, f);
162 }
#define IDS_SIZE_KB
Definition: resource.h:32
#define LOCALE_SGROUPING
Definition: winnls.h:44
#define IDS_SIZE_BYTES
Definition: resource.h:31
#define LOCALE_USER_DEFAULT
#define IDS_SIZE_PB
Definition: resource.h:36
const char * fmt
Definition: wsprintf.c:30
GLdouble GLdouble t
Definition: gl.h:2047
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
GLuint buffer
Definition: glext.h:5915
ios_base &_STLP_CALL dec(ios_base &__s)
Definition: _ios_base.h:321
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1102
#define L(x)
Definition: ntvdm.h:50
#define LOCALE_STHOUSAND
Definition: winnls.h:43
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
void wstring_sprintf(wstring &s, wstring fmt,...)
Definition: main.cpp:225
GLfloat f
Definition: glext.h:7540
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
const GLubyte * c
Definition: glext.h:8905
#define IDS_SIZE_TB
Definition: resource.h:35
#define IDS_SIZE_BYTE
Definition: resource.h:30
GLdouble s
Definition: gl.h:2039
bool load_string(HMODULE module, UINT id, wstring &s)
Definition: main.cpp:206
int _cdecl swprintf(const WCHAR *,...)
#define IDS_SIZE_EB
Definition: resource.h:37
static float(__cdecl *square_half_float)(float x
#define IDS_SIZE_LARGE
Definition: resource.h:42
#define f
Definition: ke_i.h:83
#define c
Definition: ke_i.h:80
unsigned int ULONG
Definition: retypes.h:1
INT WINAPI GetNumberFormatW(LCID lcid, DWORD dwFlags, LPCWSTR lpszValue, const NUMBERFMTW *lpFormat, LPWSTR lpNumberStr, int cchOut)
Definition: lcformat.c:1198
#define IDS_SIZE_GB
Definition: resource.h:34
Definition: dsound.c:943
#define IDS_SIZE_MB
Definition: resource.h:33

Referenced by BtrfsDeviceResize::DeviceResizeDlgProc(), BtrfsDeviceResize::do_resize(), BtrfsVolPropSheet::FormatUsage(), midi_IDirectMusicPort_GetFormat(), BtrfsDeviceAdd::populate_device_tree(), BtrfsVolPropSheet::RefreshDevList(), BtrfsPropSheet::set_size_on_disk(), BtrfsPropSheet::update_size_details_dialog(), and BtrfsScrub::UpdateTextBox().

◆ load_string()

bool load_string ( HMODULE  module,
UINT  id,
wstring &  s 
)

Definition at line 206 of file main.cpp.

206  {
207  int len;
208  LPWSTR retstr = nullptr;
209 
210  len = LoadStringW(module, id, (LPWSTR)&retstr, 0);
211 
212  if (len == 0)
213  return false;
214 
215  s = wstring(retstr, len);
216 
217  return true;
218 }
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
GLenum GLsizei len
Definition: glext.h:6722
GLdouble s
Definition: gl.h:2039
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by error_message(), format_size(), and string_error::string_error().

◆ reg_context_menu_handler()

static void reg_context_menu_handler ( const GUID  clsid,
const wstring &  filetype,
const wstring &  name 
)
static

Definition at line 444 of file main.cpp.

444  {
445  WCHAR* clsidstring;
446 
447  StringFromCLSID(clsid, &clsidstring);
448 
449  try {
450 #ifndef __REACTOS__
451  wstring path = filetype + L"\\ShellEx\\ContextMenuHandlers\\"s + name;
452 #else
453  wstring path = filetype + wstring(L"\\ShellEx\\ContextMenuHandlers\\") + name;
454 #endif
455 
456  write_reg_key(HKEY_CLASSES_ROOT, path, nullptr, clsidstring);
457  } catch (...) {
458  CoTaskMemFree(clsidstring);
459  throw;
460  }
461 }
static void write_reg_key(HKEY root, const wstring &keyname, const WCHAR *val, const wstring &data)
Definition: main.cpp:292
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
#define L(x)
Definition: ntvdm.h:50
__wchar_t WCHAR
Definition: xmlstorage.h:180
REFCLSID clsid
Definition: msctf.c:82
GLdouble s
Definition: gl.h:2039
LOCAL char * filetype(int t)
Definition: tree.c:114
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
HRESULT WINAPI StringFromCLSID(REFCLSID id, LPOLESTR *idstr)
Definition: compobj.c:2412
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by DllRegisterServer().

◆ reg_delete_tree()

static void reg_delete_tree ( HKEY  hkey,
const wstring &  keyname 
)
static

Definition at line 342 of file main.cpp.

342  {
343  HKEY k;
344  LSTATUS ret;
345 
346  ret = RegOpenKeyExW(hkey, keyname.c_str(), 0, KEY_READ, &k);
347 
348  if (ret != ERROR_SUCCESS)
349  throw last_error(ret);
350 
351  try {
352  WCHAR* buf;
353  ULONG bufsize;
354 
355  ret = RegQueryInfoKeyW(k, nullptr, nullptr, nullptr, nullptr, &bufsize, nullptr,
356  nullptr, nullptr, nullptr, nullptr, nullptr);
357  if (ret != ERROR_SUCCESS)
358  throw last_error(ret);
359 
360  bufsize++;
361  buf = new WCHAR[bufsize];
362 
363  try {
364  do {
365  ULONG size = bufsize;
366 
367  ret = RegEnumKeyExW(k, 0, buf, &size, nullptr, nullptr, nullptr, nullptr);
368 
369  if (ret == ERROR_NO_MORE_ITEMS)
370  break;
371  else if (ret != ERROR_SUCCESS)
372  throw last_error(ret);
373 
375  } while (true);
376 
377  ret = RegDeleteKeyW(hkey, keyname.c_str());
378  if (ret != ERROR_SUCCESS)
379  throw last_error(ret);
380  } catch (...) {
381  delete[] buf;
382  throw;
383  }
384 
385  delete[] buf;
386  } catch (...) {
387  RegCloseKey(k);
388  throw;
389  }
390 
391  RegCloseKey(k);
392 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:105
#define KEY_READ
Definition: nt_native.h:1023
static void reg_delete_tree(HKEY hkey, const wstring &keyname)
Definition: main.cpp:342
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1237
GLenum GLuint GLsizei bufsize
Definition: glext.h:7473
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
LONG WINAPI RegQueryInfoKeyW(HKEY hKey, LPWSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, LPDWORD lpcMaxClassLen, LPDWORD lpcValues, LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen, LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime)
Definition: reg.c:3690
int ret
unsigned int ULONG
Definition: retypes.h:1
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2527
int k
Definition: mpi.c:3369
#define RegCloseKey(hKey)
Definition: registry.h:47

Referenced by unreg_context_menu_handler(), unreg_icon_overlay(), unreg_prop_sheet_handler(), and unregister_clsid().

◆ reg_icon_overlay()

static void reg_icon_overlay ( const GUID  clsid,
const wstring &  name 
)
static

Definition at line 414 of file main.cpp.

414  {
415  WCHAR* clsidstring;
416 
417  StringFromCLSID(clsid, &clsidstring);
418 
419  try {
420 #ifndef __REACTOS__
421  wstring path = L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ShellIconOverlayIdentifiers\\"s + name;
422 #else
423  wstring path = wstring(L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ShellIconOverlayIdentifiers\\") + name;
424 #endif
425 
426  write_reg_key(HKEY_LOCAL_MACHINE, path, nullptr, clsidstring);
427  } catch (...) {
428  CoTaskMemFree(clsidstring);
429  throw;
430  }
431 
432  CoTaskMemFree(clsidstring);
433 }
static void write_reg_key(HKEY root, const wstring &keyname, const WCHAR *val, const wstring &data)
Definition: main.cpp:292
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
#define L(x)
Definition: ntvdm.h:50
__wchar_t WCHAR
Definition: xmlstorage.h:180
REFCLSID clsid
Definition: msctf.c:82
GLdouble s
Definition: gl.h:2039
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
HRESULT WINAPI StringFromCLSID(REFCLSID id, LPOLESTR *idstr)
Definition: compobj.c:2412
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by DllRegisterServer().

◆ reg_prop_sheet_handler()

static void reg_prop_sheet_handler ( const GUID  clsid,
const wstring &  filetype,
const wstring &  name 
)
static

Definition at line 472 of file main.cpp.

472  {
473  WCHAR* clsidstring;
474 
475  StringFromCLSID(clsid, &clsidstring);
476 
477  try {
478 #ifndef __REACTOS__
479  wstring path = filetype + L"\\ShellEx\\PropertySheetHandlers\\"s + name;
480 #else
481  wstring path = filetype + wstring(L"\\ShellEx\\PropertySheetHandlers\\") + name;
482 #endif
483 
484  write_reg_key(HKEY_CLASSES_ROOT, path, nullptr, clsidstring);
485  } catch (...) {
486  CoTaskMemFree(clsidstring);
487  throw;
488  }
489 }
static void write_reg_key(HKEY root, const wstring &keyname, const WCHAR *val, const wstring &data)
Definition: main.cpp:292
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
#define L(x)
Definition: ntvdm.h:50
__wchar_t WCHAR
Definition: xmlstorage.h:180
REFCLSID clsid
Definition: msctf.c:82
GLdouble s
Definition: gl.h:2039
LOCAL char * filetype(int t)
Definition: tree.c:114
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
HRESULT WINAPI StringFromCLSID(REFCLSID id, LPOLESTR *idstr)
Definition: compobj.c:2412
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by DllRegisterServer().

◆ register_clsid()

static void register_clsid ( const GUID  clsid,
const WCHAR description 
)
static

Definition at line 310 of file main.cpp.

310  {
311  WCHAR* clsidstring;
312  wstring inproc, clsidkeyname;
314 
315  StringFromCLSID(clsid, &clsidstring);
316 
317  try {
318 #ifndef __REACTOS__
319  inproc = L"CLSID\\"s + clsidstring + L"\\InprocServer32"s;
320  clsidkeyname = L"CLSID\\"s + clsidstring;
321 #else
322  inproc = wstring(L"CLSID\\") + clsidstring + wstring(L"\\InprocServer32");
323  clsidkeyname = wstring(L"CLSID\\") + clsidstring;
324 #endif
325 
326  write_reg_key(HKEY_CLASSES_ROOT, clsidkeyname, nullptr, description);
327 
328  GetModuleFileNameW(module, dllpath, sizeof(dllpath) / sizeof(WCHAR));
329 
330  write_reg_key(HKEY_CLASSES_ROOT, inproc, nullptr, dllpath);
331 
332  write_reg_key(HKEY_CLASSES_ROOT, inproc, L"ThreadingModel", L"Apartment");
333  } catch (...) {
334  CoTaskMemFree(clsidstring);
335  throw;
336  }
337 
338  CoTaskMemFree(clsidstring);
339 }
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
static void write_reg_key(HKEY root, const wstring &keyname, const WCHAR *val, const wstring &data)
Definition: main.cpp:292
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
const char * description
Definition: directx.c:2497
#define L(x)
Definition: ntvdm.h:50
WCHAR dllpath[MAX_PATH]
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
REFCLSID clsid
Definition: msctf.c:82
GLdouble s
Definition: gl.h:2039
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
HRESULT WINAPI StringFromCLSID(REFCLSID id, LPOLESTR *idstr)
Definition: compobj.c:2412

Referenced by DllRegisterServer().

◆ set_dpi_aware()

void set_dpi_aware ( )

Definition at line 50 of file main.cpp.

50  {
51  _SetProcessDpiAwareness SetProcessDpiAwareness;
52  HMODULE shcore = LoadLibraryW(L"shcore.dll");
53 
54  if (!shcore)
55  return;
56 
57  SetProcessDpiAwareness = (_SetProcessDpiAwareness)GetProcAddress(shcore, "SetProcessDpiAwareness");
58 
59  if (!SetProcessDpiAwareness)
60  return;
61 
62  SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE);
63 }
HRESULT(WINAPI * _SetProcessDpiAwareness)(PROCESS_DPI_AWARENESS value)
Definition: main.cpp:45
#define L(x)
Definition: ntvdm.h:50
#define LoadLibraryW(x)
Definition: compat.h:606
#define GetProcAddress(x, y)
Definition: compat.h:612

Referenced by AddDeviceW(), RecvSubvolGUIW(), RemoveDeviceW(), ResetStatsW(), ResizeDeviceW(), SendSubvolGUIW(), ShowPropSheetW(), and ShowScrubW().

◆ unreg_context_menu_handler()

static void unreg_context_menu_handler ( const wstring &  filetype,
const wstring &  name 
)
static

Definition at line 463 of file main.cpp.

463  {
464 #ifndef __REACTOS__
465  reg_delete_tree(HKEY_CLASSES_ROOT, filetype + L"\\ShellEx\\ContextMenuHandlers\\"s + name);
466 #else
467  wstring path = filetype + wstring(L"\\ShellEx\\ContextMenuHandlers\\") + name;
469 #endif
470 }
static void reg_delete_tree(HKEY hkey, const wstring &keyname)
Definition: main.cpp:342
#define L(x)
Definition: ntvdm.h:50
GLdouble s
Definition: gl.h:2039
Definition: name.c:38
LOCAL char * filetype(int t)
Definition: tree.c:114
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by DllUnregisterServer().

◆ unreg_icon_overlay()

static void unreg_icon_overlay ( const wstring &  name)
static

Definition at line 435 of file main.cpp.

435  {
436 #ifndef __REACTOS__
437  reg_delete_tree(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ShellIconOverlayIdentifiers\\"s + name);
438 #else
439  wstring path = wstring(L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ShellIconOverlayIdentifiers\\") + name;
441 #endif
442 }
static void reg_delete_tree(HKEY hkey, const wstring &keyname)
Definition: main.cpp:342
#define L(x)
Definition: ntvdm.h:50
GLdouble s
Definition: gl.h:2039
Definition: name.c:38
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by DllUnregisterServer().

◆ unreg_prop_sheet_handler()

static void unreg_prop_sheet_handler ( const wstring &  filetype,
const wstring &  name 
)
static

Definition at line 491 of file main.cpp.

491  {
492 #ifndef __REACTOS__
493  reg_delete_tree(HKEY_CLASSES_ROOT, filetype + L"\\ShellEx\\PropertySheetHandlers\\"s + name);
494 #else
495  wstring path = filetype + wstring(L"\\ShellEx\\PropertySheetHandlers\\") + name;
497 #endif
498 }
static void reg_delete_tree(HKEY hkey, const wstring &keyname)
Definition: main.cpp:342
#define L(x)
Definition: ntvdm.h:50
GLdouble s
Definition: gl.h:2039
Definition: name.c:38
LOCAL char * filetype(int t)
Definition: tree.c:114
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by DllUnregisterServer().

◆ unregister_clsid()

static void unregister_clsid ( const GUID  clsid)
static

Definition at line 394 of file main.cpp.

394  {
395  WCHAR* clsidstring;
396 
397  StringFromCLSID(clsid, &clsidstring);
398 
399  try {
400 #ifndef __REACTOS__
401  reg_delete_tree(HKEY_CLASSES_ROOT, L"CLSID\\"s + clsidstring);
402 #else
403  wstring path = wstring(L"CLSID\\") + clsidstring;
405 #endif
406  } catch (...) {
407  CoTaskMemFree(clsidstring);
408  throw;
409  }
410 
411  CoTaskMemFree(clsidstring);
412 }
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
static void reg_delete_tree(HKEY hkey, const wstring &keyname)
Definition: main.cpp:342
#define L(x)
Definition: ntvdm.h:50
__wchar_t WCHAR
Definition: xmlstorage.h:180
REFCLSID clsid
Definition: msctf.c:82
GLdouble s
Definition: gl.h:2039
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
HRESULT WINAPI StringFromCLSID(REFCLSID id, LPOLESTR *idstr)
Definition: compobj.c:2412

Referenced by DllUnregisterServer().

◆ utf16_to_utf8()

static string utf16_to_utf8 ( const wstring_view &  utf16)
static

Definition at line 670 of file main.cpp.

670  {
671  string utf8;
672  char* buf;
673 
674  if (utf16.empty())
675  return "";
676 
677  auto utf8len = WideCharToMultiByte(CP_UTF8, 0, utf16.data(), static_cast<int>(utf16.length()), nullptr, 0, nullptr, nullptr);
678 
679  if (utf8len == 0)
680  throw last_error(GetLastError());
681 
682  buf = (char*)malloc(utf8len + sizeof(char));
683 
684  if (!buf)
686 
687  if (WideCharToMultiByte(CP_UTF8, 0, utf16.data(), static_cast<int>(utf16.length()), buf, utf8len, nullptr, nullptr) == 0) {
688  auto le = GetLastError();
689  free(buf);
690  throw last_error(le);
691  }
692 
693  buf[utf8len] = 0;
694 
695  utf8 = buf;
696 
697  free(buf);
698 
699  return utf8;
700 }
#define IDS_OUT_OF_MEMORY
Definition: resource.h:5
#define WideCharToMultiByte
Definition: compat.h:111
return static_cast< int >(global)
#define free
Definition: debug_ros.c:5
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define CP_UTF8
Definition: nls.h:20
#define malloc
Definition: debug_ros.c:4

Referenced by create_snapshot(), create_stream(), create_subvol(), file_create2(), last_error::last_error(), mknod(), ntstatus_error::ntstatus_error(), rename_file_to_stream(), rename_stream(), set_link_information(), set_rename_information(), set_symlink(), and string_error::string_error().

◆ utf8_to_utf16()

wstring utf8_to_utf16 ( const string_view &  utf8)

Definition at line 734 of file main.cpp.

734  {
735  wstring ret;
736  WCHAR* buf;
737 
738  if (utf8.empty())
739  return L"";
740 
741  auto utf16len = MultiByteToWideChar(CP_UTF8, 0, utf8.data(), (int)utf8.length(), nullptr, 0);
742 
743  if (utf16len == 0)
744  throw last_error(GetLastError());
745 
746  buf = (WCHAR*)malloc((utf16len + 1) * sizeof(WCHAR));
747 
748  if (!buf)
750 
751  if (MultiByteToWideChar(CP_UTF8, 0, utf8.data(), (int)utf8.length(), buf, utf16len) == 0) {
752  auto le = GetLastError();
753  free(buf);
754  throw last_error(le);
755  }
756 
757  buf[utf16len] = 0;
758 
759  ret = buf;
760 
761  free(buf);
762 
763  return ret;
764 }
#define IDS_OUT_OF_MEMORY
Definition: resource.h:5
#define free
Definition: debug_ros.c:5
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define L(x)
Definition: ntvdm.h:50
#define CP_UTF8
Definition: nls.h:20
__wchar_t WCHAR
Definition: xmlstorage.h:180
int ret
#define MultiByteToWideChar
Definition: compat.h:110
#define malloc
Definition: debug_ros.c:4
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by BtrfsRecv::cmd_chmod(), BtrfsRecv::cmd_chown(), BtrfsRecv::cmd_clone(), BtrfsRecv::cmd_link(), BtrfsRecv::cmd_mkfile(), BtrfsRecv::cmd_removexattr(), BtrfsRecv::cmd_rename(), BtrfsRecv::cmd_rmdir(), BtrfsRecv::cmd_setxattr(), BtrfsRecv::cmd_snapshot(), BtrfsRecv::cmd_subvol(), BtrfsRecv::cmd_truncate(), BtrfsRecv::cmd_unlink(), BtrfsRecv::cmd_utimes(), BtrfsRecv::cmd_write(), error_message(), get_reparse_block(), get_reparse_point(), load_dir_children(), log_file_checksum_error(), open_fcb(), open_fileref_by_inode(), BtrfsRecv::recv_thread(), BtrfsRecv::RecvProgressDlgProc(), and BtrfsSend::Thread().

◆ write_reg_key()

static void write_reg_key ( HKEY  root,
const wstring &  keyname,
const WCHAR val,
const wstring &  data 
)
static

Definition at line 292 of file main.cpp.

292  {
293  LONG l;
294  HKEY hk;
295  DWORD dispos;
296 
297  l = RegCreateKeyExW(root, keyname.c_str(), 0, nullptr, 0, KEY_ALL_ACCESS, nullptr, &hk, &dispos);
298  if (l != ERROR_SUCCESS)
300 
301  l = RegSetValueExW(hk, val, 0, REG_SZ, (const BYTE*)data.c_str(), (DWORD)((data.length() + 1) * sizeof(WCHAR)));
302  if (l != ERROR_SUCCESS)
304 
305  l = RegCloseKey(hk);
306  if (l != ERROR_SUCCESS)
308 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define IDS_REGSETVALUEEX_FAILED
Definition: resource.h:202
#define DWORD
Definition: nt_native.h:44
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1091
long LONG
Definition: pedump.c:60
GLuint GLfloat * val
Definition: glext.h:7180
r l[0]
Definition: byte_order.h:167
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4899
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
unsigned char BYTE
Definition: xxhash.c:193
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define IDS_REGCLOSEKEY_FAILED
Definition: resource.h:203
static ACCESS_MASK const OBJECT_ATTRIBUTES ULONG const UNICODE_STRING ULONG PULONG dispos
Definition: reg.c:130
#define IDS_REGCREATEKEY_FAILED
Definition: resource.h:201
#define RegCloseKey(hKey)
Definition: registry.h:47
#define REG_SZ
Definition: layer.c:22

Referenced by reg_context_menu_handler(), reg_icon_overlay(), reg_prop_sheet_handler(), and register_clsid().

◆ wstring_sprintf()

void wstring_sprintf ( wstring &  s,
wstring  fmt,
  ... 
)

Definition at line 225 of file main.cpp.

225  {
226  int len;
227  va_list args;
228 
229  va_start(args, fmt);
230  len = _vsnwprintf(nullptr, 0, fmt.c_str(), args);
231 
232  if (len == 0)
233  s = L"";
234  else {
235  s.resize(len);
236  _vsnwprintf((wchar_t*)s.c_str(), len, fmt.c_str(), args);
237  }
238 
239  va_end(args);
240 }
#define args
Definition: format.c:66
Definition: match.c:390
#define L(x)
Definition: ntvdm.h:50
#define va_end(ap)
Definition: acmsvcex.h:90
char * va_list
Definition: acmsvcex.h:78
va_start(ap, x)
GLenum GLsizei len
Definition: glext.h:6722
GLdouble s
Definition: gl.h:2039
_CRTIMP int __cdecl _vsnwprintf(wchar_t *_Dest, size_t _Count, const wchar_t *_Format, va_list _Args)
Definition: dsound.c:943

Referenced by BtrfsDeviceAdd::AddDevice(), BtrfsBalance::BalanceOptsDlgProc(), create_snapshot(), BtrfsVolPropSheet::DeviceDlgProc(), BtrfsDeviceResize::DeviceResizeDlgProc(), BtrfsDeviceResize::do_resize(), format_size(), BtrfsVolPropSheet::FormatUsage(), BtrfsPropSheet::init_propsheet(), BtrfsDeviceAdd::populate_device_tree(), PropSheetDlgProc(), BtrfsRecv::recv_thread(), BtrfsBalance::RefreshBalanceDlg(), BtrfsVolPropSheet::RefreshDevList(), BtrfsScrub::RefreshScrubDlg(), BtrfsPropSheet::set_size_on_disk(), BtrfsVolPropSheet::StatsDlgProc(), and BtrfsScrub::UpdateTextBox().

Variable Documentation

◆ CLSID_ShellBtrfsContextMenu

const GUID CLSID_ShellBtrfsContextMenu = { 0x2690b74f, 0xf353, 0x422d, { 0xbb, 0x12, 0x40, 0x15, 0x81, 0xee, 0xf8, 0xf1 } }
static

Definition at line 28 of file main.cpp.

Referenced by DllGetClassObject(), DllRegisterServer(), and DllUnregisterServer().

◆ CLSID_ShellBtrfsIconHandler

const GUID CLSID_ShellBtrfsIconHandler = { 0x2690b74f, 0xf353, 0x422d, { 0xbb, 0x12, 0x40, 0x15, 0x81, 0xee, 0xf8, 0xf0 } }
static

Definition at line 27 of file main.cpp.

Referenced by DllGetClassObject(), DllRegisterServer(), and DllUnregisterServer().

◆ CLSID_ShellBtrfsPropSheet

const GUID CLSID_ShellBtrfsPropSheet = { 0x2690b74f, 0xf353, 0x422d, { 0xbb, 0x12, 0x40, 0x15, 0x81, 0xee, 0xf8, 0xf2 } }
static

Definition at line 29 of file main.cpp.

Referenced by DllGetClassObject(), DllRegisterServer(), and DllUnregisterServer().

◆ CLSID_ShellBtrfsVolPropSheet

const GUID CLSID_ShellBtrfsVolPropSheet = { 0x2690b74f, 0xf353, 0x422d, { 0xbb, 0x12, 0x40, 0x15, 0x81, 0xee, 0xf8, 0xf3 } }
static

Definition at line 30 of file main.cpp.

Referenced by DllGetClassObject(), DllRegisterServer(), and DllUnregisterServer().

◆ module

Definition at line 47 of file main.cpp.

Referenced by BtrfsVolPropSheet::AddPages(), BtrfsPropSheet::AddPages(), af_face_globals_new(), BtrfsSend::Browse(), cache_connection(), cff_size_get_globals_funcs(), cff_slot_init(), check_hook_thread(), cid_size_get_globals_funcs(), cid_slot_init(), DECLARE_INTERFACE_(), do_register_dll(), dsound_enum(), dwarf2_parse(), dwarf2_parse_compilation_unit(), elf_load_cb(), elf_search_and_load_file(), elf_synchronize_module_list(), FT_Add_Module(), ft_add_renderer(), FT_Get_Module_Interface(), FxpGetImageBase(), get_process_name_from_pid(), http_release_netconn(), InternalIsOS2OrOldWin(), ITERATE_RegisterTypeLibraries(), ITypeInfo_fnAddressOfMember(), load_d3dcompiler(), load_d3dcompiler_43(), load_d3dcompiler_47(), load_libglu(), LoadShimDLL2(), macho_load_debug_info(), macho_search_and_load_file(), macho_synchronize_module_list(), msi_load_library(), pe_load_builtin_module(), pe_load_debug_directory(), pe_load_native_module(), RecvSubvolGUIW(), ResProtocolInfo_ParseUrl(), RtlCreateActivationContext(), setup_dll(), ShowPropSheetW(), source_new(), stabs_parse_typedef(), START_TEST(), SymFromName(), T1_GlyphSlot_Init(), T1_Size_Get_Globals_Funcs(), test_comctl32_class(), test_FakeDLL(), test_HashLinks(), test_md5_ctx(), test_queryvirtualmemory(), test_thread_start_address(), TIFFError(), TIFFErrorExt(), TIFFWarning(), TIFFWarningExt(), x86_64_fetch_minidump_module(), xsltGetExtData(), xsltInitCtxtExt(), xsltRegisterExtModuleFull(), xsltRegisterExtPrefix(), xsltShutdownCtxtExt(), xsltShutdownExt(), and xsltStyleInitializeStylesheetModule().

◆ objs_loaded