]> wimlib.net Git - wimlib/commitdiff
Remove support for Windows XP
authorEric Biggers <ebiggers3@gmail.com>
Mon, 20 Mar 2023 03:59:16 +0000 (20:59 -0700)
committerEric Biggers <ebiggers3@gmail.com>
Mon, 20 Mar 2023 03:59:16 +0000 (20:59 -0700)
NEWS
README
include/wimlib_tchar.h
src/win32_capture.c
src/win32_replacements.c
src/win32_vss.c
tests/win32-test-imagex-capture_and_apply.bat

diff --git a/NEWS b/NEWS
index 9c6c71e1fb5f93d16811987783f75fcb644a1571..23003c0d774599ed7fdda4ac220bb0a51bce0174 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,8 @@ Version 1.14.0-BETA1:
        Improved the performance of the Windows binaries on CPUs that have SHA-1
        instructions.
 
+       Removed support for Windows XP.
+
        Fixed a bug in 'wimsplit' where it didn't accept part sizes of 4 GiB or
        larger on Windows and on 32-bit platforms.
 
diff --git a/README b/README
index 1952ff2497c71fdb3a3fa113cb7492727ebe47bd..6ea31854848e6b0a288f98e7341053e940fd763f 100644 (file)
--- a/README
+++ b/README
@@ -179,7 +179,7 @@ This section documents the most important options that may be passed to the
                                   PORTABILITY
 
 wimlib works on both UNIX-like systems (Linux, Mac OS X, FreeBSD, etc.) and
-Windows (XP and later).
+Windows (Vista and later).
 
 As much code as possible is shared among all supported platforms, but there
 necessarily are some differences in what features are supported on each platform
index 2585fa660b8183fe246370cd75f90a8d2db79358..2e1f44e6cce55b3c64f04e2ea8fdfa5ad86397dc 100644 (file)
@@ -64,7 +64,8 @@ typedef wchar_t tchar;
  * function defined ourselves. */
 #  define TSTRDUP      WCSDUP
 #  define tmkdir(path, mode) _wmkdir(path)
-#  define tstrerror_r   win32_strerror_r_replacement
+#  define tstrerror_r(errnum, buf, bufsize) \
+                       _wcserror_s((buf), (bufsize), (errnum))
 #  define trename      win32_rename_replacement
 #  define tglob                win32_wglob
 #else /* __WIN32__ */
