diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:14:37 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:14:37 +0200 |
commit | 8bf668665b107469086f16cb8ad23e47d479d2b4 (patch) | |
tree | 66a91ef06a8caa7cd6819dcbe1860693d3eda8d5 /shared/shadow.cpp | |
parent | 3.21 (diff) | |
download | FreeFileSync-8bf668665b107469086f16cb8ad23e47d479d2b4.tar.gz FreeFileSync-8bf668665b107469086f16cb8ad23e47d479d2b4.tar.bz2 FreeFileSync-8bf668665b107469086f16cb8ad23e47d479d2b4.zip |
4.0
Diffstat (limited to 'shared/shadow.cpp')
-rw-r--r-- | shared/shadow.cpp | 77 |
1 files changed, 17 insertions, 60 deletions
diff --git a/shared/shadow.cpp b/shared/shadow.cpp index f000a69b..7f25076e 100644 --- a/shared/shadow.cpp +++ b/shared/shadow.cpp @@ -20,31 +20,12 @@ using namespace shadow; namespace { -bool newerThanXP() -{ - OSVERSIONINFO osvi = {}; - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - - if (::GetVersionEx(&osvi)) - return osvi.dwMajorVersion > 5 || - (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion > 1) ; - //XP has majorVersion == 5, minorVersion == 1 - //Server 2003 has majorVersion == 5, minorVersion == 2 - //version overview: http://msdn.microsoft.com/en-us/library/ms724834(VS.85).aspx - return false; -} - - bool runningWOW64() //test if process is running under WOW64 (reference http://msdn.microsoft.com/en-us/library/ms684139(VS.85).aspx) { //dynamically load windows API function - typedef BOOL (WINAPI *IsWow64ProcessFun)( - HANDLE hProcess, - PBOOL Wow64Process); - - const IsWow64ProcessFun isWow64Process = - util::getDllFun<IsWow64ProcessFun>(L"kernel32.dll", "IsWow64Process"); + typedef BOOL (WINAPI *IsWow64ProcessFun)(HANDLE hProcess, PBOOL Wow64Process); + const util::DllFun<IsWow64ProcessFun> isWow64Process(L"kernel32.dll", "IsWow64Process"); if (isWow64Process) { BOOL isWow64 = FALSE; @@ -54,27 +35,6 @@ bool runningWOW64() //test if process is running under WOW64 (reference http://m return false; } - - -inline -std::wstring getShadowDllName() -{ - /* - distinguish a bunch of VSS builds: we use XP and Server 2003 implementations... - VSS version and compatibility overview: http://msdn.microsoft.com/en-us/library/aa384627(VS.85).aspx - */ - - assert_static(util::is32BitBuild || util::is64BitBuild); - - return newerThanXP() ? - (util::is64BitBuild ? - L"Shadow_Server2003_x64.dll" : - L"Shadow_Server2003_Win32.dll") : - - (util::is64BitBuild ? - L"Shadow_XP_x64.dll" : - L"Shadow_XP_Win32.dll"); -} } //############################################################################################################# @@ -84,21 +44,19 @@ class ShadowCopy::ShadowVolume { public: ShadowVolume(const Zstring& volumeNameFormatted) : //throw(FileError) + createShadowCopy(getDllName(), createShadowCopyFctName), + releaseShadowCopy(getDllName(), releaseShadowCopyFctName), backupHandle(0) { - createShadowCopy = util::getDllFun<CreateShadowCopyFct>(getShadowDllName(), createShadowCopyFctName); - releaseShadowCopy = util::getDllFun<ReleaseShadowCopyFct>(getShadowDllName(), releaseShadowCopyFctName); - //check if shadow copy dll was loaded correctly - if (createShadowCopy == NULL || - releaseShadowCopy == NULL) - throw FileError(_("Error starting Volume Shadow Copy Service!") + "\n" + - _("Could not load a required DLL:") + " \"" + getShadowDllName() + "\""); + if (!createShadowCopy || !releaseShadowCopy) + throw FileError(_("Error accessing Volume Shadow Copy Service!") + "\n" + + _("Could not load a required DLL:") + " \"" + getDllName() + "\""); //VSS does not support running under WOW64 except for Windows XP and Windows Server 2003 //(Reference: http://msdn.microsoft.com/en-us/library/aa384627(VS.85).aspx) if (runningWOW64()) - throw FileError(_("Error starting Volume Shadow Copy Service!") + "\n" + + throw FileError(_("Error accessing Volume Shadow Copy Service!") + "\n" + _("Making shadow copies on WOW64 is not supported. Please use FreeFileSync 64-bit version.")); //--------------------------------------------------------------------------------------------------------- @@ -106,14 +64,13 @@ public: wchar_t shadowVolName[1000]; wchar_t errorMessage[1000]; - if (!createShadowCopy( - volumeNameFormatted.c_str(), - shadowVolName, - 1000, - &backupHandle, - errorMessage, - 1000)) - throw FileError(_("Error starting Volume Shadow Copy Service!") + "\n" + + if (!createShadowCopy(volumeNameFormatted.c_str(), + shadowVolName, + 1000, + &backupHandle, + errorMessage, + 1000)) + throw FileError(_("Error accessing Volume Shadow Copy Service!") + "\n" + "(" + errorMessage + " Volume: \"" + volumeNameFormatted + "\")"); shadowVol = Zstring(shadowVolName) + FILE_NAME_SEPARATOR; //shadowVolName NEVER has a trailing backslash @@ -133,8 +90,8 @@ private: ShadowVolume(const ShadowVolume&); ShadowVolume& operator=(const ShadowVolume&); - shadow::CreateShadowCopyFct createShadowCopy; - shadow::ReleaseShadowCopyFct releaseShadowCopy; + const util::DllFun<CreateShadowCopyFct> createShadowCopy; + const util::DllFun<ReleaseShadowCopyFct> releaseShadowCopy; Zstring shadowVol; |