1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef VSS_WIN32_H
14#define VSS_WIN32_H
15
16#define __MIDL_user_allocate_free_DEFINED__
17#include <windows.h>
18#include <shlwapi.h>
19
20
21
22
23#define __in IN
24#define __out OUT
25#define __RPC_unique_pointer
26#define __RPC_string
27#define __RPC__deref_inout_opt
28#define __RPC__out
29#ifndef __RPC__out_ecount_part
30#define __RPC__out_ecount_part(x, y)
31#endif
32#define _declspec(x)
33#undef uuid
34#define uuid(x)
35
36
37#undef VSS_E_BAD_STATE
38#undef VSS_E_PROVIDER_NOT_REGISTERED
39#undef VSS_E_PROVIDER_VETO
40#undef VSS_E_OBJECT_NOT_FOUND
41#undef VSS_E_VOLUME_NOT_SUPPORTED
42#undef VSS_E_VOLUME_NOT_SUPPORTED_BY_PROVIDER
43#undef VSS_E_OBJECT_ALREADY_EXISTS
44#undef VSS_E_UNEXPECTED_PROVIDER_ERROR
45#undef VSS_E_INVALID_XML_DOCUMENT
46#undef VSS_E_MAXIMUM_NUMBER_OF_VOLUMES_REACHED
47#undef VSS_E_MAXIMUM_NUMBER_OF_SNAPSHOTS_REACHED
48
49
50
51
52
53#include "inc/win2003/vss.h"
54
55
56#define _L(a) L##a
57#define L(a) _L(a)
58
59
60
61#define QGA_PROVIDER_NAME "QEMU Guest Agent VSS Provider"
62#define QGA_PROVIDER_LNAME L(QGA_PROVIDER_NAME)
63#define QGA_PROVIDER_VERSION L(QEMU_VERSION)
64
65#define EVENT_NAME_FROZEN "Global\\QGAVSSEvent-frozen"
66#define EVENT_NAME_THAW "Global\\QGAVSSEvent-thaw"
67#define EVENT_NAME_TIMEOUT "Global\\QGAVSSEvent-timeout"
68
69const GUID g_gProviderId = { 0x3629d4ed, 0xee09, 0x4e0e,
70 {0x9a, 0x5c, 0x6d, 0x8b, 0xa2, 0x87, 0x2a, 0xef} };
71const GUID g_gProviderVersion = { 0x11ef8b15, 0xcac6, 0x40d6,
72 {0x8d, 0x5c, 0x8f, 0xfc, 0x16, 0x3f, 0x24, 0xca} };
73
74const CLSID CLSID_QGAVSSProvider = { 0x6e6a3492, 0x8d4d, 0x440c,
75 {0x96, 0x19, 0x5e, 0x5d, 0x0c, 0xc3, 0x1c, 0xa8} };
76
77const TCHAR g_szClsid[] = TEXT("{6E6A3492-8D4D-440C-9619-5E5D0CC31CA8}");
78const TCHAR g_szProgid[] = TEXT("QGAVSSProvider");
79
80
81enum __VSS_VOLUME_SNAPSHOT_ATTRIBUTES {
82 VSS_VOLSNAP_ATTR_NO_AUTORECOVERY = 0x00000002,
83 VSS_VOLSNAP_ATTR_TXF_RECOVERY = 0x02000000
84};
85
86
87
88template <class T>
89class COMPointer {
90 COMPointer(const COMPointer<T> &p) { }
91 T *p;
92public:
93 COMPointer &operator=(T *new_p)
94 {
95
96 if (p && p != new_p) {
97 p->Release();
98 }
99 p = new_p;
100 return *this;
101 }
102
103 T **replace(void)
104 {
105 *this = NULL;
106 return &p;
107 }
108
109 operator T*() { return p; }
110 T *operator->(void) { return p; }
111 T &operator*(void) { return *p; }
112 operator bool() { return !!p; }
113
114 COMPointer(T *p = NULL) : p(p) { }
115 ~COMPointer() { *this = NULL; }
116};
117
118
119
120
121
122class COMInitializer {
123public:
124 COMInitializer() { CoInitialize(NULL); }
125 ~COMInitializer() { CoUninitialize(); }
126};
127
128#endif
129