X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=src%2Fwin32_apply.c;h=557572330946b99118b61d54f12be6fada7b613d;hp=4a0a8a46d77ad22b41edf0354127ffb5ed61f520;hb=acfc301115f69877a634f3141908747a54f678a0;hpb=22920a29da3c42c5aa07c0ad0817d78bf26d99c3 diff --git a/src/win32_apply.c b/src/win32_apply.c index 4a0a8a46..55757233 100644 --- a/src/win32_apply.c +++ b/src/win32_apply.c @@ -33,15 +33,6 @@ #include "wimlib/error.h" #include "wimlib/lookup_table.h" -#ifdef WITH_NTDLL -# include -# include -NTSTATUS WINAPI -NtSetSecurityObject(HANDLE Handle, - SECURITY_INFORMATION SecurityInformation, - PSECURITY_DESCRIPTOR SecurityDescriptor); -#endif - static int win32_start_extract(const wchar_t *path, struct apply_ctx *ctx) { @@ -191,7 +182,7 @@ win32_extract_stream(const wchar_t *path, const wchar_t *stream_name, stream_path = alloca(sizeof(wchar_t) * (wcslen(path) + 1 + wcslen(stream_name) + 1)); - swprintf(stream_path, L"%ls:%ls", path, stream_name); + tsprintf(stream_path, L"%ls:%ls", path, stream_name); } h = CreateFile(stream_path, FILE_WRITE_DATA, 0, NULL, @@ -259,11 +250,10 @@ win32_encrypted_import_cb(unsigned char *data, void *_import_ctx, } static int -win32_extract_encrypted_stream(file_spec_t file, +win32_extract_encrypted_stream(const wchar_t *path, struct wim_lookup_table_entry *lte, struct apply_ctx *ctx) { - const tchar *path = file.path; void *file_ctx; DWORD err; int ret; @@ -481,13 +471,15 @@ do_win32_set_security_descriptor(HANDLE h, const wchar_t *path, PSECURITY_DESCRIPTOR desc) { #ifdef WITH_NTDLL - return RtlNtStatusToDosError(NtSetSecurityObject(h, info, desc)); -#else + if (func_NtSetSecurityObject) { + return (*func_RtlNtStatusToDosError)( + (*func_NtSetSecurityObject)(h, info, desc)); + } +#endif if (SetFileSecurity(path, info, desc)) return ERROR_SUCCESS; else return GetLastError(); -#endif } static int @@ -504,10 +496,12 @@ win32_set_security_descriptor(const wchar_t *path, const u8 *desc, h = INVALID_HANDLE_VALUE; #ifdef WITH_NTDLL - h = win32_open_existing_file(path, MAXIMUM_ALLOWED); - if (h == INVALID_HANDLE_VALUE) { - ERROR_WITH_ERRNO("Can't open %ls (%u)", path, GetLastError()); - goto error; + if (func_NtSetSecurityObject) { + h = win32_open_existing_file(path, MAXIMUM_ALLOWED); + if (h == INVALID_HANDLE_VALUE) { + ERROR_WITH_ERRNO("Can't open %ls (%u)", path, GetLastError()); + goto error; + } } #endif @@ -537,12 +531,14 @@ win32_set_security_descriptor(const wchar_t *path, const u8 *desc, ctx->no_security_descriptors++; break; } + SetLastError(err); goto error; } ret = 0; out_close: #ifdef WITH_NTDLL - CloseHandle(h); + if (func_NtSetSecurityObject) + CloseHandle(h); #endif return ret; @@ -614,6 +610,8 @@ const struct apply_operations win32_apply_ops = { .realpath_works_on_nonexisting_files = 1, .root_directory_is_special = 1, .requires_final_set_attributes_pass = 1, + .extract_encrypted_stream_creates_file = 1, + .requires_short_name_reordering = 1, /* TODO: check if this is really needed */ }; #endif /* __WIN32__ */