#include "winapi.h"
+#ifdef WIN32_VSS
+#include "vss.h"
+#endif
+
+// init with win9x, but maybe set to NT in InitWinAPI
+DWORD g_platform_id = VER_PLATFORM_WIN32_WINDOWS;
+#ifdef WIN32_VSS
+/* preset VSSClient to NULL */
+VSSClient* g_pVSSClient = NULL;
+#endif
+
+
/* API Pointers */
-t_OpenProcessToken p_OpenProcessToken = NULL;
+t_OpenProcessToken p_OpenProcessToken = NULL;
t_AdjustTokenPrivileges p_AdjustTokenPrivileges = NULL;
-t_LookupPrivilegeValue p_LookupPrivilegeValue = NULL;
+t_LookupPrivilegeValue p_LookupPrivilegeValue = NULL;
t_SetProcessShutdownParameters p_SetProcessShutdownParameters = NULL;
-t_CreateFileA p_CreateFileA = NULL;
-t_CreateFileW p_CreateFileW = NULL;
+t_CreateFileA p_CreateFileA = NULL;
+t_CreateFileW p_CreateFileW = NULL;
t_wunlink p_wunlink = NULL;
t_wmkdir p_wmkdir = NULL;
t_wopen p_wopen = NULL;
-t_GetFileAttributesA p_GetFileAttributesA = NULL;
-t_GetFileAttributesW p_GetFileAttributesW = NULL;
-t_GetFileAttributesExA p_GetFileAttributesExA = NULL;
-t_GetFileAttributesExW p_GetFileAttributesExW = NULL;
+t_GetFileAttributesA p_GetFileAttributesA = NULL;
+t_GetFileAttributesW p_GetFileAttributesW = NULL;
-t_SetFileAttributesA p_SetFileAttributesA = NULL;
-t_SetFileAttributesW p_SetFileAttributesW = NULL;
-t_BackupRead p_BackupRead = NULL;
-t_BackupWrite p_BackupWrite = NULL;
+t_GetFileAttributesExA p_GetFileAttributesExA = NULL;
+t_GetFileAttributesExW p_GetFileAttributesExW = NULL;
+
+t_SetFileAttributesA p_SetFileAttributesA = NULL;
+t_SetFileAttributesW p_SetFileAttributesW = NULL;
+t_BackupRead p_BackupRead = NULL;
+t_BackupWrite p_BackupWrite = NULL;
t_WideCharToMultiByte p_WideCharToMultiByte = NULL;
t_MultiByteToWideChar p_MultiByteToWideChar = NULL;
t_GetCurrentDirectoryA p_GetCurrentDirectoryA = NULL;
t_GetCurrentDirectoryW p_GetCurrentDirectoryW = NULL;
+#ifdef WIN32_VSS
+void
+VSSCleanup()
+{
+ if (g_pVSSClient)
+ delete (g_pVSSClient);
+}
+#endif
+
void
InitWinAPIWrapper()
{
/* wopen */
p_wopen = (t_wopen)
GetProcAddress(hLib, "_wopen");
-
+
FreeLibrary(hLib);
}
}
// do we run on win 9x ???
-
- DWORD dw_platform_id;
-
- OSVERSIONINFO osversioninfo;
+ OSVERSIONINFO osversioninfo;
osversioninfo.dwOSVersionInfoSize = sizeof(osversioninfo);
+ DWORD dwMinorVersion;
+
// Get the current OS version
if (!GetVersionEx(&osversioninfo)) {
- dw_platform_id = 0;
+ g_platform_id = 0;
+ dwMinorVersion = 0;
} else {
- dw_platform_id = osversioninfo.dwPlatformId;
+ g_platform_id = osversioninfo.dwPlatformId;
+ dwMinorVersion = osversioninfo.dwMinorVersion;
}
- if (dw_platform_id == VER_PLATFORM_WIN32_WINDOWS) {
+ /* deinitialize some routines on win95 - they're not implemented well */
+ if (g_platform_id == VER_PLATFORM_WIN32_WINDOWS) {
p_BackupRead = NULL;
p_BackupWrite = NULL;
- p_CreateFileW = NULL;
- p_GetFileAttributesW = NULL;
+ p_CreateFileW = NULL;
+ p_GetFileAttributesW = NULL;
p_GetFileAttributesExW = NULL;
-
+
p_SetFileAttributesW = NULL;
-
+
p_FindFirstFileW = NULL;
p_FindNextFileW = NULL;
p_SetCurrentDirectoryW = NULL;
p_wmkdir = NULL;
p_wopen = NULL;
}
+
+ /* decide which vss class to initialize */
+#ifdef WIN32_VSS
+ switch (dwMinorVersion) {
+ case 1:
+ g_pVSSClient = new VSSClientXP();
+ atexit(VSSCleanup);
+ break;
+ case 2:
+ g_pVSSClient = new VSSClient2003();
+ atexit(VSSCleanup);
+ break;
+ }
+#endif
}
+
#endif