X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=src%2Fwin32_apply.c;h=4c66575280f431109810bc244ef8f0f47f227a7b;hp=b1253956f3587f9e025ca3d74fac31768c47d474;hb=51f8edf82794f07055e3d9bcc8cd51bf0d86fae0;hpb=47898041237677686c46ccac6dd88485a63ddf93 diff --git a/src/win32_apply.c b/src/win32_apply.c index b1253956..4c665752 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) { @@ -480,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 @@ -503,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 @@ -541,7 +536,8 @@ win32_set_security_descriptor(const wchar_t *path, const u8 *desc, ret = 0; out_close: #ifdef WITH_NTDLL - CloseHandle(h); + if (func_NtSetSecurityObject) + CloseHandle(h); #endif return ret;