/*
- * win32_vss.c - Experimental Windows-specific code for creating VSS (Volume
- * Shadow Copy Service) snapshots.
+ * win32_vss.c - Windows-specific code for creating VSS (Volume Shadow Copy
+ * Service) snapshots.
*/
/*
- * Copyright (C) 2015 Eric Biggers
+ * Copyright (C) 2015-2016 Eric Biggers
*
* This file is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
#include "wimlib/win32_common.h"
#include <cguid.h>
-#include <pthread.h>
#include "wimlib/error.h"
+#include "wimlib/threads.h"
#include "wimlib/util.h"
#include "wimlib/win32_vss.h"
*----------------------------------------------------------------------------*/
static bool vss_initialized;
-static pthread_mutex_t vss_initialization_mutex = PTHREAD_MUTEX_INITIALIZER;
+static struct mutex vss_initialization_mutex = MUTEX_INITIALIZER;
/* vssapi.dll */
static HANDLE hVssapi;
if (vss_initialized)
return true;
- pthread_mutex_lock(&vss_initialization_mutex);
+ mutex_lock(&vss_initialization_mutex);
if (!vss_initialized)
vss_initialized = vss_global_init_impl();
- pthread_mutex_unlock(&vss_initialization_mutex);
+ mutex_unlock(&vss_initialization_mutex);
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;
}
if (!vss_initialized)
return;
- pthread_mutex_lock(&vss_initialization_mutex);
+ mutex_lock(&vss_initialization_mutex);
if (vss_initialized) {
(*func_CoUninitialize)();
FreeLibrary(hOle32);
FreeLibrary(hVssapi);
vss_initialized = false;
}
- pthread_mutex_unlock(&vss_initialization_mutex);
+ mutex_unlock(&vss_initialization_mutex);
}
/*----------------------------------------------------------------------------*
wait_and_release(IVssAsync *async)
{
HRESULT res = async->vtable->Wait(async, INFINITE);
+
async->vtable->Release(async);
return res;
}
return false;
}
- res = vss->vtable->SetContext(vss, VSS_CTX_BACKUP);
- if (FAILED(res)) {
- ERROR("IVssBackupComponents.SetContext() error: %x", res);
- return false;
- }
-
res = vss->vtable->SetBackupState(vss, FALSE, TRUE, VSS_BT_COPY, FALSE);
if (FAILED(res)) {
ERROR("IVssBackupComponents.SetBackupState() error: %x", res);
return true;
}
+static bool
+is_wow64(void)
+{
+ BOOL wow64 = FALSE;
+ if (sizeof(size_t) == 4)
+ IsWow64Process(GetCurrentProcess(), &wow64);
+ return wow64;
+}
+
/*
* Create a VSS snapshot of the specified @volume. Return the NT namespace path
* to the snapshot root directory in @vss_path_ret and a handle to the snapshot
vss_err:
ret = WIMLIB_ERR_SNAPSHOT_FAILURE;
- ERROR("A problem occurred while creating a VSS snapshot of \"%ls\".\n"
- " Aborting the operation.", volume);
+ if (is_wow64()) {
+ ERROR("64-bit Windows doesn't allow 32-bit applications to "
+ "create VSS snapshots.\n"
+ " Run the 64-bit version of this application "
+ "instead.");
+ } else {
+ ERROR("A problem occurred while creating a VSS snapshot of "
+ "\"%ls\".\n"
+ " Aborting the operation.", volume);
+ }
err:
if (snapshot)
vss_delete_snapshot(&snapshot->base);