index 8c9d726d3417a4fb02cdaa79dd405ec5b7301931..e4a59c3aa49c607cadf060be11e6b8f7fb2032db 100644 (file)
@@ -1321,15 +1321,10 @@ winnt_scan_data_stream(wchar_t *raw_stream_name, size_t raw_stream_name_nchars,
  * Load information about the data streams of an open file into a WIM inode.
  *
  * We use the NtQueryInformationFile() system call instead of FindFirstStream()
- * and FindNextStream().  This is done for two reasons:
- *
- * - FindFirstStream() opens its own handle to the file or directory and
- *   apparently does so without specifying FILE_FLAG_BACKUP_SEMANTICS, thereby
- *   causing access denied errors on certain files (even when running as the
- *   Administrator).
- * - FindFirstStream() and FindNextStream() is only available on Windows Vista
- *   and later, whereas the stream support in NtQueryInformationFile() was
- *   already present in Windows XP.
+ * and FindNextStream(), since FindFirstStream() opens its own handle to the
+ * file or directory and apparently does so without specifying
+ * FILE_FLAG_BACKUP_SEMANTICS.  This causing access denied errors on certain
+ * files, even when running as the Administrator.
  */
 static noinline_for_stack int
 winnt_scan_data_streams(HANDLE h, struct wim_inode *inode, u64 file_size,
index 34d4e86a217d71d0208f04ba20bf39b7ecdc8eff..566cba9ce3a3419af9f9d9b76bd85af0da4f7485 100644 (file)
@@ -27,7 +27,6 @@
 #endif
 
 #include <errno.h>
-#include <pthread.h>
 #include <io.h>        /* for _get_osfhandle()  */
 #include <fcntl.h>
 
@@ -469,21 +468,6 @@ err_set_errno:
        return -1;
 }
 
-/* This really could be replaced with _wcserror_s, but this doesn't seem to
- * actually be available in MSVCRT.DLL on Windows XP (perhaps it's statically
- * linked in by Visual Studio...?). */
-int
-win32_strerror_r_replacement(int errnum, wchar_t *buf, size_t buflen)
-{
-       static pthread_mutex_t strerror_lock = PTHREAD_MUTEX_INITIALIZER;
-
-       pthread_mutex_lock(&strerror_lock);
-       mbstowcs(buf, strerror(errnum), buflen);
-       buf[buflen - 1] = '\0';
-       pthread_mutex_unlock(&strerror_lock);
-       return 0;
-}
-
 #define MAX_IO_AMOUNT 1048576
 
 static int
index 2270feeac6814fc63e06c4865cf6f2b998238f00..0c146b4a7d5e217452a8ffc6cf935ddd5a7de437 100644 (file)
@@ -131,21 +131,14 @@ struct IVssAsyncVTable {
        void *AddRef;
        ULONG (WINAPI *Release)(IVssAsync *this);
        void *Cancel;
-       union {
-               HRESULT (WINAPI *Wait)(IVssAsync *this, DWORD dwMilliseconds);
-
-               /* Pre-Vista version */
-               HRESULT (WINAPI *OldWait)(IVssAsync *this);
-       };
+       HRESULT (WINAPI *Wait)(IVssAsync *this, DWORD dwMilliseconds);
        void *QueryStatus;
 };
 
 typedef struct IVssBackupComponentsVTable IVssBackupComponentsVTable;
-typedef struct IVssBackupComponentsVTable_old IVssBackupComponentsVTable_old;
 
-typedef union {
+typedef struct {
        IVssBackupComponentsVTable *vtable;
-       IVssBackupComponentsVTable_old *old_vtable;
 } IVssBackupComponents;
 
 struct IVssBackupComponentsVTable {
@@ -203,7 +196,6 @@ struct IVssBackupComponentsVTable {
                                        IVssAsync **ppAsync);
        void *DeleteSnapshots;
        void *ImportSnapshots;
-       /*void *RemountReadWrite;*/     /* Old API only  */
        void *BreakSnapshotSet;
        HRESULT (WINAPI *GetSnapshotProperties)(IVssBackupComponents *this,
                                                VSS_ID SnapshotId,
@@ -218,88 +210,6 @@ struct IVssBackupComponentsVTable {
        void *QueryRevertStatus;
 };
 
-/* Pre-Vista version  */
-struct IVssBackupComponentsVTable_old {
-       void *QueryInterface;
-       void *AddRef;
-       ULONG (WINAPI *Release)(IVssBackupComponents *this);
-       void *GetWriterComponentsCount;
-       void *GetWriterComponents;
-       HRESULT (WINAPI *InitializeForBackup)(IVssBackupComponents *this,
-                                             BSTR bstrXML);
-       HRESULT (WINAPI *SetBackupState)(IVssBackupComponents *this,
-                                        BOOLEAN bSelectComponents,
-                                        BOOLEAN bBackupBootableSystemState,
-                                        VSS_BACKUP_TYPE backupType,
-                                        BOOLEAN bPartialFileSupport);
-       void *InitializeForRestore;
-       /*void *SetRestoreState;*/      /* New API only */
-       HRESULT (WINAPI *GatherWriterMetadata)(IVssBackupComponents *this,
-                                              IVssAsync **ppAsync);
-       void *GetWriterMetadataCount;
-       void *GetWriterMetadata;
-       void *FreeWriterMetadata;
-       void *AddComponent;
-       HRESULT (WINAPI *PrepareForBackup)(IVssBackupComponents *this,
-                                          IVssAsync **ppAsync);
-       void *AbortBackup;
-       void *GatherWriterStatus;
-       void *GetWriterStatusCount;
-       void *FreeWriterStatus;
-       void *GetWriterStatus;
-       void *SetBackupSucceeded;
-       void *SetBackupOptions;
-       void *SetSelectedForRestore;
-       void *SetRestoreOptions;
-       void *SetAdditionalRestores;
-       void *SetPreviousBackupStamp;
-       void *SaveAsXML;
-       void *BackupComplete;
-       void *AddAlternativeLocationMapping;
-       void *AddRestoreSubcomponent;
-       void *SetFileRestoreStatus;
-       /*void *AddNewTarget;*/         /* New API only */
-       /*void *SetRangesFilePath;*/    /* New API only */
-       void *PreRestore;
-       void *PostRestore;
-       HRESULT (WINAPI *SetContext)(IVssBackupComponents *this,
-                                    LONG lContext);
-       HRESULT (WINAPI *StartSnapshotSet)(IVssBackupComponents *this,
-                                          VSS_ID *pSnapshotSetId);
-       HRESULT (WINAPI *AddToSnapshotSet)(IVssBackupComponents *this,
-                                          VSS_PWSZ pwszVolumeName,
-                                          VSS_ID ProviderId,
-                                          VSS_ID *pidSnapshot);
-       HRESULT (WINAPI *DoSnapshotSet)(IVssBackupComponents *this,
-                                       IVssAsync **ppAsync);
-       void *DeleteSnapshots;
-       void *ImportSnapshots;
-       void *RemountReadWrite;
-       void *BreakSnapshotSet;
-       HRESULT (WINAPI *GetSnapshotProperties)(IVssBackupComponents *this,
-                                               VSS_ID SnapshotId,
-                                               VSS_SNAPSHOT_PROP *pprop);
-       void *Query;
-       void *IsVolumeSupported;
-       void *DisableWriterClasses;
-       void *EnableWriterClasses;
-       void *DisableWriterInstances;
-       void *ExposeSnapshot;
-       /*void *RevertToSnapshot;*/     /* New API only */
-       /*void *QueryRevertStatus;*/    /* New API only */
-};
-
-/* Call a method, assuming its signature is identical in the old and new APIs */
-#define CALL_METHOD(obj, method, ...)                                  \
-({                                                                     \
-       HRESULT res;                                                    \
-       if (is_old_api)                                                 \
-               res = (obj)->old_vtable->method((obj), ##__VA_ARGS__);  \
-       else                                                            \
-               res = (obj)->vtable->method((obj), ##__VA_ARGS__);      \
-       res;                                                            \
-})
-
 /*----------------------------------------------------------------------------*
  *                             VSS API initialization                         *
  *----------------------------------------------------------------------------*/
@@ -308,10 +218,9 @@ static bool vss_initialized;
 static pthread_mutex_t vss_initialization_mutex = PTHREAD_MUTEX_INITIALIZER;
 
 /* vssapi.dll  */
-static bool is_old_api;                /* old VSS API (pre-Vista)?  */
 static HANDLE hVssapi;
-static HRESULT (WINAPI *func_CreateVssBackupComponents)(IVssBackupComponents **ppBackup);
-static void (WINAPI *func_VssFreeSnapshotProperties)(VSS_SNAPSHOT_PROP *pProp);
+static HRESULT (WINAPI *func_CreateVssBackupComponentsInternal)(IVssBackupComponents **ppBackup);
+static void (WINAPI *func_VssFreeSnapshotPropertiesInternal)(VSS_SNAPSHOT_PROP *pProp);
 
 /* ole32.dll  */
 static HANDLE hOle32;
@@ -327,29 +236,18 @@ vss_global_init_impl(void)
                goto err;
        }
 
-       func_CreateVssBackupComponents =
+       func_CreateVssBackupComponentsInternal =
                (void *)GetProcAddress(hVssapi, "CreateVssBackupComponentsInternal");
-       if (!func_CreateVssBackupComponents) {
-               func_CreateVssBackupComponents =
-                       (void *)GetProcAddress(hVssapi, "?CreateVssBackupComponents@@YGJPAPAVIVssBackupComponents@@@Z");
-               if (!func_CreateVssBackupComponents) {
-                       ERROR("CreateVssBackupComponents() not found in vssapi.dll");
-                       goto err_vssapi;
-               }
-               is_old_api = true;
-       } else {
-               is_old_api = false;
+       if (!func_CreateVssBackupComponentsInternal) {
+               ERROR("CreateVssBackupComponentsInternal() not found in vssapi.dll");
+               goto err_vssapi;
        }
 
-       func_VssFreeSnapshotProperties =
+       func_VssFreeSnapshotPropertiesInternal =
                (void *)GetProcAddress(hVssapi, "VssFreeSnapshotPropertiesInternal");
-       if (!func_VssFreeSnapshotProperties) {
-               func_VssFreeSnapshotProperties =
-                       (void *)GetProcAddress(hVssapi, "VssFreeSnapshotProperties");
-               if (!func_VssFreeSnapshotProperties) {
-                       ERROR("VssFreeSnapshotProperties() not found in vssapi.dll");
-                       goto err_vssapi;
-               }
+       if (!func_VssFreeSnapshotPropertiesInternal) {
+               ERROR("VssFreeSnapshotPropertiesInternal() not found in vssapi.dll");
+               goto err_vssapi;
        }
 
        hOle32 = LoadLibrary(L"ole32.dll");
@@ -395,7 +293,7 @@ vss_global_init(void)
        if (vss_initialized)
                return true;
        ERROR("The Volume Shadow Copy Service (VSS) API could not be "
-             "initialized. Probably it isn't supported on this computer.");
+             "initialized.");
        return false;
 }
 
@@ -434,20 +332,17 @@ vss_delete_snapshot(struct vss_snapshot *snapshot)
        internal = container_of(snapshot, struct vss_snapshot_internal, base);
 
        if (internal->props.m_pwszSnapshotDeviceObject)
-               (*func_VssFreeSnapshotProperties)(&internal->props);
+               (*func_VssFreeSnapshotPropertiesInternal)(&internal->props);
        if (internal->vss)
-               CALL_METHOD(internal->vss, Release);
+               internal->vss->vtable->Release(internal->vss);
        FREE(internal);
 }
 
 static HRESULT
 wait_and_release(IVssAsync *async)
 {
-       HRESULT res;
-       if (is_old_api)
-               res = async->vtable->OldWait(async);
-       else
-               res = async->vtable->Wait(async, INFINITE);
+       HRESULT res = async->vtable->Wait(async, INFINITE);
+
        async->vtable->Release(async);
        return res;
 }
@@ -459,31 +354,31 @@ request_vss_snapshot(IVssBackupComponents *vss, wchar_t *volume,
        HRESULT res;
        IVssAsync *async;
 
-       res = CALL_METHOD(vss, InitializeForBackup, NULL);
+       res = vss->vtable->InitializeForBackup(vss, NULL);
        if (FAILED(res)) {
                ERROR("IVssBackupComponents.InitializeForBackup() error: %x", res);
                return false;
        }
 
-       res = CALL_METHOD(vss, SetBackupState, FALSE, TRUE, VSS_BT_COPY, FALSE);
+       res = vss->vtable->SetBackupState(vss, FALSE, TRUE, VSS_BT_COPY, FALSE);
        if (FAILED(res)) {
                ERROR("IVssBackupComponents.SetBackupState() error: %x", res);
                return false;
        }
 
-       res = CALL_METHOD(vss, StartSnapshotSet, snapshot_id);
+       res = vss->vtable->StartSnapshotSet(vss, snapshot_id);
        if (FAILED(res)) {
                ERROR("IVssBackupComponents.StartSnapshotSet() error: %x", res);
                return false;
        }
 
-       res = CALL_METHOD(vss, AddToSnapshotSet, volume, (GUID){}, snapshot_id);
+       res = vss->vtable->AddToSnapshotSet(vss, volume, (GUID){}, snapshot_id);
        if (FAILED(res)) {
                ERROR("IVssBackupComponents.AddToSnapshotSet() error: %x", res);
                return false;
        }
 
-       res = CALL_METHOD(vss, PrepareForBackup, &async);
+       res = vss->vtable->PrepareForBackup(vss, &async);
        if (FAILED(res)) {
                ERROR("IVssBackupComponents.PrepareForBackup() error: %x", res);
                return false;
@@ -494,7 +389,7 @@ request_vss_snapshot(IVssBackupComponents *vss, wchar_t *volume,
                return false;
        }
 
-       res = CALL_METHOD(vss, DoSnapshotSet, &async);
+       res = vss->vtable->DoSnapshotSet(vss, &async);
        if (FAILED(res)) {
                ERROR("IVssBackupComponents.DoSnapshotSet() error: %x", res);
                return false;
@@ -559,7 +454,7 @@ vss_create_snapshot(const wchar_t *source, UNICODE_STRING *vss_path_ret,
        if (!vss_global_init())
                goto vss_err;
 
-       res = (*func_CreateVssBackupComponents)(&vss);
+       res = (*func_CreateVssBackupComponentsInternal)(&vss);
        if (FAILED(res)) {
                ERROR("CreateVssBackupComponents error: %x", res);
                goto vss_err;
@@ -570,7 +465,7 @@ vss_create_snapshot(const wchar_t *source, UNICODE_STRING *vss_path_ret,
        if (!request_vss_snapshot(vss, volume, &snapshot_id))
                goto vss_err;
 
-       res = CALL_METHOD(vss, GetSnapshotProperties, snapshot_id, &snapshot->props);
+       res = vss->vtable->GetSnapshotProperties(vss, snapshot_id, &snapshot->props);
        if (FAILED(res)) {
                ERROR("IVssBackupComponents.GetSnapshotProperties() error: %x", res);
                goto vss_err;
index fda65ac8181ad8408666eefd01ab0cc6d732dcd9..9cb97bd3d15e4b0dd6bb168c7bb007b9f131cf4d 100644 (file)
@@ -5,9 +5,9 @@ REM win32-test-imagex-capture_and_apply.bat
 REM\r
 REM Run some tests on the Windows version of wimlib-imagex.\r
 REM\r
-REM This must be run on Windows Vista or later in a clean directory, with\r
-REM Administrator privileges.  wimlib-imagex and win32-tree-cmp must be\r
-REM executable using the paths set below.\r
+REM This must be run in a clean directory, with Administrator privileges.\r
+REM wimlib-imagex, win32-tree-cmp, and set_reparse_point must be executable\r
+REM using the paths set below.\r
 \r
 setlocal EnableDelayedExpansion\r
 set WIMLIB_IMAGEX=wimlib-imagex\r