summaryrefslogtreecommitdiff
path: root/shared/shadow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'shared/shadow.cpp')
-rw-r--r--shared/shadow.cpp77
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;
bgstack15