X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Fwin32_apply.c;h=c8f65ef0e2db218c4a1ba203c04900497bcee6af;hb=60523d25f34692d6f3a7c8bbda88eead17f23b12;hp=48dd66d319637769b881086ffae72e54581bba1e;hpb=bb6773105af4072cf0ce7e6c8276632d6110b03b;p=wimlib diff --git a/src/win32_apply.c b/src/win32_apply.c index 48dd66d3..c8f65ef0 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, @@ -204,8 +195,7 @@ win32_extract_stream(const wchar_t *path, const wchar_t *stream_name, ret = 0; if (!lte) goto out_close_handle; - ret = extract_wim_resource(lte, wim_resource_size(lte), - win32_extract_wim_chunk, h); + ret = extract_stream(lte, lte->size, win32_extract_wim_chunk, h); out_close_handle: if (!CloseHandle(h)) goto error; @@ -248,9 +238,9 @@ win32_encrypted_import_cb(unsigned char *data, void *_import_ctx, unsigned long len = *len_p; const struct wim_lookup_table_entry *lte = import_ctx->lte; - len = min(len, wim_resource_size(lte) - import_ctx->offset); + len = min(len, lte->size - import_ctx->offset); - if (read_partial_wim_resource_into_buf(lte, len, import_ctx->offset, data)) + if (read_partial_wim_stream_into_buf(lte, len, import_ctx->offset, data)) return ERROR_READ_FAULT; import_ctx->offset += len; @@ -480,13 +470,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 @@ -503,10 +495,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 @@ -536,12 +530,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;