X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=src%2Fextract_image.c;h=86063819ab26c2e363fbbb8257544afc9efa4efc;hp=b66949e6fdbbeaa71be4e5f5c701e8ddc3db8e09;hb=2a33c303e30fd740f740e21632fd06b9e414b0c7;hpb=811a38dfe05ef337e2d627f654f8a3e559900790 diff --git a/src/extract_image.c b/src/extract_image.c index b66949e6..86063819 100644 --- a/src/extract_image.c +++ b/src/extract_image.c @@ -61,6 +61,11 @@ #include #endif +#if defined(__WIN32__) +# define swprintf _snwprintf +# define mkdir(path, mode) (!CreateDirectoryA(path, NULL)) +#endif + #if defined(__CYGWIN__) || defined(__WIN32__) static int win32_set_reparse_data(HANDLE h, @@ -245,7 +250,7 @@ static int win32_extract_stream(const struct wim_inode *inode, goto fail_close_handle; } else { if (lte) { - DEBUG("Extracting \"%ls\" (len = %zu)", + DEBUG("Extracting \"%ls\" (len = %"PRIu64")", stream_path, wim_resource_size(lte)); ret = do_win32_extract_stream(h, lte); if (ret) @@ -775,13 +780,12 @@ static int apply_dentry_timestamps_normal(struct wim_dentry *dentry, void *arg) size_t utf16_path_len; DWORD err; HANDLE h; - BOOL bret1, bret2; ret = utf8_to_utf16(output_path, len, &utf16_path, &utf16_path_len); if (ret) return ret; - DEBUG("Opening \"%ls\" to set timestamps", utf16_path); + DEBUG("Opening \"%s\" to set timestamps", output_path); h = CreateFileW((const wchar_t*)utf16_path, GENERIC_WRITE | WRITE_OWNER | WRITE_DAC | ACCESS_SYSTEM_SECURITY, FILE_SHARE_READ, @@ -796,12 +800,12 @@ static int apply_dentry_timestamps_normal(struct wim_dentry *dentry, void *arg) if (h == INVALID_HANDLE_VALUE) goto fail; - FILETIME creationTime = {.dwLowDateTime = dentry->d_inode->i_creation_time & 0xffffffff, - .dwHighDateTime = dentry->d_inode->i_creation_time >> 32}; - FILETIME lastAccessTime = {.dwLowDateTime = dentry->d_inode->i_last_access_time & 0xffffffff, - .dwHighDateTime = dentry->d_inode->i_last_access_time >> 32}; - FILETIME lastWriteTime = {.dwLowDateTime = dentry->d_inode->i_last_write_time & 0xffffffff, - .dwHighDateTime = dentry->d_inode->i_last_write_time >> 32}; + FILETIME creationTime = {.dwLowDateTime = inode->i_creation_time & 0xffffffff, + .dwHighDateTime = inode->i_creation_time >> 32}; + FILETIME lastAccessTime = {.dwLowDateTime = inode->i_last_access_time & 0xffffffff, + .dwHighDateTime = inode->i_last_access_time >> 32}; + FILETIME lastWriteTime = {.dwLowDateTime = inode->i_last_write_time & 0xffffffff, + .dwHighDateTime = inode->i_last_write_time >> 32}; DEBUG("Calling SetFileTime() on \"%s\"", output_path); if (!SetFileTime(h, &creationTime, &lastAccessTime, &lastWriteTime)) { @@ -1319,6 +1323,11 @@ WIMLIBAPI int wimlib_extract_image(WIMStruct *w, w->lookup_table = joined_tab; } +#if defined(__CYGWIN__) || defined(__WIN32__) + win32_acquire_privilege(SE_RESTORE_NAME); + win32_acquire_privilege(SE_SECURITY_NAME); + win32_acquire_privilege(SE_TAKE_OWNERSHIP_NAME); +#endif if (image == WIMLIB_ALL_IMAGES) { extract_flags |= WIMLIB_EXTRACT_FLAG_MULTI_IMAGE; ret = extract_all_images(w, target, extract_flags, @@ -1328,6 +1337,11 @@ WIMLIBAPI int wimlib_extract_image(WIMStruct *w, ret = extract_single_image(w, image, target, extract_flags, progress_func); } +#if defined(__CYGWIN__) || defined(__WIN32__) + win32_release_privilege(SE_RESTORE_NAME); + win32_release_privilege(SE_SECURITY_NAME); + win32_release_privilege(SE_TAKE_OWNERSHIP_NAME); +#endif if (extract_flags & (WIMLIB_EXTRACT_FLAG_SYMLINK | WIMLIB_EXTRACT_FLAG_HARDLINK))