summaryrefslogtreecommitdiff
path: root/lib/ShadowCopy
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 17:29:28 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 17:29:28 +0200
commit75c07011b7c4d06acd7b45dabdcd60ab9d80f385 (patch)
tree8853c3978dd152ef377e652239448b1352320206 /lib/ShadowCopy
parent5.22 (diff)
downloadFreeFileSync-75c07011b7c4d06acd7b45dabdcd60ab9d80f385.tar.gz
FreeFileSync-75c07011b7c4d06acd7b45dabdcd60ab9d80f385.tar.bz2
FreeFileSync-75c07011b7c4d06acd7b45dabdcd60ab9d80f385.zip
5.23
Diffstat (limited to 'lib/ShadowCopy')
-rw-r--r--lib/ShadowCopy/Shadow_Windows7.vcxproj240
-rw-r--r--lib/ShadowCopy/shadow.cpp199
-rw-r--r--lib/ShadowCopy/shadow.h94
3 files changed, 0 insertions, 533 deletions
diff --git a/lib/ShadowCopy/Shadow_Windows7.vcxproj b/lib/ShadowCopy/Shadow_Windows7.vcxproj
deleted file mode 100644
index 86df3453..00000000
--- a/lib/ShadowCopy/Shadow_Windows7.vcxproj
+++ /dev/null
@@ -1,240 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectName>Windows7</ProjectName>
- <ProjectGuid>{7E217D76-90A5-4B03-A6F8-E7C3ADD22901}</ProjectGuid>
- <RootNamespace>ShadowDll</RootNamespace>
- <Keyword>Win32Proj</Keyword>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <CharacterSet>Unicode</CharacterSet>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- <UseOfAtl>false</UseOfAtl>
- <PlatformToolset>v120_xp</PlatformToolset>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <CharacterSet>Unicode</CharacterSet>
- <PlatformToolset>v120_xp</PlatformToolset>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <CharacterSet>Unicode</CharacterSet>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- <PlatformToolset>v120_xp</PlatformToolset>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <CharacterSet>Unicode</CharacterSet>
- <PlatformToolset>v120_xp</PlatformToolset>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup>
- <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
- <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">OBJ\</OutDir>
- <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">OBJ\$(ProjectName)_$(Configuration)_$(Platform)\</IntDir>
- <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">OBJ\</OutDir>
- <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">OBJ\$(ProjectName)_$(Configuration)_$(Platform)\</IntDir>
- <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\</OutDir>
- <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">OBJ\$(ProjectName)_$(Configuration)_$(Platform)\</IntDir>
- <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
- <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\</OutDir>
- <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">OBJ\$(ProjectName)_$(Configuration)_$(Platform)\</IntDir>
- <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
- <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Shadow_$(ProjectName)_$(Platform)</TargetName>
- <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Shadow_$(ProjectName)_$(Platform)</TargetName>
- <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Shadow_$(ProjectName)_$(Platform)</TargetName>
- <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Shadow_$(ProjectName)_$(Platform)</TargetName>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <BuildLog>
- <Path>$(IntDir)Build.html</Path>
- </BuildLog>
- <ClCompile>
- <Optimization>Disabled</Optimization>
- <PreprocessorDefinitions>ZEN_WIN;WXINTL_NO_GETTEXT_MACRO;_DEBUG;_WINDOWS;_USRDLL;SHADOWDLL_EXPORTS;USE_SHADOW_WINDOWS7;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <MinimalRebuild>false</MinimalRebuild>
- <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
- <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
- <PrecompiledHeader>
- </PrecompiledHeader>
- <WarningLevel>Level4</WarningLevel>
- <SuppressStartupBanner>true</SuppressStartupBanner>
- <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
- <DisableSpecificWarnings>4100;4996</DisableSpecificWarnings>
- <AdditionalIncludeDirectories>../..;C:\Data\C++\boost</AdditionalIncludeDirectories>
- <SmallerTypeCheck>true</SmallerTypeCheck>
- <MultiProcessorCompilation>true</MultiProcessorCompilation>
- </ClCompile>
- <Link>
- <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
- <SuppressStartupBanner>true</SuppressStartupBanner>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <ProgramDatabaseFile>$(IntDir)$(TargetName).pdb</ProgramDatabaseFile>
- <SubSystem>Windows</SubSystem>
- <ProfileGuidedDatabase>
- </ProfileGuidedDatabase>
- <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
- <TargetMachine>MachineX86</TargetMachine>
- <AdditionalLibraryDirectories>C:\Data\C++\Boost\stage\lib</AdditionalLibraryDirectories>
- <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <BuildLog>
- <Path>$(IntDir)Build.html</Path>
- </BuildLog>
- <Midl>
- <TargetEnvironment>X64</TargetEnvironment>
- </Midl>
- <ClCompile>
- <Optimization>Disabled</Optimization>
- <MinimalRebuild>false</MinimalRebuild>
- <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
- <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
- <PrecompiledHeader>
- </PrecompiledHeader>
- <WarningLevel>Level4</WarningLevel>
- <SuppressStartupBanner>true</SuppressStartupBanner>
- <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
- <DisableSpecificWarnings>4100;4996</DisableSpecificWarnings>
- <AdditionalIncludeDirectories>../..;C:\Data\C++\boost</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>ZEN_WIN;WXINTL_NO_GETTEXT_MACRO;_DEBUG;_WINDOWS;_USRDLL;SHADOWDLL_EXPORTS;USE_SHADOW_WINDOWS7;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <SmallerTypeCheck>true</SmallerTypeCheck>
- <MultiProcessorCompilation>true</MultiProcessorCompilation>
- </ClCompile>
- <Link>
- <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
- <SuppressStartupBanner>true</SuppressStartupBanner>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <ProgramDatabaseFile>$(IntDir)$(TargetName).pdb</ProgramDatabaseFile>
- <SubSystem>Windows</SubSystem>
- <ProfileGuidedDatabase>
- </ProfileGuidedDatabase>
- <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
- <TargetMachine>MachineX64</TargetMachine>
- <AdditionalLibraryDirectories>C:\Data\C++\Boost\stage_x64\lib</AdditionalLibraryDirectories>
- <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <BuildLog>
- <Path>$(IntDir)Build.html</Path>
- </BuildLog>
- <ClCompile>
- <Optimization>MaxSpeed</Optimization>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- <PreprocessorDefinitions>ZEN_WIN;WXINTL_NO_GETTEXT_MACRO;NDEBUG;_WINDOWS;_USRDLL;SHADOWDLL_EXPORTS;USE_SHADOW_WINDOWS7;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <PrecompiledHeader>
- </PrecompiledHeader>
- <WarningLevel>Level4</WarningLevel>
- <SuppressStartupBanner>true</SuppressStartupBanner>
- <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
- <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
- <DisableSpecificWarnings>4100;4996</DisableSpecificWarnings>
- <AdditionalIncludeDirectories>../..;C:\Data\C++\boost</AdditionalIncludeDirectories>
- <MultiProcessorCompilation>true</MultiProcessorCompilation>
- </ClCompile>
- <Link>
- <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
- <SuppressStartupBanner>true</SuppressStartupBanner>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <SubSystem>Windows</SubSystem>
- <OptimizeReferences>true</OptimizeReferences>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
- <ProfileGuidedDatabase>
- </ProfileGuidedDatabase>
- <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
- <TargetMachine>MachineX86</TargetMachine>
- <AdditionalLibraryDirectories>C:\Data\C++\Boost\stage\lib</AdditionalLibraryDirectories>
- <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <BuildLog>
- <Path>$(IntDir)Build.html</Path>
- </BuildLog>
- <Midl>
- <TargetEnvironment>X64</TargetEnvironment>
- </Midl>
- <ClCompile>
- <Optimization>MaxSpeed</Optimization>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <PrecompiledHeader>
- </PrecompiledHeader>
- <WarningLevel>Level4</WarningLevel>
- <SuppressStartupBanner>true</SuppressStartupBanner>
- <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
- <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
- <DisableSpecificWarnings>4100;4996</DisableSpecificWarnings>
- <AdditionalIncludeDirectories>../..;C:\Data\C++\boost</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>ZEN_WIN;WXINTL_NO_GETTEXT_MACRO;NDEBUG;_WINDOWS;_USRDLL;SHADOWDLL_EXPORTS;USE_SHADOW_WINDOWS7;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <MultiProcessorCompilation>true</MultiProcessorCompilation>
- </ClCompile>
- <Link>
- <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
- <SuppressStartupBanner>true</SuppressStartupBanner>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <SubSystem>Windows</SubSystem>
- <OptimizeReferences>true</OptimizeReferences>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
- <ProfileGuidedDatabase>
- </ProfileGuidedDatabase>
- <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
- <TargetMachine>MachineX64</TargetMachine>
- <AdditionalLibraryDirectories>C:\Data\C++\Boost\stage_x64\lib</AdditionalLibraryDirectories>
- <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\..\zen\debug_memory_leaks.cpp" />
- <ClCompile Include="shadow.cpp" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="shadow.h" />
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project> \ No newline at end of file
diff --git a/lib/ShadowCopy/shadow.cpp b/lib/ShadowCopy/shadow.cpp
deleted file mode 100644
index adc7c5c2..00000000
--- a/lib/ShadowCopy/shadow.cpp
+++ /dev/null
@@ -1,199 +0,0 @@
-// **************************************************************************
-// * This file is part of the FreeFileSync project. It is distributed under *
-// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
-// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved *
-// **************************************************************************
-
-#include "shadow.h"
-#include <algorithm>
-#include <string>
-#include <zen/com_ptr.h>
-#include <zen/com_error.h>
-#include <zen/scope_guard.h>
-#include <boost/thread/tss.hpp>
-
-#ifdef USE_SHADOW_XP
-#include "xp/inc/vss.h"
-#include "xp/inc/vswriter.h"
-#include "xp/inc/vsbackup.h"
-
-#elif defined USE_SHADOW_2003
-#include "Server 2003/inc/vss.h"
-#include "Server 2003/inc/vswriter.h"
-#include "Server 2003/inc/vsbackup.h"
-
-#elif defined USE_SHADOW_WINDOWS7
-#include <vss.h> //
-#include <vswriter.h> //part of Windows SDK for Windows 7
-#include <vsbackup.h> //
-#pragma comment(lib, "VssApi.lib")
-
-#else
-#error adapt!
-#endif
-
-using namespace zen;
-
-
-struct shadow::ShadowData
-{
- ShadowData(const ComPtr<IVssBackupComponents>& backupComp,
- const std::wstring& shadowVolume) : backupComp_(backupComp), shadowVolume_(shadowVolume) {}
-
- ComPtr<IVssBackupComponents> backupComp_;
- std::wstring shadowVolume_;
-};
-
-
-namespace
-{
-std::wstring formatVssError(HRESULT hr) //at least the one's from IVssBackupComponents::AddToSnapshotSet; return empty if no format found
-{
- switch (hr)
- {
- case VSS_E_BAD_STATE:
- return L"VSS_E_BAD_STATE";
- case VSS_E_MAXIMUM_NUMBER_OF_VOLUMES_REACHED:
- return L"VSS_E_MAXIMUM_NUMBER_OF_VOLUMES_REACHED";
- case VSS_E_MAXIMUM_NUMBER_OF_SNAPSHOTS_REACHED:
- return L"VSS_E_MAXIMUM_NUMBER_OF_SNAPSHOTS_REACHED";
- case VSS_E_OBJECT_NOT_FOUND:
- return L"VSS_E_OBJECT_NOT_FOUND";
- case VSS_E_PROVIDER_NOT_REGISTERED:
- return L"VSS_E_PROVIDER_NOT_REGISTERED";
- case VSS_E_PROVIDER_VETO:
- return L"VSS_E_PROVIDER_VETO";
- case VSS_E_VOLUME_NOT_SUPPORTED:
- return L"VSS_E_VOLUME_NOT_SUPPORTED";
- case VSS_E_VOLUME_NOT_SUPPORTED_BY_PROVIDER:
- return L"VSS_E_VOLUME_NOT_SUPPORTED_BY_PROVIDER";
- case VSS_E_UNEXPECTED_PROVIDER_ERROR:
- return L"VSS_E_UNEXPECTED_PROVIDER_ERROR";
- default:
- return std::wstring();
- }
-}
-
-
-shadow::ShadowData createShadowCopy(const wchar_t* volumeName) //throw SysError
-{
- ComPtr<IVssBackupComponents> backupComp;
- {
- HRESULT hr = ::CreateVssBackupComponents(backupComp.init());
- if (FAILED(hr))
- {
- if (hr == E_ACCESSDENIED)
- throw SysError(formatComError(L"The caller does not have sufficient backup privileges or is not an administrator.", hr));
- throw SysError(formatComError(L"Error calling \"CreateVssBackupComponents\".", hr));
- }
- }
-
- ZEN_COM_CHECK(backupComp->InitializeForBackup()); //throw SysError
-
- //SetContext() only required if different than the default, VSS_CTX_BACKUP; not implemented on XP!!!
- //ZEN_COM_CHECK(backupComp->SetContext(VSS_CTX_BACKUP)); //throw SysError
-
- ZEN_COM_CHECK(backupComp->SetBackupState(false, false, VSS_BT_FULL)); //throw SysError
-
-
- //the Shadow Copy Optimization Writer removes items it considers non-essential,
- //http://msdn.microsoft.com/en-US/library/bb968827#shadow_copy_optimization_writer
- //like the exclusions in HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\BackupRestore\FilesNotToSnapshot
- //http://msdn.microsoft.com/en-us/library/aa819132%28v=vs.85%29.aspx
- //Outlook *.ost files in particular:
- //https://sourceforge.net/p/freefilesync/discussion/help/thread/722dcbfb
- const VSS_ID disabledWriters[] = { { 0x4dc3bdd4, 0xab48, 0x4d07, { 0xad, 0xb0, 0x3b, 0xee, 0x29, 0x26, 0xfd, 0x7f } } }; //Shadow Copy Optimization Writer
- {
- HRESULT hr = backupComp->DisableWriterClasses(disabledWriters, 1);
- if (FAILED(hr) && hr != E_NOTIMPL) //DisableWriterClasses() is not implemented on Windows XP, although MSDN documented otherwise!
- throw SysError(formatComError(L"Error calling \"backupComp->DisableWriterClasses\".", hr));
- }
-
-
- auto waitForComFuture = [](IVssAsync& fut)
- {
- ZEN_COM_CHECK(fut.Wait());
-
- HRESULT hr = S_OK;
- ZEN_COM_CHECK(fut.QueryStatus(&hr, nullptr)); //check if the async operation succeeded...
- if (FAILED(hr))
- throw SysError(formatComError(L"Error calling \"fut->QueryStatus\".", hr));
- };
-
- ComPtr<IVssAsync> gatherAsync;
- ZEN_COM_CHECK(backupComp->GatherWriterMetadata(gatherAsync.init()));
- waitForComFuture(*gatherAsync); //failure can happen if XP-version of VSS is used on Windows Vista (which needs at least VSS-Server2003 build)
-
- VSS_ID snapshotSetId = {};
- ZEN_COM_CHECK(backupComp->StartSnapshotSet(&snapshotSetId));
- ScopeGuard guardSnapShot = makeGuard([&] { backupComp->AbortBackup(); });
- //Quote: "This method must be called if a backup operation terminates after the creation of a
- //shadow copy set with "StartSnapshotSet" and before "DoSnapshotSet" returns."
-
- VSS_ID SnapShotId = {};
- {
- HRESULT hr = backupComp->AddToSnapshotSet(const_cast<wchar_t*>(volumeName), GUID_NULL, &SnapShotId);
- if (FAILED(hr))
- {
- if (hr == VSS_E_VOLUME_NOT_SUPPORTED)
- throw SysError(L"Volume Shadow Copy Service is not supported on this volume!");
- const std::wstring vssError = formatVssError(hr);
- if (!vssError.empty())
- throw SysError(L"Error calling \"backupComp->AddToSnapshotSet\": " + vssError);
- else
- throw SysError(formatComError(L"Error calling \"backupComp->AddToSnapshotSet\".", hr));
- }
- }
-
- ComPtr<IVssAsync> prepareAsync;
- ZEN_COM_CHECK(backupComp->PrepareForBackup(prepareAsync.init()));
- waitForComFuture(*prepareAsync);
-
- ComPtr<IVssAsync> snapshotAsync;
- ZEN_COM_CHECK(backupComp->DoSnapshotSet(snapshotAsync.init()));
- guardSnapShot.dismiss();
- waitForComFuture(*snapshotAsync);
-
- VSS_SNAPSHOT_PROP props = {};
- ZEN_COM_CHECK(backupComp->GetSnapshotProperties(SnapShotId, &props));
- ZEN_ON_SCOPE_EXIT(::VssFreeSnapshotProperties(&props));
-
- //finally: write volume name of newly created shadow copy
- return shadow::ShadowData(backupComp, props.m_pwszSnapshotDeviceObject);
-}
-
-boost::thread_specific_ptr<std::wstring> lastErrorMessage; //use "thread_local" in C++11
-}
-
-
-shadow::ShadowHandle shadow::createShadowCopy(const wchar_t* volumeName)
-{
- try
- {
- ShadowData result = ::createShadowCopy(volumeName); //throw SysError
- return new ShadowData(result); //shadow handle owned by caller! std::bad_alloc?
- }
- catch (const zen::SysError& e)
- {
- lastErrorMessage.reset(new std::wstring(e.toString()));
- return nullptr;
- }
-}
-
-
-const wchar_t* shadow::getShadowVolume(shadow::ShadowHandle handle)
-{
- return handle ? handle->shadowVolume_.c_str() : nullptr; //better fail in client code than here!
-}
-
-
-void shadow::releaseShadowCopy(ShadowHandle handle)
-{
- delete handle;
-}
-
-
-const wchar_t* shadow::getLastError()
-{
- return !lastErrorMessage.get() ? L"" : lastErrorMessage->c_str();
-}
diff --git a/lib/ShadowCopy/shadow.h b/lib/ShadowCopy/shadow.h
deleted file mode 100644
index e68b2655..00000000
--- a/lib/ShadowCopy/shadow.h
+++ /dev/null
@@ -1,94 +0,0 @@
-// **************************************************************************
-// * This file is part of the FreeFileSync project. It is distributed under *
-// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
-// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved *
-// **************************************************************************
-
-#ifndef SHADOWCOPY_H_14837413434
-#define SHADOWCOPY_H_14837413434
-
-#ifdef SHADOWDLL_EXPORTS
-#define DLL_FUNCTION_DECLARATION extern "C" __declspec(dllexport)
-#else
-#define DLL_FUNCTION_DECLARATION extern "C" __declspec(dllimport)
-#endif
-
-#include <zen/build_info.h>
-#include <zen/win_ver.h>
-
-
-class IVssBackupComponents;
-
-namespace shadow
-{
-/*--------------
- |declarations|
- --------------*/
-
-//COM needs to be initialized before calling any of these functions! CoInitializeEx/CoUninitialize
-struct ShadowData;
-typedef ShadowData* ShadowHandle;
-
-//volumeName *must* end with "\"
-DLL_FUNCTION_DECLARATION
-ShadowHandle createShadowCopy(const wchar_t* volumeName); //returns nullptr on failure!
-
-//release the backupHandle after shadow copy is not needed anymore!
-DLL_FUNCTION_DECLARATION
-void releaseShadowCopy(ShadowHandle handle);
-
-DLL_FUNCTION_DECLARATION
-const wchar_t* getShadowVolume(ShadowHandle handle); //never fails, returns shadowVolName, never ending with "\"
-
-//get last error message if any of the functions above fail
-DLL_FUNCTION_DECLARATION
-const wchar_t* getLastError(); //no nullptr check required!
-//##########################################################################################
-
-
-/*----------
- |typedefs|
- ----------*/
-typedef ShadowHandle (*FunType_createShadowCopy )(const wchar_t* volumeName);
-typedef void (*FunType_releaseShadowCopy)(ShadowHandle handle);
-typedef const wchar_t* (*FunType_getShadowVolume )(ShadowHandle handle);
-typedef const wchar_t* (*FunType_getLastError)();
-
-/*--------------
- |symbol names|
- --------------*/
-//(use const pointers to ensure internal linkage)
-const char funName_createShadowCopy [] = "createShadowCopy";
-const char funName_releaseShadowCopy[] = "releaseShadowCopy";
-const char funName_getShadowVolume [] = "getShadowVolume";
-const char funName_getLastError [] = "getLastError";
-/*---------------
- |library names|
- ---------------*/
-
-inline
-const wchar_t* getDllName()
-{
- // distinguish a bunch of VSS builds: we use XP, Server 2003 and Server 2008 R2 implementations...
- // VSS version and compatibility overview: http://msdn.microsoft.com/en-us/library/aa384627(VS.85).aspx
-
- if (zen::win7OrLater()) //Windows Server 2008 R2 or Windows 7
- return zen::is64BitBuild ?
- L"Shadow_Windows7_x64.dll" :
- L"Shadow_Windows7_Win32.dll";
- //else if (vistaOrLater()) -> skip Windows Server 2008 and Windows Vista
- // ;
- else if (zen::winServer2003orLater()) //Windows Server 2003 and Windows Server 2003 R2
- return zen::is64BitBuild ?
- L"Shadow_Server2003_x64.dll" :
- L"Shadow_Server2003_Win32.dll";
- else //Windows XP
- return zen::is64BitBuild ?
- L"Shadow_XP_x64.dll" :
- L"Shadow_XP_Win32.dll";
-}
-}
-
-#undef DLL_FUNCTION_DECLARATION
-
-#endif //SHADOWCOPY_H_14837413434
bgstack15