X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Fwin32_common.c;h=30f7d6238c9f8b20835debeebe2171b0491e6548;hb=5ec910e4e9126a37eed1ff199d55a1952c76e0f7;hp=6d75c47e26b44c12e79c1576d6b588b9ec99fea2;hpb=a92076249aa233d18ecc378062e654729e27c0d8;p=wimlib diff --git a/src/win32_common.c b/src/win32_common.c index 6d75c47e..30f7d623 100644 --- a/src/win32_common.c +++ b/src/win32_common.c @@ -62,16 +62,21 @@ out: static bool win32_modify_capture_privileges(bool enable) { - return win32_modify_privilege(SE_BACKUP_NAME, enable) - && win32_modify_privilege(SE_SECURITY_NAME, enable); + bool ok = true; + ok &= win32_modify_privilege(SE_BACKUP_NAME, enable); + ok &= win32_modify_privilege(SE_SECURITY_NAME, enable); + return ok; } static bool win32_modify_apply_privileges(bool enable) { - return win32_modify_privilege(SE_RESTORE_NAME, enable) - && win32_modify_privilege(SE_SECURITY_NAME, enable) - && win32_modify_privilege(SE_TAKE_OWNERSHIP_NAME, enable); + bool ok = true; + ok &= win32_modify_privilege(SE_RESTORE_NAME, enable); + ok &= win32_modify_privilege(SE_SECURITY_NAME, enable); + ok &= win32_modify_privilege(SE_TAKE_OWNERSHIP_NAME, enable); + ok &= win32_modify_privilege(SE_MANAGE_VOLUME_NAME, enable); + return ok; } static void @@ -350,8 +355,7 @@ win32_path_to_nt_path(const wchar_t *win32_path, UNICODE_STRING *nt_path) if (status == STATUS_NO_MEMORY) return WIMLIB_ERR_NOMEM; - ERROR("\"%ls\": invalid path name (status=0x%08"PRIx32")", - win32_path, (u32)status); + winnt_error(status, L"\"%ls\": invalid path name", win32_path); return WIMLIB_ERR_INVALID_PARAM; } @@ -375,6 +379,51 @@ win32_get_drive_path(const wchar_t *file_path, wchar_t drive_path[7]) return 0; } +/* Try to attach an instance of the Windows Overlay File System Filter Driver to + * the specified drive (such as C:) */ +bool +win32_try_to_attach_wof(const wchar_t *drive) +{ + HMODULE fltlib; + bool retval = false; + + /* Use FilterAttach() from Fltlib.dll. */ + + fltlib = LoadLibrary(L"Fltlib.dll"); + + if (!fltlib) { + WARNING("Failed to load Fltlib.dll"); + return retval; + } + + HRESULT (WINAPI *func_FilterAttach)(LPCWSTR lpFilterName, + LPCWSTR lpVolumeName, + LPCWSTR lpInstanceName, + DWORD dwCreatedInstanceNameLength, + LPWSTR lpCreatedInstanceName); + + func_FilterAttach = (void *)GetProcAddress(fltlib, "FilterAttach"); + + if (func_FilterAttach) { + HRESULT res; + + res = (*func_FilterAttach)(L"wof", drive, NULL, 0, NULL); + + if (res != S_OK) + res = (*func_FilterAttach)(L"wofadk", drive, NULL, 0, NULL); + + if (res == S_OK) + retval = true; + } else { + WARNING("FilterAttach() does not exist in Fltlib.dll"); + } + + FreeLibrary(fltlib); + + return retval; +} + + static void windows_msg(u32 code, const wchar_t *format, va_list va, bool is_ntstatus, bool is_error)