27 static const GUID CLSID_ShellBtrfsIconHandler = { 0x2690b74f, 0xf353, 0x422d, { 0xbb, 0x12, 0x40, 0x15, 0x81, 0xee, 0xf8, 0xf0 } };
28 static const GUID CLSID_ShellBtrfsContextMenu = { 0x2690b74f, 0xf353, 0x422d, { 0xbb, 0x12, 0x40, 0x15, 0x81, 0xee, 0xf8, 0xf1 } };
29 static const GUID CLSID_ShellBtrfsPropSheet = { 0x2690b74f, 0xf353, 0x422d, { 0xbb, 0x12, 0x40, 0x15, 0x81, 0xee, 0xf8, 0xf2 } };
30 static const GUID CLSID_ShellBtrfsVolPropSheet = { 0x2690b74f, 0xf353, 0x422d, { 0xbb, 0x12, 0x40, 0x15, 0x81, 0xee, 0xf8, 0xf3 } };
32 #define COM_DESCRIPTION_ICON_HANDLER L"WinBtrfs shell extension (icon handler)" 33 #define COM_DESCRIPTION_CONTEXT_MENU L"WinBtrfs shell extension (context menu)" 34 #define COM_DESCRIPTION_PROP_SHEET L"WinBtrfs shell extension (property sheet)" 35 #define COM_DESCRIPTION_VOL_PROP_SHEET L"WinBtrfs shell extension (volume property sheet)" 36 #define ICON_OVERLAY_NAME L"WinBtrfs" 59 if (!SetProcessDpiAwareness)
77 nb = to_wstring(
size);
90 fmt.lpThousandSep = thou;
91 fmt.NegativeOrder = 0;
100 if (*
c >=
'0' && *
c <
'9') {
102 fmt.Grouping += *
c -
'0';
108 if (
fmt.Grouping % 10 == 0)
130 if (
size >= 1152921504606846976) {
133 }
else if (
size >= 1125899906842624) {
136 }
else if (
size >= 1099511627776) {
139 }
else if (
size >= 1073741824) {
142 }
else if (
size >= 1048576) {
170 return L"(error retrieving message)";
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);
190 return L"(error loading ntdll.dll)";
196 return L"(error loading RtlNtStatusToDosError)";
215 s = wstring(retstr,
len);
221 #pragma warning(push) 222 #pragma warning(disable: 4996) 312 wstring inproc, clsidkeyname;
319 inproc =
L"CLSID\\"s + clsidstring +
L"\\InprocServer32"s;
320 clsidkeyname =
L"CLSID\\"s + clsidstring;
322 inproc = wstring(
L"CLSID\\") + clsidstring + wstring(
L"\\InprocServer32");
323 clsidkeyname = wstring(
L"CLSID\\") + clsidstring;
356 nullptr,
nullptr,
nullptr,
nullptr,
nullptr);
403 wstring
path = wstring(
L"CLSID\\") + clsidstring;
421 wstring
path =
L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ShellIconOverlayIdentifiers\\"s +
name;
423 wstring
path = wstring(
L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ShellIconOverlayIdentifiers\\") +
name;
439 wstring
path = wstring(
L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ShellIconOverlayIdentifiers\\") +
name;
559 size_t found =
fn.rfind(
L"\\");
569 path =
fn.substr(0, found);
570 file =
fn.substr(found + 1);
595 if (
args.size() >= 1)
600 size_t found =
fn.rfind(
L"\\");
610 path =
fn.substr(0, found);
611 file =
fn.substr(found + 1);
641 if (
args.size() >= 2)
657 args.reserve(num_args);
659 for (
unsigned int i = 0;
i < (
unsigned int)num_args;
i++) {
682 buf = (
char*)
malloc(utf8len +
sizeof(
char));
703 #pragma warning(push) 704 #pragma warning(disable: 4996) 770 errnum, 0, (
WCHAR*)&
buf, 0,
nullptr) == 0)
805 throw runtime_error(
"Error loading RtlNtStatusToDosError in ntdll.dll.");
#define IDS_OUT_OF_MEMORY
STDAPI DllRegisterServer(void)
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
static PIO_STATUS_BLOCK iosb
HRESULT(WINAPI * _SetProcessDpiAwareness)(PROCESS_DPI_AWARENESS value)
HRESULT __stdcall QueryInterface(REFIID riid, void **ppObj)
static void write_reg_key(HKEY root, const wstring &keyname, const WCHAR *val, const wstring &data)
VOID WINAPI CoTaskMemFree(LPVOID ptr)
wstring format_ntstatus(NTSTATUS Status)
#define WideCharToMultiByte
#define ICON_OVERLAY_NAME
#define ERROR_NO_MORE_ITEMS
ntstatus_error(NTSTATUS Status)
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
static GLenum _GLUfuncptr fn
static void create_subvol(const wstring &fn)
GLsizei const GLchar ** path
static void reg_delete_tree(HKEY hkey, const wstring &keyname)
#define LOCALE_USER_DEFAULT
return static_cast< int >(global)
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
#define INVALID_HANDLE_VALUE
DWORD WINAPI GetLastError(VOID)
#define DLL_PROCESS_ATTACH
ios_base &_STLP_CALL dec(ios_base &__s)
STDAPI DllCanUnloadNow(void)
enum _PROCESS_DPI_AWARENESS PROCESS_DPI_AWARENESS
GLenum GLuint GLsizei bufsize
#define IDS_REGSETVALUEEX_FAILED
#define CLASS_E_CLASSNOTAVAILABLE
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define COM_DESCRIPTION_PROP_SHEET
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)
static const GUID CLSID_ShellBtrfsPropSheet
#define COM_DESCRIPTION_ICON_HANDLER
GLfloat GLfloat GLfloat GLfloat h
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
string_error(int resno,...)
GLenum GLuint GLenum GLsizei const GLchar * buf
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
void error_message(HWND hwnd, const char *msg)
ULONG(WINAPI * _RtlNtStatusToDosError)(NTSTATUS Status)
static unsigned char bytes[4]
#define FSCTL_BTRFS_CREATE_SNAPSHOT
static void reg_prop_sheet_handler(const GUID clsid, const wstring &filetype, const wstring &name)
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
LPWSTR *WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int *numargs)
#define offsetof(TYPE, MEMBER)
static const GUID CLSID_ShellBtrfsContextMenu
static string utf16_to_utf8(const wstring_view &utf16)
#define FORMAT_MESSAGE_FROM_SYSTEM
#define FSCTL_BTRFS_CREATE_SUBVOL
void wstring_sprintf(wstring &s, wstring fmt,...)
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
static void register_clsid(const GUID clsid, const WCHAR *description)
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)
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
static void unreg_prop_sheet_handler(const wstring &filetype, const wstring &name)
wstring utf8_to_utf16(const string_view &utf8)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
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)
#define FILE_SHARE_DELETE
#define FILE_ADD_SUBDIRECTORY
#define memcpy(s1, s2, n)
STDAPI DllUnregisterServer(void)
GLsizei const GLfloat * value
bool load_string(HMODULE module, UINT id, wstring &s)
int _cdecl swprintf(const WCHAR *,...)
static void unregister_clsid(const GUID clsid)
void CALLBACK CreateSnapshotW(HWND hwnd, HINSTANCE hinst, LPWSTR lpszCmdLine, int nCmdShow)
#define FORMAT_MESSAGE_IGNORE_INSERTS
STDAPI DllInstall(BOOL bInstall, LPCWSTR pszCmdLine)
_CRTIMP int __cdecl _vsnwprintf(wchar_t *_Dest, size_t _Count, const wchar_t *_Format, va_list _Args)
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
static float(__cdecl *square_half_float)(float x
HLOCAL NTAPI LocalFree(HLOCAL hMem)
static void create_snapshot2(const wstring &source, const wstring &fn)
void command_line_to_args(LPWSTR cmdline, vector< wstring > &args)
wstring format_message(ULONG last_error)
#define MultiByteToWideChar
#define IDS_REGCLOSEKEY_FAILED
static ACCESS_MASK const OBJECT_ATTRIBUTES ULONG const UNICODE_STRING ULONG PULONG dispos
static void reg_context_menu_handler(const GUID clsid, const wstring &filetype, const wstring &name)
#define FILE_FLAG_BACKUP_SEMANTICS
static void unreg_context_menu_handler(const wstring &filetype, const wstring &name)
BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, void *lpReserved)
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
#define COM_DESCRIPTION_CONTEXT_MENU
void CALLBACK CreateSubvolW(HWND hwnd, HINSTANCE hinst, LPWSTR lpszCmdLine, int nCmdShow)
#define GetProcAddress(x, y)
#define HKEY_CLASSES_ROOT
#define COM_DESCRIPTION_VOL_PROP_SHEET
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)
#define IDS_REGCREATEKEY_FAILED
static void unreg_icon_overlay(const wstring &name)
#define RegCloseKey(hKey)
static const GUID CLSID_ShellBtrfsVolPropSheet
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
#define HKEY_LOCAL_MACHINE
HRESULT WINAPI StringFromCLSID(REFCLSID id, LPOLESTR *idstr)
static const GUID CLSID_ShellBtrfsIconHandler
void format_size(uint64_t size, wstring &s, bool show_bytes)
static void reg_icon_overlay(const GUID clsid, const wstring &name)
GLuint const GLchar * name