ofs | hex dump | ascii |
---|
0000 | 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 04 b7 00 00 02 21 08 02 00 00 00 33 75 cf | .PNG........IHDR.......!.....3u. |
0020 | 3d 00 00 00 03 73 42 49 54 08 08 08 db e1 4f e0 00 00 00 19 74 45 58 74 53 6f 66 74 77 61 72 65 | =....sBIT.....O.....tEXtSoftware |
0040 | 00 67 6e 6f 6d 65 2d 73 63 72 65 65 6e 73 68 6f 74 ef 03 bf 3e 00 00 20 00 49 44 41 54 78 9c ec | .gnome-screenshot...>....IDATx.. |
0060 | bd 79 7c 15 d5 fd ff ff 7e 9f 49 08 49 80 b0 5a 10 ca 26 41 59 14 10 10 15 ad 55 c1 0d f7 a2 b5 | .y|.....~.I.I..Z..&AY.....U..... |
0080 | d5 b6 d6 6a ad 5d 14 ad fa ad d6 b5 da da ba 54 ad 3f 5b a9 ad 7e 6c dd 17 dc 41 50 11 ab 56 01 | ...j.].........T.?[..~l...AP..V. |
00a0 | 01 51 54 44 44 40 36 91 00 61 0f c9 3d ef df 1f 67 99 c9 9d b9 37 37 c9 4d 02 f6 f5 6c 1f 78 33 | .QTDD@6..a..=...g....77.M...l.x3 |
00c0 | 77 e6 ac 33 73 cf eb bc df e7 7d 58 44 08 00 00 00 00 00 00 00 00 20 22 22 d5 d2 05 00 00 00 00 | w..3s.....}XD..........""....... |
00e0 | 00 00 00 00 b0 0b 01 95 08 00 00 00 00 00 00 00 20 04 2a 11 00 00 00 00 00 00 00 40 08 54 22 00 | ..................*........@.T". |
0100 | 00 00 00 00 00 00 80 90 82 96 2e 00 00 2d c3 e6 cd 9b 9f 7c f2 c9 39 73 e6 6c dc b8 b1 6d db b6 | .............-.....|..9s.l...m.. |
0120 | 43 86 0c 39 ed b4 d3 3a 75 ea d4 d2 e5 02 00 34 2d a9 54 6a ca 94 29 33 66 cc 58 b3 66 4d 51 51 | C..9...:u......4-.Tj..)3f.X.fMQQ |
0140 | 51 79 79 f9 a9 a7 9e da bf 7f ff 96 2e 17 00 00 00 b0 0b c1 88 71 0a fe 07 d9 bc 79 f3 6f 7f fb | Qyy..................q.....y.o.. |
0160 | db af be fa 2a 7a b0 5d bb 76 bf ff fd ef 3b 77 ee dc 52 a5 02 00 34 03 b7 de 7a eb 9c 39 73 a2 | ....*z.].v....;w..R...4...z..9s. |
0180 | 47 98 f9 d2 4b 2f dd 7f ff fd 5b aa 48 00 00 00 c0 ae 06 3c 4e c1 ff 22 cf 3f ff 7c 9a 44 24 a2 | G...K/....[.H......<N..".?.|.D$. |
01a0 | 4d 9b 36 3d f5 d4 53 2d 52 1e 00 40 f3 f0 de 7b ef a5 49 44 22 12 91 07 1e 78 a0 45 ca 03 00 00 | M.6=..S-R..@...{..ID"....x.E.... |
01c0 | 00 ec 9a e4 c7 e3 54 44 56 ad 5a b5 72 e5 ca f5 eb d7 ef d8 b1 83 88 8a 8b 8b 3b 77 ee fc cd 6f | ......TDV.Z.r.............;w...o |
01e0 | 7e 73 8f 3d f6 c8 4b 16 00 e4 91 4f 3f fd 34 f1 f8 a2 45 8b 9a b9 24 00 80 e6 24 d3 b3 bf 76 ed | ~s.=..K....O?.4...E...$...$...v. |
0200 | da ca ca ca b2 b2 b2 66 2e 0f 00 00 00 b0 6b d2 58 95 f8 c9 27 9f cc 98 31 e3 dd 77 df dd b2 65 | .......f......k.X...'...1..w...e |
0220 | 4b e2 09 1d 3a 74 38 e0 80 03 8e 38 e2 88 9e 3d 7b d6 99 da fd f7 df 3f 6d da b4 3a 4f 2b 2a 2a | K...:t8....8...={......?m..:O+** |
0240 | 2a 29 29 29 2b 2b eb de bd 7b cf 9e 3d 87 0e 1d 9a 3d f1 99 33 67 de 71 c7 1d f1 e3 87 1c 72 c8 | *)))++...{..=....=..3g.q......r. |
0260 | 2f 7e f1 8b 2c 17 be f2 ca 2b ff fc e7 3f d3 0e 0e 1a 34 e8 aa ab ae ca 25 fd 1c e9 d0 a1 c3 86 | /~..,....+...?....4.....%....... |
0280 | 0d 1b e2 c7 af bf fe fa 5c 96 ca 3c f0 c0 03 2f bd f4 52 da 41 66 9e 38 71 62 db b6 6d e3 e7 ff | ........\..<.../..R.Af.8qb..m... |
</*
* QEMU Guest Agent VSS utility functions
*
* Copyright Hitachi Data Systems Corp. 2013
*
* Authors:
* Tomoki Sekiyama <tomoki.sekiyama@hds.com>
*
* This work is licensed under the terms of the GNU GPL, version 2 or later.
* See the COPYING file in the top-level directory.
*/
#include <stdio.h>
#include <windows.h>
#include "qga/guest-agent-core.h"
#include "qga/vss-win32.h"
#include "qga/vss-win32/requester.h"
#define QGA_VSS_DLL "qga-vss.dll"
static HMODULE provider_lib;
/* Call a function in qga-vss.dll with the specified name */
static HRESULT call_vss_provider_func(const char *func_name)
{
FARPROC WINAPI func;
g_assert(provider_lib);
func = GetProcAddress(provider_lib, func_name);
if (!func) {
char *msg;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(char *)&msg, 0, NULL);
fprintf(stderr, "failed to load %s from %s: %s",
func_name, QGA_VSS_DLL, msg);
LocalFree(msg);
return E_FAIL;
}
return func();
}
/* Check whether this OS version supports VSS providers */
static bool vss_check_os_version(void)
{
OSVERSIONINFO OSver;
OSver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&OSver);
if ((OSver.dwMajorVersion == 5 && OSver.dwMinorVersion >= 2) ||
OSver.dwMajorVersion > 5) {
BOOL wow64 = false;
#ifndef _WIN64
/* Provider doesn't work under WOW64 (32bit agent on 64bit OS) */
if (!IsWow64Process(GetCurrentProcess(), &wow64)) {
fprintf(stderr, "failed to IsWow64Process (Error: %lx\n)\n",
GetLastError());
return false;
}
if (wow64) {
fprintf(stderr, "Warning: Running under WOW64\n");
}
#endif
return !wow64;
}
return false;
}
/* Load qga-vss.dll */
bool vss_init(bool init_requester)
{
if (!vss_check_os_version()) {
/* Do nothing if OS doesn't support providers. */
fprintf(stderr, "VSS provider is not supported in this OS version: "
"fsfreeze is disabled.\n");
return false;
}
provider_lib = LoadLibraryA(QGA_VSS_DLL);
if (!provider_lib) {
char *msg;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(char *)&msg, 0, NULL);
fprintf(stderr, "failed to load %s: %sfsfreeze is disabled\n",
QGA_VSS_DLL, msg);
LocalFree(msg);
return false;
}
if (init_requester) {
HRESULT hr = call_vss_provider_func("requester_init");
if (FAILED(hr)) {
fprintf(stderr, "fsfreeze is disabled.\n");
vss_deinit(false);
return false;
}
}
return true;
}
/* Unload qga-provider.dll */
void vss_deinit(bool deinit_requester)
{
if (deinit_requester) {
call_vss_provider_func("requester_deinit");
}
FreeLibrary(provider_lib);
provider_lib = NULL;
}
bool vss_initialized(void)
{
return !!provider_lib;
}
int ga_install_vss_provider(void)
{
HRESULT hr;
if (!vss_init(false)) {
fprintf(stderr, "Installation of VSS provider is skipped. "
"fsfreeze will be disabled.\n");
return 0;
}
hr = call_vss_provider_func("COMRegister");
vss_deinit(false);
return SUCCEEDED(hr) ? 0 : EXIT_FAILURE;
}
void ga_uninstall_vss_provider(void)
{
if (!vss_init(false)) {
fprintf(stderr, "Removal of VSS provider is skipped.\n");
return;
}
call_vss_provider_func("COMUnregister");
vss_deinit(false);
}
/* Call VSS requester and freeze/thaw filesystems and applications */
void qga_vss_fsfreeze(int *nr_volume, Error **errp, bool freeze)
{
const char *func_name = freeze ? "requester_freeze" : "requester_thaw";
QGAVSSRequesterFunc func;
ErrorSet errset = {
.error_set = (ErrorSetFunc)error_set_win32,
.errp = (void **)errp,
.err_class = ERROR_CLASS_GENERIC_ERROR
};
func = (QGAVSSRequesterFunc)GetProcAddress(provider_lib, func_name);
if (!func) {
error_setg_win32(errp, GetLastError(), "failed to load %s from %s",
func_name, QGA_VSS_DLL);
return;
}
func(nr_volume, &errset);
}