diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:07:15 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:07:15 +0200 |
commit | 8318453bf9d4fd50b137ff6c6fc8d1fd22aa6395 (patch) | |
tree | 975c6e590c31e56007006a23e7b15d0245d75b08 /shared/ShadowCopy | |
parent | 3.6 (diff) | |
download | FreeFileSync-8318453bf9d4fd50b137ff6c6fc8d1fd22aa6395.tar.gz FreeFileSync-8318453bf9d4fd50b137ff6c6fc8d1fd22aa6395.tar.bz2 FreeFileSync-8318453bf9d4fd50b137ff6c6fc8d1fd22aa6395.zip |
3.7
Diffstat (limited to 'shared/ShadowCopy')
-rw-r--r-- | shared/ShadowCopy/Shadow_2003.vcproj | 413 | ||||
-rw-r--r-- | shared/ShadowCopy/Shadow_XP.vcproj | 413 | ||||
-rw-r--r-- | shared/ShadowCopy/dllmain.cpp | 27 | ||||
-rw-r--r-- | shared/ShadowCopy/shadow.cpp | 204 | ||||
-rw-r--r-- | shared/ShadowCopy/shadow.h | 55 |
5 files changed, 1112 insertions, 0 deletions
diff --git a/shared/ShadowCopy/Shadow_2003.vcproj b/shared/ShadowCopy/Shadow_2003.vcproj new file mode 100644 index 00000000..49730440 --- /dev/null +++ b/shared/ShadowCopy/Shadow_2003.vcproj @@ -0,0 +1,413 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9,00" + Name="Server2003" + ProjectGUID="{2F2994D6-FB89-4BAA-A5DF-03BAF7337FF2}" + RootNamespace="ShadowDll" + Keyword="Win32Proj" + TargetFrameworkVersion="196613" + > + <Platforms> + <Platform + Name="Win32" + /> + <Platform + Name="x64" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" + IntermediateDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" + ConfigurationType="2" + CharacterSet="1" + BuildLogFile="$(IntDir)\Build.html" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + PreprocessorDefinitions="_DEBUG;_WINDOWS;_USRDLL;SHADOWDLL_EXPORTS;USE_SHADOW_2003" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + UsePrecompiledHeader="0" + WarningLevel="3" + SuppressStartupBanner="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="Shadow_$(ProjectName)_$(PlatformName).dll" + LinkIncremental="1" + SuppressStartupBanner="false" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(IntDir)$(TargetName).pdb" + SubSystem="2" + ProfileGuidedDatabase="" + ImportLibrary="$(IntDir)$(TargetName).lib" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Debug|x64" + OutputDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" + IntermediateDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" + ConfigurationType="2" + CharacterSet="1" + BuildLogFile="$(IntDir)\Build.html" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + TargetEnvironment="3" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + PreprocessorDefinitions="_DEBUG;_WINDOWS;_USRDLL;SHADOWDLL_EXPORTS;USE_SHADOW_2003" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + UsePrecompiledHeader="0" + WarningLevel="3" + SuppressStartupBanner="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="Shadow_$(ProjectName)_$(PlatformName).dll" + LinkIncremental="1" + SuppressStartupBanner="false" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(IntDir)$(TargetName).pdb" + SubSystem="2" + ProfileGuidedDatabase="" + ImportLibrary="$(IntDir)$(TargetName).lib" + TargetMachine="17" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" + IntermediateDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" + ConfigurationType="2" + CharacterSet="1" + WholeProgramOptimization="1" + BuildLogFile="$(IntDir)\Build.html" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + EnableIntrinsicFunctions="true" + PreprocessorDefinitions="NDEBUG;_WINDOWS;_USRDLL;SHADOWDLL_EXPORTS;USE_SHADOW_2003" + RuntimeLibrary="0" + EnableFunctionLevelLinking="true" + UsePrecompiledHeader="0" + WarningLevel="3" + SuppressStartupBanner="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="Shadow_$(ProjectName)_$(PlatformName).dll" + LinkIncremental="1" + SuppressStartupBanner="false" + GenerateDebugInformation="false" + SubSystem="2" + OptimizeReferences="2" + EnableCOMDATFolding="2" + LinkTimeCodeGeneration="1" + ProfileGuidedDatabase="" + ImportLibrary="$(IntDir)$(TargetName).lib" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|x64" + OutputDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" + IntermediateDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" + ConfigurationType="2" + CharacterSet="1" + WholeProgramOptimization="1" + BuildLogFile="$(IntDir)\Build.html" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + TargetEnvironment="3" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + EnableIntrinsicFunctions="true" + PreprocessorDefinitions="NDEBUG;_WINDOWS;_USRDLL;SHADOWDLL_EXPORTS;USE_SHADOW_2003" + RuntimeLibrary="0" + EnableFunctionLevelLinking="true" + UsePrecompiledHeader="0" + WarningLevel="3" + SuppressStartupBanner="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="Shadow_$(ProjectName)_$(PlatformName).dll" + LinkIncremental="1" + SuppressStartupBanner="false" + GenerateDebugInformation="false" + SubSystem="2" + OptimizeReferences="2" + EnableCOMDATFolding="2" + LinkTimeCodeGeneration="1" + ProfileGuidedDatabase="" + ImportLibrary="$(IntDir)$(TargetName).lib" + TargetMachine="17" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Quelldateien" + Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\dllmain.cpp" + > + <FileConfiguration + Name="Debug|Win32" + > + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0" + CompileAsManaged="0" + /> + </FileConfiguration> + <FileConfiguration + Name="Debug|x64" + > + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0" + CompileAsManaged="0" + /> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + > + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0" + CompileAsManaged="0" + /> + </FileConfiguration> + <FileConfiguration + Name="Release|x64" + > + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0" + CompileAsManaged="0" + /> + </FileConfiguration> + </File> + <File + RelativePath=".\shadow.cpp" + > + </File> + </Filter> + <Filter + Name="Headerdateien" + Filter="h;hpp;hxx;hm;inl;inc;xsd" + UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" + > + <File + RelativePath=".\shadow.h" + > + </File> + </Filter> + <File + RelativePath=".\Server 2003\lib\$(PlatformName)\vssapi.lib" + > + </File> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/shared/ShadowCopy/Shadow_XP.vcproj b/shared/ShadowCopy/Shadow_XP.vcproj new file mode 100644 index 00000000..74b231de --- /dev/null +++ b/shared/ShadowCopy/Shadow_XP.vcproj @@ -0,0 +1,413 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9,00" + Name="XP" + ProjectGUID="{70394AEF-5897-4911-AFA1-82EAF0581EFA}" + RootNamespace="ShadowDll" + Keyword="Win32Proj" + TargetFrameworkVersion="196613" + > + <Platforms> + <Platform + Name="Win32" + /> + <Platform + Name="x64" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" + IntermediateDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" + ConfigurationType="2" + CharacterSet="1" + BuildLogFile="$(IntDir)\Build.html" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + PreprocessorDefinitions="_DEBUG;_WINDOWS;_USRDLL;SHADOWDLL_EXPORTS;USE_SHADOW_XP" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + UsePrecompiledHeader="0" + WarningLevel="3" + SuppressStartupBanner="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="Shadow_$(ProjectName)_$(PlatformName).dll" + LinkIncremental="1" + SuppressStartupBanner="false" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(IntDir)$(TargetName).pdb" + SubSystem="2" + ProfileGuidedDatabase="" + ImportLibrary="$(IntDir)$(TargetName).lib" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Debug|x64" + OutputDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" + IntermediateDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" + ConfigurationType="2" + CharacterSet="1" + BuildLogFile="$(IntDir)\Build.html" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + TargetEnvironment="3" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + PreprocessorDefinitions="_DEBUG;_WINDOWS;_USRDLL;SHADOWDLL_EXPORTS;USE_SHADOW_XP" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + UsePrecompiledHeader="0" + WarningLevel="3" + SuppressStartupBanner="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="Shadow_$(ProjectName)_$(PlatformName).dll" + LinkIncremental="1" + SuppressStartupBanner="false" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(IntDir)$(TargetName).pdb" + SubSystem="2" + ProfileGuidedDatabase="" + ImportLibrary="$(IntDir)$(TargetName).lib" + TargetMachine="17" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" + IntermediateDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" + ConfigurationType="2" + CharacterSet="1" + WholeProgramOptimization="1" + BuildLogFile="$(IntDir)\Build.html" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + EnableIntrinsicFunctions="true" + PreprocessorDefinitions="NDEBUG;_WINDOWS;_USRDLL;SHADOWDLL_EXPORTS;USE_SHADOW_XP" + RuntimeLibrary="0" + EnableFunctionLevelLinking="true" + UsePrecompiledHeader="0" + WarningLevel="3" + SuppressStartupBanner="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="Shadow_$(ProjectName)_$(PlatformName).dll" + LinkIncremental="1" + SuppressStartupBanner="false" + GenerateDebugInformation="false" + SubSystem="2" + OptimizeReferences="2" + EnableCOMDATFolding="2" + LinkTimeCodeGeneration="1" + ProfileGuidedDatabase="" + ImportLibrary="$(IntDir)$(TargetName).lib" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|x64" + OutputDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" + IntermediateDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" + ConfigurationType="2" + CharacterSet="1" + WholeProgramOptimization="1" + BuildLogFile="$(IntDir)\Build.html" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + TargetEnvironment="3" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + EnableIntrinsicFunctions="true" + PreprocessorDefinitions="NDEBUG;_WINDOWS;_USRDLL;SHADOWDLL_EXPORTS;USE_SHADOW_XP" + RuntimeLibrary="0" + EnableFunctionLevelLinking="true" + UsePrecompiledHeader="0" + WarningLevel="3" + SuppressStartupBanner="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="Shadow_$(ProjectName)_$(PlatformName).dll" + LinkIncremental="1" + SuppressStartupBanner="false" + GenerateDebugInformation="false" + SubSystem="2" + OptimizeReferences="2" + EnableCOMDATFolding="2" + LinkTimeCodeGeneration="1" + ProfileGuidedDatabase="" + ImportLibrary="$(IntDir)$(TargetName).lib" + TargetMachine="17" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Quelldateien" + Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\dllmain.cpp" + > + <FileConfiguration + Name="Debug|Win32" + > + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0" + CompileAsManaged="0" + /> + </FileConfiguration> + <FileConfiguration + Name="Debug|x64" + > + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0" + CompileAsManaged="0" + /> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + > + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0" + CompileAsManaged="0" + /> + </FileConfiguration> + <FileConfiguration + Name="Release|x64" + > + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0" + CompileAsManaged="0" + /> + </FileConfiguration> + </File> + <File + RelativePath=".\shadow.cpp" + > + </File> + </Filter> + <Filter + Name="Headerdateien" + Filter="h;hpp;hxx;hm;inl;inc;xsd" + UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" + > + <File + RelativePath=".\shadow.h" + > + </File> + </Filter> + <File + RelativePath=".\XP\lib\$(PlatformName)\vssapi.lib" + > + </File> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/shared/ShadowCopy/dllmain.cpp b/shared/ShadowCopy/dllmain.cpp new file mode 100644 index 00000000..7db39bff --- /dev/null +++ b/shared/ShadowCopy/dllmain.cpp @@ -0,0 +1,27 @@ +// ************************************************************************** +// * 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) 2008-2010 ZenJu (zhnmju123 AT gmx.de) * +// ************************************************************************** +// + +#define WIN32_LEAN_AND_MEAN +#include <windows.h> + + +BOOL APIENTRY DllMain( HMODULE hModule, + DWORD ul_reason_for_call, + LPVOID lpReserved + ) +{ + switch (ul_reason_for_call) + { + case DLL_PROCESS_ATTACH: + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + case DLL_PROCESS_DETACH: + break; + } + return TRUE; +} + diff --git a/shared/ShadowCopy/shadow.cpp b/shared/ShadowCopy/shadow.cpp new file mode 100644 index 00000000..b15bd4f9 --- /dev/null +++ b/shared/ShadowCopy/shadow.cpp @@ -0,0 +1,204 @@ +// ************************************************************************** +// * 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) 2008-2010 ZenJu (zhnmju123 AT gmx.de) * +// ************************************************************************** +// +#include "shadow.h" + +#define WIN32_LEAN_AND_MEAN +#include "windows.h" + +#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" +#else +adapt! +#endif + +#include <algorithm> +#include <string> +#include <cstdio> +#include <comdef.h> + +//typedef GUID VSS_ID; + + +void writeString(const wchar_t* input, wchar_t* output, unsigned int outputBufferLen) +{ + const size_t newSize = min(wcslen(input) + 1, outputBufferLen); //including null-termination + memcpy(output, input, newSize * sizeof(wchar_t)); + output[newSize-1] = 0; //if output buffer is too small... +} + + +std::wstring numberToHexString(const long number) +{ + wchar_t result[100]; + swprintf(result, 100, L"0x%08x", number); + return std::wstring(result); +} + + +void writeErrorMsg(const wchar_t* input, HRESULT hr, wchar_t* output, unsigned int outputBufferLen) +{ + std::wstring formattedMsg(input); + formattedMsg += L" ("; + formattedMsg += numberToHexString(hr); + formattedMsg += L": "; + formattedMsg += _com_error(hr).ErrorMessage(); + formattedMsg += L")"; + + writeString(formattedMsg.c_str(), output, outputBufferLen); +} + + +bool shadow::createShadowCopy(const wchar_t* volumeName, + wchar_t* shadowVolName, + unsigned int shadowBufferLen, + void** backupHandle, + wchar_t* errorMessage, + unsigned int errorBufferLen) +{ + //MessageBox(0, L"backup err", L"", 0); */ + *backupHandle = NULL; + HRESULT hr = NULL; + + IVssBackupComponents* pBackupComponents = NULL; + if (FAILED(hr = CreateVssBackupComponents(&pBackupComponents))) + { + if (hr == E_ACCESSDENIED) + writeErrorMsg(L"The caller does not have sufficient backup privileges or is not an administrator.", hr, errorMessage, errorBufferLen); + else + writeErrorMsg(L"Error calling \"CreateVssBackupComponents\".", hr, errorMessage, errorBufferLen); + return false; + } + + + if (FAILED(hr = pBackupComponents->InitializeForBackup())) + { + releaseShadowCopy(pBackupComponents); + writeErrorMsg(L"Error calling \"InitializeForBackup\".", hr, errorMessage, errorBufferLen); + return false; + } + + + IVssAsync* pWriteMetaData = NULL; + if (FAILED(hr = pBackupComponents->GatherWriterMetadata( &pWriteMetaData ))) + { //this can happen if XP-version of VSS is used on Windows Vista (which needs at least VSS-Server2003 build) + releaseShadowCopy(pBackupComponents); + writeErrorMsg(L"Error calling \"GatherWriterMetadata\".", hr, errorMessage, errorBufferLen); + return false; + } + + //wait for shadow copy writers to complete + hr = pWriteMetaData->Wait(); + if (SUCCEEDED(hr)) + pWriteMetaData->QueryStatus(&hr, NULL); //check if the async operation succeeded... + + pWriteMetaData->Release(); + if (FAILED(hr)) + { + releaseShadowCopy(pBackupComponents); + writeErrorMsg(L"Error calling \"ppWriteMetaData->Wait\".", hr, errorMessage, errorBufferLen); + return false; + } + + + VSS_ID snapshotSetId = {0}; + if (FAILED(hr = pBackupComponents->StartSnapshotSet( &snapshotSetId ))) + { + releaseShadowCopy(pBackupComponents); + writeErrorMsg(L"Error calling \"StartSnapshotSet\".", hr, errorMessage, errorBufferLen); + return false; + } + + + VSS_ID SnapShotId = {0}; + if (FAILED(hr = pBackupComponents->AddToSnapshotSet(const_cast<wchar_t*>(volumeName), GUID_NULL, &SnapShotId))) + { + releaseShadowCopy(pBackupComponents); + writeErrorMsg(L"Error calling \"AddToSnapshotSet\".", hr, errorMessage, errorBufferLen); + return false; + } + + + if (FAILED(hr = pBackupComponents->SetBackupState( false, false, VSS_BT_FULL ))) + { + releaseShadowCopy(pBackupComponents); + writeErrorMsg(L"Error calling \"SetBackupState\".", hr, errorMessage, errorBufferLen); + return false; + } + + + IVssAsync* pPrepare = NULL; + if (FAILED(hr = pBackupComponents->PrepareForBackup( &pPrepare ))) + { + releaseShadowCopy(pBackupComponents); + writeErrorMsg(L"Error calling \"PrepareForBackup\".", hr, errorMessage, errorBufferLen); + return false; + } + + hr = pPrepare->Wait(); + if (SUCCEEDED(hr)) + pPrepare->QueryStatus(&hr, NULL); //check if the async operation succeeded... + + pPrepare->Release(); + if (FAILED(hr)) + { + releaseShadowCopy(pBackupComponents); + writeErrorMsg(L"Error calling \"pPrepare->Wait\".", hr, errorMessage, errorBufferLen); + return false; + } + + + IVssAsync* pDoShadowCopy = NULL; + if (FAILED(hr = pBackupComponents->DoSnapshotSet( &pDoShadowCopy ))) + { + releaseShadowCopy(pBackupComponents); + writeErrorMsg(L"Error calling \"DoSnapshotSet\".", hr, errorMessage, errorBufferLen); + return false; + } + + hr = pDoShadowCopy->Wait(); + if (SUCCEEDED(hr)) + pDoShadowCopy->QueryStatus(&hr, NULL); //check if the async operation succeeded... + + pDoShadowCopy->Release(); + if (FAILED(hr)) + { + releaseShadowCopy(pBackupComponents); + writeErrorMsg(L"Error calling \"pPrepare->Wait\".", hr, errorMessage, errorBufferLen); + return false; + } + + VSS_SNAPSHOT_PROP props; + if (FAILED(hr = pBackupComponents->GetSnapshotProperties( SnapShotId, &props ))) + { + releaseShadowCopy(pBackupComponents); + writeErrorMsg(L"Error calling \"GetSnapshotProperties\".", hr, errorMessage, errorBufferLen); + return false; + } + + //finally: write volume name of newly created shadow copy + writeString(props.m_pwszSnapshotDeviceObject, shadowVolName, shadowBufferLen); + + VssFreeSnapshotProperties(&props); + + *backupHandle = pBackupComponents; + + return true; +} + + +void shadow::releaseShadowCopy(void* backupHandle) +{ + if (backupHandle != NULL) + static_cast<IVssBackupComponents*>(backupHandle)->Release(); +} diff --git a/shared/ShadowCopy/shadow.h b/shared/ShadowCopy/shadow.h new file mode 100644 index 00000000..61d6ae7e --- /dev/null +++ b/shared/ShadowCopy/shadow.h @@ -0,0 +1,55 @@ +// ************************************************************************** +// * 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) 2008-2010 ZenJu (zhnmju123 AT gmx.de) * +// ************************************************************************** +// +#ifndef SHADOWCOPY_H +#define SHADOWCOPY_H + +#ifdef SHADOWDLL_EXPORTS +#define SHADOWDLL_API extern "C" __declspec(dllexport) +#else +#define SHADOWDLL_API extern "C" __declspec(dllimport) +#endif + + +namespace Shadow +{ +//COM needs to be initialized before calling any of these functions! CoInitializeEx/CoUninitialize + + +//volumeName must end with "\", while shadowVolName does not end with "\" +SHADOWDLL_API +bool createShadowCopy(const wchar_t* volumeName, + wchar_t* shadowVolName, + unsigned int shadowBufferLen, + void** backupHandle, + wchar_t* errorMessage, + unsigned int errorBufferLen); + + +//don't forget to release the backupHandle after shadow copy is not needed anymore! +SHADOWDLL_API +void releaseShadowCopy(void* backupHandle); + + + +//function typedefs +typedef bool (*CreateShadowCopyFct)(const wchar_t* volumeName, + wchar_t* shadowVolName, + unsigned int shadowBufferLen, + void** backupHandle, + wchar_t* errorMessage, + unsigned int errorBufferLen); + +typedef void (*ReleaseShadowCopyFct)(void* backupHandle); + +//function names +const char* const createShadowCopyFctName = "createShadowCopy"; +const char* const releaseShadowCopyFctName = "releaseShadowCopy"; +} + + + +#endif //SHADOWCOPY_H |